DealX
官方DealX 平台的 MCP 服务器
你可以用 Deal X MCP 做什么?
- 按关键词搜索广告 — 通过
search_ads使用文本查询在 DealX 平台上查找列表。 - 对结果进行排序和分页 — 控制排序顺序(例如,使用
-created按最新优先)、页面偏移量和结果数量。 - 限制结果数量 — 设置自定义页面大小,每次请求最多 100 条广告。
文档
@dealx/mcp-server
这是用于 DealX 平台 的模型上下文协议 (MCP) 服务器。它允许 LLM 与 DealX 平台交互,特别是用于搜索广告。
目录
托管部署
Fronteir AI 上提供了托管部署。
概述
DealX MCP 服务器实现了 模型上下文协议,为 LLM 与 DealX 平台 交互提供了标准化方式。目前,它支持搜索广告,并计划在未来添加更多功能。
什么是 MCP?
模型上下文协议 (MCP) 是 LLM 与外部系统交互的标准化方式。它为 LLM 访问数据和执行现实世界操作提供了结构化接口。此服务器实现了 MCP 规范,允许 LLM 与 DealX 平台交互。
安装
先决条件
- Node.js(v20 或更高版本)
- npm(v11 或更高版本)
MCP 配置
要将此服务器与 Claude 等 LLM 一起使用,您需要将其添加到 LLM 的 MCP 配置中:
-
打开 LLM 的 MCP 配置文件:
- Claude 桌面应用:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
- Cline(VS Code 扩展):
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
- Claude 桌面应用:
-
将 DealX MCP 服务器添加到
mcpServers部分:{ "mcpServers": { "dealx": { "command": "npx", "args": ["-y", "@dealx/mcp-server"], "env": { "DEALX_API_URL": "https://dealx.com.ua" }, "disabled": false, "autoApprove": [] } } }
通过 npm 安装
安装 DealX MCP 服务器最简单的方式是通过 npm:
npm install -g @dealx/mcp-server
开发环境安装
如果您想修改服务器或为其开发做出贡献:
-
克隆仓库:
git clone <repository-url> cd dealx/mcp -
安装依赖项:
npm install -
基于
.env.example文件创建.env文件:cp .env.example .env -
编辑
.env文件以设置适当的值:# DealX API URL DEALX_API_URL=http://localhost:3001 # Optional: Specify the port for the MCP server MCP_SERVER_PORT=3100 # Optional: Log level (debug, info, warn, error) LOG_LEVEL=info -
构建服务器:
npm run build
使用方法
启动服务器
您可以通过多种方式运行服务器:
-
如果已全局安装:
node node_modules/@dealx/mcp-server/build/index.js -
使用 npx 无需安装:
npx -y @dealx/mcp-server -
使用环境变量:
DEALX_API_URL=https://dealx.com.ua npx -y @dealx/mcp-server -
用于开发:
npm start
与 LLM 一起使用
在 LLM 的 MCP 设置中配置后,您可以使用自然语言与 DealX 平台交互。
示例提示:
- “在 DealX 上搜索广告,查询词为 'laptop'”
- “在 DealX 上查找最新的 5 条 'iPhone' 广告”
- “在 DealX 上搜索基辅的公寓”
可用工具
search_ads
在 DealX 平台上搜索广告。
参数:
query(字符串,可选):搜索查询字符串sort(字符串,可选):排序顺序(例如,“-created” 表示最新优先)offset(数字,可选):分页偏移量(从 1 开始,默认值:1)limit(数字,可选):每页结果数(最大 100,默认值:30)
使用示例:
{
"query": "laptop",
"sort": "-created",
"offset": 1,
"limit": 10
}
扩展服务器
服务器设计为易于通过附加工具进行扩展。以下是添加新工具的方法:
-
在
src/index.ts的TOOLS对象中定义工具:const TOOLS = { SEARCH_ADS: "search_ads", NEW_TOOL: "new_tool", // Add your new tool here }; -
在
src/tools目录中为您的工具实现创建一个新文件:// src/tools/new-tool.ts import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js"; interface NewToolParams { // Define your tool parameters here } export async function newTool(params: NewToolParams) { try { // Implement your tool logic here return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { // Handle errors // ... } } -
将工具添加到
src/index.ts的ListToolsRequestSchema处理程序中:this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ // Existing tools... { name: TOOLS.NEW_TOOL, description: "Description of your new tool", inputSchema: { type: "object", properties: { // Define your tool parameters here }, required: [], // List required parameters }, }, ], })); -
将工具添加到
src/index.ts的CallToolRequestSchema处理程序中:this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; switch (name) { // Existing cases... case TOOLS.NEW_TOOL: return await newTool(args); default: throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } }); -
在
src/index.ts中导入您的新工具:import { newTool } from "./tools/new-tool.js";
计划中的未来工具
计划在未来实现以下工具:
create_ad:在 DealX 平台 上创建新广告edit_ad:编辑现有广告delete_ad:删除广告get_threads:获取广告的讨论线程create_thread:创建新的讨论线程
开发
项目结构
mcp/
├── build/ # Compiled JavaScript files
├── src/ # TypeScript source files
│ ├── tools/ # Tool implementations
│ │ └── search-ads.ts
│ └── index.ts # Main server implementation
├── .env # Environment variables (not in git)
├── .env.example # Example environment variables
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This file
npm 脚本
npm run build- 将 TypeScript 编译为 JavaScriptnpm start- 使用编译后的 JavaScript 启动服务器npm run dev- 在开发模式下启动服务器,支持热重载npm run lint- 使用 ESLint 检查代码npm run format- 使用 Prettier 格式化代码npm test- 运行测试
故障排除
常见问题
服务器无法启动
如果服务器无法启动,请检查以下内容:
- 确保已安装正确的 Node.js 版本
- 检查所有依赖项是否已安装
- 验证
.env文件是否存在且具有正确的值 - 检查控制台输出中的错误消息
连接问题
如果 LLM 无法连接到服务器:
- 确保服务器正在运行
- 检查 LLM 设置中的 MCP 配置是否正确
- 验证服务器可执行文件的路径是否正确
- 检查环境变量是否设置正确
API 连接问题
如果服务器无法连接到 DealX API:
- 确保 DealX API 正在运行
- 检查
DEALX_API_URL环境变量是否设置正确 - 验证 API 端点是否可从服务器访问
获取帮助
如果您遇到此处未涵盖的问题,请在此 GitHub 仓库中提交 issue。