DataMerge MCP(模型上下文协议)
用于DataMerge公司API的模型上下文协议(MCP)服务器,使人工智能助手能够通过DataMerge丰富和检索公司数据。
这是什么?
该MCP服务器将AI助手(如Claude、ChatGPT和其他支持MCP的助手)连接到DataMerge公司API。它允许工具按照DataMerge n8n节点中公开的相同操作集,使用DataMerge的基础架构和数据模型启动丰富作业、轮询作业状态、获取公司记录和检查公司层次结构\[https://github.com/poolside-ventures/n8n-nodes-datamerge\].
它是如何工作的:
- 向MCP服务器提供DataMerge API密钥(环境变量或
configure_datamerge工具)。 - 配置您的AI助手以使用此MCP服务器。
- 让你的助理丰富公司,查找公司详细信息,或探索公司等级制度;助理会私下给DataMerge打电话。
如果您还没有DataMerge API密钥,您可以在 http://api.datamerge.ai/schema 了解可用的操作。
特性
- 公司丰富:通过以下方式启动异步丰富作业
POST /v1/company/enrich. - 作业状态:通过以下方式调查丰富工作
GET /v1/job/{job_id}/status. - 公司查询:通过以下方式获取单个公司
GET /v1/company/get. - 层级:通过以下方式检索公司层次结构
GET /v1/company/hierarchy. - 类型安全:完全支持TypeScript,具有面向DataMerge的类型和Zod模式。
- 身份验证支持:基于令牌的身份验证(
Authorization: Token). - 健康检查:通过以下方式进行基本健康监测
/auth/info. - MCP协议合规性:完整的模型上下文协议服务器实现。
- 双模式支持:本地运行(stdio)或远程运行(HTTP/SSE)。
安装
npm install @datamerge/mcp快速开始
1.安装和配置
# Install the package
npm install @datamerge/mcp
# Or install globally for CLI usage
npm install -g @datamerge/mcp2.配置MCP服务器
您可以使用环境变量或 configure_datamerge 工具。
// Configure via tool call
await configure_datamerge({
apiKey: "your_datamerge_api_key_here"
// baseUrl: "https://api.datamerge.ai" // optional override
});或者,设置环境变量:
export DATAMERGE_API_KEY="your_datamerge_api_key_here"3.使用可用工具
MCP服务器提供以下工具:
启动公司拓展
await start_company_enrichment({
domain: "example.com",
// company_name: "Example Inc",
// country_code: "US",
// strict_match: true,
// global_ultimate: true,
// webhook_url: "https://yourapp.com/datamerge-webhook"
});
// Starts an enrichment job and returns a job id and initial status开始公司充实并等待
await start_company_enrichment_and_wait({
domain: "example.com",
// company_name: "Example Inc",
// country_code: "US",
// strict_match: true,
// global_ultimate: true,
// poll_interval_seconds: 5,
// timeout_seconds: 60
});
// Starts an enrichment job and polls its status until completion or timeout (default: 5s interval, 60s timeout)获取公司丰富成果
await get_company_enrichment_result({
job_id: "job_123"
});
// Returns job status and (when ready) enriched company records获取公司
await get_company({
domain: "example.com"
// or company_id: "cmp_123"
// or company_name: "Example Inc"
});
// Returns a single company record from DataMerge获取公司层次结构
await get_company_hierarchy({
company_id: "cmp_123"
// or domain / company_name + country_code
});
// Returns parents/children of the company to inspect hierarchy健康检查
await health_check();
// Verifies API connectivity using the /auth/info endpoint部署选项
MCP服务器可以在两种模式下运行:
1.本地模式(标准运输)
用于与Claude Desktop等人工智能助手进行本地集成。使用stdio传输进行通信。
# Run locally
npx @datamerge/mcp
# Or with environment variable
DATAMERGE_API_KEY="your_key" npx @datamerge/mcp2.HTTP模式(流式HTTP/SSE传输)
用于使用HTTP/SSE传输的远程部署。这允许通过网络访问MCP服务器。
运行HTTP服务器
# Build and start the HTTP server
npm run build
npm run start:http
# Or with custom port
PORT=8080 npm run start:http
# Or run directly with npx
npx datamerge-mcp-http服务器端点
- MCP端点(SSE+JSON-RPC):
- POST / –MCP客户端到服务器消息 - GET / –MCP服务器到客户端SSE流 - DELETE / –终止会话
- 健康检查:
GET /health–服务器运行状况
认证
所有HTTP请求都需要在 Authorization 头球
Authorization: Token MCP服务器随后使用相同的API密钥向DataMerge API进行身份验证。
测试HTTP服务器
# Health check (should fail without auth)
curl http://localhost:3000/health
# Health check with authentication
curl -H "Authorization: Token YOUR_API_KEY" http://localhost:3000/health
# Connect to streamable endpoint
curl -N -H "Authorization: Token YOUR_API_KEY" http://localhost:3000/
# Or use the test script
./test-http-server.sh YOUR_API_KEYMCP集成
使用AI助手
此MCP服务器可以与Claude、ChatGPT等支持模型上下文协议的AI助手集成。
配置示例
{
"mcpServers": {
"datamerge": {
"command": "npx",
"args": ["@datamerge/mcp"],
"env": {
"DATAMERGE_API_KEY": "your_datamerge_api_key_here"
}
}
}
}可用的MCP工具
服务器为AI助手公开了这些工具:
configure_datamerge–配置API连接(如果DATAMERGE_API_KEY已设置)。start_company_enrichment–开始充实工作。start_company_enrichment_and_wait–启动富集作业并轮询,直到完成或超时。get_company_enrichment_result–轮询工作状态和结果。get_company–获取单个公司记录。get_company_hierarchy–为公司找回父母/孩子。health_check–使用验证API连接/auth/info.
使用示例
作为图书馆
import { DataMergeClient, DataMergeMCPServer } from '@datamerge/mcp';
// Use as a direct API client
const client = new DataMergeClient({
apiKey: 'your_datamerge_api_key_here',
});
// Use as an MCP server
const server = new DataMergeMCPServer();
await server.run();作为MCP服务器
# Run the MCP server
npx @datamerge/mcp
# Or install globally
npm install -g @datamerge/mcp
datamerge-mcp配置
环境变量
您可以使用环境变量配置MCP服务器:
export DATAMERGE_API_KEY="your_datamerge_api_key_here"
# Then run the server
datamerge-mcp认证
MCP服务器将DataMerge API密钥用于所有出站API请求以及HTTP模式下的可选HTTP身份验证。
发展
运行测试
npm test
npm run test:watch代码检查
npm run lint
npm run lint:fixCLI使用情况
该软件包包括用于运行MCP服务器的命令行界面:
# Install globally
npm install -g @datamerge/mcp
# Run the stdio MCP server
datamerge-mcp
# Run the HTTP/streamable MCP server
datamerge-mcp-http错误处理
MCP服务器为常见问题提供详细的错误消息:
- 配置错误(例如,缺少API密钥)。
- DataMerge的身份验证错误。
- 工具参数的验证错误(通过Zod)。
- 来自DataMerge API的API错误(显示为文本错误内容)。
许可证
MIT许可证——见 LICENSE 了解详情。
