MCP Tools
MCP 工具
自定义模型上下文协议 (MCP) 服务器实现,为 Claude Desktop 和其他 LLM 客户端提供文件系统和命令执行工具。
什么是模型上下文协议?
模型上下文协议 (MCP) 是一种开放协议,它规范了应用程序向大型语言模型 (LLM) 提供上下文的方式。就像 USB-C 端口提供了一种将设备连接到各种外设的标准化方式一样,MCP 也提供了一种将 AI 模型连接到不同数据源和工具的标准化方式。
该项目实现了一个 FastMCP 服务器,其中包含一些实用工具,使 Claude 和其他 LLM 能够与本地文件系统交互并执行命令。它通过定义明确的工具接口,以可控的方式扩展了 LLM 的本地系统访问能力。
Related MCP server: Desktop Commander MCP
MCP 的主要优势
标准化集成:MCP 提供了越来越多的预构建集成,您的 LLM 可以直接插入
供应商灵活性:轻松在 LLM 提供商和供应商(Claude、GPT-4o、Gemini 等)之间切换
安全性:保护基础设施内数据的最佳实践
工具公开:封装现有工具,使任何兼容 MCP 的 LLM 客户端都可以访问它们
特征
MCP 服务器提供以下文件系统和命令执行工具:
execute_shell_command :执行 shell 命令并获取 stdout/stderr 结果
show_file :使用可选的行范围规范查看文件内容
search_in_file :使用正则表达式在文件中搜索模式
edit_file :使用字符串替换和行操作对文件进行精确更改
write_file :将内容写入或附加到文件
MCP 架构
MCP 遵循客户端-服务器架构:
主机:发起连接的 LLM 应用程序(如 Claude Desktop 或 IDE)
客户端:在主机应用程序内部与服务器保持 1:1 连接
服务器:向客户端提供上下文、工具和提示(该项目实现了一个服务器)
先决条件
Python 3.10 或更高版本
与 MCP 兼容的客户端(Claude Desktop 或任何其他支持 MCP 的客户端)
安装
克隆此存储库或下载源代码
运行
uv run mcp install来安装 MCP 服务器运行
which uv以获取uv可执行文件的绝对路径在 Claude Desktop 中更新 MCP 服务器配置以使用
uv可执行文件的绝对路径
我的 MCP 服务器配置如下:
{
"globalShortcut": "",
"mcpServers": {
"zbigniew-mcp": {
"command": "/Users/zbigniewtomanek/.local/bin/uv",
"args": [
"run",
"--with",
"mcp[cli]",
"--with",
"marker-pdf",
"mcp",
"run",
"/Users/zbigniewtomanek/PycharmProjects/my-mcp-tools/server.py"
]
}
}
}用法
从 Claude Desktop 连接
打开 Claude 桌面
使用标识符“zbigniew-mcp”连接到 MCP 服务器
注意:虽然此实现侧重于 Claude Desktop,但 MCP 旨在与任何 MCP 兼容工具或 LLM 客户端兼容,从而提供实现和集成的灵活性。
可用工具
执行shell命令
使用参数列表安全地执行 shell 命令:
execute_shell_command(["ls", "-la"])
execute_shell_command(["grep", "-r", "TODO", "./src"])
execute_shell_command(["python", "analysis.py", "--input", "data.csv"])
execute_shell_command(["uname", "-a"])显示文件
使用可选的行范围规范查看文件内容:
show_file("/path/to/file.txt")
show_file("/path/to/file.txt", num_lines=10)
show_file("/path/to/file.txt", start_line=5, num_lines=10)在文件中搜索
使用正则表达式在文件中搜索模式:
search_in_file("/path/to/script.py", r"def\s+\w+\s*\(")
search_in_file("/path/to/code.py", r"#\s*TODO", case_sensitive=False)编辑文件
对文件进行精确的更改:
# Replace text
edit_file("config.json", replacements={"\"debug\": false": "\"debug\": true"})
# Insert at line 5
edit_file("script.py", line_operations=[{"operation": "insert", "line": 5, "content": "# New comment"}])
# Delete lines 10-15
edit_file("file.txt", line_operations=[{"operation": "delete", "start_line": 10, "end_line": 15}])
# Replace line 20
edit_file("file.txt", line_operations=[{"operation": "replace", "line": 20, "content": "Updated content"}])写入文件
向文件写入或附加内容:
# Overwrite file
write_file("/path/to/file.txt", "New content")
# Append to file
write_file("/path/to/log.txt", "Log entry", mode="a")获取页面
将网页内容提取为 PDF(需要安装 Chromium),然后使用本地 LLM 将其解析为 markdown:
fetch_page("https://example.com")运输机制
MCP 支持客户端与服务器之间多种传输方式的通信:
标准输入/输出(stdio) :使用标准输入/输出进行通信,非常适合本地进程
服务器发送事件 (SSE) :通过 HTTP POST 请求实现服务器到客户端的流式传输,实现客户端到服务器的通信
此实现使用通过文本输入/输出进行通信的本地 MCP 服务器。
使用您自己的工具进行扩展
您可以使用@mcp.tool装饰器轻松扩展此 MCP 服务器,添加新工具。请按照 server.py 中的模式创建新工具,以向 LLM 客户端公开更多功能。
相关项目
langchain-mcp-adapters : 将 MCP 与 LangChain 结合使用
MCP-Bridge :将 MCP 工具映射到 OpenAI 的格式
安全注意事项
MCP 服务器允许 Claude 访问您的本地系统。请注意以下事项:
服务器以你的用户身份执行shell命令
它可以读取、写入和修改系统上的文件
如果担心安全问题,请考虑限制对特定目录的访问
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 Servers
- Alicense-qualityDmaintenanceA filesystem Model Context Protocol server that provides Claude Desktop with capabilities to read, write, and manipulate files on your system.11MIT
- AlicenseAqualityDmaintenanceA server that lets Claude desktop app execute terminal commands on your computer and edit files through Model Context Protocol, featuring command execution, process management, and advanced file operations.1938,6266MIT
- Flicense-qualityFmaintenanceA Model Context Protocol server that extends AI capabilities by providing file system access and management functionalities to Claude or other AI assistants.1465
- Flicense-qualityDmaintenanceA Model Context Protocol server that allows integration with Claude Desktop by creating and managing custom tools that can be executed through the MCP framework.46
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
A Model Context Protocol server for Wix AI tools
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
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/ZbigniewTomanek/my-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server