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.2.tar.gz (45.8 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.2-py3-none-any.whl (51.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for meta_tooling_protocol-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d347895cd565aa5514c29180dbae6e759b63ebf85d953da10e146f78ec021041
MD5 98b2fb01593c2bd6ae142f065658d642
BLAKE2b-256 4a09d7fa1b8024ba25e1f2e4779f8ccaee4a6f9776dce4ffe02004a3b49103dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for meta_tooling_protocol-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e4956dbefdc5be060e089eded0077c968597027c406de14753678129b4e9d70
MD5 0b8a70fbdbbe9c556ea498e98047ba03
BLAKE2b-256 1084476ffaa7bae2191624496db2432ced5cffd1e5e2d50ec4c7f5e8e7f97908

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