MCP PokeAPI 服务器
一种模型上下文协议服务器,通过 stdio 上的 JSON-RPC 与 PokeAPI 接口,为 LLM 应用程序提供 Pokémon 信息。
服务介绍
mcp-pokeapi-server
这是一个与 POKEAPI 集成的服务器,能够以 MCP(Model Context Protocol)规范获取宝可梦信息。
概要
- 通过 MCP 协议(JSON-RPC 2.0 over stdio),为 LLM 应用或 MCP 客户端提供宝可梦信息获取工具。
- 利用 POKEAPI(https://pokeapi.co/)。
- 使用 zod 进行模式验证。
设置
npm install
构建
npx tsc
开发启动(ts-node)
npx ts-node src/index.ts
从 MCP 客户端使用示例
从 MCP 客户端或 LLM 应用程序中,通过标准输入/输出发送 JSON-RPC 请求。
1. 获取工具列表(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": { ... }
}
]
}
}
2. 获取宝可梦信息(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"]
}
}
]
}
}
测试
npm test