一个智能的MCP(模型上下文协议)服务器,通过React代理提供专门的文件系统操作。设计用于增强像Claude Code这样的AI应用程序,通过将文件系统任务委托给专注于子代理来减少上下文窗口的使用并提高响应准确性。
npm install -g dispatch-agent
git clone https://github.com/abhinav-mangla/dispatch-agent.git
cd dispatch-agent
npm install
npm run build
使用环境变量配置代理:
export API_KEY="your-api-key-here"
# LLM提供商(默认:openai)
export LLM_PROVIDER="openai" # 或 "anthropic"
# 基础URL(默认:https://openrouter.ai/api/v1)
export BASE_URL="https://api.openai.com/v1"
# 模型名称(默认:openai/gpt-4o-mini)
export MODEL_NAME="gpt-4o"
# 温度(默认:0,范围:0-2)
export TEMPERATURE="0.1"
export LLM_PROVIDER="openai"
export API_KEY="sk-..."
export BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4o"
export LLM_PROVIDER="anthropic"
export API_KEY="sk-ant-..."
export MODEL_NAME="claude-3-5-sonnet-20241022"
export API_KEY="sk-or-..."
export BASE_URL="https://openrouter.ai/api/v1"
export MODEL_NAME="anthropic/claude-3.5-sonnet"
export LLM_PROVIDER="anthropic"
启动具有工作目录的MCP服务器:
# 如果全局安装
dispatch-agent /path/to/your/project
# 或使用npx(无需安装)
npx dispatch-agent /path/to/your/project
添加到您的Claude Desktop MCP配置(~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"dispatch-agent": {
"command": "npx",
"args": ["dispatch-agent", "/path/to/your/project"],
"env": {
"API_KEY": "your-api-key-here",
"LLM_PROVIDER": "anthropic",
"MODEL_NAME": "claude-3-5-sonnet-20241022",
"TEMPERATURE": "0"
}
}
}
}
或者如果全局安装:
{
"mcpServers": {
"dispatch-agent": {
"command": "dispatch-agent",
"args": ["/path/to/your/project"],
"env": {
"API_KEY": "your-api-key-here",
"LLM_PROVIDER": "openai",
"BASE_URL": "https://api.openai.com/v1",
"MODEL_NAME": "gpt-4o",
"TEMPERATURE": "0"
}
}
}
}
该服务器实现了标准的MCP协议,并可以与任何兼容MCP的客户端集成:
import { StdioServerTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
const client = new Client({
name: "dispatch-agent-client",
version: "1.0.0"
}, {
capabilities: {}
});
const transport = new StdioServerTransport({
command: "dispatch-agent",
args: ["/path/to/working/directory"]
});
await client.connect(transport);
调度代理架构为AI应用程序提供了显著的性能优势:
dispatch_agent服务器暴露了一个单一工具用于代理调度:
{
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "代理需要处理的消息/任务"
}
},
"required": ["message"]
}
{
"name": "dispatch_agent",
"arguments": {
"message": "查找src目录中导入React的所有TypeScript文件"
}
}
{
"content": [
{
"type": "text",
"text": "找到5个导入React的TypeScript文件:\n- /abs/path/src/components/App.tsx\n- /abs/path/src/components/Button.tsx\n- /abs/path/src/hooks/useEffect.tsx\n- /abs/path/src/pages/Home.tsx\n- /abs/path/src/utils/ReacHelpers.tsx"
}
]
}
调度代理可以访问以下文件系统工具:
✅ 推荐用于:
❌ 不推荐用于:
# 好:复杂的搜索查询
"查找提到数据库的所有配置文件"
"列出项目中大于1MB的Python文件"
# 更适合直接工具:具体文件访问
"读取src/config.json的内容"
"列出/src目录下的文件"
npm run build
npm run dev
dispatch-agent/
├── src/
│ ├── index.ts # CLI入口点
│ ├── server.ts # MCP服务器实现
│ ├── tools/
│ │ └── dispatch-agent.ts # 核心代理逻辑
│ ├── types/
│ │ └── index.ts # TypeScript类型定义
│ └── utils/
│ └── validation.ts # 输入验证实用工具
├── package.json
├── tsconfig.json
└── README.md
git checkout -b feature/new-featurenpm run buildgit commit -am '添加新功能'git push origin feature/new-featureMIT许可证 - 查看LICENSE文件获取详情。
Abhinav Mangla - GitHub
对于问题、建议或贡献:
关键词:MCP,模型上下文协议,AI代理,文件系统,LangGraph,React代理,Claude,OpenAI,Anthropic