modelcontextprotocol / modelcontextprotocol/python-sdk

FastMCP: Support dynamic annotation updates

Open
#1,475 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement improves spec compliance P2
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

Problem

FastMCP will support resource annotations (audience, priority, lastModified) via the @mcp.resource() decorator (see #1468). However, annotations are set once at decoration time and cannot be updated as the server runs.

This is problematic for lastModified especially. If you annotate a file resource, there's no easy way to keep the timestamp current as the file changes:

@mcp.resource("file://docs/readme.md", annotations=Annotations(
    audience=["user"],
    lastModified="2025-01-12T15:00:58Z"
))
def read_readme() -> str:
    return open("readme.md").read()

Once deployed, this annotation is stale. If the file updates tomorrow, clients see outdated metadata.

Solution

Allow annotations to be updated dynamically. Possible approaches:

  • Provide a method to update resource annotations at runtime
  • Allow annotation callables/lambdas that compute values on each list_resources() call
  • Return fresh annotations from resource handler functions

This would enable:

  • Accurate lastModified timestamps from file mtimes
  • Dynamic audience/priority based on server state
  • Better integration with external data sources

Issue written by Claude, reviewed by @maxisbey

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the FastMCP @mcp.resource() registration path and the list_resources() behavior mentioned in the issue. Compare the proposed runtime update, callable, and handler-return approaches, then define how an implementation would keep audience, priority, and lastModified annotations current for clients.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.