mcp代码生成器v1.0.0
⚡ 这段代码已经过vibe编码
⚡ 从MCP服务器生成Python客户端代码+使用内置沙盒执行代理代码
mcp编码 是一个用于使用MCP(模型上下文协议)服务器的综合工具包。它使您能够:
- 发现并列出工具 从任何MCP服务器
- 生成类型安全的Python客户端代码 带有完整的类型提示
- 直接调用工具 从CLI无需编写代码
- 创建渐进式文件系统布局 用于及时加载工具
- 搜索工具 跨服务器而不加载完整模式
- 执行Python代理代码 内置资源限制、网络隔离和隐私保护
非常适合需要安全高效地使用MCP工具的AI代理。
功能概览
| 功能 | v0.x | v1.0.0 |
|---|---|---|
| 列出工具 | ✅ | ✅ |
| 生成类型安全的Python存根 | ✅ | ✅ |
| 直接工具调用 | ✅ | ✅ |
| 汽车运输谈判 | ✅ | ✅ |
| 渐进式文件系统布局 | ❌ | ✅ 新 |
| 不加载模式的工具搜索 | ❌ | ✅ 新 |
| Python代码执行运行器 | ❌ | ✅ 新 |
| 资源限制(CPU、内存) | ❌ | ✅ 新 |
| 网络隔离 | ❌ | ✅ 新 |
| PII清洗 | ❌ | ✅ 新 |
| 沙盒模式(seccomp、Firejail) | ❌ | ✅ 新 |
快速开始
注: mcp编码如下 人类学 用于上下文高效的代理工作流。
安装
pip install -e .
# Optional: For Linux sandboxing features
pip install -e ".[runner]"1.列出可用工具
mcp-codegen ls --url https://your-mcp-server.com输出:
Tools:
- get_weather_forecast: Get weather forecast for a location (params: lat, lon, limit)
- list_locations: List available locations (params: )
- search_location: Search for a location (params: query)2.生成Python模块(单个文件)
mcp-codegen gen \
--url https://your-mcp-server.com \
--out weather_tools.py \
--name weather在Python中使用它:
import asyncio
from weather_tools import get_weather_forecast
async def main():
params = get_weather_forecast.Params(lat=64.75, lon=20.95, limit=1)
result = await get_weather_forecast.call(
'https://your-mcp-server.com',
params
)
print(result)
asyncio.run(main())3.直接调用工具(无代码生成)
mcp-codegen call \
--url https://your-mcp-server.com \
--tool get_weather_forecast \
--arg lat=64.75 \
--arg lon=20.954.生成渐进式文件系统布局(v1.0.0中的新功能)
mcp-codegen gen --fs-layout \
--url https://your-mcp-server.com \
--name weather创建可浏览的结构:
servers/
└── weather/
├── __init__.py # Server index
├── get_weather_forecast.py # Individual tool
├── list_locations.py
└── search_location.py只导入您需要的内容:
from servers.weather.get_weather_forecast import call, Params
# Load just this tool, not all 100 tools
result = await call('https://...', Params(lat=64.75, lon=20.95))生成克劳德代码技能(新):
添加 --generate-skill 为Claude Code自动创建技能文件:
mcp-codegen gen --fs-layout \
--url https://your-mcp-server.com \
--name weather \
--generate-skill这创造了 .claude/skills/mcp-weather/SKILL.md 这有助于Claude Code:
- 自动发现何时使用这些工具
- 知道服务器URL和工具位置
- 了解工具类别(天气、交通等)
- 访问使用模式和示例
5.搜索工具(v1.0.0中的新功能)
在不加载完整模式的情况下查找工具:
mcp-codegen search "weather forecast" --detail basic输出:
Found 1 tool(s) matching 'weather forecast':
weather/get_weather_forecast
Get weather forecast for a location或者在Python中:
from mcp_codegen.runtime import search_tools
tools = search_tools("weather forecast")
for tool in tools:
print(f"{tool.server}/{tool.tool}")
print(f" {tool.summary}")
# Load on demand
module = tool.load()
result = await module.call(base_url, module.Params(...))6.使用沙盒执行代理代码(v1.0.0中的新功能)
mcp-codegen run --file agent.py \
--cpu-seconds 10 \
--memory-mb 512您的代理脚本可以安全地使用MCP工具:
# agent.py
from mcp_codegen.runtime import search_tools, workspace, run_async
from servers.weather.get_weather_forecast import call, Params
# Search for available tools
tools = search_tools("weather")
print(f"Found {len(tools)} weather tools")
# Call a tool
async def get_forecast():
params = Params(lat=64.75, lon=20.95)
result = await call('https://your-mcp-server.com', params)
return result
# Execute async code
run_async(get_forecast)
# Write results without hitting the model
workspace.write("forecast.json", forecast_result)命令参考
mcp-codegen ls -列出工具
列出MCP服务器上的所有可用工具。
语法:
mcp-codegen ls \
--url \
[--transport {auto,streamable-http,sse}] \
[--verbose]选项:
--url URL(必填)-MCP服务器URL--transport(默认:自动)-传输协议--verbose-显示调试信息
示例:
# Auto-detect transport
mcp-codegen ls --url http://localhost:8000
# Force SSE transport
mcp-codegen ls --url http://localhost:8000 --transport sse
# Verbose output
mcp-codegen ls --url http://localhost:8000 --verbosemcp-codegen gen -生成代码
从MCP服务器定义生成Python模块。
语法:
mcp-codegen gen \
--url \
--out \
--name \
[--fs-layout] \
[--output-dir ]选项:
--url URL(必填)-MCP服务器URL--out FILE(必填)-输出文件路径(适用于单文件模式)--name NAME(默认值:mcp_stub)-模块/服务器名称--fs-layout-生成每个工具的文件,而不是单个文件--output-dir DIR(默认:服务器)-fs布局的输出目录--generate-skill-生成克劳德代码技能文件(新)--skill-dir DIR(默认:.claude/stkills)-技能目录
示例:
单文件生成:
mcp-codegen gen \
--url http://localhost:8000 \
--out weather_tools.py \
--name weather文件系统布局生成:
mcp-codegen gen \
--url http://localhost:8000 \
--fs-layout \
--name weather使用Claude Code技能生成(推荐):
mcp-codegen gen \
--url http://localhost:8000 \
--fs-layout \
--name weather \
--generate-skillmcp-codegen call -调用工具
直接调用MCP工具,无需生成代码。
语法:
mcp-codegen call \
--url \
--tool \
[--arg KEY=VALUE] \
[--json]选项:
--url URL(必填)-MCP服务器URL--tool TOOL(必需)-要调用的工具名称--arg KEY=VALUE-工具参数(可重复)--json-输出原始JSON-RPC结果
示例:
字符串参数:
mcp-codegen call \
--url http://localhost:8000 \
--tool greet \
--arg name=WorldJSON参数:
mcp-codegen call \
--url http://localhost:8000 \
--tool search \
--arg limit=10 \
--arg filters='{"type":"active"}'数字参数:
mcp-codegen call \
--url http://localhost:8000 \
--tool get_weather \
--arg lat=64.75 \
--arg lon=20.95 \
--arg limit=1mcp-codegen search -搜索工具(新)
在生成的服务器上搜索工具。
语法:
mcp-codegen search \
[--servers-dir ] \
[--detail {name,basic,full}]选项:
QUERY(必需)-搜索查询(匹配服务器名称、工具名称或摘要)--servers-dir DIR(默认:服务器)-包含生成的服务器的目录--detail(默认:基本)-要显示的详细程度
- name:仅显示姓名 - basic:显示名称和摘要 - full:显示所有内容+使用示例
示例:
# Quick search
mcp-codegen search "weather" --detail name
# Search with summaries
mcp-codegen search "forecast" --detail basic
# Full details
mcp-codegen search "get" --detail fullmcp-codegen run -执行代理代码(新)
执行具有资源限制和沙盒的Python代理代码。
语法:
mcp-codegen run \
[--file | --code
] \
[--servers-dir ] \
[--workspace ] \
[--cpu-seconds ] \
[--memory-mb ] \
[--disable-network] \
[--seccomp] \
[--firejail]选项:
--file FILE或--code CODE-要执行的脚本或代码(需要一个)--servers-dir DIR(默认:服务器)-服务器工具目录--workspace DIR(默认值:.workspace)-工作区输出目录--cpu-seconds N(默认值:10)-CPU时间限制(秒)--memory-mb N(默认值:512)-内存限制(MB)--disable-network-阻止网络访问(默认情况下为MCP工具启用)--seccomp-启用seccomp系统调用筛选(仅限Linux)--firejail-使用Firejail沙盒运行(仅限Linux)
示例:
使用默认值运行脚本:
mcp-codegen run --file agent.py增加限制:
mcp-codegen run --file agent.py \
--cpu-seconds 30 \
--memory-mb 1024启用硬化:
mcp-codegen run --file agent.py \
--seccomp \
--disable-network # Block network if not needed使用Firejail沙盒:
mcp-codegen run --file agent.py --firejail来自stdin:
echo "print('Hello from agent')" | mcp-codegen run --code -了解v1.0.0的新功能
渐进式文件系统布局
传统方法产生了 单个大文件 使用所有工具:
# mcp_tools.py - might be 50KB+ with 100+ tools
class tool1: ...
class tool2: ...
class tool3: ...
# ... hundreds more问题: 即使你只需要 tool1,您可以加载和解析100多个工具。
v1.0.0中的解决方案: 生成 每个工具的单个文件:
servers/
└── weather/
├── get_forecast.py (2KB - only what you need)
├── list_locations.py (2KB)
└── search_location.py (2KB)优点:
- ✅ 快速进口 -只加载您使用的内容
- ✅ 小背景 -非常适合具有令牌限制的AI代理
- ✅ 发现的 -易于浏览的可用工具
- ✅ 可组合 -混合来自多个服务器的工具
不加载模式的工具搜索
在所有服务器上查找工具 不执行任何代码:
from mcp_codegen.runtime import search_tools
# Super fast - uses AST parsing, not module execution
tools = search_tools("weather forecast")
# Tools are ToolRef objects - not loaded yet
for tool in tools:
print(tool.server) # "weather"
print(tool.tool) # "get_forecast"
print(tool.summary) # "Get weather forecast..."
# Load module on demand
module = tool.load()
result = await module.call(base_url, module.Params(...))它是如何工作的:
- 扫描
servers/工具文件目录 - 使用AST解析提取文档字符串(无需执行)
- 返回轻量级
ToolRef物体 - 仅在需要时加载模块
使用沙盒执行Python代码
安全执行任意Python代码:
mcp-codegen run --file agent.py \
--cpu-seconds 10 \
--memory-mb 512 \
--seccomprunner为您的代码提供了什么:
# Automatically available:
from mcp_codegen.runtime import search_tools, workspace, run_async
from privacy import scrub
from logger import logger
# Search for tools
tools = search_tools("weather")
# Use workspace for I/O (doesn't go to model)
workspace.write("results.json", data)
# Execute async code
run_async(my_async_function)
# Scrub PII from logs
safe_text = scrub("email: user@example.com") # → "[EMAIL]"
# Log safely (auto-scrubbed)
logger.info("Processing data", status="ok")安全层(内置):
- 资源限制 (所有平台)
- CPU:默认10秒(杀死失控循环) - 内存:默认512MB(防止OOM) - 文件描述符:64(防止资源耗尽) - 进程数:64(防止分叉炸弹)
- 网络隔离 (仅Python级别)
- 默认启用-允许MCP工具调用 - 阻碍: socket.socket(), socket.create_connection()等禁用时 - ⚠️ 还阻止MCP客户端 -使用 --disable-network 仅当不需要API调用时 - 目的:可选择通过直接网络访问防止数据泄露
- 输出限制 (所有平台)
- 200KB标准输出上限(防止垃圾邮件) - 200KB标准错误上限(防止垃圾邮件)
- PII清洗 (所有平台)
- 自动编辑:电子邮件、电话号码、社会安全号码、信用卡 - 私有IP检测 - 基于密钥的编校:密码、令牌、秘密
- 可选的Linux强化:
- seccomp:系统调用过滤(在内核级别阻止套接字系统调用) - 消防监狱:具有网络隔离、只读文件系统和降级功能的完整沙盒
这一切是如何协同工作的
一个完整的例子:
# Step 1: Generate filesystem layout from MCP server
mcp-codegen gen --fs-layout \
--url https://github-mcp.example.com \
--name github
# Step 2: Agent code searches for specific tools
# agent.py
from mcp_codegen.runtime import search_tools, workspace
tools = search_tools("github create pr") # Fast search
for tool in tools:
module = tool.load()
# Now use the tool...
# Step 3: Run agent safely
mcp-codegen run --file agent.py \
--cpu-seconds 30 \
--memory-mb 1024 \
--seccomp
# Network enabled by default for MCP tools发生了什么:
- ✅ 代理从应用资源限制开始
- ✅ MCP工具调用已启用网络
- ✅ 代理在不加载架构的情况下搜索工具
- ✅ 代理仅按需加载所需的工具
- ✅ 代理通过以下方式调用MCP工具
await tool.call(...) - ✅ 结果已写入
workspace/(不去模型) - ✅ 输出上限为200KB
- ✅ 从日志中自动编辑PII
- ✅ 超时会杀死长时间运行的代码
- ✅ 监控所有系统调用(seccomp模式)
基于MCP最佳实践
mcp编码遵循Anthropic文章中推荐的模式 使用MCP执行代码:构建更高效的代理.
渐进呈现
mcp-codegen没有预先将所有工具定义加载到上下文中,而是生成了一个文件系统布局,可以按需发现和加载工具:
- 每个工具都是一个单独的文件(约1.5-2KB)
- Claude只加载当前任务所需的工具
- 将上下文使用率降低98%(从150K令牌减少到2K令牌)
传统方法(低效):
# All 100+ tool definitions loaded into context immediately
# Even if you only need one tool, you pay for all of them
from monolithic_tools import tool1, tool2, tool3, ... tool100mcp编码方法(高效):
# Load only what you need
from servers.github.create_issue import call, Params
from servers.github import SERVER_URL不加载模式的工具搜索
这 search_tools() 函数允许在不加载完整定义的情况下查找工具:
from mcp_codegen.runtime import search_tools
# Find tools without loading schemas (uses AST parsing, not execution)
tools = search_tools("weather")
# Returns lightweight ToolRef objects, load on demand
tool = tools[0].load() # Load only when needed这符合Anthropic对 search_tools 允许详细级别(仅名称、基本描述或完整模式)的函数。
可重用模式的技能
生成的技能(通过 --generate-skill)向克劳德代码提供:
- 服务器信息和URL -在哪里可以找到工具以及如何连接
- 工具类别和说明 -天气、交通、数据等。
- 使用模式和示例 -如何导入和调用工具
- 激活触发器 -自动激活技能的关键字
来自Anthropic的文章:
“将SKILL.md文件添加到这些保存的函数中,可以创建模型可以参考和使用的结构化技能。”
mcp codegen会自动生成这些SKILL.md文件,其中包含有关每个mcp服务器的全面信息。
基于代码的工具交互
工具以类型安全的Python API形式呈现,而不是基于字符串的工具调用:
from servers.smhi.get_weather_forecast import call, Params
from servers.smhi import SERVER_URL
# Type-safe, validated parameters with Pydantic
params = Params(lat=64.75, lon=20.95, limit=6)
result = await call(SERVER_URL, params)这种方法提供了:
- 具有自动补全功能的完整IDE支持
- 开发时的类型检查
- 通过Pydantic模型进行参数验证
- 熟悉的编程模式(导入、函数、类型)
这种方法的好处
上下文效率:
- 仅加载所需工具(并非所有100+定义)
- 在返回模型之前,在代码中过滤和转换数据
- 在一次执行中编写多个工具调用
- 在不增加上下文的情况下处理大型数据集
开发人员经验:
- 熟悉的编程模式(导入、函数、类型)
- 完整的IDE支持,具有自动补全和类型检查功能
- 易于调试和测试
- 无自定义DSL或基于字符串的工具调用语法
可扩展性:
- 在数十台服务器上处理数千个工具
- 无上下文膨胀的多服务器编排
- 通过文件系统(工作区)实现状态持久化
- 根据需要逐步加载工具
文章中的示例: 本文展示了直接工具调用如何要求通过上下文传递完整结果:
TOOL CALL: gdrive.getDocument() → 50,000 tokens flow through model
TOOL CALL: salesforce.updateRecord() → 50,000 tokens written again通过代码执行,相同的工作流变成:
# Data flows through code, not through model context
transcript = (await gdrive.getDocument(documentId='abc123')).content
await salesforce.updateRecord(data={'Notes': transcript})
# Model only sees: "Updated 1 record" (instead of 100K tokens)mcp-codegen通过使mcp工具作为代码API可用来实现这种模式。
有关这些模式及其背后原理的更多详细信息,请参阅 Anthropic的完整文章.
传输协议
mcp codegen自动检测最佳传输,延迟最小:
- 可流式传输http -使用MCP帧流式传输HTTP
- 通过以下方式检测: HEAD /mcp 随着 Accept: text/event-stream - 可用时最快
- SSE(服务器发送事件) -标准网络流媒体
- 通过以下方式检测: HEAD /sse 随着 Accept: text/event-stream - 流式传输http的好替代品
- HTTP POST(JSON-RPC 2.0) -基于HTTP的标准JSON-RPC
- 通过以下方式检测: POST /mcp 使用初始化探针 - 所有服务器的回退 - 适用于简单的HTTP服务器
检测时间: 约1-2秒,有短暂超时(1.5秒连接,0.4秒读取)
缓存: 传输被检测一次,并为所有后续请求缓存
生成的代码质量
生成的模块包括:
- ✅ 类型安全 -带有完整类型提示的Pydantic模型
- ✅ 独立 -运行时不依赖于mcp codegen
- ✅ 零拷贝 -最小的开销,直接MCP呼叫
- ✅ 快速 -自动协商传输,缓存连接
- ✅ 可靠的 -自动传输回退
每个工具都变成一个类:
class get_weather_forecast:
class Params(BaseModel):
lat: float
lon: float
limit: int | None = None
@staticmethod
async def call(
base_url: str,
params: Params,
headers: dict[str, str] | None = None
) -> Any:
# ...call MCP tool...建筑
核心组件
mcp-codegen/
├── codegen.py # Code generation engine
├── client.py # MCP client with transport detection
├── cli.py # Command-line interface
├── fs_layout.py # Filesystem layout generator
└── runtime/
├── search.py # Tool discovery (ToolRef, search_tools)
├── client.py # Runtime MCP client
└── privacy.py # PII scrubbing
examples/runner/
├── run.py # Main runner script
├── limits.py # Resource limit enforcement
├── privacy.py # PII detection & redaction
├── workspace.py # Workspace file I/O
├── logger.py # Structured logging
├── sandbox.py # seccomp & Firejail integration
└── firejail-mcp.profile # Sandbox profile template数据流
User Input
↓
[CLI] mcp-codegen command
↓
[codegen] Connect to MCP server → Fetch schemas
↓
[client] Negotiate transport & protocol version
↓
[generate] Create Python code (single file or fs-layout)
↓
[runtime] Agent loads and uses tools
↓
[runner] Enforce limits, scrub PII, sandbox
↓
Output (workspace or stdout)用例
1.人工智能代理开发
# Agent needs to use multiple MCP tools safely
from mcp_codegen.runtime import search_tools, workspace
tools = search_tools("github") # Find all GitHub tools
for tool in tools:
mod = tool.load()
result = await mod.call(base_url, mod.Params(...))
workspace.write("results.json", result) # Agent output2.CLI工具集成
# List GitHub tools
mcp-codegen ls --url https://github-mcp.example.com
# Call directly without code
mcp-codegen call --url https://github-mcp.example.com \
--tool create_pr \
--arg title="Fix bug" \
--arg body="Fixes #123"3.类型安全的Python应用程序
# Generate and use in production code
from github_tools import create_pr, list_repos
async def deploy_pr():
repos = await list_repos.call(base_url, list_repos.Params())
for repo in repos:
pr = await create_pr.call(
base_url,
create_pr.Params(
owner=repo.owner,
title="Release v1.0"
)
)4.服务器到服务器集成
# Generate client for your MCP server
mcp-codegen gen \
--url http://api.partner.com/mcp \
--out partner_client.py
# Now you have type-safe access to their tools
import partner_client
result = await partner_client.query.call(...)5.在Claude代码中使用MCP服务器
Claude Code可以安装和使用MCP服务器。渐进式文件系统布局使Claude能够轻松发现和使用工具,而无需一次加载所有内容。
设置:为MCP服务器生成文件系统布局
# Generate layout + skill for a GitHub MCP server
mcp-codegen gen --fs-layout \
--url http://localhost:3000 \
--name github \
--generate-skill
# Generate layout + skill for a Slack MCP server
mcp-codegen gen --fs-layout \
--url http://localhost:3001 \
--name slack \
--generate-skill
# Result: browsable tool directory + Claude Code skills
# servers/
# ├── github/
# │ ├── __init__.py
# │ ├── create_issue.py
# │ ├── create_pr.py
# │ ├── list_repos.py
# │ └── search_code.py
# └── slack/
# ├── __init__.py
# ├── send_message.py
# └── list_channels.py
#
# .claude/skills/
# ├── mcp-github/
# │ └── SKILL.md
# └── mcp-slack/
# └── SKILL.md用法:Claude按需发现和使用工具
当您要求Claude Code执行任务时,它可以:
- 搜索相关工具 不加载架构:
from mcp_codegen.runtime import search_tools
# Claude searches: "I need to create a GitHub issue"
tools = search_tools("github issue")
# Returns: [ToolRef(server="github", tool="create_issue", ...)]
# Load only the needed tool
tool = tools[0].load()- 直接导入特定工具 当任务明确时:
# Claude knows exactly what tool to use
from servers.github.create_issue import call, Params
result = await call(
'http://localhost:3000',
Params(
owner="myorg",
repo="myrepo",
title="Bug: login fails",
body="Steps to reproduce..."
)
)- 整合来自多台服务器的工具:
# Claude can orchestrate multi-server workflows
from servers.github.create_issue import call as create_issue, Params as IssueParams
from servers.slack.send_message import call as send_message, Params as SlackParams
# Create GitHub issue
issue = await create_issue(
'http://localhost:3000',
IssueParams(owner="myorg", repo="myrepo", title="Deploy v2.0")
)
# Notify team on Slack
await send_message(
'http://localhost:3001',
SlackParams(
channel="#deploys",
text=f"New deploy issue created: {issue.url}"
)
)为什么这对Claude Code很有效:
- ✅ 自动技能激活 -生成的技能告诉克劳德何时使用这些工具
- ✅ 快速工具发现 -Claude可以在不执行代码的情况下搜索工具
- ✅ 最小化上下文使用 -仅导入所需内容(2KB vs 50KB+)
- ✅ 类型安全性 -完整的IDE自动补全和类型检查
- ✅ 可浏览结构 -克劳德可以探索
servers/了解可用工具的目录 - ✅ 多服务器支持 -每个服务器都有自己的技能,易于编排
- ✅ 按需加载 -工具是JIT加载的,减少了内存和启动时间
与Claude Code的对话示例:
You: "Create a GitHub issue for the login bug and notify the team on Slack"
Claude: I'll help you create the issue and send a Slack notification.
[Claude searches for tools]
from mcp_codegen.runtime import search_tools
tools = search_tools("github issue") # Finds create_issue
slack_tools = search_tools("slack message") # Finds send_message
[Claude imports only what's needed]
from servers.github.create_issue import call as create_issue, Params as IssueParams
from servers.slack.send_message import call as send_message, Params as SlackParams
[Claude executes the workflow]
...发展
在开发模式下安装
pip install -e ".[dev,test,runner]"运行测试
pytest tests/ -v测试新组件
实施包括全面的测试:
test_fs_layout.py-文件系统布局生成test_runtime_search.py-工具发现test_codegen_v2.py-代码生成test_exceptions.py-错误处理
贡献
贡献时:
- 遵循现有代码样式
- 为新功能添加测试
- 更新README.md
- 如果可能,使用真实的MCP服务器进行测试
安全考虑
网络隔离
默认情况下, mcp-codegen run 允许MCP工具访问网络。使用 --disable-network 要阻止所有网络:
# With --disable-network flag:
import socket
socket.socket() # RuntimeError: Network access blocked
# By default, this works:
from servers.my_tool import call
result = await call(base_url, params)资源限制
防止拒绝服务:
# Limits by default
--cpu-seconds 10 # Kill at 10s
--memory-mb 512 # Kill at 512MB
# Increase if needed
--cpu-seconds 300 --memory-mb 2048Linux强化
对于生产使用,启用系统调用筛选:
mcp-codegen run --file agent.py --seccomp
# Or full sandbox
mcp-codegen run --file agent.py --firejailPII保护
敏感数据的自动编辑:
from privacy import scrub
# Before: "Contact: user@example.com, phone: 555-123-4567"
# After: "Contact: [EMAIL], phone: [PHONE]"
text = scrub("Contact: user@example.com, phone: 555-123-4567")故障排除
连接问题
# Test with verbose output
mcp-codegen ls --url http://localhost:8000 --verbose
# Force specific transport
mcp-codegen ls --url http://localhost:8000 --transport sse导入错误
# Make sure installed
pip install -e .
# Check Python path
python -c "from mcp_codegen import codegen; print('OK')"跑步者问题
# Check resource limits on Linux
ulimit -a
# Run with more memory
mcp-codegen run --file agent.py --memory-mb 2048
# Disable sandbox if issues
mcp-codegen run --file agent.py # No --seccomp flag许可证
有关许可证信息,请参阅存储库。
贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 添加测试
- 提交拉取请求
______________________________________________________________________
