MCP DataForSEO 工具
一个基于stdio的服务器,通过模型上下文协议启用与DataForSEO API的交互,允许用户获取包括搜索结果、关键词数据、反向链接、页面内分析等在内的SEO数据。
服务介绍
DataForSEO MCP 服务器
一个基于标准输入输出的模型上下文协议(MCP)服务器,用于 DataForSEO API。
安装
你可以直接使用 npx 运行:
npx @skobyn/mcp-dataforseo --config '{"username":"your_username","password":"your_password"}'
或者全局安装:
npm install -g @skobyn/mcp-dataforseo
mcp-dataforseo --config '{"username":"your_username","password":"your_password"}'
使用方法
向标准输入发送 JSON 请求,并从标准输出接收 JSON 响应:
echo '{"type":"dataforseo_serp","keyword":"artificial intelligence"}' | npx @skobyn/mcp-dataforseo --config '{"username":"your_username","password":"your_password"}'
支持的请求类型
SERP API
{
"type": "dataforseo_serp",
"keyword": "artificial intelligence",
"location_code": 2840,
"language_code": "en",
"device": "desktop",
"os": "windows"
}
关键词数据 API
{
"type": "dataforseo_keywords_data",
"keywords": ["seo", "search engine optimization"],
"location_code": 2840,
"language_code": "en"
}
反向链接 API
{
"type": "dataforseo_backlinks",
"target": "example.com",
"limit": 100
}
页面内 API
{
"type": "dataforseo_onpage",
"url": "https://example.com",
"check_spell": true,
"enable_javascript": true
}
域名分析 API
{
"type": "dataforseo_domain_analytics",
"domain": "example.com"
}
应用数据 API
{
"type": "dataforseo_app_data",
"app_id": "com.example.app"
}
商家 API
{
"type": "dataforseo_merchant",
"keyword": "bluetooth speakers",
"location_code": 2840,
"language_code": "en"
}
商业数据 API
{
"type": "dataforseo_business_data",
"keyword": "pizza delivery",
"location_code": 2840,
"language_code": "en"
}
集成示例
以下是如何在你的 Node.js 代码中使用这个 MCP 服务器:
const { spawn } = require('child_process');
// Start the MCP server
const server = spawn('npx', ['@skobyn/mcp-dataforseo', '--config', '{"username":"your_username","password":"your_password"}']);
// Define the request
const request = {
type: 'dataforseo_serp',
keyword: 'artificial intelligence'
};
// Send the request
server.stdin.write(JSON.stringify(request) + '\n');
server.stdin.end();
// Process the response
server.stdout.on('data', (data) => {
const response = JSON.parse(data.toString());
console.log(response);
});
// Handle errors
server.stderr.on('data', (data) => {
console.error(`Error: ${data}`);
});
环境变量
你也可以使用环境变量代替配置文件:
export DATAFORSEO_USERNAME=your_username
export DATAFORSEO_PASSWORD=your_password
npx @skobyn/mcp-dataforseo
发布
要将此包发布到 npm:
-
如果尚未登录 npm,请先登录:
npm login -
发布包:
npm publish --access public -
若要以后更新包:
npm version patch npm publish