You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dolphinium (via GitHub)" <gi...@apache.org> on 2026/04/16 10:07:18 UTC

[PR] feat(config): support HTTP Basic Authentication and tolerate text/plain responses [solr-mcp]

dolphinium opened a new pull request, #89:
URL: https://github.com/apache/solr-mcp/pull/89

   ## Summary
   
   Two small, focused changes that together let the MCP server talk to authenticated, standalone Solr deployments out of the box:
   
   1. **`feat(config)`: optional HTTP Basic Authentication.** Adds `solr.username` / `solr.password` configuration properties (bound from `SOLR_USERNAME` / `SOLR_PASSWORD` env vars). When both are set, credentials are applied via `HttpJdkSolrClient.Builder#withBasicAuthCredentials`; otherwise the client is built exactly as before.
   
   2. **`fix(config)`: tolerate `text/plain` responses.** Some Solr request handlers (notably `/admin/ping` and a number of standalone-mode paths) return JSON-encoded bodies with `Content-Type: text/plain`. SolrJ validates the header against the parser's advertised content types, so these otherwise-valid responses surface through MCP tools (`check-health`, `search`, …) as errors like `Expected mime type in [application/json] but got text/plain`. Widening `JsonResponseParser#getContentTypes()` to advertise both types fixes this with no behaviour change for handlers that already return `application/json`.
   
   The two commits are kept separate so they can be reviewed (or reverted) independently; happy to split into two PRs if preferred.
   
   ## Motivation
   
   Tested end-to-end against a production, Basic-auth-protected, classic-mode Solr reached through an SSH tunnel:
   
   - Before: every tool call returned `401 require authentication`; once credentials were wired in, several handlers still failed the Content-Type check.
   - After: `check-health`, `search`, `get-schema`, etc. all succeed against real cores (standalone mode; `list-collections` remains SolrCloud-only — out of scope here).
   
   ## Changes
   
   - `SolrConfigurationProperties`: add nullable `username` and `password` record components (JSpecify `@Nullable`); expanded JavaDoc.
   - `SolrConfig#solrClient`: apply `withBasicAuthCredentials` when both credentials are present and username is non-blank.
   - `JsonResponseParser#getContentTypes`: advertise `application/json` and `text/plain`.
   - Docs: `dev-docs/ARCHITECTURE.md` and `dev-docs/DEVELOPMENT.md` list the two new env vars next to `SOLR_URL`.
   
   ## Tests
   
   - `SolrConfigAuthTest` (new): 5 cases covering none / username-only / password-only / blank-username / both — asserts via reflection on `HttpSolrClientBase#basicAuthAuthorizationStr`.
   - `JsonResponseParserContentTypesTest` (new): pins the advertised Content-Type set.
   - `SolrConfigUrlNormalizationTest`: updated to the new record constructor.
   - `./gradlew build` passes locally (Spotless + NullAway + full unit test suite).
   
   ## Test plan
   
   - [x] `./gradlew spotlessCheck`
   - [x] `./gradlew build` (unit tests)
   - [x] Manual end-to-end against an authenticated classic-mode Solr 9.x over an SSH tunnel
   
   ## Notes
   
   - No new runtime dependencies.
   - Behaviour is strictly backwards-compatible: existing deployments that set neither variable are unchanged.
   - Signed off under DCO; commits follow Conventional Commits per `CONTRIBUTING.md`.
   
   Co-authored-by: Claude <no...@anthropic.com>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] feat(config): support HTTP Basic Authentication credentials [solr-mcp]

Posted by "adityamparikh (via GitHub)" <gi...@apache.org>.
adityamparikh commented on PR #89:
URL: https://github.com/apache/solr-mcp/pull/89#issuecomment-4700825832

   Thanks for this, @dolphinium! I took your feature commit unchanged and opened #152 on top of it, folding in a small review-cleanup pass (reuse `StringUtils.hasText` + Spring `ReflectionUtils` in the test, tighten the auth-header assertion to an exact match). Your authorship is preserved as the first commit there, and `./gradlew build` passes.
   
   Whether to continue here or land via #152 is up to the maintainers — just wanted to link the two so the connection is visible from both sides.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] feat(config): support HTTP Basic Authentication and tolerate text/plain responses [solr-mcp]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #89:
URL: https://github.com/apache/solr-mcp/pull/89#issuecomment-4260790572

   If you can split it that would be awesome!!!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] feat(config): support HTTP Basic Authentication credentials [solr-mcp]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh merged PR #89:
URL: https://github.com/apache/solr-mcp/pull/89


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] feat(config): support HTTP Basic Authentication credentials [solr-mcp]

Posted by "dolphinium (via GitHub)" <gi...@apache.org>.
dolphinium commented on PR #89:
URL: https://github.com/apache/solr-mcp/pull/89#issuecomment-4262526662

   hi @epugh, I separated features as you requested. so happy to contribute to this project. have a great day.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] feat(config): support HTTP Basic Authentication credentials [solr-mcp]

Posted by "adityamparikh (via GitHub)" <gi...@apache.org>.
adityamparikh commented on PR #89:
URL: https://github.com/apache/solr-mcp/pull/89#issuecomment-4364619053

   Hi! A new PR-validation CI workflow recently landed on `main` (#117). To get this PR's tests evaluated against the new pipeline, could you rebase your branch onto current `main` and push? That will trigger the new `ci.yml` (build / unit / integration). Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org