# Create MCP Token

`POST /mcp/tokens` · Core · MCP

Mints the bearer token an MCP client presents to the project's MCP endpoint. The body names the tools the token may call: project functions, all functions of named extensions, and tools on the project's registered MCP servers. There is no wildcard. `ttlSeconds` is 60 to 3600 (one hour). The token is minted from an operator session, not a personal access token, and it works only on the MCP endpoint. It is revoked by its `jti`.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `tools` | object | no | The functions the token may call. Required unless `externalTools` names at least one tool. At most 100 tools in all, functions and external tools together. |
| `tools.functions` | array of string | no | Names of individual functions the token may call. No wildcards. |
| `tools.extensions` | array of string | no | Slugs of extensions: the token may call every function of each one that exists now. Functions added later are not included. |
| `externalTools` | array of object | no | Tools on the project's registered MCP servers that the token may call, each named by server and tool. The caller must be allowed to call that server. |
| `externalTools.[]server` | string | yes | The name of a registered MCP server of this project. |
| `externalTools.[]tool` | string | yes | The tool on that server. |
| `ttlSeconds` | integer | no | How long the token lasts, in seconds: 60 to 3600. Default 3600. |

## Responses

- **201**: Created

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes |  |
| `data.token` | string | yes | The bearer token for the MCP endpoint. It is shown only in this response. |
| `data.tokenId` | string | yes | The token's id: use it to revoke the token with `DELETE /mcp/tokens/{jti}`. |
| `data.tokenType` | enum ("Bearer") | yes | Always `Bearer`. |
| `data.scope` | string | yes | The scope the token carries: `project_invoke_only`, which allows calling only the named tools. |
| `data.audience` | string | yes | The MCP endpoint URI the token is bound to. Another project's endpoint refuses it. |
| `data.tools` | array of string | yes | The functions the token may call, resolved to names at mint time. |
| `data.externalTools` | array of object | yes | The external MCP tools the token may call. |
| `data.externalTools.[]server` | string | yes | The registered MCP server. |
| `data.externalTools.[]tool` | string | yes | The tool on that server. |
| `data.externalTools.[]name` | string | yes | The tool's name in `tools/list` and `tools/call`. |
| `data.expiresAt` | string (date-time) | yes | When the token stops working. |
| `meta` | object | yes |  |


## Errors

| HTTP | Code | When |
|---|---|---|
| 400 | `K9O_INVALID_FIELD_VALUE` | The tool selection is empty, names a wildcard, or names something that is not a function name or extension slug. |
| 403 | `K9O_FORBIDDEN` | The caller is an MCP token, a plugin token, a delegated agent or a sandbox token; none of these can mint. |
| 403 | `K9O_IAM_POLICY_DENIED` | The caller is not an operator, or the bound IAMPolicy ceiling denies functions:invoke for the caller. |
| 404 | `K9O_NOT_FOUND` | The caller has no access to the project, or a selected function or extension has no active extension function on the project. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/mcp/tokens' \
  -H 'Authorization: Bearer $K9O_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/mcp/tokens', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({}),
});
const { data, meta } = await res.json();
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/create-mcp-token
