# 修复说明
## 问题
`/tools` 端点报错:`Internal Server Error`
## 原因
`app.list_tools()` 不是一个可以直接调用的方法。MCP Server 的 `@app.list_tools()` 装饰器注册了一个处理函数,但 Server 对象本身没有直接暴露调用这个函数的方法。
## 修复方案
1. 创建了独立的 `get_tools_list()` 函数来返回工具列表
2. `@app.list_tools()` 装饰的函数调用 `get_tools_list()`
3. `/tools` 端点直接调用 `get_tools_list()`
4. `/mcp` 端点中的 `tools/list` 方法也调用 `get_tools_list()`
## 测试步骤
1. **停止当前服务器**(如果正在运行)
- 按 `Ctrl+C` 停止
2. **重新启动服务器**
```powershell
python mcp_server_http.py
```
3. **测试端点**
```powershell
# 测试健康检查
curl http://localhost:8000/health
# 测试工具列表(应该不再报错)
curl http://localhost:8000/tools
# 测试MCP端点
curl -X POST http://localhost:8000/mcp -H "Content-Type: application/json" -d '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/list\",\"params\":{}}'
```
## 预期结果
`/tools` 端点应该返回:
```json
{
"tools": [
{
"name": "hello_world",
"description": "一个简单的Hello World工具,支持多语言问候",
"inputSchema": {
"type": "object",
"properties": {
"name": {...},
"language": {...},
"count": {...}
},
"required": []
}
}
]
}
```