Riftbound商场MCP服务器
模型上下文协议(MCP)服务器,包装Riftbound Emporium库存管理API,使VS Code中的AI代理和其他MCP客户端能够与您的库存系统交互。
特性
此MCP服务器提供5类17个工具:
产品管理
list_products-列出所有带页码的产品search_products-按名称搜索产品get_product-获取详细的产品信息create_product-创建新产品
销售管理
list_sales-列出所有销售,并进行过滤和分页get_sale-获取详细的销售信息create_sale-创建新的销售交易
交付管理
list_deliveries-按页码列出所有交货get_delivery-获取详细的交货信息create_delivery-创建新的产品交付
库存事件的
list_inventory_events-列出所有库存事件get_inventory_event-获取详细的库存事件信息create_inventory_event-创建手动库存调整
TCG玩家定价
list_tcg_pricing-列出所有TCG Player定价快照get_tcg_pricing-获取特定定价快照create_tcg_pricing-创建新的定价快照
先决条件
- .NET 9.0 SDK(用于本地开发)
- Podman或Docker(用于容器化部署)
- 带有GitHub Copilot扩展的VS代码
- Riftbound Emporium库存管理API运行于
http://localhost:5000
安装和设置
选项1:本地运行(开发)
- 克隆和构建:
cd c:\git\RiftboundEmporiumMCP
dotnet build- 运行服务器:
# Set API URL if different from default
$env:INVENTORY_API_URL = "http://localhost:5000"
# Run the server
dotnet run- 配置VS代码 (见下面的VS代码配置部分)
选项2:在Podman中运行(建议用于生产)
- 构建容器映像:
cd c:\git\RiftboundEmporiumMCP
podman build -t riftbound-emporium-mcp .- 运行容器:
# Basic run - connects to API on host at localhost:5000
podman run -i --rm riftbound-emporium-mcp
# Custom API URL
podman run -i --rm -e INVENTORY_API_URL=http://host.containers.internal:5000 riftbound-emporium-mcp
# With persistent container name
podman run -i --name riftbound-mcp riftbound-emporium-mcp- 配置VS代码以使用容器 (见下面的VS代码配置部分)
VS代码配置
用于本地执行
将此添加到您的VS代码设置中(settings.json):
{
"github.copilot.chat.mcp.enabled": true,
"github.copilot.chat.mcp.servers": {
"riftbound-emporium": {
"command": "dotnet",
"args": ["run", "--project", "c:\\git\\RiftboundEmporiumMCP"],
"env": {
"INVENTORY_API_URL": "http://localhost:5000"
}
}
}
}用于Podman/Docker执行
将此添加到您的VS代码设置中(settings.json):
{
"github.copilot.chat.mcp.enabled": true,
"github.copilot.chat.mcp.servers": {
"riftbound-emporium": {
"command": "podman",
"args": ["run", "-i", "--rm", "riftbound-emporium-mcp"],
"env": {
"INVENTORY_API_URL": "http://host.containers.internal:5000"
}
}
}
}Docker用户注意事项: 替换 podman 随着 docker 在上面的命令中。
从其他MCP客户端(克劳德桌面等)访问
对于Claude Desktop,请将此添加到 claude_desktop_config.json:
本地执行:
{
"mcpServers": {
"riftbound-emporium": {
"command": "dotnet",
"args": ["run", "--project", "c:\\git\\RiftboundEmporiumMCP"],
"env": {
"INVENTORY_API_URL": "http://localhost:5000"
}
}
}
}波德曼处决:
{
"mcpServers": {
"riftbound-emporium": {
"command": "podman",
"args": ["run", "-i", "--rm", "riftbound-emporium-mcp"],
"env": {
"INVENTORY_API_URL": "http://host.containers.internal:5000"
}
}
}
}配置
环境变量
INVENTORY_API_URL-库存管理API的基本URL(默认值:http://localhost:5000)
波德曼网络
在Podman中运行并访问主机上的API时:
- 使用
http://host.containers.internal:5000达到localhost:5000在主机上 - 或者,使用
--network=host标志:podman run -i --rm --network=host riftbound-emporium-mcp
使用示例
在VS Code中配置后,您可以使用GitHub Copilot Chat与您的库存进行交互:
@workspace List all products in the inventory
@workspace Create a new Magic the Gathering card product called "Black Lotus"
@workspace Show me recent sales for product ID abc123
@workspace Create a delivery from TCGPlayer with invoice total $500 for product xyz789
@workspace What inventory events happened for product abc123?工具参考
产品工具
产品列表
按页码列出产品。
page(数字,可选):页码(默认值:1)pageSize(数量,可选):每页项目数(默认值:20)
搜索产品
按名称搜索产品。
query(字符串,必填):搜索查询
get_产品
获取详细的产品信息。
id(字符串,必填):产品ID(GUID)
创建产品
创建新产品。
name(字符串,必填):产品名称productType(数字,必填):0=卡片,1=密封产品,2=供应,3=其他description(字符串,可选):产品描述tcgPlayerUrl(字符串,可选):TCGPlayer URL
销售工具
创建_销售
创建新的销售交易。
productId(字符串,必填):产品ID(GUID)quantity(数字,必填):已售出数量grossRevenue(数字,必填):总收入金额fees(数字,必填):交易手续费paymentMethod(数字,必填):0=现金,1=信用,2=商店信用,3=其他customerName(字符串,可选):客户名称notes(字符串,可选):销售说明
交付工具
创建_交付
创建新的产品交付。
distributor(数字,必填):0=TCGPlayer,1=DirectFromManufacturer,2=其他invoiceTotal(数字,必填):发票总金额productId(字符串,必填):产品ID(GUID)quantity(数量,必填):交付数量distributorPrice(数量,必填):经销商提供的每单位价格partnerFee(布尔值,可选):这是否是合作伙伴费用项目
库存事件工具
create_inventory_event
创建手动库存调整。
type(数字,必填):0=调整,1=损坏,2=丢失,3=找到productId(字符串,必填):产品ID(GUID)quantity(数字,必填):数量变化(正或负)note(字符串,可选):关于调整的注释
建筑
此MCP服务器通过stdio使用直接JSON-RPC实现模型上下文协议:
┌─────────────┐ ┌──────────────────┐ ┌────────────────┐
│ VS Code / │ stdio │ MCP Server │ HTTP │ Inventory API │
│ MCP Client │◄───────►│ (JSON-RPC) │◄───────►│ (REST) │
└─────────────┘ └──────────────────┘ └────────────────┘组件
- 程序cs -入口点,初始化API客户端和服务器
- 服务器/McpStdioServer.cs -stdio上的JSON-RPC协议处理程序
- 服务器/ToolRegistry.cs -工具注册和执行
- 服务器/协议/JsonRpcProtocol.cs -JSON-RPC消息类型
- 服务/库存API客户端 -库存API的HTTP客户端
- 型号/ApiModels.cs -API通信DTO
发展
建筑
dotnet build运行测试(如果添加)
dotnet test调试
服务器将调试日志写入stderr。要查看它们:
dotnet run 2>&1 | Out-File -FilePath debug.log故障排除
连接问题
问题: 服务器无法连接到资源清册API
- 解决方案: 验证API正在运行
http://localhost:5000/swagger - 检查
INVENTORY_API_URL环境变量 - 从容器中,使用
http://host.containers.internal:5000
VS代码集成问题
问题: Copilot聊天中未显示工具
- 解决方案:
1. 确保 github.copilot.chat.mcp.enabled 是 true 1. 更改设置后重新启动VS Code 1. 检查输出面板→ “MCP服务器”错误
波德曼问题
问题: 容器无法访问主机服务
- 解决方案: 使用
http://host.containers.internal:5000或--network=host旗帜
问题: Windows上的权限错误
- 解决方案: 以管理员身份运行Podman Desktop或检查WSL2网络
许可证
MIT许可证-有关详细信息,请参阅许可证文件
支持
关于以下问题:
- MCP服务器: 在此存储库中打开问题
- 库存API: 查看库存管理API文档
- VS代码/副本: 请参阅GitHub Copilot文档
