MCP服务器工具包

一个生产就绪的MCP服务器,提供文件系统访问、网络搜索、SQLite数据库查询和系统工具功能,可直接集成到Claude桌面版或任何MCP兼容客户端。

  • by plasmacat420
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 plasmacat420/mcp-server-toolkit

使用说明

MCP服务器工具包

一个生产就绪的MCP服务器,公开文件系统、web搜索、SQLite和系统工具-- 直接插入Claude Desktop或任何兼容MCP的客户端。


什么是MCP?

这 模型上下文协议 是一个开放标准,允许像克劳德这样的人工智能助手 安全地调用外部工具——让它们实时访问您的文件系统、数据库、, 无需手动将内容粘贴到聊天中。


特性

  • 文件系统 — read_file 返回任何带有编号行的文本文件; search_files globs一个目录树。这两个工具都强制执行可配置 ROOT_DIR 所以路径遍历 攻击是不可能的。
  • 网络搜索 — web_search 查询DuckDuckGo的免费JSON API。没有API密钥,没有费率 限制,异步,超时10秒。
  • SQLite — query_sqlite 只运行SELECT查询并返回类型化的列+行; list_tables 一目了然地显示了模式。
  • 系统 — get_system_info 快照操作系统、Python版本、CPU计数、内存使用情况, 一次调用即可释放磁盘、主机名和正常运行时间。

快速开始

选项1-pip

pip install git+https://github.com/plasmacat420/mcp-server-toolkit.git
mcp-toolkit          # starts the server on stdio (Claude Desktop mode)

选项2-Docker

docker pull ghcr.io/plasmacat420/mcp-server-toolkit:latest
docker run -it ghcr.io/plasmacat420/mcp-server-toolkit:latest

选项3-Docker Compose(建议用于SSE/网络使用)

git clone https://github.com/plasmacat420/mcp-server-toolkit
cd mcp-server-toolkit
cp .env.example .env          # edit ROOT_DIR if needed
docker compose up

然后,SSE端点在以下位置可用 http://localhost:8000.


Claude桌面集成

将以下块添加到 claude_desktop_config.json (~/Library/Application Support/Claude/ 在macOS上, %APPDATA%\Claude\ 在Windows上):

{
  "mcpServers": {
    "mcp-toolkit": {
      "command": "mcp-toolkit",
      "env": {
        "ROOT_DIR": "/Users/you/projects"
      }
    }
  }
}

重新启动Claude Desktop——四个工具类别会自动出现在每个对话中。


工具参考

工具 描述 参数 返回
read_file 读取带有行号的文本文件 path: str {content, path, lines, size_bytes}
search_files 在目录内进行全局搜索 directory: str, pattern: str, recursive: bool = True {results[], count}
web_search DuckDuckGo搜索(无需密钥) query: str, max_results: int = 5 {results[], query, count}
query_sqlite 执行SELECT查询 db_path: str, sql: str {columns[], rows[], row_count}
list_tables 列出SQLite数据库中的所有表 db_path: str {tables[], count}
get_system_info 主机操作系统/资源快照 (无) {os, cpu_count, memory_gb, …}

CLI使用情况

这 mcp-client 二进制允许您从终端调用任何工具:

# Search for Python files
mcp-client search-files . "*.py"
# {"results": [...], "count": 12}

# Read a file
mcp-client read-file src/mcp_toolkit/server.py
# {"content": "   1 | \"\"\"MCP Server Toolkit...", "lines": 34, ...}

# Web search
mcp-client web-search "python asyncio tutorial" --max-results 3
# {"results": [{"title": "...", "url": "...", "snippet": "..."}], ...}

# Query a SQLite database
mcp-client query-db examples/sample.db "SELECT name, email FROM users LIMIT 3"
# {"columns": ["name", "email"], "rows": [["Alice Johnson", "alice@..."]], ...}

# System snapshot
mcp-client system-info
# {"os": "Linux", "cpu_count": 8, "memory_gb": 15.87, ...}

# Full demo against sample.db
mcp-client demo

发展

git clone https://github.com/plasmacat420/mcp-server-toolkit
cd mcp-server-toolkit

# Install with dev extras
pip install -e ".[dev]"

# Create the sample database
python examples/create_db.py

# Run the test suite
pytest -v

# Lint + format check
ruff check .
ruff format --check .

# Auto-fix
ruff check . --fix && ruff format .

# Full demo (requires sample.db)
python examples/demo.py

运行单个测试

pytest tests/test_filesystem.py::test_read_file_success -v

建筑

服务器构建在 FastMCP,它处理MCP有线协议。 每个工具类别都位于其自己的模块中 src/mcp_toolkit/tools/; 模块直接导出 async 对MCP一无所知的功能。 server.py 创建 FastMCP 实例,导入每个工具功能, 并将其注册到 mcp.tool()配置是单一的 pydantic-settings BaseSettings 对象(config.py)这读自 环境变量或a .env 文件。CLI客户端(client/cli.py) 直接导入相同的异步函数——不涉及MCP协议-- 使得对单个工具进行冒烟测试变得容易。

src/mcp_toolkit/
├── server.py        ← FastMCP app + tool registration
├── config.py        ← pydantic-settings Settings singleton
└── tools/
    ├── filesystem.py   read_file, search_files
    ├── websearch.py    web_search
    ├── database.py     query_sqlite, list_tables
    └── system.py       get_system_info

许可证

麻省 理工© 等离子体420