adityamparikh opened a new pull request, #326:
URL: https://github.com/apache/solr-mcp/pull/326
Closes #325.
## Summary
A STDIO client shuts the server down by closing its stdin. The server exited
only if no tool had called Solr yet: SolrJ's `HttpJdkSolrClient` starts its own
pool of non-daemon threads on the first request and stops them only in
`close()`, and nothing closes the Spring context on stdin EOF. Those threads
kept the JVM running after the client had gone.
`SolrConfig` now hands the client an executor with daemon threads, sized
like SolrJ's default pool (4 core, 256 max, 60 s keep-alive, 1024-deep queue):
```diff
stdin EOF
MCP STDIO transport stops (2025 and 2026-07-28 alike)
- HttpJdkSolrClient-1-thread-1..4 (non-daemon) keep the JVM alive
+ solr-client-N threads are daemon: no non-daemon threads left, JVM exits
+ shutdown hook closes the context: SolrClient.close(), then
solrClientExecutor.close()
```
The executor is a bean so the context shuts it down; SolrJ does not shut
down an executor it was given. It is declared `defaultCandidate = false` and
injected by name, because Spring Boot backs off from auto-configuring
`applicationTaskExecutor` when any other `Executor` bean exists, and HTTP
mode's async request handling uses that executor. HTTP mode otherwise behaves
as before: Tomcat's threads keep it running.
## Evidence
- `StdioShutdownIntegrationTest` launches the jar over STDIO in both modes
(`MCP_PROTOCOL=streamable` and `modern`), calls `list-collections`, closes
stdin and waits for the process to exit:
**Before:** both cases fail, `the server must exit once the client closes
stdin`, still running after 30 s.
**After:** both pass, about 1.5 s each.
- `SolrClientExecutorTest`: the client's threads are daemon threads, Spring
Boot still auto-configures `applicationTaskExecutor`, and closing the context
shuts the executor down.
- Every tool, a resource, a prompt and a completion called over STDIO, then
stdin closed: the JVM exits 0.4 s after EOF in both modes, where before it ran
on indefinitely.
- Native STDIO images, run in Docker after calling every entry point: the
modern image (`MCP_PROTOCOL=modern ./gradlew bootBuildImage -Pnative`) exits
with code 0 after stdin EOF, with nothing but JSON-RPC on stdout, where before
the container kept running; the default image exits 0.2 s after EOF.
- `./gradlew dockerIntegrationTest -Pnative`:
`DockerImageMcpClientStdioIntegrationTest` 48 and
`DockerImageStdioIntegrationTest` 4, 0 failures, 0 skipped.
- `./gradlew build`: 523 tests, 0 failures, 0 skipped.
## Merge Danger
**Door:** two-way
**Blast Radius:** Solr client threads
Every Solr request now runs on the new executor in both transports. If a
request is still running when the JVM exits on stdin EOF, it is abandoned
instead of keeping the process alive; the client has already closed its end, so
nobody is waiting for the answer.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]