Skip to main content

Lightweight Python runtime for Meta Tooling Protocol (MTP)

Project description

MTP (Meta Tooling Protocol)

Python Is All You Need.

MTP 是下一代 AI 交互方式,让 AI 通过 Python 解决所有问题,将交互效率提升 2 倍以上。

核心理念

传统的 MCP/Function Call 为每个功能定义独立工具:

AI: 我需要读取文件
→ 调用 read_file 工具
→ 等待响应
→ 我需要分析数据
→ 调用 analyze_data 工具
→ 等待响应
→ 我需要生成报告
→ 调用 generate_report 工具

MTP 只提供一个 python_exec 工具:

AI: 我需要读取文件、分析数据、生成报告
→ 写 Python 代码一次性完成
→ 返回结果

结果:交互次数减少 70%,Token 消耗减半,效率提升 2 倍。

Quick Start

安装

pip install mtp

在 Claude Code 中使用

# 添加工具
mtp add playwright

# 配置 MCP 服务器
claude mcp add --transport stdio mtp -- 'mtp mcp'

现在可以直接对话:

  • "用 Playwright 打开百度并截图"
  • "分析这个 CSV 文件并生成报告"

MTP 只暴露一个 python_exec 工具,AI 会自动用 Python 调用所有能力。

在代码中使用

7 行代码构建一个完整的 Agent:

import sys
from pydantic_ai import Agent
from mtp import PydanticAdapter

agent = Agent('openai:gpt-4', tools=[PydanticAdapter().tool()])
print(agent.run_sync(" ".join(sys.argv[1:])).data)

运行:

python agent.py "分析数据并导出 Excel"

AI 会在 python_exec 中使用工具:

# 从 mtp.infra 导入工具
from mtp.infra import playwright, github
result = playwright.goto(url="https://example.com")
repos = github.list_repos(owner="anthropics")

工具管理

# 添加 MCP 服务器
mtp add github --env GITHUB_TOKEN=$GITHUB_TOKEN

# 添加 OpenAPI
mtp add myapi --openapi https://api.example.com/openapi.json

# 添加命令行工具
mtp add curl --cmd curl

# 列出所有工具
mtp list

MTP 是 Agent 时代的包管理器,统一管理所有工具。

使用场景

安全测试

  • 自动化渗透测试(腾讯云 AI 渗透赛第四名)
  • 漏洞扫描和分析
  • 安全报告生成

数据分析

  • CSV/Excel 数据处理
  • 数据可视化
  • 自动生成报告

API 集成

  • 调用任意 OpenAPI 服务
  • GitHub/GitLab 自动化
  • 云服务管理

自定义 Agent

  • 快速构建专属 Agent
  • 集成到现有应用
  • 支持 LangChain、Pydantic AI 等框架

核心特性

  • 持久化执行:基于 IPython,跨调用保持状态,内存即上下文,数据留在 Python 内存中
  • 渐进发现:极简的工具描述,通过 help()dir() 逐步探索工具能力,避免上下文膨胀
  • 装饰器 SDK:简洁的 @namespace@toolset@tool 装饰器系统,快速注册自定义工具
  • 多协议支持:REST API、MCP、Function Call、LangChain、Pydantic AI
  • 统一管理:通过 infra.yaml 管理所有工具(MCP、OpenAPI、Python、CLI)
  • MCP 兼容:支持 Anthropic 官方 MCP Registry,可透传和聚合 MCP 服务

文档

文档 描述
CLI 使用指南 命令行工具详细使用方法
SDK 使用指南 Python SDK 完整 API 参考
最佳实践 AI 集成、项目组织、部署指南
核心设计 架构原理和设计理念

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meta_tooling_protocol-0.1.0.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meta_tooling_protocol-0.1.0-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

Details for the file meta_tooling_protocol-0.1.0.tar.gz.

File metadata

  • Download URL: meta_tooling_protocol-0.1.0.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for meta_tooling_protocol-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4dad5398ca62cd36de60244c72a2b9fac3adb485981a3f28f77b51a9d707d4da
MD5 113da6abb129c265758e7fd8b17890e8
BLAKE2b-256 5c8e257466d4934053a51a89590edf2c5b6a2939aa520c0fb5e8f45ec9a0209e

See more details on using hashes here.

File details

Details for the file meta_tooling_protocol-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for meta_tooling_protocol-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 140390b28c5f34e99cea1578160aa91f5ef34194f8dcb66907a2c9fa87bb1dfe
MD5 af73513604cc00c0c90e57f0b717106f
BLAKE2b-256 8efc8aec84c9f22e63e7fcca1ce51e873f7e7ce26dcbde479f013b61218fef19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page