Optional integrity pinning for MCP server metadata

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
20/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python
領域
security

調査の方向性

This is a design proposal, not a scoped task: the thread asks the maintainers whether the Python SDK should carry metadata pinning at all, and the author already has a working implementation, so nothing should be started before a maintainer answers. To follow the discussion, read the Client entry point in src/mcp/client and note where list_tools results are received, since the fingerprint would have to be computed there and compared against stored state. Done means an agreed design (SDK-level option vs. protocol change) with a maintainer, not a patch from a newcomer.

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

説明

enhancement
Description

Hi!

I'd like to propose an optional mechanism for detecting unexpected changes to an MCP server's advertised metadata across connections. This is applicable in cases where the MCP server gets compromised and is used to attack the user e.g., phish and then exfiltrate sensitive data. Happy to provide an example attack chain that I have working.

It works as follows:

  • On the first connection, the client fingerprints and pin the server's advertised metadata, including tools, descriptions etc.
  • On subsequent connections, unexpected changes cause the client to fail closed until the new fingerprint is explicitly accepted by the user/agent owner.

This follows the established trust-on-first-use pattern. It's commonly used in SSH host-key checking, where the host key is trusted on first connection, and subsequent connections verify that it has not unexpectedly changed. If it does change, a configured policy determines how to proceed. The same principle can be applied to the interface advertised by an MCP server.

This does not establish that the server is trustworthy on first connection, but it's a reasonable assumption to make as a user (eg as per ssh host-key checking). This mechanism provides continuity of trust by making later changes to the previously accepted interface detectable.

Would this be something the Python SDK would be interested in supporting?
I'm happy to contribute a PR as I have it already working.
If this is better addressed at the protocol or SDK-wide level, I'm also happy to move the discussion there.

Example

Standard client:

from mcp import Client
async with Client("https://<mcp-server>/mcp") as client:
    tools = await client.list_tools()

With integrity pinning:
(The only change is metadata_integrity="enforce")

from mcp import Client 
async with Client( "https://<mcp-server>/mcp", metadata_integrity="enforce",) as client: 
    tools = await client.list_tools()
References

No response

主要言語
Python
スター
25k
フォーク
4.2k
平均マージ
10分
マージ済み PR(30日)
1

環境構築

はじめの一歩

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

modelcontextprotocol/python-sdk のほかの issue

modelcontextprotocol/python-sdk の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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