MCP server
mpaka-mcp is a local Model Context Protocol (MCP) server that forwards tool
requests to the mPaka HTTP API. It does not run submitted Python on the MCP
host; execution is provided by the API service.
Install
Section titled “Install”The MCP project provides a signed release channel at https://mcp.mpaka.dev.
After it has published its first release, install the latest version on Linux
or macOS with:
curl -fsSL https://mcp.mpaka.dev/install | bashOn Windows, use PowerShell 7 or later:
irm https://mcp.mpaka.dev/install.ps1 | iexThe installers verify the signed release manifest, archive size, and SHA-256
before installing. To build from source, install stable Rust and run
cargo build --locked --release in the mpaka-mcp repository. The executable
is target/release/mpaka-mcp (or mpaka-mcp.exe on Windows).
Configure an MCP client
Section titled “Configure an MCP client”Install the server on the same machine as the MCP client, then register it as a
local stdio server. For clients using the mcpServers configuration format:
{ "mcpServers": { "mpaka": { "command": "mpaka-mcp", "env": { "MPAKA_API_URL": "https://api.mpaka.dev" } } }}Provide MPAKA_API_KEY through the environment that launches the client, and
ensure the client passes it to the server process. Keep the value in a secret
store or the client environment; do not put a literal key in a project config
file or tool arguments. The generic example above intentionally contains no
key. For clients that require a config entry, use that client’s supported
secret or environment-variable interpolation.
MPAKA_API_KEY is required. MPAKA_API_URL defaults to
https://api.mpaka.dev; MPAKA_API_BASE_URL is supported as a legacy alias
when MPAKA_API_URL is unset. Remote API URLs must use HTTPS; plain HTTP is
accepted only for loopback addresses. Set MPAKA_API_TIMEOUT_SECONDS to change
the HTTP request timeout, which defaults to 15 seconds.
For Codex, expose MPAKA_API_KEY in the environment that launches Codex and
add this to ~/.codex/config.toml:
[mcp_servers.mpaka]command = "mpaka-mcp"env_vars = ["MPAKA_API_KEY"]
[mcp_servers.mpaka.env]MPAKA_API_URL = "https://api.mpaka.dev"Cursor supports environment interpolation in .cursor/mcp.json:
{ "mcpServers": { "mpaka": { "command": "mpaka-mcp", "env": { "MPAKA_API_KEY": "${env:MPAKA_API_KEY}", "MPAKA_API_URL": "https://api.mpaka.dev" } } }}Restart the MCP client after changing its configuration and check that it discovers the mPaka tools. The server reserves stdout for protocol messages and writes diagnostics to stderr.
Available tools
Section titled “Available tools”The server exposes 13 tools, grouped here by workflow:
| Workflow | Tools | What they do |
|---|---|---|
| Execute Python | execute_python, get_execution, list_executions, wait_execution, cancel_execution |
Submit code, inspect and list executions, wait for a bounded period, or request cancellation. |
| Python environments | create_environment, get_environment, list_environments, wait_environment |
Build, inspect, list, and wait for reusable dependency environments. |
| Discover resources | get_resource_profiles |
Read API request bounds and current CPU and memory profiles. |
| Tenant controls | get_quota |
Read the tenant’s effective unit and active-execution quota. |
| Usage | get_usage, get_usage_summary |
Read measured execution attempts or aggregate and daily provisioned resource use. |
Submit and inspect work
Section titled “Submit and inspect work”execute_python accepts Python source and a required stable idempotency_key.
It can also take timeout_ms, cpu_profile, memory_profile, and a ready
environment_id. To safely retry an ambiguous submission, reuse the same key
with the same code and options. The tool returns the current execution
resource; call wait_execution or get_execution to follow it to a terminal
state. The MCP tool accepts named resource profiles; use the HTTP API if your
client needs the numeric vcpu_count or memory_mb fields.
An execution is successful only when its status is completed, its mode is not
mock_no_code_execution, and its exit code is 0. Cancellation is a request;
inspect the returned state because completion can win the race.
Build and reuse environments
Section titled “Build and reuse environments”create_environment takes pinned requirements such as
["requests==2.32.3"] plus an idempotency_key. It returns the initial build
state rather than waiting for completion. Use wait_environment or
get_environment until it is ready or failed; stop polling at either
terminal state, and pass its ID to execute_python only when it is ready.
The API validates and authorizes every operation. Environment support depends
on deployment configuration: a tenant that cannot create environments can
receive HTTP 403 with tenant_disabled, while an unavailable environment
service returns HTTP 503 with environments_unavailable.
Environment and execution waits accept timeout_ms from 100 to 30,000 and
poll_interval_ms from 100 to 5,000 (default 500); the interval cannot exceed
the timeout, and each wait defaults to 10 seconds. The server bounds API
requests by the wait deadline. If it has received a resource that remains
pending, the result includes its latest state and timed_out: true. If the
deadline expires before the initial API response, the tool returns a timeout
error without a resource state. Either timeout ends only the local wait; it
does not cancel the build or execution. A terminal failed resource returns
timed_out: false with its terminal status.
Read resource profiles, quota, and usage
Section titled “Read resource profiles, quota, and usage”Call get_resource_profiles before selecting CPU or memory profiles; its
response contains the request bounds and supported profiles currently reported
by the API. get_quota reports the configured tenant’s unit and active
execution limits.
get_usage accepts optional RFC 3339 since and until times, limit (1 to
1,000), offset, or cursor. Its default range is the last 30 days and its
default page size is 100. For stable pagination, reuse the response’s until
and pass next_cursor on the next call; a cursor cannot be combined with a
non-zero offset. get_usage_summary returns aggregate totals and can request
daily rows with group_by: "day". Both usage tools report provisioned resource
metering, not a monetary charge.
Errors and data handling
Section titled “Errors and data handling”The MCP server preserves API error codes in tool errors, including codes such
as invalid_requirements, environment_not_found, environment_not_ready,
tenant_disabled, and environments_unavailable. Local input and transport
errors use MCP-specific codes. Keep the API key in the client environment or a
secret store, never in tool arguments or a shared config file. Treat submitted
code, package requirements, stdout, and stderr returned by tools as untrusted
data.