article
README
🚀 mcp-pokeapi-server
本项目将POKEAPI与MCP(模型上下文协议)规范相结合,为用户提供了一个获取宝可梦信息的工具服务器。它允许LLM应用或MCP客户端通过特定协议方便地获取宝可梦的相关信息。
🚀 快速开始
安装依赖
npm install
项目构建
npx tsc
开发环境启动(使用ts-node)
npx ts-node src/index.ts
运行测试
npm test
✨ 主要特性
- 采用MCP协议(JSON - RPC 2.0 over stdio),支持LLM应用和MCP客户端获取宝可梦信息。
- 借助POKEAPI(https://pokeapi.co/)获取宝可梦的详细数据。
- 使用zod进行模式验证,确保数据的准确性。
💻 使用示例
基础用法
从MCP客户端获取工具列表(list_tools)
{
"jsonrpc": "2.0",
"id": 1,
"method": "list_tools"
}
响应示例
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"tools": [
{
"name": "getPokemonInfo",
"description": "从宝可梦名称或ID中,通过POKEAPI获取宝可梦信息。",
"input_schema": { ... },
"output_schema": { ... }
}
]
}
}
获取宝可梦信息(call_tool)
{
"jsonrpc": "2.0",
"id": 2,
"method": "call_tool",
"params": {
"name": "getPokemonInfo",
"arguments": {
"nameOrId": "pikachu"
}
}
}
响应示例
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [
{
"type": "json",
"data": {
"name": "pikachu",
"id": 25,
"height": 4,
"weight": 60,
"types": ["electric"]
}
}
]
}
}
扫码联系在线客服