
MCP Server Demo
一个基于MCP框架的服务器演示项目,提供了简单的API接口实现,包括数字运算、时间查询、订单信息查询等功能。
What is MCP Server Demo?
MCP Server Demo is a server demonstration project based on the MCP framework, providing simple API implementations for various functionalities including numerical operations, time queries, and order information retrieval.
How to use MCP Server Demo?
To use MCP Server Demo, install the MCP SDK, configure the database connection if you want to use the order query feature, and then start the server using the command mcp dev server.py
.
Key features of MCP Server Demo?
- Basic numerical operation API
- Machine time query
- Order information retrieval (requires database configuration)
- Dynamic greeting message generation
Use cases of MCP Server Demo?
- Performing basic arithmetic operations through API calls.
- Retrieving the current machine time for applications.
- Querying order information based on order ID.
- Generating personalized greeting messages for users.
FAQ from MCP Server Demo?
- What programming language is used?
The project is developed in Python.
- Do I need to configure a database?
Yes, a database configuration is required if you want to use the order information query feature.
- Is there a license for this project?
Yes, the project is licensed under the MIT License.
MCP Server Demo
一个基于MCP框架的服务器演示项目,提供了简单的API接口实现,包括数字运算、时间查询、订单信息查询等功能。
功能特性
- 基础数字运算API
- 机器时间查询
- 订单信息查询(需配置数据库)
- 动态问候语生成
环境要求
- Python >= 3.10
- MCP框架
- PyMySQL(用于数据库连接)
安装说明
-
安装MCP SDK MCP SDK的源码可在 https://github.com/modelcontextprotocol/python-sdk 获取
-
配置数据库连接(如需使用订单查询功能)
- 在
server.py
中修改数据库连接参数:
host='localhost' user='DATABASE_USERNAME_HERE' password='YOUR_PASSWORD_HERE' database='YOUR_DATABASE_HERE'
- 在
启动服务
使用以下命令启动服务:
mcp dev server.py
API文档
1. 数字相加
- 功能:将两个数字相加并加上1000
- 参数:
- a: 整数
- b: 整数
- 返回:计算结果(整数)
2. 获取机器时间
- 功能:获取当前机器时间(延后30分钟)
- 返回:JSON格式的时间信息
3. 订单信息查询
- 功能:根据订单ID查询订单信息
- 参数:
- orderid: 订单编号
- 返回:JSON格式的订单信息
4. 问候语生成
- 端点:
greeting://{name}
- 功能:生成个性化问候语
- 参数:
- name: 用户名
- 返回:问候语字符串