README
🚀 PlayFab MCP 服务器
PlayFab MCP 服务器是一个中间件,允许大型语言模型(如Claude和VS Code)直接与PlayFab服务交互。它就像一个安全高效的翻译器,能将您的AI助手连接到各种PlayFab功能,包括商品搜索、段查询、玩家资料查找、库存管理和PlayFab ID转换。
🚀 快速开始
它是什么? 🤔
这是一个中间件,允许大型语言模型(如Claude和VS Code)直接与PlayFab服务交互。作为安全高效的翻译器,它将您的AI助手连接到各种PlayFab功能,包括商品搜索、段查询、玩家资料查找、库存管理和PlayFab ID转换。
快速示例
你: "显示最新的10个物品。"
Claude: *调用PlayFab的search_items API并以纯文本形式返回结果*
它是如何工作的? 🛠️
此服务器利用模型上下文协议(MCP)建立AI模型与PlayFab服务之间的通用接口。尽管MCP设计支持任何AI模型,但目前仍处于开发者预览阶段。
按照以下步骤开始:
- 设置你的项目。
- 将项目详细信息添加到您的LLM客户端配置中。
- 开始自然地与PlayFab数据交互!
它能做什么? 📊
- 使用PlayFab的search_items API搜索商品。
- 获取完整的段信息。
- 在指定段中查询玩家资料。
- 通过get_inventory_items API获取当前库存物品。
- 使用get_inventory_collection_ids API获取库存集合ID。
- 通过get_title_player_account_id_from_playfab_id API将PlayFab ID转换为Title Player Account ID。
通过Smithery安装
要通过Smithery自动安装Claude Desktop的PlayFab MCP Server:
npx -y @smithery/cli install @akiojin/playfab-mcp-server --client claude
先决条件
- Node.js 14或更高版本。
- 有效的PlayFab账户(通过PlayFab Game Manager获取您的Title ID和Developer Secret Key)。
- 支持的LLM客户端,例如Claude Desktop。
设置项目
从PlayFab Game Manager获取您的Title ID和Developer Secret Key,然后在项目根目录中创建一个.env文件,内容如下(将占位符替换为实际凭据):
PLAYFAB_TITLE_ID=
PLAYFAB_DEV_SECRET_KEY=
开始
- 安装依赖项
在项目根目录中运行以下命令以安装所有必需的依赖项:
npm install
- 构建项目
编译项目,执行:
npm run build
- 启动服务器
切换到dist文件夹并启动服务器:
npm start
- 确认消息
启动后,您应该看到以下消息:
PlayFab 服务端正在stdio上运行
使用Cursor运行
要使用PlayFab MCP服务器与Cursor一起使用,请按照以下步骤操作:
- 如果还没有安装,请安装Cursor Desktop。
- 打开终端并运行以下命令以安装必要的依赖项:
npm install
- 启动服务器:
npm start
- 在另一个终端窗口中,启动Cursor。
- 在Cursor中,输入以下内容与PlayFab MCP Server交互:
const pf = require('playfab');
pf.initialize('your_title_id', 'your_secret_key');
pf.searchItems('search_term', (error, result) => {
if (error) {
console.error('错误:', error);
} else {
console.log('结果:', result);
}
});
与Claude Desktop集成
- 启动Claude Desktop。
- 在Claude中,输入以下内容:
const pf = require('playfab');
pf.initialize('your_title_id', 'your_secret_key');
pf.searchItems('search_term', (error, result) => {
if (error) {
console.error('错误:', error);
} else {
console.log('结果:', result);
}
});
现在,您可以与PlayFab MCP Server交互并使用其功能了。
微信扫一扫