modelcontextprotocol / modelcontextprotocol/python-sdk
FastMCP: Support dynamic annotation updates
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 31
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il percorso di registrazione FastMCP di @mcp.resource() e il comportamento di list_resources() menzionato nell’issue. Confronta gli approcci proposti di aggiornamento a runtime, callable e restituzione dell’handler, quindi definisci come un’implementazione manterrebbe aggiornate per i client le annotazioni audience, priority e lastModified.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100