Skip to main content

Trusted Model Context Protocol (Trusted MCP)

PyPI version License: MIT Python min version Protocol

什么是Trusted MCP?

Trusted MCP是火山引擎推出的可信MCP,在标准MCP协议的基础上扩展核心组件之间的身份证明及验证能力,提供组件之间端到端的通信安全保障,可以解决MCP应用中服务身份不可信、数据被篡改、流量劫持、数据隐私泄露等安全威胁。

安装

推荐使用 uv 进行Python项目管理(支持Python 3.11及以上版本)。

uv add trustedmcp

或者,对于使用 pip 管理依赖的项目:

pip install trustedmcp

快速开始

在代码中引入TrustedMCP,仅需要将现有MCP模块替换成TrustedMCP模块即可。如下代码展示:

# Original MCP code
# Import MCP, and create an MCP server
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(name="Demo")

# Replace with TrustedMCP code
# Import TrustedMCP, and create a TrustedMCP server
from bytedance.jeddak_trusted_mcp import TrustedMCP
trusted_mcp = TrustedMCP(name="Demo")

注意:实际代码运行还需要提供TrustedMCP以及大模型调用的必要配置。

如何部署和运行Trusted MCP服务

典型MCP应用通常主要包含三个模块,即Host、Client和Server,Client和Server可以灵活部署。Trusted MCP支持在普通环境(非机密环境)中运行,同时也支持在机密环境中运行。在普通环境中运行时,Trusted MCP仅为Client和Server提供端到端的机密通信能力,而在机密环境中运行时,Trusted MCP还能够提供远程证明验证,确保对端运行在机密计算环境、且服务可信。

推荐:开发调试以及功能验证可在普通环境下部署更方便,生产环境下建议部署到机密计算环境以提供最完备的安全保障。

部署到普通环境

以本地部署demo目录下的server.py和client.py为例,展示如何在普通环境中部署Trusted MCP服务。

  1. 环境配置

    # 生成公私钥对,此处openssl生产RSA公私钥对为例:
    openssl genrsa -out ./myPrivateKey.pem 4096
    openssl rsa -pubout -in ./myPrivateKey.pem -out ./myPublicKey.pem
    
    # 注:
    # 1. 此处生成的公私钥对仅用于演示,在生产环境中请使用安全的密钥管理方案。
    # 2. 公私钥对需要分别配置到Client和Server中,Client的公钥需要配置到Server中,Server的公钥需要配置到Client中。
    
  2. 部署启动Server

    # 配置Server运行环境
    # 1. 配置Server私钥,缺省默认使用目录下的 ./myPrivateKey.pem
    # 2. 配置Server的地址,缺省默认是 http://127.0.0.1:8000/mcp
    uv run python server.py
    
  3. 部署启动Client

    # 配置Client运行环境
    # 1. 配置Client公钥,缺省默认使用目录下的 ./myPublicKey.pem
    # 2. 配置Server的地址,缺省使用默认地址 http://127.0.0.1:8000/mcp
    # 3. 配置火山方舟的API Key环境变量 LLM_API_KEY,如果没有可以联系火山引擎获取一个临时的API Key
    # 4. 配置火山方舟的模型名称环境变量 LLM_MODEL_NAME,缺省默认使用 doubao-1.5-pro-32k-250115
    uv run python local_client.py
    

完成以上步骤后,即可在普通环境中运行Trusted MCP服务,可在Client中输入任意请求(如查询北京天气)。

部署到机密计算环境

以在火山引擎AICC机密计算平台部署demo目录下的aicc_server.py和aicc_client.py为例,展示如何在机密计算环境中部署Trusted MCP服务。

  1. 准备机密计算环境

    请参考火山引擎AICC文档,开通机密计算实例,并记录相关信息,如实例ID、AK、SK等。

  2. 配置环境

    编辑Server和Client的配置文件(server_config.json和client_config.json)中,将机密计算环境相关信息进行更新,如实例ID、AK、SK等。

  3. 部署启动Server

    # 配置Server运行环境
    # 1. 配置Server配置文件路径,缺省默认使用目录下的 ./server_config.json
    # 2. 配置Server的地址
    uv run python aicc_server.py
    
  4. 部署启动Client

    # 配置Client运行环境
    # 1. 配置Client配置文件路径,缺省默认使用目录下的 ./client_config.json
    # 2. 配置Server的地址
    # 3. 配置火山方舟的API Key环境变量 LLM_API_KEY
    # 4. 配置火山方舟的模型名称环境变量 LLM_MODEL_NAME
    uv run python aicc_client.py
    

完成以上步骤后,即可在机密计算环境中运行Trusted MCP服务,可在Client中输入任意请求(如查询北京天气)。

致谢

感谢火山引擎AICC项目组成员,倘若没有项目组成员的努力,该项目无法实现开源发布。期望本项目能够在AI智能体隐私保护领域,特别是在涉及用户数据安全的场景中,贡献一份力量。

许可证

MIT。

Metadata

Release files for trustedmcp 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trustedmcp 0.0.5
File Size Uploaded Provenance
trustedmcp-0.0.5.tar.gz 786.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for trustedmcp 0.0.5
File Interpreter ABI Platform
trustedmcp-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 839.8 kB

Release files / trustedmcp-0.0.5.tar.gz

Download URL trustedmcp-0.0.5.tar.gz
Size 786.4 kB
Tags Source
SHA-256 checksum
How to use checksums
de4dca0aa0beda0196132d61529d7067719587a3db0ef33d4117c44ea7546629
BLAKE2b-256 checksum
How to use checksums
670b94958348500186f4ab134b5bc3700c2e2a5c57643a92413c5805ba55ae84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / trustedmcp-0.0.5-py3-none-any.whl

Download URL trustedmcp-0.0.5-py3-none-any.whl
Size 53.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e89f6c9f5fb17cb70aaaa37df21a6e01722ccb1eec6cb8fc2e61417016986d4
BLAKE2b-256 checksum
How to use checksums
e05b9d60a8633f4ab94c9ec0621b51a74d866086b4cb6579882fa4fb9186023b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for trustedmcp 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page