Skip to content

Add Primitive repository APIs (ResourceRepository, ToolsRepository, ... ) #578

Description

@sdelamo

Currently, McpStatelessAsyncServer and McpAsyncServer save resources, tools, prompts, and completionswithCopyOnWriteArrayList`.

https://github.com/modelcontextprotocol/java-sdk/blob/main/mcp-core/src/main/java/io/modelcontextprotocol/server/McpStatelessAsyncServer.java#L60-L68

I want to provide an API (for example, ResourcesRepository) that, by default, uses the current in-memory strategy but can be replaced, for example, by a dynamic implementation that returns a different list of resources depending on the currently authenticated user.

Image

Activity

  1. chemicL commented on Oct 2, 2025

    @chemicL
    Member

    I believe the repository-oriented design should be able to address the needs expressed in #593 (comment). If we can unify these ideas in this issue we could close #593 and make progress designing a comprehensive solution with this issue. @tzolov, @sdelamo WDYT?

  2. hbsjz-swl commented on Oct 9, 2025

    @hbsjz-swl
    Contributor

    @sdelamo @chemicL
    hi, I think these problems are essentially the same type of problems that the org.springframework.ai.mcp.McpToolUtils.prefixedToolName(String prefix, String title, String toolName) method in the SpringAI project solves. They are all about how to manage tools by grouping them so that the MCP client can more intelligently heuristically call tools among a large number of tools, first calling the tool group and then calling the specific tool.
    https://github.com/spring-projects/spring-ai/blob/main/mcp/common/src/main/java/org/springframework/ai/mcp/McpToolUtils.java

  3. ultramancode commented on Jan 13, 2026

    @ultramancode

    Hi! @sdelamo @chemicL Could you take a look at my pr (#747)? I think it’s closely related to this issue, and I’d really appreciate any feedback.

  4. added
    enhancementNew feature or request
    P3Nice to haves, rare edge cases
    on Feb 18, 2026
  5. chemicL commented on Feb 20, 2026

    @chemicL
    Member

    More requirements are described in #746, which I closed as a duplicate but should keep in mind when implementing this.

  6. bcersows commented on Feb 23, 2026

    @bcersows

    As all the related tickets seem to have been closed, I want to throw in one requirement that we at our company need; we've implemented a dynamic tool approach depending on some header field in the tools/list request. So a repository-based approach would be great, but also on a per-request basis.

  7. ultramancode commented on Feb 24, 2026

    @ultramancode

    @chemicL
    Hi! After #746 was closed as a duplicate of this issue, I’d like to confirm the direction.
    I put together PR #747 as an early attempt at the ToolsRepository portion (repository abstraction, per-request filtering, and cursor pagination).

    Does this approach align with the direction you’re aiming for here? If not, I’m happy to adjust it accordingly.
    If it does, I’d be glad to help with the remaining work via follow-up PRs.

  8. tim-schneider-elo commented on Mar 23, 2026

    @tim-schneider-elo

    Any updates on when this feature will be addressed and will be available?

  9. 15 remaining items

  10. added this to the 3.x Planning milestone on Aug 26, 2026
  11. ultramancode commented on Aug 26, 2026

    @ultramancode

    I’ve closed #953 and #1034 in line with the updated direction here.
    If there’s a useful piece I can contribute to when the 3.x repository work starts, I’d be glad to help.

  12. ujibang commented on Sep 8, 2026

    @ujibang

    A concrete case for the per-client half of this, from a server built on the SDK.

    RESTHeart derives MCP resources from MongoDB collections and GraphQL applications. Two things we wanted to do turned out not to be expressible against a server-wide registry:

    A schema that differs per caller. We added a @visible(roles: [...]) directive to our GraphQL apps: a field the caller's roles do not name is removed from the schema they see, so introspection does not reveal it exists. We wanted the resource description in the catalog to carry the same role-filtered schema. It cannot: resources is one registry for the whole server, so the description we register is the one every client gets. Publishing the unfiltered schema there would have revealed exactly what the directive removes, so we left the schema out of the catalog entirely and point clients at GraphQL introspection instead — which does answer per caller.

    A catalog that reflects what the caller may read. Reads are authorized per principal (a resource read is checked as the equivalent REST GET), so a client can see catalog entries it will be refused. That is a deliberate trade on our side, not a complaint — but with a repository API it would be a choice rather than a constraint.

    Both would be covered by the interface proposed here, provided the lookup receives the exchange (i.e. the authenticated identity), not just a key.

    One adjacent note, since it comes up in the same place: #746 was closed as a duplicate of this issue, but it also asked for cursor-based pagination, which this issue does not cover — the server-side list handlers ignore cursor and never set nextCursor. Filed separately as #1128, so it does not get lost again.

  13. modified the milestones: 2.2.0-M1, 2.2.0-M2 on Oct 16, 2026
  14. modified the milestones: 2.2.0-M2, 2.2.0-M3 on Nov 2, 2026
  15. Kehrlann commented on Nov 12, 2026

    @Kehrlann
    Contributor

    Covered by #1170 ; we'll improve this with #1200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions