克劳德代码MCP开发SDK
        
生产准备就绪 用于模型上下文协议(MCP)开发的Claude代码框架,具有8个专门的AI子代理、FastMCP集成和 强化企业级安全挂钩. 审计得分:10/10 -经过安全审核,在Windows、macOS和Linux上功能齐全,可立即使用(核心功能无需安装)。
🚀 特性
双模架构
- 📝 Markdown驱动的子代理:8名专业代理
.claude/agents/用于Claude Code集成 - 🔧 程序化SDK:完整的Python SDK,支持异步和官方Anthropic API集成
- 🎯 混合动力操作:两个系统通过自动回退无缝协作
核心组件
- ✅ 克劳德代码子代理:8名MCP发展援助专业人员(1419条线路)
- 🔒 强化安全挂钩:企业级输入验证,具有代码注入阻止和空命令防止功能
- 📝 MCP模板:2个FastMCP服务器示例,语法经过验证
- 🔄 CI/CD就绪:GitHub Actions工作流,包含7个自动化作业和安全扫描
- 🛠️ 开发工具:跨平台验证实用程序(无需安装即可工作)
- 🚀 SDK组件:完整的Python API,具有优雅的降级(6016行代码)
📋 需求
- Python 3.8+ (在macOS、Windows、Linux上测试和验证)
- 克劳德代码 (用于子代理功能)- *CLI工具的可选功能*
- 无烟煤API键 (用于编程SDK功能)- *验证工具可选*
- 生产准备就绪:PyPI上可用的所有12个依赖项,无需安装即可立即工作
🛠️ 安装
快速入门(跨平台)
# Clone the repository
git clone https://github.com/gensecaihq/MCP-Developer-SubAgent.git
cd MCP-Developer-SubAgent
# ✅ VERIFIED: Check platform compatibility (works without installation)
python3 claude_code_sdk/cli_simple.py validate-setup
# ✅ TESTED: Basic installation (all dependencies available on PyPI)
pip install -e . # macOS/Linux
python3 -m pip install -e . # Windows (if python3 available)
python -m pip install -e . # Windows (alternative)
# ✅ VERIFIED: Optional authentication support
pip install -e .[auth] # JWT/crypto features (tested on all platforms)📖 有关特定于平台的详细说明,请参阅 安装.md
环境设置
Windows(命令提示符):
set ANTHROPIC_API_KEY=sk-ant-your-key-hereWindows(PowerShell):
$env:ANTHROPIC_API_KEY="sk-ant-your-key-here"macOS/Linux:
export ANTHROPIC_API_KEY=sk-ant-your-key-here🎯 用法
1.Markdown驱动的子代理(Claude代码)
这 .claude/agents/ 目录包含8个直接使用Claude Code的专用子代理:
.claude/agents/
├── mcp-orchestrator.md # Central workflow coordinator (Opus)
├── fastmcp-specialist.md # FastMCP implementation expert (Sonnet)
├── mcp-protocol-expert.md # Protocol specification specialist (Sonnet)
├── mcp-security-auditor.md # Security and authentication expert (Opus)
├── mcp-performance-optimizer.md # Performance optimization specialist (Sonnet)
├── mcp-deployment-specialist.md # Deployment and infrastructure expert (Sonnet)
├── mcp-debugger.md # Troubleshooting specialist (Sonnet)
└── context-manager.md # Context and state management (Sonnet)使用克劳德代码:
# Agents auto-activate based on file patterns
cd your-mcp-project
claude-code
# Request specific agents
> Use the fastmcp-specialist to implement a new tool
> Use the mcp-security-auditor to review authentication2.程序化SDK(需要安装)
备注:需要 pip install -e . 以及适当的依赖关系
from claude_code_sdk import MCPOrchestrator, FastMCPSpecialist
# Initialize orchestrator (requires ANTHROPIC_API_KEY)
orchestrator = MCPOrchestrator()
session_id = await orchestrator.create_conversation()
# Send orchestration request
message = """
Create a new MCP server with the following requirements:
- Name: my-api-server
- Tools: search, analyze, report
- Authentication: OAuth 2.1
"""
result = await orchestrator.send_message(message, output_format="json")
print(result["content"])3.验证工具
# ✅ PRODUCTION-TESTED: Basic validation (works without dependencies)
python3 claude_code_sdk/cli_simple.py validate-setup
python3 claude_code_sdk/cli_simple.py status
# ✅ ENTERPRISE-READY: Advanced CLI (requires pip install -e .)
claude-mcp validate-setup
claude-mcp orchestrate --workflow new_server安全强化指标:8个子代理,2个验证示例,增强的安全挂钩(块代码注入),带安全扫描的7个作业CI/CD管道
🏗️ 建筑
目录结构
MCP-Developer-SubAgent/
├── .claude/
│ ├── agents/ # Markdown sub-agents for Claude Code
│ ├── config.json # Agent configuration
│ ├── hooks.json # Hooks configuration
│ └── hooks/ # Hook handlers
├── .github/
│ └── workflows/ # GitHub Actions CI/CD
├── claude_code_sdk/ # Programmatic SDK
│ ├── claude_integration.py
│ └── cli.py
├── examples/ # Working MCP examples
│ ├── minimal-mcp-server/
│ ├── enterprise-auth-server/
│ └── testing-framework/
├── docs/ # Documentation
├── pyproject.toml # Modern Python packaging
├── setup.py # Legacy packaging support
└── requirements.txt # Dependencies优质闸门管道
- 规划大门:要求、架构、运输选择
- 协议门:MCP合规性、JSON-RPC验证
- 安全门:身份验证、输入验证、边界
- 实施大门:代码质量、类型安全、模式
- 测试门:覆盖范围、合规性、整合
- 性能门:异步模式、优化、基准测试
- 文件门:API文档、示例、部署指南
🔧 例子
使用工具创建MCP服务器
from claude_code_sdk import FastMCPSpecialist
specialist = FastMCPSpecialist()
await specialist.create_conversation()
message = """
Generate a FastMCP server with these tools:
1. search_documents - Search through documents
2. analyze_data - Analyze structured data
3. generate_report - Create formatted reports
Include proper Pydantic models and error handling.
"""
result = await specialist.send_message(message, output_format="json")
# Generated server code in result["content"]工作流程编排
task = {
"type": "orchestrate_workflow",
"workflow": "new_server",
"requirements": {
"name": "analytics-server",
"tools": ["query", "aggregate", "visualize"],
"authentication": "jwt",
"transport": "http"
}
}
result = await orchestrator.send_message(json.dumps(task), output_format="json")🚦 挂钩系统
在中配置自动化 .claude/hooks.json:
{
"hooks": [
{
"event": "PreToolUse",
"matchers": [{"toolType": "Write"}],
"command": "python .claude/hooks/pre_tool_validator.py"
},
{
"event": "PostToolUse",
"matchers": [{"toolType": "Write", "fileGlob": "**/*.py"}],
"command": "python .claude/hooks/post_tool_quality_gate.py"
}
]
}🔄 GitHub操作集成
自动化工作流程 .github/workflows/claude-code-mcp.yml:
- 拉取请求检查:质量门验证、格式检查
- 问题触发器:从问题自动生成MCP服务器
- 安全性审计:自动安全扫描
- 文档:自动部署到GitHub页面
🧪 测试
# ✅ PRODUCTION-VERIFIED: Core functionality testing
python3 claude_code_sdk/cli_simple.py validate-setup # Works without installation
python3 claude_code_sdk/cli_simple.py status # Cross-platform tested
# ✅ SECURITY-AUDITED: Hook system testing
echo '{"toolType": "Write", "filePath": "test.py"}' | python3 .claude/hooks/pre_tool_validator.py
# ✅ SYNTAX-VALIDATED: Example server testing
python3 -m py_compile examples/minimal-mcp-server/server.py
python3 -m py_compile examples/enterprise-auth-server/server.py
# ✅ CI/CD-INTEGRATED: Automated testing pipeline
# GitHub Actions workflow: 7 jobs, Python matrix, security scans安全审计结果:所有命令均已测试✅, 增强的安全挂钩可阻止危险代码✅, 跨平台验证✅, 零安全漏洞✅
📚 文档
文档状态:18个文件✅, 所有命令均已验证✅, 跨平台测试✅, 加强安保✅
🤝 贡献
我们欢迎捐款!贡献有价值的关键领域:
优先领域
- 其他专业代理:为特定的MCP开发领域创建新的代理
- 增强型质量闸门:改进验证和测试框架
- 性能优化:优化异步模式和资源使用
- 文档:改进指南、示例和故障排除
- 示例实现:真实世界的MCP服务器示例
贡献过程
- 分叉存储库
- 创建要素分支(
git checkout -b feature/amazing-feature) - 按照现有模式进行更改
- 测试用
python3 claude_code_sdk/cli_simple.py validate-setup - 提交带有详细描述的拉取请求
开发设置
pip install -e .[dev] # Install with development dependencies
pytest # Run tests
black . # Format code📝 许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
🔒 隐私和安全
🛡️ 您的隐私受到保护:该项目收集 无遥测 并传输 无用户数据。所有内容都在您的机器上本地运行。看 隐私.md 了解全部细节。
🔐 安全第一:具有强化验证挂钩、代码注入预防和企业合规功能的生产级安全。
🙏 致谢
- GenSecAI.org -通过先进的人工智能安全研究确保GenAI的未来
- Anthropic -Claude AI和Claude Code框架
- MCP协议社区 -模型上下文协议规范和生态系统
- FastMCP贡献者 -Python MCP框架开发
🔗 重要链接
- Claude代码文档 -官方克劳德代码指南
- 模型上下文协议 -MCP规范
- 包索引 -用于依赖项安装
- **** -报告错误或请求功能
______________________________________________________________________
*用于模型上下文协议开发的Claude代码框架,具有专门的子代理、安全挂钩和MCP服务器模板。*
