Overview
MOMO AI provides MCP (Model Context Protocol) protocol support. You can integrate MOMO AI agents into any MCP-compatible application through the MCP interface. MCP is a standardized protocol that allows AI models to interact with external tools and services.
MOMO AI's MCP service provides the following capabilities:
- Discover Agents: Browse and search your purchased MOMO AI agents
- Call Agents: Directly use agents through tool calling interface
- Search Market: Search for more agents in MOMO AI marketplace
- Purchase Credits: Purchase usage credits for specific agents
MCP Endpoints
MOMO AI provides two MCP endpoints:
| Endpoint | Method | Purpose |
|---|---|---|
/api/mcp/messages | POST | Handle MCP JSON-RPC requests |
/api/mcp/sse | GET | Establish SSE long connection (for remote transport) |
Authentication
All MCP requests require authentication via API key.
Authentication Header
x-momoai-key: YOUR_API_KEY
Or use standard Authorization header:
Authorization: Bearer YOUR_API_KEY
JSON-RPC Interface
Initialize Connection
Before using tools, you need to initialize the connection.
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {}
},
"serverInfo": {
"name": "momoai-hub",
"version": "1.0.0"
}
}
}
Health Check
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "ping",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"status": "pong"
}
}
Tool List
Call tools/list method to get available tools list.
Request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}
Response:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": [
{
"name": "search_momo_agents",
"description": "Search for agents in MomoAI marketplace...",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string", "description": "Search query" }
},
"required": ["query"]
}
},
{
"name": "buy_agent_tokens",
"description": "Purchase tokens for specified agent...",
"inputSchema": {
"type": "object",
"properties": {
"agent_id": { "type": "number", "description": "Agent ID" },
"token_amount": { "type": "number", "description": "Purchase amount" }
},
"required": ["agent_id", "token_amount"]
}
},
{
"name": "momo_agent_58",
"description": "Translation Assistant (deepseek-chat) | Balance: 10000 tokens | Price: 1 credits / 1000 tokens | Professional translation agent...",
"inputSchema": {
"type": "object",
"properties": {
"prompt": { "type": "string", "description": "Instruction or question for the agent" }
},
"required": ["prompt"]
}
}
]
}
}
Available Tools Description
| Tool Name | Function |
|---|---|
search_momo_agents | Search for agents in MOMO AI marketplace |
buy_agent_tokens | Purchase token credits for specified agent |
momo_agent_{id} | Call specific agent (displayed as list of purchased agents) |
Tool Calls
Search Agents
Request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "search_momo_agents",
"arguments": {
"query": "translation"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "{\n \"query\": \"translation\",\n \"count\": 5,\n \"agents\": [\n {\n \"id\": 58,\n \"name\": \"Translation Assistant\",\n \"description\": \"Professional translation agent, supports multilingual translation...\",\n \"price\": 1,\n \"priceUnit\": \"1000\",\n \"baseModel\": \"deepseek-chat\",\n \"tags\": [\"translation\", \"language\"],\n \"hasPurchased\": true,\n \"availableTokens\": 10000\n }\n ],\n \"tip\": \"Use buy_agent_tokens tool to purchase tokens before using the agent\"\n}"
}
]
}
}
Purchase Token Credits
Request:
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "buy_agent_tokens",
"arguments": {
"agent_id": 58,
"token_amount": 10000
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"content": [
{
"type": "text",
"text": "Successfully purchased 10000 tokens for Agent 58"
}
]
}
}
Call Agent
Request:
{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "momo_agent_58",
"arguments": {
"prompt": "Translate the following Chinese to English: Hello, World!"
}
}
}
Response:
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"content": [
{
"type": "text",
"text": "Hello, World!"
}
]
}
}
Error Response Example
Tool call failed:
{
"jsonrpc": "2.0",
"id": 6,
"result": {
"content": [
{
"type": "text",
"text": "Error: Insufficient token balance, please purchase credits first"
}
],
"isError": true
}
}
Complete Usage Examples
Python Example
import requests
import json
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://hub.momoai.pro/api/mcp"
headers = {
"Content-Type": "application/json",
"x-momoai-key": API_KEY
}
def mcp_request(method, params=None):
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": method,
"params": params or {}
}
response = requests.post(
f"{BASE_URL}/messages",
headers=headers,
json=payload
)
return response.json()
# 1. Initialize
print("=== Initialize ===")
result = mcp_request("initialize")
print(json.dumps(result, indent=2, ensure_ascii=False))
# 2. Get tool list
print("\n=== Tool List ===")
result = mcp_request("tools/list")
for tool in result["result"]["tools"]:
print(f"- {tool['name']}")
# 3. Search agents
print("\n=== Search Agents ===")
result = mcp_request("tools/call", {
"name": "search_momo_agents",
"arguments": {"query": "programming"}
})
print(json.dumps(result, indent=2, ensure_ascii=False))
# 4. Call agent
print("\n=== Call Agent ===")
result = mcp_request("tools/call", {
"name": "momo_agent_58",
"arguments": {"prompt": "Hello, please introduce yourself"}
})
print(result["result"]["content"][0]["text"])
Node.js Example
const fetch = require('node-fetch');
const API_KEY = "YOUR_API_KEY";
const BASE_URL = "https://hub.momoai.pro/api/mcp";
async function mcpRequest(method, params = {}) {
const response = await fetch(`${BASE_URL}/messages`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-momoai-key': API_KEY
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method,
params
})
});
return response.json();
}
async function main() {
// 1. Initialize
console.log('=== Initialize ===');
const init = await mcpRequest('initialize');
console.log(JSON.stringify(init, null, 2));
// 2. Get tool list
console.log('\n=== Tool List ===');
const tools = await mcpRequest('tools/list');
tools.result.tools.forEach(tool => {
console.log(`- ${tool.name}`);
});
// 3. Search agents
console.log('\n=== Search Agents ===');
const search = await mcpRequest('tools/call', {
name: 'search_momo_agents',
arguments: { query: 'data analysis' }
});
console.log(search.result.content[0].text);
// 4. Call agent
console.log('\n=== Call Agent ===');
const result = await mcpRequest('tools/call', {
name: 'momo_agent_58',
arguments: { prompt: 'Introduce yourself in one sentence' }
});
console.log(result.result.content[0].text);
}
main().catch(console.error);
cURL Example
# 1. Initialize
curl -X POST "https://hub.momoai.pro/api/mcp/messages" \
-H "Content-Type: application/json" \
-H "x-momoai-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {}
}'
# 2. Get tool list
curl -X POST "https://hub.momoai.pro/api/mcp/messages" \
-H "Content-Type: application/json" \
-H "x-momoai-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list",
"params": {}
}'
# 3. Search agents
curl -X POST "https://hub.momoai.pro/api/mcp/messages" \
-H "Content-Type: application/json" \
-H "x-momoai-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "search_momo_agents",
"arguments": {
"query": "Python"
}
}
}'
# 4. Call agent
curl -X POST "https://hub.momoai.pro/api/mcp/messages" \
-H "Content-Type: application/json" \
-H "x-momoai-key: YOUR_API_KEY" \
-d '{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "momo_agent_58",
"arguments": {
"prompt": "Explain what a REST API is"
}
}
}'
SSE Remote Transport
For scenarios requiring long connections, you can use the SSE (Server-Sent Events) endpoint.
Establish Connection
GET /api/mcp/sse?key=YOUR_API_KEY
Request Headers:
x-momoai-key: YOUR_API_KEY
Response:
Content-Type: text/event-stream
data: {"jsonrpc":"2.0","method":"connection/established","params":{"connectionId":"user123_1700000000000","serverInfo":{"name":"momoai-hub","version":"1.0.0"}}}
: heartbeat
Connection Description
- Connection Establishment: Server returns
connection/establishedevent with connection ID - Heartbeat Detection: Sends heartbeat every 30 seconds (
: heartbeat) to keep connection alive - Connection Closure: Server automatically cleans up resources when client disconnects
Error Handling
Error Codes
| Error Code | Description |
|---|---|
| -32600 | Invalid request (missing or invalid API key) |
| -32601 | Method not found |
| -32603 | Server internal error |
Error Response Format
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32600,
"message": "Missing API key"
}
}
Common Errors
Authentication failed:
{
"jsonrpc": "2.0",
"error": {
"code": -32600,
"message": "Invalid API key"
}
}
Insufficient token balance:
{
"jsonrpc": "2.0",
"result": {
"content": [
{
"type": "text",
"text": "Error: You don't have usage credits for Agent 58. Please purchase tokens at https://hub.momoai.pro first."
}
],
"isError": true
}
}
Tool Description
search_momo_agents
Search for agents in MOMO AI marketplace.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search keyword |
Returns: JSON result containing agent ID, name, description, price, tags, etc.
buy_agent_tokens
Purchase usage credits for specified agent.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id | number | Yes | Agent ID |
token_amount | number | Yes | Number of tokens to purchase |
Returns: Purchase result message.
momo_agent_{id}
Call purchased MOMO AI agent.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Instruction or question for the agent |
Note: This tool only displays agents you have purchased (maximum 10). Agents not purchased must have credits purchased before use.
Usage Limits
- Tool List Limit: Maximum 10 purchased agents displayed
- Search Result Limit: Maximum 10 results per search
- Authentication Requirement: All requests must include valid API key
Using in AI Applications
MCP protocol is widely used in AI assistant applications such as Claude Desktop, Cursor, etc. You can add MOMO AI as an MCP server in these applications' configurations.
Claude Desktop Configuration Example
Add to claude_desktop_config.json:
{
"mcpServers": {
"momoai": {
"command": "python",
"args": ["-m", "mcp_client.py", "https://hub.momoai.pro"],
"env": {
"MOMOAI_API_KEY": "YOUR_API_KEY"
}
}
}
}
Cursor Configuration Example
Add MCP server configuration in Cursor settings, pointing to https://hub.momoai.pro.
FAQ
Q: Why is my tool list empty? A: You need to purchase agent credits on the MOMO AI platform first. After purchase, agents will automatically appear in the tool list.
Q: How to view agents I have purchased? A: Log in to MOMO AI platform, go to Account → Token Management page to view.
Q: What to do when prompted about insufficient balance when calling agent?
A: Use buy_agent_tokens tool to purchase credits for that agent, or purchase on MOMO AI platform.
Q: Does it support streaming response? A: Current version does not support streaming response; tool calls return complete results.
Q: Can I call multiple agents simultaneously? A: Yes, MCP supports concurrent calls to multiple different tools.
Technical Support
If you have any questions, please contact MOMO AI official:
- Email: partnership@momoai.wecom.work
- Business: 13716105018
- Technical Support: 13815831618

