Skip to content

mcp: support per-resource cache policy for resources/read #1185

Description

@makeavish

Is your feature request related to a problem? Please describe.

A server may expose both public static resources and tenant-specific resource templates. Today, assigning the correct ttlMs and cacheScope to each resources/read result requires receiving middleware—or the proposed DefaultCacheable callback in #1128—to inspect the request URI. That duplicates policy already known where the resource is registered.

Describe the solution you'd like

Allow direct resources and resource templates to declare a cache hint at registration. The matched resource's hint should apply only to its resources/read result, take precedence over the server default, and not appear in resources/list or resources/templates/list.

For example, a server could register static documentation as public and a tenant-backed template as private without central URI matching.

The TypeScript SDK already supports this through cacheHint on registerResource.

Describe alternatives you've considered

  • Receiving middleware works, but moves resource-specific policy away from registration.
  • mcp: add ServerOptions.DefaultCacheable #1128's server-level callback is useful for broad or request-dependent defaults, but registration-level policy would complement it for stable per-resource semantics.

Additional context

Related: #1094 and #1128.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions