> ## Documentation Index
> Fetch the complete documentation index at: https://docs.macstadium.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an AI agent to the Orka MCP server

> Let Claude Code, Cursor, and other AI agents create, use, and delete macOS VMs in your Orka cluster through the Orka MCP server.

The Orka MCP server lets an AI agent start a clean macOS VM in your Orka cluster, work in it over SSH, and delete it when it's done. Any client that supports the [Model Context Protocol (MCP)](https://modelcontextprotocol.io) can connect, including Claude Code and Cursor.

The server runs inside your cluster, next to the Orka API, so it's reachable on the same network you already use for Orka. It's off by default, and MacStadium turns it on per cluster.

For the tools the server provides, see [Orka MCP server tools](https://docs.macstadium.com/orka/orka-devops-integrations/orka-mcp-server-tools.md).

## How access works

The agent signs in with an Orka service account token. Every request the server makes to Orka runs as that service account, so the agent can do what the service account can do in its namespace, and nothing more.

An agent only sees the VMs its service account created through Orka. It can't list, inspect, or delete VMs that people or other service accounts created, even in the same namespace, and an admin's token gets no wider view through the MCP server. Agents that use the same service account share VMs, so give each agent its own.

## Before you begin

* Your cluster is hosted by MacStadium.&#x20;
* You're an Orka admin, so you can create service accounts.
* The commands on this page use the `orka` CLI from Orka 4.0. On an Orka 3.6 cluster, use `orka3` instead. The commands and flags are the same.
* You're connected to your cluster's network (for example, over the VPN), and so is the machine where the agent runs.

## Connect an agent

**1. Enable the MCP server**

Contact [MacStadium support](mailto:support@macstadium.com) and ask to turn on the Orka MCP server for your cluster. MacStadium turns it on and sends you the server's URL, which looks like `https://<CUSTOMER>.orka.app/mcp`.

**2. Create a service account for the agent**

```bash theme={null}
orka sa create <SERVICE_ACCOUNT_NAME> --namespace <TARGET_NAMESPACE>
```

Create one service account for each agent. Don't reuse a person's service account, or one that your CI pipelines use.

Orka adds the new service account to the `orka-dev` role binding in its namespace, which is the access the MCP server needs.

&#x20;For more on service accounts, see [Manage Orka service accounts for CI/CD](https://docs.macstadium.com/orka/orka-cluster-access/orka-cluster-manage-service-accounts.md).

**3. Get a token for the service account**

```bash theme={null}
orka sa token <SERVICE_ACCOUNT_NAME> --namespace <TARGET_NAMESPACE> --duration 720h
```

Give the token a short lifetime, such as `720h` (30 days). Without `--duration`, it lasts 1 year, and Orka can return a different lifetime than the one you ask for. The MCP server doesn't renew tokens, so when the token expires, the agent's requests fail until you give it a new one.

To cut an agent off, delete its service account. That revokes its token within about 10 seconds. See [Which credential should you use, and how long does it last?](https://docs.macstadium.com/orka/orka-cluster-access/how-access-works.md#which-credential-should-you-use-and-how-long-does-it-last)

**4. Add the server to your MCP client**

The server uses the streamable HTTP transport and reads the token from an `Authorization: Bearer` header.

> [tab] Claude Code
>
> ```bash theme={null}
> claude mcp add --transport http orka <MCP_SERVER_URL> --header "Authorization: Bearer <SERVICE_ACCOUNT_TOKEN>"
> ```
>
> To make the server available in every project, add `--scope user`. Don't use `--scope project`, which writes the token into `.mcp.json` in your repository.

> [tab] Cursor
>
> Add the server to `~/.cursor/mcp.json`, or to `.cursor/mcp.json` in a project:
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "orka": {
>       "url": "<MCP_SERVER_URL>",
>       "headers": {
>         "Authorization": "Bearer <SERVICE_ACCOUNT_TOKEN>"
>       }
>     }
>   }
> }
> ```
>
> To keep the token out of the file, set it in an environment variable and reference it as `"Bearer ${env:<VARIABLE_NAME>}"`. See [Model Context Protocol in Cursor](https://cursor.com/docs/context/mcp).

> [tab] Other clients
>
> Add `<MCP_SERVER_URL>` as a remote (HTTP) MCP server, and set the `Authorization` header to `Bearer <SERVICE_ACCOUNT_TOKEN>`.

> [!WARNING]
>
> Treat the token as a full Orka account, not just an MCP key. It also works with the `orka` CLI and `kubectl`, and it can delete images and VM configs in its namespace. Keep it out of files you commit, and use your client's support for environment variables or secret storage where it has one.

**5. Check the connection**

Ask the agent to list its Orka VMs. A new agent has none yet, so an empty list means the connection and token work. An authentication error means the token is wrong or has expired.

## Work inside a VM

The server doesn't run commands inside a VM. When the agent deploys a VM, the server waits until the VM answers on SSH, then returns its SSH host and port, and the agent connects over SSH to do its work. The result also includes VNC and Screen Sharing ports, when the VM has them. The SSH username and password come from the image the VM was created from, so the agent needs the image's credentials. MacStadium's base images ship with well-known default credentials, so change them in any image you give an agent. See [Understanding Orka credentials](https://docs.macstadium.com/orka/orka-cluster-access/understanding-orka-credentials.md).

## Clean up

Each VM the agent creates uses capacity in your cluster until it's deleted. Ask the agent to delete VMs when it's finished with them. If an agent crashes or loses track of a VM, it can list the VMs it owns and delete the ones it no longer needs. If a deploy times out or the connection drops, the agent should retry it with the same `idempotency_key`, which returns the same VM instead of starting a second one.

## What the MCP server doesn't do yet

The first release covers the VM lifecycle only. It deploys from OCI images, and it doesn't:

* Run commands inside a VM without SSH
* Check capacity before it deploys a VM
* Report per-VM usage, or limit how much a single agent can use


## Related topics

- [Orka MCP server tools](https://docs.macstadium.com/orka/orka-devops-integrations/orka-mcp-server-tools.md)
- [Use these docs with AI tools](https://docs.macstadium.com/macstadium/macstadium-overview/use-these-docs-with-ai-tools.md)
- [AI agent integration with the Orka CLI](https://docs.macstadium.com/orka/orka-devops-integrations/claude-code.md)
- [Working with Orka VM metadata and custom tags](https://docs.macstadium.com/orka/orka-resources/working-with-vm-metadata.md)
- [Connect to your Orka cluster via VPN](https://docs.macstadium.com/orka/networking-with-orka-at-macstadium/vpn-connection.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.