关于 CustomMCPServer
CustomMCPServer 是一个 Python 项目,演示如何构建 MCP 服务并连接 AI Agent。项目包含 Python MCP Server SDK 参考及示例代码。
主要功能
- 01Python MCP 服务示例
- 02Python MCP Server SDK 参考
- 03开放资源的示例
- 04定义工具和提示词的示例
适用场景
- 01学习构建 Python MCP 服务
- 02添加数据库操作工具
MCP 相关
项目演示向 LLM 应用开放资源、工具和提示词的 MCP 服务。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
暂未收录安装方式
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
CustomMCPServer
使用 Python 构建自定义 MCP 服务,并将其连接到 AI Agent。
-
资源:
-
MCP 服务本质上是大模型和 AI 工具彼此通信的方式。Model Context Protocol 允许应用以标准化的方式为大模型提供上下文,将提供上下文与实际的大模型交互分开。
# create a uv-managed project
$ uv init .
Initialized project `custommcpserver` at `C:\Users\abhis\Desktop\AIAgents\CustomMCPServer`
# Then add MCP to your project dependencies:
$ uv add "mcp[cli]"
# activate python environment as well
$ source .venv/scripts/activate
# You can install this server in Claude Desktop and interact with it right away by running:
# mcp install main.py
# since we're in this vs code we do
$ uv run mcp install main.py
[04/16/25 10:06:31] INFO Added server 'Demo' to Claude config
INFO Successfully installed Demo in Claude app
# go to claude app > File > settings > Developer > Edit Config - opens up some file and open that claude_desktop_config.json file
# we can see the mcp run main.py(path) is added in that file.
# the mcp server should show up on claude app - if it's not - we do the following
# close claude app - open task manager and search fo claude and right click & do end task.
# wait a sec & open the app again
# once the app loads , it spins up the mcp server and it shows on app - refer the image below & when you click on tool we can see the
# add tool and server:DEMO

高级 MCP 服务
- 在继续之前,MCP 的本质是什么?:
- 它允许你构建以安全、标准化的方式向大模型应用_公开数据_和功能的服务。可以把它想象成 Web API,但专为大模型交互设计。
- 通过资源公开数据(可以把它们想象成类似 GET 端点;用于将信息加载到大模型的上下文中)
- 通过工具提供功能(类似 POST 端点;用于执行代码或以其他方式产生副作用)
- 通过提示词定义交互模式(用于大模型交互的可重用模板)
- 等等!
- 它允许你构建以安全、标准化的方式向大模型应用_公开数据_和功能的服务。可以把它想象成 Web API,但专为大模型交互设计。
uv add black
# after creating new mcp server & tool
$ uv run mcp install adv_main.py
[04/16/25 10:44:02] INFO Added server 'AI Sticky Notes' to Claude config
INFO Successfully installed AI Sticky Notes in Claude app

- 从上面的示例中,我们可以看到如何使用自己创建的工具,并用它来完成各种任务。
- 添加一个连接数据库的工具,然后让 Claude 在数据库中创建 100 个虚假用户,而不是由我们手动复制粘贴……这样可以自动化很多事情。
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。