MCP Server Basic Example
MCP 服务器基本示例
这是模型上下文协议 (MCP) 服务器实现的基本示例,演示了包括工具和资源在内的核心功能。
设置步骤
初始化项目(转到任何本地文件夹并启动 powershell 或 cmd):
uv init mcp-server-basic
cd mcp-server-basic创建虚拟环境并激活
uv venv
.venv\Scripts\activate安装依赖项:
uv add "mcp[cli]"或者
uv add -r requirements.txtRelated MCP server: MCP Server Basic Example
特征
该服务器实现了以下功能:
工具
add(a: int, b: int):将两个数字相加subtract(a: int, b: int):从第一个数字中减去第二个数字
资源
greeting://{name}:返回个性化问候语
运行服务器
要使用 MCP Inspector 运行服务器进行开发:
uv run mcp dev main.py要正常运行服务器:
uv run mcp run要在 Claude 桌面应用程序中安装服务器:
uv run mcp install main.pyMCP 在 VS 代码中连接
在 vs code 中打开文件夹/mcp-server-basic
打开终端并运行以下命令:
uv run main.py单击 Cntrl+Shift+I 在 VS Code 中启动聊天
使用 Github 登录并设置
请按照以下步骤操作(为 vs 代码用户设置添加 mcp 配置的两种方法):
#来自 mcp 的你好
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
- AlicenseNot gradedqualityCmaintenanceA simple implementation of a Model Context Protocol server that demonstrates core functionality including mathematical tools (add, subtract) and personalized greeting resources.93GPL 3.0
- AlicenseNot gradedqualityDmaintenanceA basic implementation of a Model Context Protocol server that demonstrates core functionality with simple math tools (add, subtract) and greeting resources for AI assistants like Claude.GPL 3.0
- FlicenseNot gradedqualityDmaintenanceA demonstration implementation of a Model Context Protocol server that provides simple mathematical tools (add, subtract) and personalized greeting resources.
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides basic tools for arithmetic operations (addition) and dynamic greeting resources, demonstrating MCP integration patterns for other projects and clients.23ISC
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP Spec Compliance MCP — audits any MCP server.json against the official Model Context Protocol
Appeared in Searches
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/ugundhar/mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server