使用说明
Generate production-ready MCP servers from natural language prompts.
8 templates · 11 APIs · TypeScript & Python · Docker · Web Dashboard · Claude Desktop integration
MCP工厂
MCP Factory是一个CLI+web工具,它采用简单的英文描述,并生成一个完全可用的 模型上下文协议 服务器——内置工具、类型、错误处理、验证、代码审查和最佳实践。
pip install "prompt2mcp[web]"
mcpfactory create "a server that reads CSV files and runs SQL queries on them"
没有样板。无需手动接线。只需描述您想要什么。
目录
先决条件
| 要求 | 最低版本 | 为什么 | 检查 |
|---|---|---|---|
| python | 3.10+ | 自行运营MCP工厂 | python --version |
| 点 | 最新 | 安装MCP工厂 | pip --version |
| Node.js | 18+ | 需要构建/运行TypeScript服务器 | node --version |
| npm | 9+ | 安装TypeScript服务器依赖项 | npm --version |
注: Node.js和npm只有在生成时才需要 TypeScript 服务器(默认)。仅支持Python的服务器不需要它们。
安装后,运行
mcpfactory doctor验证所有设置是否正确。
安装
来自PyPI(推荐):
# Core CLI only
pip install prompt2mcp
# With web dashboard
pip install "prompt2mcp[web]"
来源:
git clone https://github.com/JatinTaori1904/mcp-factory.git
cd mcp-factory
pip install -e ".[dev,web]"
快速开始
1.创建您的第一台服务器
mcpfactory create "github repo manager with issues and PRs"
这将在中生成一个完整的MCP服务器 ./output/github-repo-manager/ 与:
github-repo-manager/
├── src/
│ └── index.ts # Full MCP server with tools
├── package.json # Dependencies configured
├── tsconfig.json # TypeScript config
├── .env.example # Environment variables needed
├── Dockerfile # Container-ready deployment
├── .dockerignore # Docker build exclusions
└── README.md # Usage instructions
2.运行生成的服务器
cd output/github-repo-manager
npm install
npm start
2b。或者使用Docker运行
cd output/github-repo-manager
docker build -t github-repo-manager .
docker run -i --env-file .env github-repo-manager
3.连接到克劳德桌面
mcpfactory config-add github-repo-manager
# → Automatically adds the server to Claude Desktop's config
就是这样——您的服务器现在可以作为Claude中的工具使用。
更多示例
# Python server for Slack
mcpfactory create "slack bot that posts messages and manages channels" --lang python
# Use OpenAI for smarter analysis
mcpfactory create "stripe payment processor with refunds" --provider openai --model gpt-4
# Interactive mode — MCP Factory asks follow-up questions
mcpfactory create "something for files" --interactive
# Custom name and output directory
mcpfactory create "notion wiki manager" --name my-wiki --output ./servers
# Browse all available templates
mcpfactory templates
# See supported APIs with auth details
mcpfactory supported-apis
Web仪表板
MCP Factory包括一个内置的web仪表板,用于直观地管理您的服务器。
mcpfactory web
# → Opens at http://localhost:8000
仪表板功能:
| Page | 它的作用 |
|---|---|
| 家 | 统计概述——创建的服务器、模板、API、总体工具 |
| 创建 | 从浏览器生成具有实时反馈的服务器 |
| API注册表 | 浏览所有11个支持的API,包括身份验证信息和免费层状态 |
| 配置 | 管理Claude Desktop集成——添加/删除服务器,导出配置 |
仪表板使用现代的glassmorphism UI,具有深色主题、渐变色调和流畅的动画。
# Custom host/port
mcpfactory web --host 0.0.0.0 --port 3000
特性
🧠 智能提示分析
5层LLM管道确保您的提示始终被理解:
| 层级 | 提供商 | 何时 |
|---|---|---|
| 1 | 奥拉玛 (本地) | 默认值--私人、免费、离线 |
| 2 | 开放人工智能 | --provider openai |
| 3 | 克劳德 | --provider claude |
| 4 | 关键字回退 | 如果所有LLM都不可用,则自动 |
| 5 | 默认模板 | 终极安全网 |
📦 8个内置模板
| 模板 | 用例 | 生成的工具 |
|---|---|---|
file-reader |
读取、搜索和查看文件 | file_read, file_search, file_watch |
database-connector |
查询PostgreSQL、MySQL、SQLite | db_query, db_list_tables, db_describe |
api-wrapper |
包裹任何REST API | api_get, api_post, api_list |
web-scraper |
抓取和解析web内容 | scrape_url, extract_links, parse_html |
document-processor |
解析PDF、DOCX、Markdown | doc_parse, doc_convert, doc_extract |
auth-server |
OAuth2/JWT身份验证 | auth_login, auth_verify, auth_refresh |
data-pipeline |
ETL:提取、转换、加载 | pipeline_extract, pipeline_transform, pipeline_load |
notification-hub |
通过电子邮件、Slack、webhooks发送 | notify_send, notify_broadcast, notify_schedule |
🔌 11个具有自动设置功能的API
当提示提到支持的API时,MCP工厂自动生成 预构建、生产就绪的工具 --不是通用的包装。
| API | Auth | 环境变量 | 自由层 | 预构建工具 |
|---|---|---|---|---|
| GitHub | Token | GITHUB_TOKEN |
✅ | gh_list_repos, gh_create_issue, gh_get_pr |
| Slack | 机器人令牌 | SLACK_BOT_TOKEN |
✅ | slack_post, slack_list_channels, slack_reply |
| 开放人工智能 | API密钥 | OPENAI_API_KEY |
❌ | openai_complete, openai_embed |
| 条纹 | 密钥 | STRIPE_SECRET_KEY |
✅ 测试 | stripe_create_charge, stripe_list_customers |
| 概念 | 集成 | NOTION_API_KEY |
✅ | notion_query_db, notion_create_page |
| 声破天 | OAuth2 | SPOTIFY_CLIENT_ID |
✅ | — |
| 谷歌 | API密钥 | GOOGLE_API_KEY |
✅ 有限公司 | |
| 推特 | 持票人 | TWITTER_BEARER_TOKEN |
✅ 有限公司 | |
| Discord 的中文翻译是“不和谐”或“纷争”。 | 机器人令牌 | DISCORD_BOT_TOKEN |
✅ | discord_send, discord_list_channels |
| 线性 | API密钥 | LINEAR_API_KEY |
✅ | — |
| Jira | API代币 | JIRA_API_TOKEN |
✅ | — |
💬 交互模式
对于模糊的提示,MCP Factory会提出有针对性的后续问题:
mcpfactory create "build something for files" --interactive
# MCP Factory asks:
# 1. What file types? (code, documents, data files, all)
# 2. What operations? (read, write, search, all)
# → Generates a refined, specific server
✅ MCP最佳实践
每个生成的服务器都遵循 MCP官方最佳实践:
- 工具注释 —
readOnlyHint,destructiveHint,idempotentHint,openWorldHint - 前缀命名 --一致的工具前缀(
gh_,slack_,stripe_) - 架构描述 --佐德
.describe()/PydanticField(description=...)在每个参数上 - 可操作的错误 --错误包括出了什么问题+下一步该怎么办
- 分页 --列表操作支持
cursor/maxResults - 通过env变量的秘密 --从不硬编码,总是从
.env
🔍 LLM代码审查
生成后,LLM会审查以下代码:
- 安全问题(硬编码秘密、注入风险)
- MCP合规性(缺少注释、命名违规)
- 代码质量(错误处理、边缘情况)
- 性能(不必要的循环、缺少分页)
🌍 TypeScript和Python
mcpfactory create "..." --lang typescript # default
mcpfactory create "..." --lang python
这两种语言具有相同的质量:正确的类型、错误处理和MCP合规性。
🔒 隐私第一
- 所有代码都保留在本地文件系统上
- 本地SQLite中的元数据(
~/.mcpfactory/servers.db) - 没有遥测,没有云,没有跟踪
- 使用Ollama进行100%离线私人发电
Claude桌面集成
MCP Factory可以自动为Claude Desktop配置服务器:
# Add a server to Claude Desktop
mcpfactory config-add my-server
# Remove a server
mcpfactory config-remove my-server
# Show current Claude config
mcpfactory config-show
# Export full configuration
mcpfactory config-export
这 config-add 命令:
- 查找您的Claude Desktop配置文件
- 使用正确的命令和参数添加服务器条目
- 您的服务器立即出现在Claude的工具列表中
CLI参考
COMMAND DESCRIPTION
─────────────────────────────────────────────────────────────
mcpfactory create <prompt> Generate a new MCP server
-n, --name Server name (auto-generated if omitted)
-l, --lang typescript | python (default: typescript)
-o, --output Output directory (default: ./output)
-p, --provider LLM: ollama | openai | claude (default: ollama)
-m, --model Model name (e.g., llama3, gpt-4)
--interactive / --no-interactive Follow-up questions for vague prompts
mcpfactory list-servers List all generated servers
mcpfactory templates Show available templates
mcpfactory supported-apis Browse APIs with auth details
mcpfactory info <name> Show details for a specific server
mcpfactory delete <name> Delete a server
mcpfactory config-add <name> Add server to Claude Desktop
mcpfactory config-remove <name> Remove server from Claude Desktop
mcpfactory config-show Show Claude Desktop config
mcpfactory config-export Export full configuration
mcpfactory web Launch web dashboard
--host Bind address (default: 127.0.0.1)
--port Port number (default: 8000)
建筑
┌─────────────────────────────────────────────────┐
│ User Input │
│ (CLI prompt or Web Dashboard) │
└──────────────────────┬──────────────────────────┘
│
┌────────────▼────────────┐
│ Interactive Refinement │ ← Follow-up questions
└────────────┬────────────┘
│
┌────────────▼────────────┐
│ LLM Prompt Analyzer │ ← Ollama / OpenAI / Claude
│ (Keyword Fallback) │ ← Offline safety net
└────────────┬────────────┘
│
┌──────────────┼──────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────────┐
│ API │ │ Template │ │ LLM Tool │
│ Detector │ │ Matcher │ │ Generator │
│ (11 APIs)│ │(8 templ) │ │ │
└────┬─────┘ └────┬─────┘ └──────┬───────┘
│ │ │
└──────────────┼───────────────┘
▼
┌───────────────────────┐
│ Code Generator │
│ ├─ Pre-built API tools│
│ ├─ LLM-generated tools│
│ └─ Template code │
└───────────┬───────────┘
│
┌───────────▼───────────┐
│ Validator + Linter │ ← Syntax + structure checks
└───────────┬───────────┘
│
┌───────────▼───────────┐
│ LLM Code Reviewer │ ← Security, quality, MCP
└───────────┬───────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌──────────┐ ┌───────────┐ ┌──────────┐
│ File │ │ SQLite │ │ Claude │
│ System │ │ Storage │ │ Config │
└──────────┘ └───────────┘ └──────────┘
发展
# Clone and install
git clone https://github.com/JatinTaori1904/mcp-factory.git
cd mcp-factory
pip install -e ".[dev,web]"
# Run all tests (142 tests)
pytest
# Run with verbose output
pytest -v
# Lint
ruff check .
项目结构
mcp-factory/
├── mcp_factory/
│ ├── cli/ # Typer CLI commands
│ ├── generator/ # Core engine (prompt analysis, code gen, review)
│ ├── storage/ # SQLite database layer
│ └── config/ # Claude Desktop config management
├── web/
│ ├── app.py # FastAPI application
│ ├── templates/ # Jinja2 HTML templates
│ └── static/ # CSS with glassmorphism theme
├── tests/
│ └── test_generator.py # 142 tests across 21 test classes
├── pyproject.toml # Build config (Hatchling)
└── README.md
贡献
欢迎投稿!以下是如何开始:
- 分叉存储库
- 创建要素分支:
git checkout -b feature/my-feature - 安装开发依赖项:
pip install -e ".[dev,web]" - 进行更改并添加测试
- 运行测试套件:
pytest - 提交拉取请求
许可证
麻省理工学院 --建造于 Jatin Taori
