AI 服务/Agent
调用 MCP
Agent 工具的 MCP Streamable HTTP 端点,无状态,响应为 JSON。
可用 X-Api-Key,也可以使用 Authorization: Bearer <API Key>。Key 缺失或无效时不会返回 401,而是降级为匿名会话,只暴露 aitoearn_connection_help。旧地址 POST /api/unified/mcp 会转发到本接口。
POST
/
api
/
ai
/
agent
/
mcp
调用 MCP
curl --request POST \
--url https://aitoearn.cn/api/ai/agent/mcp \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
'import requests
url = "https://aitoearn.cn/api/ai/agent/mcp"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'tools/list'})
};
fetch('https://aitoearn.cn/api/ai/agent/mcp', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://aitoearn.cn/api/ai/agent/mcp"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"tools/list\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{}授权
需要从 AiToEarn 获取 API Key。点击前往「API Key 获取教程」。
请求体
application/json
MCP JSON-RPC 请求体。
响应
第三方协议原生响应或 SSE 数据。不使用 AiToEarn 通用响应包裹。
第三方协议原生响应,不使用 AiToEarn 通用响应包裹。
最后修改于 2026年9月24日
⌘I
调用 MCP
curl --request POST \
--url https://aitoearn.cn/api/ai/agent/mcp \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
'import requests
url = "https://aitoearn.cn/api/ai/agent/mcp"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'tools/list'})
};
fetch('https://aitoearn.cn/api/ai/agent/mcp', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://aitoearn.cn/api/ai/agent/mcp"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"tools/list\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{}
