Title: feat: support dynamic MCP primitive repositories by ultramancode · Pull Request #953 · modelcontextprotocol/java-sdk · GitHub
Open Graph Title: feat: support dynamic MCP primitive repositories by ultramancode · Pull Request #953 · modelcontextprotocol/java-sdk
X Title: feat: support dynamic MCP primitive repositories by ultramancode · Pull Request #953 · modelcontextprotocol/java-sdk
Description: Adds request-aware, pluggable repository APIs for dynamic MCP server primitives: tools, resources, prompts, and completions. This allows server implementations to resolve visible primitives from request/session context, while preserving the existing static in-memory registration behavior by default. Fixes #578 Motivation and Context Some MCP servers need to expose different tools, resources, prompts, or completion handlers depending on the authenticated user, tenant, token, or request context. This change makes primitive discovery and resolution request-aware: */list responses can be scoped per request context follow-up operations such as tools/call, resources/read, prompts/get, and completion/complete resolve through the same request-aware repositories custom implementations can choose their own pagination and cursor handling existing static registration methods continue to work through default in-memory repositories How Has This Been Tested? Added unit and in-process server tests for the new repository path, including request-context based tool/resource/prompt visibility, completion capability wiring, cursor forwarding, runtime add/remove behavior, repository/static registration conflict validation, and stateful list-changed notifications for supported runtime mutations. I tested the change locally end-to-end with a small servlet server and a Postman collection. The test server returns different tools, resources, prompts, and completions based on the X-User request header, so I could verify that listing and resolution both go through the repository layer. I also checked runtime add/remove behavior and stateful list-changed notifications. Files used for the local test: DynamicRepositoryDemoServlet.java dynamic-repository-demo.postman_collection.json I attached the servlet and Postman collection so the same checks can be reproduced locally. Breaking Changes None intended. Existing static registrations continue to work. When no custom repository is provided, registrations are loaded into default in-memory repositories. Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context Design notes: Static registrations and custom repositories cannot be mixed for the same primitive family. This avoids implicit SDK-level merge semantics. Repository list methods receive McpSchema.PaginatedRequest, so custom implementations can choose whether and how to apply pagination and cursor handling.
Open Graph Description: Adds request-aware, pluggable repository APIs for dynamic MCP server primitives: tools, resources, prompts, and completions. This allows server implementations to resolve visible primitives from re...
X Description: Adds request-aware, pluggable repository APIs for dynamic MCP server primitives: tools, resources, prompts, and completions. This allows server implementations to resolve visible primitives from re...
Opengraph URL: https://github.com/modelcontextprotocol/java-sdk/pull/953
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9ab5bb06-371b-3a36-4018-89408d8b885e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D346:1247D9:244DBFB:3426A11:6A58F09C |
| html-safe-nonce | 2e3456c57f122a87b21cb87ef7809c2f64fc2ee9c59b1764d508e90ed18e3c74 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzQ2OjEyNDdEOToyNDREQkZCOjM0MjZBMTE6NkE1OEYwOUMiLCJ2aXNpdG9yX2lkIjoiNTEyOTE4NDA0ODQzMTI5NjY2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 932d8ee4ecf2a43a493e5790d8d2f0455eb9c9dbdcb7a688aff64ff8641ee08a |
| hovercard-subject-tag | pull_request:3663224597 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/modelcontextprotocol/java-sdk/pull/953/files |
| twitter:image | https://avatars.githubusercontent.com/u/116135174?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/116135174?s=400&v=4 |
| og:image:alt | Adds request-aware, pluggable repository APIs for dynamic MCP server primitives: tools, resources, prompts, and completions. This allows server implementations to resolve visible primitives from re... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width