PokeMCP服务器-带模型上下文协议(MCP)的Pokemon服务器
描述
PokeMCP服务器是一个使用模型上下文协议(MCP)提供Pokemon相关功能的服务器。该项目允许查询有关宝可梦的信息,计算战斗结果,并估计闪亮的宝可梦遭遇概率。
特性
- 通过PokeAPI检索Pokemon信息
- 计算两个宝可梦之间的战斗结果
- 估计找到闪亮口袋妖怪的概率
- 基于清洁建筑原则
- 实现客户端-服务器通信的MCP协议
需求
- .NET 9
- 互联网连接(访问PokeAPI)
安装
- 克隆存储库:
git clone https://github.com/GuillermoRuizDev/PokeMCP-Server.git cd PokeMCP
- 恢复依赖关系:
dotnet restore
- 构建项目:
dotnet build
运行应用程序
发展模式
要在开发模式下运行应用程序,请执行以下操作:
dotnet run --project PokeMCP
默认情况下,应用程序将在以下位置运行:
- HTTP:http://localhost:3002
- HTTPS:https://localhost:7133
您可以通过访问来验证它是否正常工作http://localhost:3002/home在浏览器中,您应该看到消息:“口袋妖怪MCP服务器-已准备好与SSE一起使用”。
与MCP客户端集成
要从MCP客户端(如语义内核或兼容应用程序)使用此服务器:
- 使用MCP客户端连接到MCP服务器,方法是将以下json添加到
mcp.json文件:
{
"servers": {
"pokeapi-mcp-server": {
"type": "sse",
"url": "http://localhost:3002/sse"
}
}
}- 使用公开的工具与口袋妖怪功能进行交互
项目结构(清洁建筑)
PokeMCP/
├── Core/ # Domain Layer
│ ├── Entities/ # Domain entities
│ ├── Enums/ # Enumerations
│ └── Interfaces/ # Repository and service interfaces
├── Application/ # Application Layer
│ ├── DTOs/ # Data transfer objects
│ └── UseCases/ # Use cases and business logic implementation
├── Infrastructure/ # Infrastructure Layer
│ ├── Clients/ # External service clients (PokeAPI)
│ └── Repositories/ # Repository implementations
└── Tools/ # MCP tools for exposing functionalityMCP服务器使用情况
服务器通过MCP协议公开以下功能:
PokeApiTool 的
GetPokemonInfo(pokemonName):通过口袋妖怪的名称或ID检索其详细信息。
PokeFunctions工具
GetBattleResult(attacker, defender):计算两个宝可梦之间的战斗结果。ProbabilityFindingShiny(encounters, hasShinyCharm):计算找到闪亮的宝可梦的概率。
许可证
该项目根据 MIT许可证.
联系
如果您有任何问题或建议,请随时提出问题或通过以下方式联系我: 领英.
