modelcontextprotocol / modelcontextprotocol/python-sdk

FastMCP: Support dynamic annotation updates

Offen
#1,475 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

enhancement improves spec compliance P2
Vorherrschende Sprache
Python
Sterne
24.3k
Forks
4k
Ø Merge
1 T. 1 Std.
Gemergte PRs (30 T.)
31

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 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

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.

Bewertung

Tech-Stack
python
Bereich
api
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.