Agent Factory MCP
A universal MCP server that automatically discovers and registers CLI tools as AI-powered agents with persona configuration, enabling any CLI tool to be used as an MCP tool.
README
Agent Factory MCP
<div align="center">
</div>
A universal Model Context Protocol (MCP) server that automatically discovers and registers CLI tools as MCP tools. Transform any CLI tool (Qwen, Ollama, Aider, etc.) into an AI-powered agent with persona configuration.
Features
- Auto-Discovery: Automatically parse CLI
--helpoutput to generate tool metadata - Zero-Code Registration: Register tools via config file or command-line arguments
- Persona Support: Configure system prompts to create specialized AI agents
- Multi-Provider: Use multiple AI tools simultaneously (Qwen, Gemini, Aider, etc.)
- Runtime Registration: Add new tools dynamically via MCP protocol
Architecture
graph TB
subgraph "MCP Client"
A[Claude Desktop / Claude Code]
end
subgraph "Agent Factory MCP Server"
B[Server Entry Point]
C[Config Loader]
D[Tool Registry]
E[Dynamic Tool Factory]
subgraph "Providers"
F[QwenProvider]
G[GenericCliProvider]
end
subgraph "Parsers"
H[HelpParser]
end
end
subgraph "CLI Tools"
I[qwen]
J[gemini]
K[aider]
L[ollama]
M[...any CLI tool]
end
A -->|stdio| B
B --> C
B -->|CLI args| G
C -->|load config| D
G -->|create| D
D --> E
E -->|generate| F
F -->|execute| I
F -->|execute| J
F -->|execute| K
G -->|parse --help| H
H -->|metadata| G
State Transition
stateDiagram-v2
[*] --> Initialization
Initialization --> LoadConfig: Start
Initialization --> ProcessCLIArgs: CLI args provided
LoadConfig --> ProcessCLIArgs: Config loaded
ProcessCLIArgs --> RegisterProviders
RegisterProviders --> ProviderCreated: Tool available
RegisterProviders --> ProviderSkipped: Tool not found
ProviderCreated --> GenerateTools
ProviderSkipped --> RegisterProviders: Next tool
GenerateTools --> ToolRegistered
ToolRegistered --> RegisterProviders: Next tool
RegisterProviders --> ServerRunning: All tools processed
ServerRunning --> [*]: Ready for MCP requests
ServerRunning --> RuntimeRegistration: register_cli_tool called
RuntimeRegistration --> ServerRunning: Tool added
note right of LoadConfig
Loads ai-tools.json
or .qwencoderc.json
end note
note right of ProcessCLIArgs
Parses CLI args like:
npx agent-factory-mcp qwen gemini aider
end note
Installation
# Install via npm
npm install -g agent-factory-mcp
# Or use with npx without installation
npx agent-factory-mcp
# Or use with bun
bunx agent-factory-mcp
Configuration
Method 1: Command-Line Arguments
Register tools directly via CLI arguments:
npx agent-factory-mcp qwen gemini aider
Method 2: Configuration File
Create ai-tools.json in your project root:
{
"$schema": "./schema.json",
"version": "1.0",
"tools": [
{
"command": "qwen",
"alias": "code-reviewer",
"description": "Code review expert focusing on security and performance",
"systemPrompt": "You are a senior code reviewer. Focus on security vulnerabilities, performance issues, and maintainability."
},
{
"command": "qwen",
"alias": "doc-writer",
"description": "Technical documentation specialist",
"systemPrompt": "You write clear, concise technical documentation for developers."
}
]
}
Method 3: Runtime Registration
Use the register_cli_tool MCP tool:
register_cli_tool({
command: "ollama",
alias: "local-llm",
description: "Run local LLM models via Ollama",
systemPrompt: "You are a helpful AI assistant running locally.",
persist: true
})
MCP Client Setup
Claude Desktop
Add to your Claude Desktop config:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json
{
"mcpServers": {
"agent-factory": {
"command": "npx",
"args": ["agent-factory-mcp", "qwen", "gemini", "aider"]
}
}
}
Claude Code CLI
claude mcp add agent-factory -- npx agent-factory-mcp qwen gemini aider
Usage Examples
Using Specialized Agents
# Code review with security focus
"Use code-reviewer to analyze this file for security issues"
# Documentation generation
"Ask doc-writer to generate API docs for this module"
# General AI assistance
"Use ask-qwen to explain this code"
Multiple AI Tools
# Use different AIs for different tasks
"Use gemini-vision to analyze this screenshot"
"Use aider to refactor this function"
"Use qwen to review the changes"
Configuration Schema
See schema.json for the full configuration schema:
| Field | Type | Required | Description |
|---|---|---|---|
command |
string | ✅ | CLI command to register (e.g., "qwen", "ollama") |
enabled |
boolean | ❌ | Whether the tool is enabled (default: true) |
alias |
string | ❌ | Custom tool name (default: "ask-{command}") |
description |
string | ❌ | Custom tool description |
systemPrompt |
string | ❌ | System prompt for AI persona |
providerType |
string | ❌ | Provider type: "cli-auto" or "custom" |
defaultArgs |
object | ❌ | Default argument values |
Development
# Install dependencies
bun install
# Build
bun run build
# Run tests
bun test
# Type check
bun run type-check
# Lint
bun run lint
# Format
bun run format
Project Structure
agent-factory-mcp/
├── src/
│ ├── index.ts # Server entry point
│ ├── constants.ts # Constants
│ ├── providers/ # Provider implementations
│ │ ├── base-cli.provider.ts
│ │ ├── generic-cli.provider.ts
│ │ └── qwen.provider.ts
│ ├── tools/ # Tool registry and factory
│ │ ├── registry.ts
│ │ ├── dynamic-tool-factory.ts
│ │ └── simple-tools.ts
│ ├── parsers/ # CLI help parser
│ │ └── help-parser.ts
│ ├── types/ # TypeScript types
│ │ └── cli-metadata.ts
│ └── utils/ # Utilities
│ ├── configLoader.ts
│ ├── commandExecutor.ts
│ ├── logger.ts
│ └── progressManager.ts
├── test/ # Test files
├── ai-tools.json.example # Example configuration
├── schema.json # JSON schema
└── Taskfile.yml # Task runner configuration
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。