Python MCP Toolkit Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Python MCP Toolkit Server search for MCP Python SDK documentation"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Python MCP Toolkit Server
一个基于 Python 编写的可扩展 MCP 工具服务器,使用官方 MCP Python SDK 的 FastMCP 作为服务入口,内置常用工具,并支持通过插件模块继续扩展工具集。
功能特性
web_search联网搜索:只保留 Bing 和 Tavily;provider=auto有TAVILY_API_KEY时优先使用 Tavily,否则使用 Bing;也可显式选择provider=bing或provider=tavilyfile_operation文件操作:在一个工具内完成列表、读取、查找、grep、写入、替换、复制、移动和删除agent轻量任务状态工具:记录任务目标、步骤、进展和完成结果插件式工具扩展,支持按模块加载自定义工具
支持
stdio、sse和streamable-http三种 MCP 传输方式支持
.env自动加载、命令行参数覆盖和远程请求头授权提供
/healthz健康检查端点,便于远程部署验证默认安全边界:文件访问限制在
MCP_WORKSPACE,写入、复制、移动和删除默认关闭
Related MCP server: MCP Server
文档
安装
本项目按系统级 Python 运行和安装。Termux 中系统 Python 通常是 /data/data/com.termux/files/usr/bin/python。先确认 python 指向系统 Python,然后安装到该 Python 环境:
python -c "import sys; print(sys.executable)"
python -m pip install -e .在 Termux 或 Android Python 环境中,如果 pydantic-core 等原生依赖从源码编译并出现 Text file busy,使用单线程 Cargo 构建重试:
CARGO_BUILD_JOBS=1 python -m pip install -e .离线环境可直接使用 mcp-toolkit-server-offline-pip.tar.gz:
mkdir -p mcp-toolkit-server-offline-pip
tar -xzf mcp-toolkit-server-offline-pip.tar.gz -C mcp-toolkit-server-offline-pip
cd mcp-toolkit-server-offline-pip
./install.sh也可以使用 wheelhouse 格式安装:
./install-wheelhouse-offline.sh mcp-toolkit-server==0.1.0在 Termux 中,如果希望脚本自动检查 Python、离线安装 pip 包、提示填写运行环境变量并启动服务,可以使用:
./termux-install.sh脚本会把输入的运行环境变量默认保存到 .termux-mcp.env,下次运行自动加载。只安装不运行时使用:
./termux-install.sh --no-run完整流程见 离线版构建与安装。
配置
不要把真实 API Key 写入源码。启动前通过环境变量配置工作区;TAVILY_API_KEY 可选,未设置时 web_search 的自动模式会使用 Bing;显式使用 provider=tavily 时必须设置该变量:
export TAVILY_API_KEY='your-tavily-key'
export MCP_WORKSPACE=/data/data/com.termux/files/home/mcp启动时会自动读取当前目录的 .env 文件;已有环境变量优先级更高,不会被 .env 覆盖。也可以通过 MCP_ENV_FILE=/path/to/.env 指定配置文件。
常用可选配置:
export MCP_ENV_FILE=.env
export MCP_SERVER_NAME=python-mcp-toolkit
export MCP_TRANSPORT=stdio
export MCP_HOST=127.0.0.1
export MCP_PORT=8000
export MCP_STATELESS_HTTP=true
export MCP_AUTH_TOKEN=
export MCP_AUTH_HEADER=X-MCP-Auth-Token
export MCP_ALLOW_WRITE=false
export MCP_MAX_FILE_BYTES=2097152
export MCP_REQUEST_TIMEOUT=20
export MCP_TOOLKIT_PLUGINS=examples.custom_tools关键环境变量说明:
变量名 | 默认值 | 说明 |
| 空 | Tavily API Key。为空时 |
|
| Tavily 搜索接口地址。 |
|
| 启动时自动读取的环境变量文件。设为空可禁用自动加载。 |
|
| MCP 传输方式: |
|
| HTTP/SSE 监听地址,远程访问通常设为 |
|
| HTTP/SSE 监听端口。 |
|
|
|
|
|
|
| 空 | HTTP/SSE 请求头授权码。为空时不启用请求头鉴权。 |
|
| 读取授权码的请求头名。设为 |
|
| 是否允许 |
|
| 单个可读取文件大小上限,默认 |
|
| HTTP 请求超时时间,单位秒。 |
| 空 | 逗号分隔的插件模块列表。 |
启动
安装后运行:
mcp-toolkit也可以通过系统 Python 模块入口启动:
python -m mcp_toolkit.server命令行参数会覆盖环境变量,常用示例:
mcp-toolkit \
--transport streamable-http \
--host 0.0.0.0 \
--port 8000 \
--workspace /data/data/com.termux/files/home/mcp查看当前解析后的非敏感配置:
mcp-toolkit --show-config常用命令行参数:
参数 | 说明 |
| 指定启动时读取的 |
`--transport stdio | sse |
| 覆盖 HTTP/SSE 监听地址。 |
| 覆盖 HTTP/SSE 监听端口。 |
| 覆盖 |
| 设置 HTTP/SSE 请求头授权码。 |
| 设置读取授权码的请求头名。 |
| 覆盖 |
| 加载插件模块,可重复使用,也可逗号分隔。 |
| 覆盖 |
| 打印非敏感配置后退出。 |
远程运行推荐使用 streamable-http。默认不需要请求头 token,也不要求客户端手动维护 mcp-session-id:
export MCP_TRANSPORT=streamable-http
export MCP_HOST=0.0.0.0
export MCP_PORT=8000
mcp-toolkit远程地址:
http://服务器IP:8000/mcp如需启用请求头鉴权,再额外设置:
export MCP_AUTH_TOKEN='change-this-token'客户端请求需要带上:
X-MCP-Auth-Token: change-this-token健康检查地址:
http://服务器IP:8000/healthz启用 MCP_AUTH_TOKEN 后,健康检查同样需要带授权请求头。
MCP 客户端配置示例
{
"mcpServers": {
"python-mcp-toolkit": {
"command": "/data/data/com.termux/files/usr/bin/python",
"args": ["-m", "mcp_toolkit.server"],
"env": {
"TAVILY_API_KEY": "your-tavily-key",
"MCP_WORKSPACE": "/data/data/com.termux/files/home/mcp",
"MCP_ALLOW_WRITE": "false"
}
}
}
}示例中的 command 使用 Termux 系统 Python 路径;其他系统请替换为对应的系统 Python 可执行文件。插件模块需要能被系统 Python 导入;推荐把插件作为包安装到系统 Python,或从插件父目录启动客户端。
远程 streamable-http 客户端示例:
{
"mcpServers": {
"python-mcp-toolkit-remote": {
"type": "streamable-http",
"url": "http://服务器IP:8000/mcp"
}
}
}内置工具
工具名 | 说明 |
| 联网搜索公开网页,只保留 Bing 和 Tavily; |
| 在 |
| 管理轻量 agent 任务状态,记录目标、步骤、进展和完成结果。 |
扩展工具
新增工具推荐使用插件模块。插件需要暴露 register(registry, settings) 函数:
from mcp_toolkit.core.config import Settings
from mcp_toolkit.core.registry import ToolRegistry
def register(registry: ToolRegistry, settings: Settings) -> None:
@registry.tool()
def echo(text: str) -> dict[str, str]:
"""Return the input text."""
return {"text": text}启用插件:
export MCP_TOOLKIT_PLUGINS=examples.custom_tools
mcp-toolkit多个插件用英文逗号分隔:
export MCP_TOOLKIT_PLUGINS=examples.custom_tools,examples.math_tools,examples.workspace_stats更多扩展示例见 examples/ 目录和 详细使用与扩展手册。
验证
编译检查:
python -m compileall src examples tests运行单元测试:
python -m unittest discover -s tests列出已注册工具:
python - <<'PY'
import asyncio
from mcp_toolkit.server import create_server
async def main():
server = create_server()
tools = await server.list_tools()
for tool in tools:
print(tool.name)
asyncio.run(main())
PY验证插件加载:
MCP_TOOLKIT_PLUGINS=examples.custom_tools python - <<'PY'
import asyncio
from mcp_toolkit.server import create_server
async def main():
server = create_server()
tools = await server.list_tools()
print(any(tool.name == "echo" for tool in tools))
asyncio.run(main())
PY安全说明
TAVILY_API_KEY只应通过环境变量传入,不应提交到仓库。远程 HTTP/SSE 模式建议设置
MCP_AUTH_TOKEN,并在公网环境前置 HTTPS 反向代理。file_operation只能访问MCP_WORKSPACE内路径。文件写入、替换、复制、移动和删除能力默认关闭,需要显式设置
MCP_ALLOW_WRITE=true。建议为不同项目配置不同的
MCP_WORKSPACE。
授权协议
本项目基于 GNU General Public License v3.0 or later(GPL-3.0-or-later)授权发布,详见 LICENSE。
Available Tools
3 toolsagentC
管理一个轻量 agent 任务状态,用于记录目标、步骤、进展和完成结果。
Inputs: action, task, steps, note. Returns: object
file_operationA
在 MCP_WORKSPACE 内执行文件操作;写入、复制、移动、删除需要 MCP_ALLOW_WRITE=true。
Inputs: action (required), path, content, destination, +13 more. Returns: object
web_searchB
联网搜索公开网页,返回标题、URL 和摘要。
Inputs: query (required), max_results, provider. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool targets a clearly distinct domain: agent manages task state, file_operation handles files, and web_search performs internet searches. There is no overlap or ambiguity.
All tool names follow a consistent pattern of lowercase with underscores (agent, file_operation, web_search), making them predictable and easy to distinguish.
With 3 tools, the server is minimal but focused on essential utilities (task management, file ops, web search). It is slightly on the low end but appropriate for its stated purpose.
The set covers basic utility functions but lacks other common toolkit operations like code execution, data processing, or API calls, making it somewhat incomplete for a general 'Toolkit' server.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A simple MCP server built with FastMCP and python
Related MCP Servers
- AlicenseBqualityDmaintenanceA config-driven, zero-dependency MCP server with plugin architecture that enables filesystem operations, shell commands, HTTP requests, and utilities through simple JSON configuration.31MIT
- AlicenseNot gradedqualityDmaintenanceA modular MCP server providing file operations, web search, URL scraping, and sandboxed command execution for LLM interactions.1MIT
- FlicenseNot gradedqualityDmaintenanceMCP server providing filesystem operations, shell execution, and web search capabilities.-
- AlicenseNot gradedqualityCmaintenanceA batteries-included MCP server providing common coding-agent tools like web search, page fetching, file system access, shell command execution, and Git integration, built in Python with a local-first, Unix-style philosophy.MIT