FastMCP: Support dynamic annotation updates
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginnen Sie mit dem FastMCP-Registrierungspfad von @mcp.resource() und dem im issue erwähnten Verhalten von list_resources(). Vergleichen Sie die vorgeschlagenen Ansätze für Laufzeitaktualisierung, Callable und Handler-Rückgabe und legen Sie anschließend fest, wie eine Implementierung die Anmerkungen zu audience, priority und lastModified für Clients aktuell halten würde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 24.3k
- Forks
- 4k
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 30
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/python-sdk
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
modelcontextprotocol/python-sdk#3566 ·
-
v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
modelcontextprotocol/python-sdk#3546 · 5 Kommentare ·
-
v1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
modelcontextprotocol/python-sdk#3545 · 1 Kommentar ·
-
v1 v2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 91/100
modelcontextprotocol/python-sdk#3508 · 2 Kommentare ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
modelcontextprotocol/python-sdk#3504 ·
Alle Issues in modelcontextprotocol/python-sdk
Ähnliche Issues
-
bug confirmed issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
open-webui/open-webui#30750 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 90/100