Title: Stateless server handler throws exception instead of returning JSON-RPC -32601 (Method not found) for not registered capabilities · Issue #784 · modelcontextprotocol/java-sdk · GitHub
Open Graph Title: Stateless server handler throws exception instead of returning JSON-RPC -32601 (Method not found) for not registered capabilities · Issue #784 · modelcontextprotocol/java-sdk
X Title: Stateless server handler throws exception instead of returning JSON-RPC -32601 (Method not found) for not registered capabilities · Issue #784 · modelcontextprotocol/java-sdk
Description: Bug description In the stateless server path (DefaultMcpStatelessServerHandler), when a request is received for a method that does not have a registered handler, the server currently throws an McpError exception instead of returning a JS...
Open Graph Description: Bug description In the stateless server path (DefaultMcpStatelessServerHandler), when a request is received for a method that does not have a registered handler, the server currently throws an McpE...
X Description: Bug description In the stateless server path (DefaultMcpStatelessServerHandler), when a request is received for a method that does not have a registered handler, the server currently throws an McpE...
Opengraph URL: https://github.com/modelcontextprotocol/java-sdk/issues/784
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Stateless server handler throws exception instead of returning JSON-RPC -32601 (Method not found) for not registered capabilities","articleBody":"**Bug description**\nIn the stateless server path (`DefaultMcpStatelessServerHandler`), when a request is received for a method that does not have a registered handler, the server currently throws an `McpError` exception instead of returning a JSON-RPC response with an error code. This is inconsistent with the stateful/session server implementations (`McpServerSession`, etc.), which respond with the standard JSON-RPC error -32601 (Method not found).\n\n**Environment**\nModelContextProtocol Java SDK, stateless/server mode.\n\n**Steps to reproduce**\n1. Start a stateless MCP server instance (e.g., without advertising or registering a resources or prompts capability).\n2. Send a request with method: \"resources/list\" (or another method for which the handler is not registered).\n3. Exception is thrown instead of returning a JSON-RPC response with a \"Method not found\" error\n\n**Expected behavior**\nStateless server should respond to any unknown/unregistered method with the standard JSON-RPC -32601 \"Method not found\" error, to be consistent with other server implementations in the SDK and with JSON-RPC specification.\n\n**Minimal Complete Reproducible example**\n\nMinimal Spring AI reproducer:\n\n```java\npackage com.example.demo;\n\nimport org.springaicommunity.mcp.annotation.McpTool;\nimport org.springaicommunity.mcp.annotation.McpToolParam;\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\nimport org.springframework.stereotype.Component;\n\n@SpringBootApplication\npublic class DemoApplication {\n\n public static void main(String[] args) {\n SpringApplication.run(DemoApplication.class, args);\n }\n\n @Component\n public static class DemoTools {\n\n @McpTool\n public String hello(@McpToolParam String name) {\n return \"Hello, \" + name;\n }\n\n }\n}\n\n```\n\n```yaml\nspring:\n ai:\n mcp:\n server:\n enabled: true\n type: sync\n protocol: stateless\n annotation-scanner:\n enabled: true\n streamable-http:\n mcp-endpoint: /mcp\n capabilities:\n completion: false\n prompt: false\n resource: false\n tool: true\n```\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cproject xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\"\u003e\n \u003cmodelVersion\u003e4.0.0\u003c/modelVersion\u003e\n \u003cparent\u003e\n \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n \u003cartifactId\u003espring-boot-starter-parent\u003c/artifactId\u003e\n \u003cversion\u003e4.0.2\u003c/version\u003e\n \u003crelativePath/\u003e \u003c!-- lookup parent from repository --\u003e\n \u003c/parent\u003e\n\n \u003cgroupId\u003ecom.example\u003c/groupId\u003e\n \u003cartifactId\u003edemo\u003c/artifactId\u003e\n \u003cversion\u003e0.0.1-SNAPSHOT\u003c/version\u003e\n \u003cname\u003edemo\u003c/name\u003e\n \u003cdescription\u003eDemo project for Spring Boot\u003c/description\u003e\n\n \u003cproperties\u003e\n \u003cjava.version\u003e21\u003c/java.version\u003e\n \u003cspring-ai.version\u003e2.0.0-M2\u003c/spring-ai.version\u003e\n \u003c/properties\u003e\n\n \u003cdependencyManagement\u003e\n \u003cdependencies\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.ai\u003c/groupId\u003e\n \u003cartifactId\u003espring-ai-bom\u003c/artifactId\u003e\n \u003cversion\u003e${spring-ai.version}\u003c/version\u003e\n \u003ctype\u003epom\u003c/type\u003e\n \u003cscope\u003eimport\u003c/scope\u003e\n \u003c/dependency\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eio.modelcontextprotocol.sdk\u003c/groupId\u003e\n \u003cartifactId\u003emcp-bom\u003c/artifactId\u003e\n \u003cversion\u003e0.17.2\u003c/version\u003e\n \u003ctype\u003epom\u003c/type\u003e\n \u003cscope\u003eimport\u003c/scope\u003e\n \u003c/dependency\u003e\n \u003c/dependencies\u003e\n \u003c/dependencyManagement\u003e\n\n \u003cdependencies\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.ai\u003c/groupId\u003e\n \u003cartifactId\u003espring-ai-starter-mcp-server\u003c/artifactId\u003e\n \u003c/dependency\u003e\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.ai\u003c/groupId\u003e\n \u003cartifactId\u003espring-ai-starter-mcp-server-webmvc\u003c/artifactId\u003e\n \u003c/dependency\u003e\n\n \u003cdependency\u003e\n \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n \u003cartifactId\u003espring-boot-starter-test\u003c/artifactId\u003e\n \u003cscope\u003etest\u003c/scope\u003e\n \u003c/dependency\u003e\n \u003c/dependencies\u003e\n\n \u003cbuild\u003e\n \u003cplugins\u003e\n \u003cplugin\u003e\n \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n \u003cartifactId\u003espring-boot-maven-plugin\u003c/artifactId\u003e\n \u003c/plugin\u003e\n \u003c/plugins\u003e\n \u003c/build\u003e\n\u003c/project\u003e\n```\n\nRunning a `resources/list` command against this server returns a JSON stack trace instead of a JSON-RPC response:\n\n```\n$ curl -H \"Accept: application/json, text/event-stream\" -H \"Content-Type: application/json\" -X POST http://localhost:8080/mcp -d '{\"jsonrpc\": \"2.0\", \"method\": \"resources/list\", \"id\": 1}' | jq\n{\n \"cause\": null,\n \"jsonRpcError\": null,\n \"localizedMessage\": \"Failed to handle request: Missing handler for request type: resources/list\",\n \"message\": \"Failed to handle request: Missing handler for request type: resources/list\",\n \"stackTrace\": [\n {\n \"classLoaderName\": \"app\",\n \"className\": \"io.modelcontextprotocol.server.transport.WebMvcStatelessServerTransport\",\n \"fileName\": \"WebMvcStatelessServerTransport.java\",\n \"lineNumber\": 126,\n \"methodName\": \"handlePost\",\n \"moduleName\": null,\n \"moduleVersion\": null,\n \"nativeMethod\": false\n },\n {\n \"classLoaderName\": \"app\",\n \"className\": \"org.springframework.web.servlet.function.support.HandlerFunctionAdapter\",\n \"fileName\": \"HandlerFunctionAdapter.java\",\n // ...\n },\n // ...\n ],\n \"suppressed\": []\n}\n```","author":{"url":"https://github.com/maff","@type":"Person","name":"maff"},"datePublished":"2026-02-12T20:04:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/784/java-sdk/issues/784"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b3840dc0-7314-6e7a-f616-413f9d1d8a91 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C13E:13C9B5:9A262E:CD66FF:6A5B5A62 |
| html-safe-nonce | d14189ca3e0614303dfabe701cda49e070df3a281c0c69cc5cd5f340e429441e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTNFOjEzQzlCNTo5QTI2MkU6Q0Q2NkZGOjZBNUI1QTYyIiwidmlzaXRvcl9pZCI6IjEzNDgxNTM2OTAxMjIwNTAxNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 19b8c175d31f6359c095dce8e235ebdf657941d606cec99af6b67621e5ee66be |
| hovercard-subject-tag | issue:3933758233 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/java-sdk/784/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c2581cdc6e054183a96c2ca21b39ad528afc941781a64fa1b91dbc75b9bc5e4e/modelcontextprotocol/java-sdk/issues/784 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c2581cdc6e054183a96c2ca21b39ad528afc941781a64fa1b91dbc75b9bc5e4e/modelcontextprotocol/java-sdk/issues/784 |
| og:image:alt | Bug description In the stateless server path (DefaultMcpStatelessServerHandler), when a request is received for a method that does not have a registered handler, the server currently throws an McpE... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/java-sdk git https://github.com/modelcontextprotocol/java-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 919609219 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/java-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 919609219 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/java-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width