# MCP server
Keln has an MCP server at `https://mcp.keln.ai/mcp`. Connect it to Claude, ChatGPT, Cursor, Codex, or any MCP client that connects over HTTP to give your assistant access to sandboxes, code execution, web search, and web page reading. No installation required.
- **Transport:** Streamable HTTP over HTTPS.
- **Authentication:** Sign in with your Keln account in supported apps, or use a [Keln API key](platform/authentication.md) with `Authorization: Bearer <key>`.
- **Billing:** Tool calls use standard [sandbox](sandboxes/index.md#pricing) and [web API](capabilities/web-search.md) pricing. Keln bills usage to your project balance, within the connected key's limits. There's no additional MCP fee.
## Sign in with Keln
Apps that support MCP authentication only need the server URL.
When you connect for the first time, sign in to Keln, choose a project, and select **Allow**. You must have a verified email and own or administer the project.
Keln creates an API key for the connection, named after the app, such as **Claude (connected app)**. You can find it on the project's [API keys](https://app.keln.ai/keys) page, where you can manage its limits or revoke access.
To reconnect after revoking the key, sign in through the app again.
### Claude
In Claude on the web or desktop, go to **Settings → Connectors → Add custom connector**.
Enter `https://mcp.keln.ai/mcp` and select **Connect**.
### ChatGPT
In the ChatGPT desktop app, go to **Settings → Plugins → Add → Add MCP server**.
Enter `https://mcp.keln.ai/mcp`, save it, and select **Authenticate** next to the server.
### Claude Code
```bash
claude mcp add --transport http keln https://mcp.keln.ai/mcp
```
Run `/mcp` in Claude Code, choose **keln**, and select **Authenticate**.
### Other apps
Any app that supports MCP authentication can connect using `https://mcp.keln.ai/mcp`.
## Connect with an API key
For clients that support custom request headers, you can authenticate with a [Keln API key](platform/authentication.md).
The examples below read your key from an environment variable:
```bash
export KELN_API_KEY=sk-keln-…
```
### Claude Code
```bash
claude mcp add --transport http keln https://mcp.keln.ai/mcp \
--header "Authorization: Bearer $KELN_API_KEY"
```
This saves the server and your key in Claude Code settings.
To share the server configuration without sharing a key, add `.mcp.json` to your project root. Each developer sets their own `KELN_API_KEY`.
```json
{
"mcpServers": {
"keln": {
"type": "http",
"url": "https://mcp.keln.ai/mcp",
"headers": { "Authorization": "Bearer ${KELN_API_KEY}" }
}
}
}
```
### Cursor
Add the server to `~/.cursor/mcp.json` for all projects, or `.cursor/mcp.json` for one project.
```json
{
"mcpServers": {
"keln": {
"url": "https://mcp.keln.ai/mcp",
"headers": { "Authorization": "Bearer ${env:KELN_API_KEY}" }
}
}
}
```
Cursor reads `KELN_API_KEY` from its environment, such as your shell profile.
### Codex
```bash
codex mcp add keln --url https://mcp.keln.ai/mcp --bearer-token-env-var KELN_API_KEY
```
Or add it to `~/.codex/config.toml`:
```toml
[mcp_servers.keln]
url = "https://mcp.keln.ai/mcp"
bearer_token_env_var = "KELN_API_KEY"
```
The Codex IDE extension and ChatGPT desktop app use the same configuration file.
### VS Code
GitHub Copilot in VS Code reads `.mcp.json` from your workspace root, or `~/.copilot/mcp-config.json` for all workspaces.
```json
{
"mcpServers": {
"keln": {
"type": "http",
"url": "https://mcp.keln.ai/mcp",
"headers": { "Authorization": "Bearer ${KELN_API_KEY}" },
"tools": ["*"]
}
}
}
```
### Other clients
Any client that supports Streamable HTTP and custom request headers can connect using:
- **URL:** `https://mcp.keln.ai/mcp`
- **Header:** `Authorization: Bearer <your Keln API key>`
### From an API
You can also use Keln's MCP server with agents built on other providers' APIs.
The provider connects to `mcp.keln.ai` using your Keln API key. We recommend using a separate key so you can revoke access independently.
**OpenAI Responses API**
Add this to `tools`:
```json
{
"type": "mcp",
"server_label": "keln",
"server_url": "https://mcp.keln.ai/mcp",
"headers": { "Authorization": "Bearer <your Keln API key>" },
"require_approval": "never"
}
```
**Anthropic Messages API**
Include the header `anthropic-beta: mcp-client-2025-11-20` and add:
```json
{
"mcp_servers": [
{
"type": "url",
"url": "https://mcp.keln.ai/mcp",
"name": "keln",
"authorization_token": "<your Keln API key>"
}
],
"tools": [{ "type": "mcp_toolset", "mcp_server_name": "keln" }]
}
```
## Tools
The MCP server provides tools for managing sandboxes, running commands, working with files, and searching the web.
| Tool | Description |
|---|---|
| `create_sandbox` | Create a sandbox, optionally from an [image](sandboxes/images.md). Default timeout is 300 seconds. Keln deletes the sandbox's files when it stops. |
| `list_sandboxes` | List sandboxes by state or label, newest first. |
| `get_sandbox` | Get a sandbox's state, expiry, size, and open ports. |
| `set_sandbox_timeout` | Change when a sandbox stops, up to 24 hours from creation or last resume. |
| `pause_sandbox` | Pause a sandbox while preserving its memory, processes, and files. Billing stops while paused. |
| `resume_sandbox` | Resume a paused sandbox with its previous state. |
| `delete_sandbox` | Stop and delete a sandbox and its files. Billing ends. |
| `snapshot_sandbox` | Save a running sandbox's files as an [image](sandboxes/images.md). Waits until the image is ready. |
| `list_images` | List images with their state and size, newest first. |
| `delete_image` | Delete an image. Sandboxes already created from it keep running. |
| `run_command` | Run a shell command and return its exit code, stdout, and stderr. Use `background: true` to return a command ID immediately. |
| `command_output` | Read a background command's output or wait for it to finish. |
| `send_stdin` | Send input to a background command or close its stdin. |
| `kill_command` | Stop a running command. |
| `write_file` | Write text or base64 content to a file. Creates missing directories. |
| `read_file` | Read a file as text or base64. PNG, JPEG, GIF, and WebP images up to 5 MB are returned as images your assistant can see. |
| `list_files` | List files in a directory. |
| `open_port` | Create a private or public preview URL for a port. See [Preview ports](sandboxes/ports.md). |
| `web_search` | Search the web and return ranked results with relevant passages. |
| `web_fetch` | Read up to 5 web pages as clean text, or extract passages relevant to a question. |
**Sandbox billing:** Sandboxes are billed while running. Pause or delete them when they're no longer needed.
## Limits
- **Request size:** Maximum 12 MB.
- **Files:** `write_file` accepts and `read_file` returns files up to 8 MB, as text or base64. Read or write a larger file in parts with `run_command`.
- **Command output:** `run_command` and `command_output` return up to 30,000 characters each for stdout and stderr (`max_output_chars`, up to 100,000). Longer output is truncated, keeping the beginning and end.
- **Line endings:** Output is returned line by line. A final line without a newline gets one added. See [Output format](sandboxes/commands.md#output-format).
- **Long-running commands:** For commands taking more than about a minute, use `background: true` and retrieve the result with `command_output`.
## Errors
| Case | Response |
|---|---|
| Missing authentication | `401` with `WWW-Authenticate: Bearer`. Supported apps use this to start Keln sign-in. |
| Invalid API key | `401` |
| Revoked app connection | `401` with `This connection is no longer active. Connect again.` |
| Address blocked after too many invalid API keys | `403` with `address_blocked`. Write to `support@keln.ai` if this is a mistake. |
| Tool failure | Result marked as an error, starting with the API error code, such as `sandbox_not_found: …`. See [Sandbox API errors](api/sandboxes.md#errors). |
| Command exits non-zero | Not treated as a tool error. The exit code is included in the result. |
## Privacy
The MCP server doesn't store API keys or retain tool inputs and outputs.
For security and debugging, it temporarily caches key validation results and addresses that submit invalid keys. Request logs don't include API keys.
Apps connected through Keln sign-in can only use these tools, and only for the project you authorize. They don't receive your password or API keys.
Sandbox data follows the [Data handling](sandboxes/data-handling.md) policy. Web queries follow the [Web search privacy](capabilities/web-search.md#privacy) policy.
MCP server
Keln has an MCP server at https://mcp.keln.ai/mcp. Connect it to Claude, ChatGPT, Cursor, Codex, or any MCP client that connects over HTTP to give your assistant access to sandboxes, code execution, web search, and web page reading. No installation required.
Transport: Streamable HTTP over HTTPS.
Authentication: Sign in with your Keln account in supported apps, or use a Keln API key with Authorization: Bearer <key>.
Billing: Tool calls use standard sandbox and web API pricing. Keln bills usage to your project balance, within the connected key's limits. There's no additional MCP fee.
Sign in with Keln
Apps that support MCP authentication only need the server URL.
When you connect for the first time, sign in to Keln, choose a project, and select Allow. You must have a verified email and own or administer the project.
Keln creates an API key for the connection, named after the app, such as Claude (connected app). You can find it on the project's API keys page, where you can manage its limits or revoke access.
To reconnect after revoking the key, sign in through the app again.
Claude
In Claude on the web or desktop, go to Settings → Connectors → Add custom connector.
Enter https://mcp.keln.ai/mcp and select Connect.
ChatGPT
In the ChatGPT desktop app, go to Settings → Plugins → Add → Add MCP server.
Enter https://mcp.keln.ai/mcp, save it, and select Authenticate next to the server.
Any client that supports Streamable HTTP and custom request headers can connect using:
URL:https://mcp.keln.ai/mcp
Header:Authorization: Bearer <your Keln API key>
From an API
You can also use Keln's MCP server with agents built on other providers' APIs.
The provider connects to mcp.keln.ai using your Keln API key. We recommend using a separate key so you can revoke access independently.
OpenAI Responses API
Add this to tools:
{"type":"mcp","server_label":"keln","server_url":"https://mcp.keln.ai/mcp","headers":{"Authorization":"Bearer <your Keln API key>"},"require_approval":"never"}
Anthropic Messages API
Include the header anthropic-beta: mcp-client-2025-11-20 and add:
{"mcp_servers":[{"type":"url","url":"https://mcp.keln.ai/mcp","name":"keln","authorization_token":"<your Keln API key>"}],"tools":[{"type":"mcp_toolset","mcp_server_name":"keln"}]}
Tools
The MCP server provides tools for managing sandboxes, running commands, working with files, and searching the web.
Tool
Description
create_sandbox
Create a sandbox, optionally from an image. Default timeout is 300 seconds. Keln deletes the sandbox's files when it stops.
list_sandboxes
List sandboxes by state or label, newest first.
get_sandbox
Get a sandbox's state, expiry, size, and open ports.
set_sandbox_timeout
Change when a sandbox stops, up to 24 hours from creation or last resume.
pause_sandbox
Pause a sandbox while preserving its memory, processes, and files. Billing stops while paused.
resume_sandbox
Resume a paused sandbox with its previous state.
delete_sandbox
Stop and delete a sandbox and its files. Billing ends.
snapshot_sandbox
Save a running sandbox's files as an image. Waits until the image is ready.
list_images
List images with their state and size, newest first.
delete_image
Delete an image. Sandboxes already created from it keep running.
run_command
Run a shell command and return its exit code, stdout, and stderr. Use background: true to return a command ID immediately.
command_output
Read a background command's output or wait for it to finish.
send_stdin
Send input to a background command or close its stdin.
kill_command
Stop a running command.
write_file
Write text or base64 content to a file. Creates missing directories.
read_file
Read a file as text or base64. PNG, JPEG, GIF, and WebP images up to 5 MB are returned as images your assistant can see.
list_files
List files in a directory.
open_port
Create a private or public preview URL for a port. See Preview ports.
web_search
Search the web and return ranked results with relevant passages.
web_fetch
Read up to 5 web pages as clean text, or extract passages relevant to a question.
Sandbox billing: Sandboxes are billed while running. Pause or delete them when they're no longer needed.
Limits
Request size: Maximum 12 MB.
Files:write_file accepts and read_file returns files up to 8 MB, as text or base64. Read or write a larger file in parts with run_command.
Command output:run_command and command_output return up to 30,000 characters each for stdout and stderr (max_output_chars, up to 100,000). Longer output is truncated, keeping the beginning and end.
Line endings: Output is returned line by line. A final line without a newline gets one added. See Output format.
Long-running commands: For commands taking more than about a minute, use background: true and retrieve the result with command_output.
Errors
Case
Response
Missing authentication
401 with WWW-Authenticate: Bearer. Supported apps use this to start Keln sign-in.
Invalid API key
401
Revoked app connection
401 with This connection is no longer active. Connect again.
Address blocked after too many invalid API keys
403 with address_blocked. Write to support@keln.ai if this is a mistake.
Tool failure
Result marked as an error, starting with the API error code, such as sandbox_not_found: …. See Sandbox API errors.
Command exits non-zero
Not treated as a tool error. The exit code is included in the result.
Privacy
The MCP server doesn't store API keys or retain tool inputs and outputs.
For security and debugging, it temporarily caches key validation results and addresses that submit invalid keys. Request logs don't include API keys.
Apps connected through Keln sign-in can only use these tools, and only for the project you authorize. They don't receive your password or API keys.