v1.0.0
MatrixAI MCP Server API 文档
通过 Model Context Protocol (MCP) 让外部 AI Agent(如 Claude、Manus、GPT)直接操作 MatrixAI 的全部营销功能 — 发布内容、生成文案、查看数据、管理账号。
JSON-RPC 2.0Bearer Auth18 ToolsSSE Support
快速开始
1. 获取 API Key
前往 MCP 集成 页面,在 "API Keys" 标签页中创建新的 API Key。创建后请立即复制保存,密钥仅显示一次。
2. 发送第一个请求
bash
# 初始化连接
curl -X POST https://YOUR_DOMAIN/api/mcp \
-H "Authorization: Bearer mxai_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}'3. 列出可用工具
bash
curl -X POST https://YOUR_DOMAIN/api/mcp \
-H "Authorization: Bearer mxai_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}'4. 调用工具
bash
curl -X POST https://YOUR_DOMAIN/api/mcp \
-H "Authorization: Bearer mxai_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_dashboard_stats",
"arguments": {}
}
}'认证说明
所有 API 请求必须在 HTTP Header 中携带有效的 API Key。密钥以 mxai_ 前缀开头,使用 Bearer Token 方式传递。
http
Authorization: Bearer mxai_a1b2c3d4e5f6...API Key 管理
- 在 MCP 集成页面创建和管理 API Key
- 支持设置过期时间
- 密钥使用 SHA256 哈希存储,无法反向查看
- 可随时撤销已发放的密钥
安全建议
- 不要在客户端代码中硬编码 API Key
- 使用环境变量存储密钥
- 定期轮换密钥
- 为不同用途创建独立的密钥
端点
| 端点 | 方法 | 说明 | 认证 |
|---|---|---|---|
| /api/mcp | POST | JSON-RPC 2.0 主端点 | Required |
| /api/mcp/sse | GET | SSE 传输端点(Streamable HTTP) | Required |
| /api/mcp/info | GET | 服务器信息(公开) | Public |
协议方法
| Method | 说明 | Params |
|---|---|---|
| initialize | 初始化MCP连接,返回服务器能力 | {} |
| tools/list | 列出所有可用工具及其参数定义 | {} |
| tools/call | 调用指定工具 | { name, arguments } |
| ping | 心跳检测 | {} |
工具参考
MatrixAI MCP Server 提供 18 个工具,覆盖内容发布、草稿管理、AI文案生成、账号管理、凭证检查、数据分析、热点话题和文案库等全部核心功能。
错误码参考
| Code | Name | 说明 |
|---|---|---|
| -32700 | Parse error | 请求体不是有效的JSON |
| -32600 | Invalid Request | 不是有效的JSON-RPC 2.0请求 |
| -32601 | Method not found | 请求的method不存在 |
| -32602 | Invalid params | 工具名称缺失或参数无效 |
| -32000 | Unauthorized | API Key无效、过期或缺失 |
| -32001 | Tool execution error | 工具执行过程中发生错误 |
Claude Desktop 集成指南
在 Claude Desktop 的配置文件中添加 MatrixAI MCP Server,即可在对话中直接操作营销功能。
1. 编辑 Claude Desktop 配置文件
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
json
{
"mcpServers": {
"matrixai": {
"url": "https://YOUR_DOMAIN/api/mcp/sse",
"headers": {
"Authorization": "Bearer mxai_YOUR_API_KEY"
}
}
}
}2. 重启 Claude Desktop
保存配置后重启 Claude Desktop,在工具列表中即可看到 MatrixAI 的 18 个工具。
3. 开始使用
在 Claude 中直接说:
"帮我查看最近的发布任务状态"
"为我的新产品写一条小红书种草文案"
"查看哪些平台凭证需要更新"
"获取今天的热门话题,然后创建一条相关的发布任务"
Manus Agent 集成指南
Manus AI Agent 可通过 MCP 协议直接操作 MatrixAI,实现自动化营销工作流。
bash
# 使用 manus-mcp-cli 连接 MatrixAI
manus-mcp-cli tool list --server matrixai
# 调用工具
manus-mcp-cli tool call generate_content --server matrixai \
--input '{"prompt": "写一条抖音推广文案", "platform": "douyin"}'
# 创建发布任务
manus-mcp-cli tool call create_publish_task --server matrixai \
--input '{
"title": "自动化发布",
"content": "AI生成的内容...",
"contentType": "text",
"platforms": ["douyin", "weibo"]
}'Python SDK 示例
python
import requests
import json
BASE_URL = "https://YOUR_DOMAIN/api/mcp"
API_KEY = "mxai_YOUR_API_KEY"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
def call_tool(name: str, arguments: dict = {}, request_id: int = 1):
"""Call a MatrixAI MCP tool"""
payload = {
"jsonrpc": "2.0",
"id": request_id,
"method": "tools/call",
"params": {"name": name, "arguments": arguments}
}
response = requests.post(BASE_URL, headers=HEADERS, json=payload)
result = response.json()
if "error" in result:
raise Exception(f"MCP Error: {result['error']['message']}")
content = result["result"]["content"][0]["text"]
return json.loads(content)
# Example: Generate content and create a publish task
content = call_tool("generate_content", {
"prompt": "为一款新上市的智能手表写推广文案",
"platform": "douyin",
"contentType": "post"
})
print("Generated:", content["content"][:100])
task = call_tool("create_publish_task", {
"title": "智能手表推广",
"content": content["content"],
"contentType": "text",
"platforms": ["douyin", "xiaohongshu", "weibo"]
})
print("Task created:", task["taskId"])使用限制
| 限制项 | Free | Startup | Pro | Enterprise |
|---|---|---|---|---|
| API Keys 数量 | 1 | 5 | 20 | Unlimited |
| 请求频率 | 10/min | 60/min | 300/min | 1000/min |
| AI 生成次数/月 | 10 | 100 | 500 | Unlimited |
MCP API 调用受用户订阅计划的配额限制。超出限制时将返回错误码 -32001。
