project-mcp-tools
project-mcp-tools
一个 Python 框架,可通过三种协议同时暴露开发者工具:MCP(Model Context Protocol)、REST API 和 CLI——全部来自同一个共享的工具注册表。
概述
project-mcp-tools 解决了为不同消费者维护独立工具后端的问题。使用 @tool() 装饰器编写一次工具,它就会立即提供给以下使用者:
通过 MCP 协议(由 FastMCP 驱动)提供给 AI 助手
通过 REST API(由 FastAPI + uvicorn 驱动)提供给 HTTP 客户端
通过 CLI(由 argparse 驱动)提供给 终端用户
内置工具涵盖 C++ 开发(编译、静态分析、格式化、类/测试脚手架、include 树分析)、Python 格式化校验以及 git 操作——所有这些都通过 subprocess 执行实现进程隔离。
安装
要求: Python 3.14+、uv 包管理器
# Clone the repository
git clone <repository-url>
cd project-mcp-tools
# Install dependencies
uv sync使用
MCP 服务器
启动一个 AI 助手可以连接的 FastMCP 服务器:
uv run mcp-server配置你的 MCP 客户端以使用此服务器。例如,在 宿主项目(你希望工具操作的项目,而不是 project-mcp-tools 目录本身)根目录下的 opencode.json 中:
{
"mcp": {
"project-mcp-tools": {
"type": "local",
"command": ["uv", "--directory", "project-mcp-tools", "run", "mcp-server", "--target-project", "../my-host-project"]
}
}
}重要提示:
--directory告诉uv在哪里找到project-mcp-tools包(pyproject.toml、依赖、venv)。--target-project为 MCP 进程及其所有子进程设置工作目录——这是工具实际要操作的项目。该路径相对于project-mcp-tools/解析(因为uv --directory会改变工作目录)。如果没有这种区分,git/cpp/python 工具就会在project-mcp-tools/内部操作,而不是在你的宿主项目中。
REST API 服务器
在 http://0.0.0.0:8000 上启动一个 FastAPI 服务器:
uv run api --target-project ../my-host-project每个工具都以 POST /tools/<tool_name> 的形式暴露。来自工具函数签名的查询参数会成为 JSON 请求体中的字段。
示例请求:
curl -X POST http://localhost:8000/tools/git_quick_upload \
-H "Content-Type: application/json" \
-d '{"message": "my commit"}'Swagger UI 可通过 http://localhost:8000/docs 访问。
CLI
从终端调用任意工具:
uv run cli --target-project ../my-host-project git_quick_upload --message "your commit message"--target-project 必须放在工具名称之前。不引用宿主项目的工具(例如 get_random_number)可以在不带 --target-project 的情况下调用。
工具目录
通用
工具 | 签名 | 描述 |
|
| 根据给定的文本描述,使用 Gemini(模型 |
|
| 使用 Gemini 视觉能力(固定模型 |
|
| 返回环境调试信息(cwd、路径、环境变量) |
|
| 返回 start 与 end 之间的随机数 |
Git
工具 | 签名 | 描述 |
|
| 丢弃所有未提交的更改并移除未跟踪的文件。恢复到 HEAD |
|
| 将所有子模块更新到最新的远程提交(要求子模块处于干净状态);指针更新保持未提交 |
|
| 执行 |
Python
工具 | 签名 | 描述 |
|
| 对工具目录中的所有 |
|
| 移除当前目录下的所有 |
|
| 校验指定文件的 Python 格式规则 |
C++
工具 | 签名 | 描述 |
|
| 对所有 |
|
| 校验指定文件的 C++ 格式规则 |
|
| 使用 Clang 并行编译整个 C++ 项目 |
|
| 根据层级字符串(例如 |
|
| 生成一个 C++ 测试文件 |
|
| 显示 C++ 文件的递归 include 依赖树。默认使用项目主文件 |
|
| 生成 |
会话
工具 | 签名 | 描述 |
|
| 报告当前 opencode 聊天会话正在使用多少模型上下文窗口( |
项目结构
project-mcp-tools/
├── main.py # Entry point — builds tool_manager, starts servers
├── pyproject.toml # Project config, dependencies, entry points
├── tools/ # Core engine package
│ ├── __init__.py
│ ├── tool_manager.py # Core orchestrator — shared registry, tool folder loading, subprocess dispatch, CLI/API/MCP exposure
│ ├── tool.py # @tool() decorator, ToolInfo/ParameterInfo models, response contract helpers
│ ├── path_manager.py # Project/target root resolution — injectable, no global state
│ └── folder_scanner.py # Auto-discovers @tool-decorated functions in directories
├── general/ # General-purpose tools (no host project dependency)
│ ├── create_image.py # Gemini image generation tool
│ ├── describe_image.py # Gemini image interpretation tool
│ ├── debug.py # Environment debugging tool
│ └── get_random_number.py # Random number generator
├── sak/
│ ├── common.py # Utilities (process creation, JSON, assertions)
│ └── fso/ # File system objects
├── lib/
│ ├── base_verifier.py # Abstract regex-based code formatter
│ ├── project_config.py # Global project configuration
│ ├── project_file.py # Abstract source file with license header management
│ └── template.py # Jinja-like template engine with imports and lists
├── cpp/
│ ├── analyze.py # C++ full analysis tool
│ ├── code_verifier.py # C++ formatting verification tool
│ ├── compile.py # C++ parallel compilation tool
│ ├── create_class.py # C++ class scaffolding tool
│ ├── create_test.py # C++ test scaffolding tool
│ ├── include_tree.py # C++ include dependency tree tool
│ └── cpp_lib/ # C++ domain library (compiler, model, verifier, build)
├── python/
│ ├── analyze.py # Python full analysis tool
│ ├── code_verifier.py # Python formatting verification tool
│ └── python_lib/ # Python domain library (model, verifier, config)
├── session/
│ ├── context_usage.py # opencode session context usage tool
│ └── session_lib/ # Session domain library (opencode database reader)
├── git/
│ ├── discard_changes.py # Git reset + clean tool
│ └── quick_upload.py # Git pull/add/commit/push tool
├── resources/
│ └── images/ # Generated images (from create_image tool)
├── .agents/
│ └── skills/ # AI assistant skills (compliance audit, uv package manager)
└── docs/
├── templates/ # Template files for class/test scaffolding (user zone)
├── example/ # Usage examples (e.g. google-genai.py) (user zone)
└── agent/ # AI-managed knowledge base (architecture, guides, workflows, status)
├── architecture.md # System architecture and design decisions
├── development/ # Tool development guide
├── style-guide/ # Coding style guides
├── workflow/ # Workflow documentation
└── status.md # Agent task status架构
系统围绕一个核心的 tool_manager 对象构建,该对象持有共享工具注册表,并处理全部三种传输方式(CLI、REST API 和 MCP)。
有关系统架构、设计决策和目标项目机制的详细说明,请参阅 系统架构 指南。
添加新工具
要添加新工具,请在现有工具文件夹(或新文件夹)中创建一个 Python 文件,并用 @tool() 装饰你的函数。
有关工具层和领域库结构的分步教程与指南,请参阅 工具开发指南。
配置
全局配置和领域特定配置集中在代码库中。有关配置键和值的完整列表,请参阅 系统架构 - 集中式配置。
编码规范
本项目中的所有代码都必须遵守严格的指南,包括所有标识符一律使用 snake_case,以及特定的空格规则。有关完整的指南,请参阅 Python 风格指南。
许可证
GNU General Public License v3.0——详情请参阅源文件中的许可证头。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Package intelligence MCP for AI agents — 22 tools, 19 ecosystems, AGPL SDK, free.
Free public MCP for AI agents — 193 tools, 44 workflows. No API key.
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/maxwellaguiarsilva/project-mcp-tools'
If you have feedback or need assistance with the MCP directory API, please join our Discord server