---
title: "Create client MCP WebSocket token"
method: POST
path: "/api/experimental/client-mcp/token"
tags: ["mcp"]
---

# Create client MCP WebSocket token

`POST /api/experimental/client-mcp/token`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/experimental/client-mcp/token`
- Auth: none required

Create a short-lived single-use ticket for opening a client MCP WebSocket connection from a browser.

## Query parameters

- `location` object, nullable
  - `directory` string, nullable
- `name` string, required

## Headers

- `x-opencode-ticket` string, nullable

## Response `200`

Success

- object
  - `location` LocationPublicRef, required
    - `directory` string, required
  - `data` PtyTicketConnectToken, required
    - `ticket` string, required
    - `expires_in` integer, required

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `403`: ForbiddenError
- `404`: LocationNotFoundError

## Changes

> 50 revisions in range; 1 not diffed.

- **2026-10-23** `f52efc43928f`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kaaass/apis/opencode/changes/api/experimental/client-mcp/token/post.md)

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
