Optional integrity pinning for MCP server metadata

Abierto
#3,907 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
20/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
security

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Python
Estrellas
25k
Forks
4.2k
Merge medio
10 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modelcontextprotocol/python-sdk

Todos los issues de modelcontextprotocol/python-sdk

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.