MCP server
Lucida speaks the Model Context Protocol, so AI clients (Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Zed, Codex) can query your analytics, read...
Lucida speaks the Model Context Protocol, so AI clients (Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Zed, Codex) can query your analytics, read replays and experiments, and propose changes.
There are two ways to run it:
Transport | How | Use it for |
|---|---|---|
Hosted, streamable HTTP | the | every client that supports remote MCP servers |
Local, stdio |
| clients that only launch local processes |
Both serve the same tools. Every write is a proposal first: the tool returns a summary and a confirmation_token, and nothing changes until the client calls the tool again with that token. A token works once only: the first use is recorded in Lucida (shared by every MCP replica and CLI run), so replaying it is refused, and so is a write when that record cannot be reached.
Authentication
Hosted MCP accepts personal (account) API keys (lc_pat_...) only; a project key is not accepted. Create one in Settings > Personal API keys and send it as Authorization: Bearer <key>. Lucida checks the key against the API on every new session; a key that is revoked stops working within five minutes. The key's own permissions always apply, and the service's LC_MCP_SCOPES can only narrow them.
Pick the project with the X-Lucida-Project: <project id> header or ?project_id=<id> on the URL. Without either (and without LC_MCP_PROJECT_ID on the service) the endpoint answers 400. A missing or bad key answers 401 as application/problem+json with a WWW-Authenticate: Bearer challenge. OAuth discovery documents are at /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server on the same host.
Enterprise-managed authorization (ID-JAG)
For organizations whose identity provider (IdP) brokers MCP access, an MCP client can skip the consent screen and redeem an ID-JAG identity assertion at the token endpoint with the JWT-bearer grant. An org admin first registers the IdP in Settings > Organization > Trusted identity providers (or POST /v1/orgs/{id}/trusted-idps): its issuer URL, its signing keys (a jwks_uri or a pinned JWKS document), the email domains it may assert, and a scope ceiling. Every change is audited.
POST /v1/oauth/token
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
assertion=<ID-JAG>&project_id=<project>&client_id=<client>[&scope=query:read][&resource=<api>/v1]The assertion is an RS256 JWT with header typ: oauth-id-jag+jwt and claims iss (the trusted issuer), aud (this authorization server's issuer URL), client_id (the client making the request), sub, email (a member of the project's org, in an allowed domain), jti, exp (at most ten minutes ahead), and optionally resource (must be this API) and scope. Lucida verifies the signature, rejects a replayed jti, and grants the requested scopes only if they sit inside the assertion, the IdP's ceiling and the client's registered scopes. The response is a normal 15-minute access token bound to the project, with no refresh token: ask the IdP for a new assertion. Failures are RFC 6749 errors (invalid_grant, invalid_scope, invalid_target). The grant is listed in grant_types_supported of /.well-known/oauth-authorization-server, and every 401 from the API carries WWW-Authenticate: Bearer resource_metadata="<base>/.well-known/oauth-protected-resource" (RFC 9728) so a client can discover all of this from a bare unauthorized call.
Token validation mode (admin)
The hosted endpoint checks each new bearer token once against lc-api /v1/me. Two modes:
| Behaviour | Revocation lag |
|---|---|---|
| the answer is cached for | the cache TTL |
| requests are authorised from the local cache and never wait on lc-api; a sweep re-checks every cached token every | the sweep interval |
Lower either value for faster revocation at the cost of more /v1/me calls.
Request controls
Add these to the URL to shape what the client sees:
Parameter | Effect |
|---|---|
| hide every write tool ( |
| only tools of these families: |
| only these tools, by exact name |
Each credential is rate limited (LC_MCP_RATE requests per second, burst LC_MCP_BURST); over the limit the endpoint answers 429 with Retry-After.
Every tool carries MCP annotations: reads are readOnlyHint, so clients can auto-approve them; edits of existing objects (toggle_flag, update_flag_rollout) are destructiveHint and idempotentHint; creates are additive.
Guides, taxonomy and access tools
Scope | Tools |
|---|---|
|
|
|
|
|
|
|
|
Every write is a proposal first, as above. merge_events creates an action named into that matches any of the source events (history included, so charts of the action cover the old names) and then deprecates the sources (deprecate_sources: false keeps them as they are). merge_properties creates the calculated property calc:<into>, the first non-empty of the sources, and deprecates the definitions listed in deprecate_ids. Nothing is rewritten in stored events. The access tools only read: lc-api still applies the caller's own permissions (member lists need settings access, an object report needs manage access on the object) and answers 404 for anything the caller cannot see.
Inbox and scout tools
Scope | Tools |
|---|---|
|
|
|
|
|
|
Every write is a proposal first. Reports live in lc-api; scouts in lc-ai, which still requires project admin for runs and scratchpad edits. Claiming fails when someone else holds the report; merging resolves the source as duplicate and later signals for its key land in the target.
Charts in MCP Apps hosts
Hosts that support the MCP Apps extension render query results as an interactive chart. The query tools (query_events, get_trends, run_insight, run_lql, get_funnel, get_retention) name the view ui://lucida/chart in their _meta.ui.resourceUri, and their result carries the evidence as structuredContent. The view is one self-contained HTML page (text/html;profile=mcp-app, no external scripts or network access): a line chart with one series per numeric column, hover values, a table when nothing is numeric, and the host's light or dark theme.
Clients without MCP Apps get the same result as text, plus a resource link lucida://chart/<key>.svg to a static SVG of the chart that the client can read with resources/read. A session keeps its last 32 charts.
Client setup
Lucida Cloud serves the hosted endpoint at https://lucidace.com/mcp (streamable HTTP). In Claude (Desktop, web or Code) and Cursor, add it as a remote MCP server with that URL. Clients that implement MCP authorization discover /.well-known/oauth-protected-resource and /.well-known/oauth-authorization-server, register themselves at /v1/oauth/register and send you through the consent screen, so no key has to be pasted. For clients that take a header instead, use a personal API key (see Authentication).
claude mcp add --transport http lucida "https://lucidace.com/mcp?project_id=<project id>"Cursor (~/.cursor/mcp.json): {"mcpServers": {"lucida": {"url": "https://lucidace.com/mcp?project_id=<project id>"}}}.
Replace https://app.lucida.example.com with your host (self-hosted: the web host, which routes /mcp to the mcp component; Lucida Cloud: the host of your region).
The quickest path is lucida mcp add <client>. It writes the entry into the client's config and keeps every other server in that file:
lucida login --api-url https://api.lucida.example.com --project <project id>
lucida mcp add cursor --url https://app.lucida.example.com/mcp --readonlyClient | File written |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The key is never written to these files. Remote entries read it from $LUCIDA_API_KEY, and the stdio entries (zed, claude-desktop) run lucida mcp, which takes the token from lucida login. --dir picks the project for project-scoped files. --print shows the entry without writing it, which is what you need when the file has comments (JSONC); the command refuses to rewrite such files. --url defaults to $LC_MCP_URL, else <api url>/mcp.
Claude Code plugin
lucida mcp add claude-code-plugin writes a Claude Code plugin: .claude-plugin/plugin.json, .mcp.json with the Lucida server, and skills for common analytics tasks (investigate-metric-drop, funnel-analysis, tracking-plan-audit, instrument-events, experiment-readout, replay-friction). It goes to ./lucida-claude-plugin unless --dir says otherwise, never into the project root, where its .mcp.json would replace the project's own.
lucida mcp add claude-code-plugin --url https://app.lucida.example.com/mcp
claude --plugin-dir ./lucida-claude-pluginA ready copy is checked in at plugins/claude-code. It holds no host, project or key: it reads LUCIDA_MCP_URL (default https://lucidace.com/mcp), LUCIDA_PROJECT_ID and LUCIDA_API_KEY from the environment Claude Code starts in. lucida mcp add claude-code-plugin --generic writes the same thing.
Claude Code:
claude mcp add --transport http lucida "https://app.lucida.example.com/mcp?project_id=<project id>" \
--header "Authorization: Bearer $LUCIDA_API_KEY"Cursor (~/.cursor/mcp.json), VS Code (.vscode/mcp.json, key servers instead of mcpServers), Windsurf and Claude Desktop use the same shape:
{
"mcpServers": {
"lucida": {
"url": "https://app.lucida.example.com/mcp?project_id=<project id>&readonly=1",
"headers": { "Authorization": "Bearer <personal api key>" }
}
}
}Local stdio, for clients without remote support:
{
"mcpServers": {
"lucida": {
"command": "lucida",
"args": ["mcp"],
"env": { "LC_API_URL": "https://api.lucida.example.com", "LC_API_KEY": "<account key>", "LC_PROJECT_ID": "<id>" }
}
}
}LC_API_KEY is an account or admin key for the CLI and MCP, not the SDK key; the Node SDK reads LUCIDA_SECRET_KEY.
Running the service
lc-mcp is in the compose file (mcp, port 8096) and the Helm chart (components.mcp, enabled by default, routed at /mcp on the web host).
Variable | Default | Meaning |
|---|---|---|
|
| lc-api base URL |
|
| listen address |
| empty | default project when the request names none |
| read scopes | grant ceiling, comma list ( |
|
| requests per second per credential |
|
| burst per credential |
| empty | when set, AI-backed tools ( |
Health: GET /healthz.