modelcontextprotocol / modelcontextprotocol/python-sdk

FastMCP: Support dynamic annotation updates

オープン
#1,475 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement improves spec compliance P2
主要言語
Python
スター
24.3k
フォーク
4k
平均マージ
1日 1時間
マージ済み PR(30日)
31

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

FastMCP の @mcp.resource() 登録パスと、issue で言及されている list_resources() の動作から始めます。提案されているランタイム更新、callable、handler-return のアプローチを比較し、実装によって audience、priority、lastModified のアノテーションをクライアント向けに最新の状態に保つ方法を定義します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。