Add your description here
Project description
MCPCC - Excel读取MCP服务器
这是一个使用FastMCP构建的MCP服务器,专门用于读取Excel文件并返回JSON格式数据。
功能特性
- read_excel_to_json工具: 读取Excel文件并转换为JSON格式
- 支持指定工作表名称
- 自动检测文件存在性
- 返回结构化的JSON数据,包含行数、列名、数据内容
- greeting资源: 动态生成个性化问候语
安装依赖
确保使用Python 3.13+,并安装以下依赖:
# 基础MCP依赖
pip install "mcp[cli]>=1.12.3"
# Excel处理依赖
pip install pandas openpyxl
Excel工具使用方法
工具参数
file_path(必需): Excel文件的完整路径sheet_name(可选): 工作表名称,如果不提供则读取第一个工作表
返回格式
{
"success": true,
"sheet_name": "Sheet1",
"rows": 3,
"columns": ["姓名", "年龄", "城市", "工资"],
"data": [
{"姓名": "张三", "年龄": 25, "城市": "北京", "工资": 8000},
{"姓名": "李四", "年龄": 30, "城市": "上海", "工资": 12000},
{"姓名": "王五", "年龄": 35, "城市": "广州", "工资": 15000}
]
}
## 运行和调试方法
### 1. 直接运行服务器
```bash
# 方法1: 使用Python模块
python -m mcpcc
# 方法2: 使用运行脚本
python run_server.py
服务器将在stdio模式下运行,等待JSON-RPC消息。
2. 调试模式
运行调试脚本来测试服务器功能:
python debug_server.py
3. 客户端测试
使用测试客户端与服务器交互:
python test_client.py
4. VS Code调试
项目已配置了VS Code调试选项:
- 打开VS Code
- 按F5或转到"运行和调试"面板
- 选择以下配置之一:
- Run MCP Server: 运行服务器
- Debug MCP Server: 调试模式运行
- Test MCP Client: 运行客户端测试
手动测试JSON-RPC消息
如果要手动测试,可以向运行中的服务器发送JSON-RPC消息:
// 初始化
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}}}
// 列出工具
{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}
// 调用add工具
{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "add", "arguments": {"a": 5, "b": 3}}}
// 读取资源
{"jsonrpc": "2.0", "id": 4, "method": "resources/read", "params": {"uri": "greeting://World"}}
项目结构
mcpcc/
├── src/mcpcc/__init__.py # 主服务器代码
├── debug_server.py # 调试脚本
├── test_client.py # 客户端测试
├── run_server.py # 简单运行脚本
├── .vscode/launch.json # VS Code调试配置
└── pyproject.toml # 项目配置
开发建议
- 添加新工具: 在
__init__.py中使用@mcp.tool()装饰器 - 添加新资源: 使用
@mcp.resource()装饰器定义资源模式 - 调试: 使用
debug_server.py快速测试功能 - 集成测试: 使用
test_client.py进行完整的客户端-服务器测试
故障排除
如果遇到问题:
- 确保Python路径正确设置
- 检查依赖是否正确安装
- 使用调试脚本测试基本功能
- 查看终端输出了解详细错误信息
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mcpcc-0.1.4.tar.gz
(3.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
mcpcc-0.1.4-py3-none-any.whl
(4.7 kB
view details)
File details
Details for the file mcpcc-0.1.4.tar.gz.
File metadata
- Download URL: mcpcc-0.1.4.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f88735b8c2b7104541f1411ec47abf4483118b88fcabb896d0bf0c5a6c2734c7
|
|
| MD5 |
6dbc05e7797c6d7cdf8a4627504a9206
|
|
| BLAKE2b-256 |
ef97c201f526b050711392bc9513ad725527fd04d1b5fadc5a2d2060182666ff
|
File details
Details for the file mcpcc-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mcpcc-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
074911a1a76fd981af407048b7c8d94f949b3e9bf4ca5ad0caf00c9b7eb47d5c
|
|
| MD5 |
3c66ff2cbee8b380ddd984a8140ba2ec
|
|
| BLAKE2b-256 |
f8560c5ae8e09d7b723d9fa4479ac26f88852f5c9442b32522488742cd59b5b2
|