import requests
url = "https://api.onecortex.io/v1/agents/{agentId}/mcp"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ask_echo",
"arguments": { "prompt": "hello" },
"_meta": {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": {}
}
}
}
headers = {
"MCP-Protocol-Version": "<mcp-protocol-version>",
"Mcp-Method": "<mcp-method>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
const url = new URL('https://api.onecortex.io/v1/agents/agt_.../mcp')
const client = new Client({ name: 'my-app', version: '1.0.0' }, { versionNegotiation: { mode: 'auto' } })
await client.connect(new StreamableHTTPClientTransport(url, {
requestInit: { headers: { Authorization: `Bearer ${process.env.ONECORTEX_API_KEY}` } },
}))
const { tools } = await client.listTools()
const result = await client.callTool({ name: tools[0].name, arguments: { prompt: 'hello' } })
console.log(result.content)
curl https://api.onecortex.io/v1/agents/agt_.../mcp \
-H "Authorization: Bearer $ONECORTEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2026-07-28" \
-H "Mcp-Method: tools/call" \
-H "Mcp-Name: ask_echo" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"ask_echo","arguments":{"prompt":"hello"},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}}}'
{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32022,
"message": "Unsupported protocol version: 2024-01-01",
"data": {
"supported": [
"2026-07-28"
],
"requested": "2024-01-01"
}
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "A valid Onecortex API key is required."
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "That agent does not exist."
}
}{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}Call an agent as an MCP tool
The agent as an MCP server with one tool, ask_ and the agent’s slug with hyphens as underscores. MCP 2026-07-28, and the 2025-11-25 initialize handshake. Stateless: every request is answered on its own. server/discover and tools/list describe the tool, tools/call runs the agent with its prompt, session_id and resume arguments, and returns the reply as one text block with the session in structuredContent.
A client that sends a progress token gets progress notifications on a stream while the run works. A run that fails is a tool result with isError: true. A paused run asks a client that can elicit for a form and continues on its retry; any other client gets the question as text and answers with resume.
An API key works here, and so does an access token from signing in: a call with no credential answers 401 with a WWW-Authenticate header naming the sign in metadata. A refusal of the call itself keeps its HTTP status with a JSON-RPC error body. See MCP.
import requests
url = "https://api.onecortex.io/v1/agents/{agentId}/mcp"
payload = {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "ask_echo",
"arguments": { "prompt": "hello" },
"_meta": {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": {}
}
}
}
headers = {
"MCP-Protocol-Version": "<mcp-protocol-version>",
"Mcp-Method": "<mcp-method>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client'
const url = new URL('https://api.onecortex.io/v1/agents/agt_.../mcp')
const client = new Client({ name: 'my-app', version: '1.0.0' }, { versionNegotiation: { mode: 'auto' } })
await client.connect(new StreamableHTTPClientTransport(url, {
requestInit: { headers: { Authorization: `Bearer ${process.env.ONECORTEX_API_KEY}` } },
}))
const { tools } = await client.listTools()
const result = await client.callTool({ name: tools[0].name, arguments: { prompt: 'hello' } })
console.log(result.content)
curl https://api.onecortex.io/v1/agents/agt_.../mcp \
-H "Authorization: Bearer $ONECORTEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-H "MCP-Protocol-Version: 2026-07-28" \
-H "Mcp-Method: tools/call" \
-H "Mcp-Name: ask_echo" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"ask_echo","arguments":{"prompt":"hello"},"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}}}'
{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32022,
"message": "Unsupported protocol version: 2024-01-01",
"data": {
"supported": [
"2026-07-28"
],
"requested": "2024-01-01"
}
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "A valid Onecortex API key is required."
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "That agent does not exist."
}
}{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}Authorizations
An Onecortex API key, oc_live_..., from API keys in the dashboard, or an access token, oc_oat_..., that an app received when a person allowed it to use one agent.
Headers
2026-07-28, equal to the version in the request's _meta. A 2025-11-25 client sends it after initialize.
"2026-07-28"
The JSON-RPC method, as in the body.
"tools/call"
The tool's name, on tools/call.
"ask_echo"
Path Parameters
The agent's ID, from its page in the dashboard.
"agt_01K0000000000000000000000"