# Serve MCP over HTTP

Connect a script, test harness, or agent to OSMates over HTTP instead of starting `osmates mcp`.

## Turn on MCP over HTTP

1. Choose **OSMates > Settings**, then click **Remote**.
2. Under **This Mac**, turn on **Serve MCP over HTTP on this Mac**.

In Terminal, run `osmates remote set local on`.

OSMates serves MCP at `http://127.0.0.1:7330/mcp`. Only programs on this Mac with a token can connect, not other computers or your machines. To stop serving and end every session, turn the switch off or run `osmates remote set local off`.

## Make a token

1. In **Remote** settings, under **Tokens**, click **New Token**.
2. Name the token after its client.
3. Under **Tools**, choose **Read Only**, **Operator**, or **Full**. See [Pick a profile](https://osmates.com/docs/agents#pick-a-profile).
4. Set an expiry if you want one, then click **Make Token**.
5. Click **Copy Token** and paste it into the client's settings.

The token starts with `osm_`, works only on this Mac, and isn't shown again. Give each client its own.

To make one in Terminal, with Operator as the default profile and an expiry of 1 to 365 days:

```sh
osmates remote token create ci --profile operator --days 30
```

## Connect a client

In a client that supports Streamable HTTP, enter the URL `http://127.0.0.1:7330/mcp` and the header `Authorization: Bearer <token>`. A client with a JSON configuration takes:

```json
{
  "mcpServers": {
    "osmates": {
      "type": "http",
      "url": "http://127.0.0.1:7330/mcp",
      "headers": { "Authorization": "Bearer <token>" }
    }
  }
}
```

The client gets the [MCP tools](https://osmates.com/docs/mcp) its token's profile allows. You answer on this Mac before it uses a machine.

## Disconnect a client

A session ends after 30 minutes without requests, or when its token expires. To disconnect a client now, revoke its token:

```sh
osmates remote connections
osmates remote token revoke ci
```

## Limits

- A client can't open files on your Mac. Create or import machines from installation files in the app or with `osmates mcp`.
- To reach this Mac from a cloud MCP client, see [Connect cloud MCP clients](https://osmates.com/docs/cloud-clients).

## If it doesn't work

- [MCP client can't connect to localhost](https://osmates.com/docs/known-issues#mcp-client-cant-connect-to-localhost)
