# MCP: connect Lykia to your AI client

> Add Lykia to Claude, Claude Code, Cursor, VS Code or any MCP client as a remote connector or through the npm bridge, sign in in the browser, pick a project, and control spending and access.

Lykia runs a remote MCP (Model Context Protocol) server. Add it to an AI client such as Claude, Claude Code, Cursor or VS Code, sign in to Lykia in the browser, choose the company and the project to use, and approve. From then on you can work with Lykia from the chat: look up models and prices, estimate a cost, run a prompt on any text model, generate images, videos and speech, and check your balance and usage. Ready-made workflows turn a product photo into ads, a script into a storyboard or a voiceover, and more. Everything the client spends is billed to the project you chose.

The server address is:

```text
https://api.getlykia.com/mcp
```

There are two ways to connect:

- **Remote connector** (recommended): the client talks to the server directly. Nothing to install.
- **npm bridge** (`@lykia/mcp`): a small local program for clients that can only start local (stdio) servers.

Both offer the same tools. The tools themselves are described in the [MCP tools reference](https://www.getlykia.com/en/docs/api-reference/mcp-tools).

## Remote connector

Add `https://api.getlykia.com/mcp` as a remote (HTTP) MCP server. The client opens a browser window the first time you use it: sign in to Lykia, choose a company and a project, review the permissions and approve.

### Claude

In Claude (web or desktop app) open **Settings → Connectors → Add custom connector** and enter the server address.

### Claude Code

```bash
# Add the Lykia remote MCP server to Claude Code, then run /mcp in Claude Code to sign in
claude mcp add --transport http lykia https://api.getlykia.com/mcp
```

Then run `/mcp` inside Claude Code and choose Lykia to sign in.

### Cursor

```json
{
  "mcpServers": {
    "lykia": {
      "url": "https://api.getlykia.com/mcp"
    }
  }
}
```

### VS Code

```json
{
  "servers": {
    "lykia": {
      "type": "http",
      "url": "https://api.getlykia.com/mcp"
    }
  }
}
```

### Other clients

Any client that can add a remote MCP connector with OAuth sign-in works the same way: add a custom connector, enter the server address and choose OAuth if the client asks for an authentication method. Clients that can only start local servers use the [npm bridge](#npm-bridge).

## What happens when you approve

The approval page shows:

- **Who is asking**: the app's name, where its details come from, and whether Lykia could verify them. Apps that publish a client metadata document are shown with their web address; apps that registered themselves on the fly are marked as not verified. Only approve apps you started yourself.
- **Where you will be sent back**: usually an address on your own computer (`127.0.0.1`) for desktop apps and command-line tools. The page warns you when the app wants to send you somewhere else.
- **Permissions**: the scopes the app asked for, with the ones that spend credits marked. You can untick the ones you do not want to give.
- **Company and project**: only companies and projects where you can manage API keys are listed. The connection uses that project's credits, budget and settings.
- **Monthly spending limit** (optional): a cap in USD for this connection.

The approval page is valid for ten minutes and belongs to the first account that opens it. If it expires, or you need to use another account, start again from your app.

To approve, your e-mail address must be verified and you need permission to manage API keys in the company you pick: the company owner and managers can approve for every project, project managers only for the projects assigned to them.

## npm bridge

`@lykia/mcp` is a stdio bridge: your client starts it as a local server, and it connects to the Lykia server and passes its tools through. It also adds two [local file tools](#local-file-tools).

> **Not on npm yet:** `@lykia/mcp` is being published to npm. Until it is, the `npx` commands below will not run; connect with the [remote connector](#remote-connector) instead.

First sign in once:

```bash
# Sign in once in the browser (prints the address instead with --no-browser)
npx @lykia/mcp login

# Company, project, limits and scopes of the credential in use
npx @lykia/mcp whoami

# Node version, credentials, file permissions, server reachability and MCP connection
npx @lykia/mcp doctor

# Print the settings for a client (claude-desktop, claude-code, cursor or vscode); --write merges them into its config file
npx @lykia/mcp config cursor

# Revoke the session at Lykia and delete it from this computer
npx @lykia/mcp logout
```

Then add the bridge to your client. `npx @lykia/mcp config <client>` prints the right settings (`claude-desktop`, `claude-code`, `cursor` or `vscode`); add `--write` to merge them into the client's config file. The previous file is backed up first, and nothing is written without `--write`. Add `--remote` to print the remote connector settings instead.

**Claude Desktop** (`claude_desktop_config.json`; on macOS in `~/Library/Application Support/Claude/`, on Windows in `%APPDATA%\Claude\`):

```json
{
  "mcpServers": {
    "lykia": {
      "command": "npx",
      "args": ["-y", "@lykia/mcp"]
    }
  }
}
```

**Claude Code**:

```bash
# Run the stdio bridge from Claude Code (sign in first with: npx @lykia/mcp login)
claude mcp add lykia -- npx -y @lykia/mcp
```

or, for one project, in `.mcp.json`:

```json
{
  "mcpServers": {
    "lykia": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@lykia/mcp"]
    }
  }
}
```

**Cursor** (`~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project):

```json
{
  "mcpServers": {
    "lykia": {
      "command": "npx",
      "args": ["-y", "@lykia/mcp"]
    }
  }
}
```

**VS Code**:

```json
{
  "servers": {
    "lykia": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@lykia/mcp"]
    }
  }
}
```

### Bridge commands

| Command                                                             | What it does                                                                                                           |
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `npx @lykia/mcp login [--no-browser]`                               | Signs in with your browser. With `--no-browser` it prints the address to open.                                         |
| `npx @lykia/mcp logout`                                             | Revokes the session at Lykia and deletes it from this computer.                                                        |
| `npx @lykia/mcp whoami [--json]`                                    | Shows the company, project, limits and scopes of the credential in use.                                                |
| `npx @lykia/mcp doctor [--json]`                                    | Checks the Node.js version, credentials, file permissions, server reachability, the MCP connection and the tool count. |
| `npx @lykia/mcp config <client> [--remote] [--write] [--path file]` | Prints or writes the client settings.                                                                                  |

The bridge looks for a credential in this order: the `LYKIA_API_KEY` environment variable, then the saved login session. Without either it stops and tells you to sign in. The session is stored in your user configuration folder with permissions that only you can read; on a shared computer run `logout` when you are done. Tokens are renewed automatically; if Lykia refuses a renewal (for example because the app was disconnected), the bridge deletes the session and asks you to sign in again.

### Local file tools

The bridge adds two tools that run on your computer:

- **`file_input`** reads an image (PNG, JPEG, WebP, GIF) or audio file (MP3, WAV, OGG, FLAC, M4A, WebM), checks its type from its content and its size, and returns a short handle (`lykia-file:…`) to use as a file value in a Lykia tool call. The bridge sends the file as a `data:` URI.
- **`output_save`** downloads a result link to a file. It only accepts `https` links on Lykia's own hosts and `data:` URIs, so it cannot be used to fetch arbitrary addresses, and it keeps existing files unless you pass `overwrite: true`.

Both tools can only reach the client's working directory, folders you allow with `--allow-dir` and the client's MCP roots, checked after following symbolic links. When the client starts the bridge from your home folder or the file system root, that folder is not used; allow a folder explicitly:

```json
{
  "mcpServers": {
    "lykia": {
      "command": "npx",
      "args": ["-y", "@lykia/mcp", "--allow-dir", "/Users/me/Projects/ads"]
    }
  }
}
```

Today's Lykia tools work with text, so these two tools matter mostly once image, video and speech tools arrive.

### Environment variables

| Variable                                             | Use                                                                                 |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `LYKIA_API_KEY`                                      | A project API key. Takes precedence over the login session.                         |
| `LYKIA_MCP_URL`                                      | The server address (default `https://api.getlykia.com/mcp`).                        |
| `LYKIA_BASE_URL`                                     | The API base used by `whoami` and `doctor` (default `https://api.getlykia.com/v1`). |
| `LYKIA_CONFIG_DIR`                                   | Where the session is stored.                                                        |
| `LYKIA_MCP_ALLOW_DIRS`                               | Extra folders for the local file tools.                                             |
| `LYKIA_MCP_DOWNLOAD_HOSTS`                           | Extra hosts `output_save` may download from.                                        |
| `LYKIA_MCP_MAX_FILE_MB`, `LYKIA_MCP_MAX_DOWNLOAD_MB` | Size limits for the local file tools.                                               |
| `LYKIA_MCP_TIMEOUT_MS`                               | Upper bound for one forwarded tool call.                                            |
| `LYKIA_NO_BROWSER`                                   | Do not open a browser during `login`.                                               |
| `LYKIA_MCP_DEBUG`                                    | Detailed logs on standard error.                                                    |

The bridge writes only MCP messages to standard output; everything meant for people goes to standard error, with tokens and keys hidden. It sends no telemetry.

## API key mode

On a server or in CI, where nobody can sign in through a browser, use a project [API key](https://www.getlykia.com/en/docs/guides/authentication) instead. With the bridge, set `LYKIA_API_KEY`:

```bash
# Headless use (server, CI): the bridge takes a project API key from the environment instead of a login session
export LYKIA_API_KEY="<your project API key>"
npx @lykia/mcp whoami
```

Or call the server directly with the key in the `Authorization` header:

```bash
# Call the remote MCP server directly with a project API key: list the tools
curl https://api.getlykia.com/mcp \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "MCP-Protocol-Version: 2025-06-18" \
  -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} }'
```

A key gives access to every tool, in the key's own project, with the key's limits. Keep keys out of configuration files that you commit or share.

## Permissions (scopes)

| Scope         | What it allows                                                     | Spends credits |
| ------------- | ------------------------------------------------------------------ | -------------- |
| `models:read` | List models and prices, get model details, estimate costs.         | No             |
| `chat`        | Run text models with the project's credits.                        | Yes            |
| `images`      | Generate and edit images with the project's credits.               | Yes            |
| `videos`      | Start and follow video jobs with the project's credits.            | Yes            |
| `speech`      | Turn text into speech with the project's credits.                  | Yes            |
| `usage:read`  | Read the company balance, the project's usage and request records. | No             |

Clients usually ask for every scope the server offers. `image_generate` uses `images`, `video_generate`, `video_status` and `video_wait` use `videos`, and `speech_generate` and `voices_list` use `speech`. A tool whose scope you did not grant is not listed to the client, and calling it is refused. The ready-made workflows need no scope of their own; each appears when the scopes its steps use are granted. Every tool and workflow is listed in the [MCP tools reference](https://www.getlykia.com/en/docs/api-reference/mcp-tools).

## Spending and limits

A connection spends like an API key of the project you picked: requests are paid from the company balance, count toward the project budget and show up in the project's activity and request logs, marked with the app's name. The usual limits apply (see [Limits](https://www.getlykia.com/en/docs/guides/limits)).

On top of that, every connection can have its own **monthly spending limit** in USD. It starts over on the first day of each month at 00\:00 UTC. When it is reached, spending tools return an error until the next month or until you raise the limit; reading tools keep working. You set the limit on the approval page and can change it later under **Settings → Connected apps**.

The spending tools (`chat`, `image_generate`, `video_generate` and `speech_generate`) also take `max_cost_usd`: Lykia works out the highest possible cost of the call first and refuses to run it, without charging anything, when that is above the amount. Ask your client to estimate the cost and to confirm with you before spending.

## Revoking access

Open **Settings → Connected apps** in the dashboard. It lists every app connected to the company, who connected it, its project, scopes, monthly limit and spending. Revoke a connection and the app loses access at its next request. People who can manage API keys see and manage every connection of their company (project managers those of their projects); everyone else sees and revokes the connections they made themselves.

Lykia also ends a connection on its own when the person who approved it leaves the company or loses permission to manage API keys, or when the project is archived. `npx @lykia/mcp logout` revokes the bridge's own session.

## Troubleshooting

- **The client says the server needs authentication**: start the sign-in from the client (for example `/mcp` in Claude Code). If the browser does not open, copy the address the client shows.
- **"This authorization request has expired" or "was opened with another account"**: start the connection again from your app.
- **No company or project to choose**: you need permission to manage API keys in a company and a project that is not archived, and a verified e-mail address.
- **"No Lykia credentials found"** (bridge): run `npx @lykia/mcp login` or set `LYKIA_API_KEY`.
- **"Session expired or was revoked"** (bridge): run `npx @lykia/mcp login` again; the app may have been revoked under Connected apps.
- **Only `file_input` and `output_save` are listed**: the bridge cannot reach the Lykia server. Run `npx @lykia/mcp doctor`; the bridge keeps retrying and lists the server's tools again when it reconnects.
- **"Outside the allowed directories"**: start the bridge with `--allow-dir <folder>`.
- **`npx` is not found on Windows**: start it through `cmd`:

```json
{
  "mcpServers": {
    "lykia": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@lykia/mcp"]
    }
  }
}
```

- **A spending tool returns `insufficient_credits` or `limit_exceeded`**: top up credits, or raise the connection's monthly limit, the project budget or the key limit (see [Errors](https://www.getlykia.com/en/docs/guides/errors)).
- **Detailed logs**: set `LYKIA_MCP_DEBUG=1` for the bridge; your client shows the server's log in its MCP log view.

## Related

- [MCP tools reference](https://www.getlykia.com/en/docs/api-reference/mcp-tools): every tool, its inputs and outputs.
- [JavaScript / TypeScript SDK](https://www.getlykia.com/en/docs/guides/javascript-sdk): call the API from your own code.
- [Projects](https://www.getlykia.com/en/docs/guides/projects): budgets and settings of the project a connection uses.
