modelcontextprotocol / modelcontextprotocol/python-sdk
FastMCP: Support dynamic annotation updates
Nobody has claimed this yet.
- 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
lastModifiedtimestamps 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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