Documentation
Home/Documentation/API and MCP

API and MCP

Save and call programs from your code or connect them to an agent. This page covers the program interface: access, requests, responses and checking a run.

Address and authorization

Service address: https://api.extella.ai. The requests below use the POST method with a JSON body.

Get a token in your Extella account. You can ask the agent: “Create an API token for my script”. Use the IDs of the agent and profile in whose scope you save programs. Do not publish the token and do not put it in the code of a website page.

Request headers
Content-Type: application/json
X-Auth-Token: YOUR_TOKEN
X-Profile-Id: YOUR_PROFILE_ID
X-Agent-Id: YOUR_AGENT_ID

Keep the token on a server or in your local environment. The Python example asks for it with hidden input.

POST/api/expert/save

Creates or replaces a saved program. name, description and code are required. Set cspl explicitly.

JSON
{
  "name": "add_two_numbers_v1",
  "description": "Add two numbers a and b; return total.",
  "code": "def add_two_numbers_v1(a: float = 0, b: float = 0) -> dict:\n    return {\"total\": a + b}",
  "cspl": "fython",
  "kwargs": {},
  "global": false
}

Check the name first. Saving over an existing record replaces its code.

POST/api/expert/get

Returns the record by name. Check the fields expert_name, expert_code, cspl and expert_params.

JSON
{"name": "add_two_numbers_v1"}

POST/api/expert/run

Passes parameters to a saved program. In the current request schema, the name goes in the expert_name field.

JSON
{
  "expert_name": "add_two_numbers_v1",
  "params": {"a": 5, "b": 7},
  "targets": ["DEVICE_ID"],
  "wait": true
}

Check status, then the contents of result. On an error, read execution_log. HTTP 200 alone does not prove that the program finished successfully.

Deferred result

If the call returned a task_id, request its state with POST /api/tasks/check and the body {"task_id":"TASK_ID"}. Wait for a final status before you repeat an action that changes data.

Limit the number of retries and the total waiting time. Do not print the token to a log while you investigate an error.

Troubleshooting

SignalNext step
HTTP 401Check the token value and whether it has expired.
HTTP 422Check the names of the required fields and the value types.
HTTP 400 / 500Read the service message and the execution log. Do not repeat the write blindly.
The program is not foundCheck the name and the profile / agent scope.
No response from the deviceCheck the executor connection, the Device ID and the dependencies.

Connecting through MCP

MCP gives an agent access to Extella tools. In a client that supports Streamable HTTP and authorization headers, add a connection:

ParameterValue
TransportStreamable HTTP
URLhttps://api.extella.ai/mcp/
HeadersX-Auth-Token, X-Profile-Id, X-Agent-Id, the same as for the API.

After connecting, get the list of available tools. First find and read the program you need. The tested examples run it with the run_expert tool; take the parameters from the schema your MCP server returned.

Give the agent only the rights it needs. Connecting tools does not replace preparing the device.