# MCP Server

> Your app's MCP server at /api/mcp: what customers can do with it, how they authenticate (API keys or browser OAuth), and how to turn it on.

*Canonical: https://makerkit.dev/docs/void-cloudflare/mcp-server/overview*

---

Your app ships an MCP server at `/api/mcp`. Your customers point AI tools and their own code at it, and the tools you register act on **their** account: a personal account or one organization. API keys also work on your own JSON routes ([API Keys in Your Routes](./api-keys)).

This is the server **your customers** use. The `makerkit` MCP server your coding agent uses to build the app is a different thing ([Working with Agents](../development-guide/working-with-agents)).

API keys and the MCP server are both off by default. Nothing is reachable until you [turn them on](#turn-it-on).

## How Customers Get In

| Credential | Who creates it | Sent as | Account it acts on |
|---|---|---|---|
| **API key** | The customer, on **Settings → API keys** (personal) or the organization's API keys page | `x-api-key` header | The key's owner. Organization keys outlive the member who made them. |
| **Browser OAuth** | The customer approves a client you provisioned, on the consent page | OAuth access token (Bearer or DPoP) | The one account they picked on the consent page |

Each request carries one credential. The account always comes from the credential, never from tool arguments, cookies or the active organization.

## Turn It On

Two boolean environment switches:

| Variable | Turns on |
|---|---|
| `API_ACCESS_KEYS` | Creating API keys, and key access to `/api/mcp` and your key routes |
| `API_ACCESS_MCP` | `/api/mcp`, OAuth discovery, consent and the **Connect an app** panel |

- `/api/mcp` takes API keys only with both on.
- Browser OAuth needs only `API_ACCESS_MCP`.
- The tables always exist, so switching needs no migration.

**Locally**, both are already on: `pnpm kit:setup` creates `apps/web/.env` from `env.example`, which sets them to `true`. A settings file made before that default has them off: ask your agent to set them (it uses `kit_env_update`), or edit `apps/web/.env` yourself, then restart `pnpm dev`:

```bash
API_ACCESS_KEYS=true
API_ACCESS_MCP=true
```

**In production**, both are off until you set them: every variable is a Worker secret ([Environment Variables](../configuration/environment-variables)). Run each in your own terminal and enter `true` at the prompt, then deploy:

```bash
pnpm --filter web exec void secret put API_ACCESS_KEYS
pnpm --filter web exec void secret put API_ACCESS_MCP
```

- **A change takes effect on the next deploy or restart.** The switches apply when the auth instance is built.
- **Turning a switch off** keeps existing keys and connections listed and revocable.
- **Turning it back on** never un-revokes anything.

## Try It in Five Minutes

1. Turn both switches on and restart.
2. Sign in, open **Settings → API keys**, and create a key with `account:read`. Copy the secret: it's shown once.
3. Run the client in [Connect with an API Key](./connecting-clients#connect-with-an-api-key) against `http://localhost:5173/api/mcp` with that key.
4. It calls `account_context` and prints your account's `id`, `name`, `type` and `scopes`.
5. Revoke the key on the same page and run it again: it now fails with `INVALID_API_KEY`.

## What Ships

- One tool, `account_context`: returns the credential's account and effective scopes. Add your own with [Adding Tools](./adding-tools).
- One scope, `account:read`. Your scopes live in `apiAccessScopes` in `apps/web/config/api-access.config.server.ts`.
- Settings pages for personal keys, organization keys and connected apps ([API Keys](../account/api-keys)).
- 20 active keys per account and 120 requests per minute per credential, set in `apiAccessLimits` in the same file.

## Where to Next

- [Connecting Clients](./connecting-clients): API-key and OAuth clients, revoking access.
- [Adding Tools](./adding-tools): register a read tool, add a scope, write tools.
- [API Keys in Your Routes](./api-keys): accept keys on your own `/api` endpoints.
- [Customer API Access reference](../authentication/api-access): every rule, limit, error code, cleanup and audit event.
