Opik MCP Server
The official Model Context Protocol (MCP) server for Opik, the open-source LLM observability and evaluation platform, built by Comet. Plug your AI host (Claude Code, Cursor, VS Code Copilot, Codex, opencode, or any MCP client) directly into your Opik workspace: read traces, log scores, and save prompt versions, all from the chat.
Built for LLM engineers who already run Opik and want to drive it from the same AI assistant they code with.
You: "Which traces in project 'demo' failed today?"
Claude: → list(entity_type="trace", project_name="demo") → "Three traces failed…"
You: "Score trace 7f2e… 0.9 on helpfulness with reason 'great recovery'."
Claude: → write(score.create) → done
Quick start
One command sets Opik up in the AI clients on your machine, Claude Code
included. It finds your Opik (the one saved in ~/.opik.config, one running on
localhost, or it asks which), registers the MCP server, installs the Opik skill
pack, and checks the connection. On Opik Cloud there is no API key to handle:
your client signs in in the browser. It needs uv
and no Opik SDK:
uvx opik@latest mcp configure
Without a terminal, as from a coding agent or a script, name the client:
uvx opik@latest mcp configure --ai-client claude-code --skills
--ai-client also takes codex, cursor, vscode and opencode. Run that
way it uses the Opik saved in ~/.opik.config, API key included, or one
answering on localhost, and otherwise stops and asks for --deployment.
A coding agent asked to "install opik mcp" gets the full steps, including what
to ask the user, from uvx opik-mcp@latest --help. They are the same as
Install with a coding agent below.
Registering the server by hand, with the client commands under Set it up by hand, skips the check of which Opik you use and the skill pack, so it is for clients the installer doesn't support.
| Your Opik | Server | Transport | Sign-in |
|---|---|---|---|
Opik Cloud (www.comet.com) |
the hosted server, run by Comet | Streamable HTTP | in the browser (OAuth); no API key |
| Self-hosted Comet, open-source Opik | the local server, this package | stdio | env vars; an API key only where the deployment needs one |
Clients load MCP servers when a session starts, so start a new session afterwards.
Setup guide, troubleshooting and FAQ: comet.com/docs/opik/mcp-server.
Opik Cloud: the hosted server
Comet runs the server at https://www.comet.com/opik/api/v1/mcp. Your client
connects over HTTP and opens a browser sign-in the first time. There is nothing
to install, no API key, and no workspace to set: the server works in the
workspace you pick when you sign in. After adding it, start a new session and
ask: "list my Opik projects".
The Quick start command sets this up for Claude Code, Codex, Cursor, VS Code Copilot and opencode, with the skill pack. In Claude Code, the plugin does the same in one command. The buttons below add it to Cursor or VS Code in one click; other ways to register it by hand are under Set it up by hand.
Claude Code plugin
The opik plugin installs the Opik skills and registers the hosted MCP server
for Opik Cloud:
/plugin install opik --marketplace comet-ml/opik-mcp
On Claude Code before 2.1.275, run /plugin marketplace add comet-ml/opik-mcp,
then /plugin install opik@opik. The skills load as opik:<skill>, such as
opik:opik-instrument, and /mcp shows the server as plugin:opik:opik-cloud.
The server is Opik Cloud's. Start a new session, then sign in from /mcp →
Authenticate. For a self-hosted Comet that runs the MCP OAuth server, add
it with claude mcp add --transport http opik-mcp https://<host>/opik/api/v1/mcp;
for any other self-hosted or open-source Opik, use the
Quick start command. Then disable plugin:opik:opik-cloud in
/mcp. Claude Code does not update a plugin from
this marketplace on its own: run /plugin marketplace update opik, then
/plugin update opik@opik, or turn on auto-update for the marketplace in
/plugin. This marketplace serves main, which can be ahead of the last
release. An update arrives only when the plugin's version changes, at each
release.
If you added opik-mcp before at the same URL, Claude Code keeps your copy and
skips the plugin's. If yours is another server, such as the local
uvx opik-mcp, both load: run claude mcp remove opik-mcp to keep only the
plugin's. Skills from the skill pack also load next to the plugin's copies;
remove them with npx skills remove --global --agent claude-code, which asks
which ones.
Self-hosted and open-source Opik: the local server
opik-mcp runs on your machine: the client starts it with uvx opik-mcp and
talks to it over stdio. The Quick start command sets it up from
your ~/.opik.config or a local Opik; to register it by hand, see
Set it up by hand. Install uv once; it
fetches the package, and Python 3.13 if needed, on first use:
curl -LsSf https://astral.sh/uv/install.sh | sh # macOS / Linux
# or: brew install uv
uvx opik-mcp reuses the copy uv has cached, so it starts quickly;
uv cache clean opik-mcp makes the next start fetch the newest release.
uvx opik-mcp@latest asks PyPI on every start, which adds about a second and a
half. Codex waits mcp_optional_startup_grace_ms (1 s by default) for servers
before it builds the first tool list, so a slower start can leave the tools out
of the first turn. The one-off commands in this README (opik mcp configure,
opik mcp status, --help, --check) carry @latest, so they never run a
copy uv cached months ago.
Env vars point the server at your Opik:
| Your Opik | Env vars |
|---|---|
| Open-source Opik on this machine | OPIK_URL=http://localhost:5173/api |
| Open-source Opik on a server | OPIK_URL=https://<host>/api, plus OPIK_API_KEY only if the deployment adds authentication |
Self-hosted Comet platform (the Opik UI is at https://<host>/opik) |
COMET_URL_OVERRIDE=https://<host>, OPIK_WORKSPACE, OPIK_API_KEY |
- Open source serves its API at
/apiand has one workspace,default, so it needs noOPIK_WORKSPACE.COMET_URL_OVERRIDEwould point the server at/opik/api, which open source does not serve. - A self-hosted Comet has named workspaces. Set
OPIK_WORKSPACEto the segment after/opik/in your Opik URL; left out, reads come from your account's default workspace, with no error to say so. - A self-hosted Comet that runs the MCP OAuth server (off by default) can use
the hosted flow instead, at
https://<host>/opik/api/v1/mcp. - Substitute every value. The server refuses a placeholder workspace such as
<your-workspace>or${input:OPIK_WORKSPACE}; a placeholder URL is sent as-is and fails to connect. OPIK_MCP_ANALYTICS_SOURCE=""in theenvblock opts a self-hosted install out of the cloud-Comet source label on telemetry events.
Before adding the server to a client, check the settings: run it with the same
env and --check. It makes one call to Opik and prints the workspace and how
many projects it sees, or what to fix with a link to the docs, and exits 0 or 1.
A client can't tell you this before a new session: Claude Code shows Connected
even with a wrong key, and Codex starts nothing until then.
OPIK_URL=http://localhost:5173/api uvx opik-mcp@latest --check
Then register it with your client: the local server, by hand.
Install with a coding agent
For an AI agent asked to install the server, as in "install opik mcp". The aim
is the server registered for the user's Opik, the Opik skill pack installed,
and the user signed in. Work out which Opik from this machine, and ask the user
only what it can't tell you: one question per message, each answer before the
next. The installer in step 3 does the whole setup in one run, so settle steps
1 and 2 before you run it. uvx opik-mcp@latest --help prints these steps.
See what is there.
uvx opik@latest mcp statusIt shows the Opik saved in
~/.opik.config(URL and workspace, never the key) and the clients that already have the server. In Claude Code, also runclaude mcp list: it shows claude.ai connectors and entries under other names. It also prints each entry's command, which for an old npx entry can hold an API key: don't repeat it.- A server for
https://www.comet.com/opik/api/v1/mcpunder any name, such as a claude.ai connector, means it is registered: don't add a second one. Install the skill pack on its own withnpx skills add comet-ml/opik-skills -g --all. Go to step 4 if the server shows! Needs authentication. - The installer replaces an existing
opik-mcpentry without asking, such as one for the old npx server. Ask the user before you run it.
- A server for
Find the user's Opik.
- Saved in
~/.opik.config: use it, and tell the user which one you are setting up. The installer reads it, API key included, so don't ask for a key. - No
~/.opik.config:curl -s http://localhost:5173/api/is-alive/ping. An answer is an open-source Opik on this machine. In a sandboxed shell, such as Codex's, no answer can mean the shell has no network rather than no Opik. - Neither: ask, and don't pick one yourself. An Opik URL in the
project, such as
OPIK_URL_OVERRIDEin.env, makes it a yes-or-no question. Otherwise: "Which Opik do you use: Opik Cloud (www.comet.com), an open-source Opik (its URL), or a self-hosted Comet platform (its URL and workspace)?"
- Saved in
Run the installer for the client you run in. It installs the Opik skill pack with the server, with or without
--skills; keep the flag in a command you give the user to run later. On Opik Cloud it opens the browser sign-in and waits a minute for it, so tell the user first.uvx opik@latest mcp configure --ai-client claude-code --skills--ai-clientalso takescodex,cursor,vscodeandopencode. For an Opik saved in~/.opik.configor running on localhost, run it as it is:--deploymentsets the saved config aside, API key included. With neither, add the flag for the Opik the user named in step 2:The user's Opik Add Opik Cloud, www.comet.com--deployment cloudOpen-source Opik --deployment local, and--url <url>when it is not on localhostA self-hosted Comet platform, /opik/in its URL--deployment self-hosted --url <url> --workspace <workspace>, withOPIK_API_KEYin the shellIf it fails, as when the Opik doesn't answer, tell the user what it printed and what to check, such as a VPN or the URL. Don't switch to another Opik.
Sign-in, for Opik Cloud. If the installer reports the server as not signed in yet, give the user
claude mcp login opik-mcpto run, or/mcpin a Claude Code session, rather than running it yourself: it waits on the browser. A claude.ai connector signs in from/mcp. The sign-in asks for a workspace; name the one saved in~/.opik.config, if any.Finish. Say what was installed and what is left. Name the skill pack: the Opik skills, installed for every project, which teach the agent to instrument, evaluate and debug with Opik. Clients load MCP servers and skills when a session starts: ask the user to start a new session, then try "list my Opik projects".
On every path:
- Don't ask the user to paste an API key into the chat. The hosted server needs
none; otherwise take it from the shell environment (
"$OPIK_API_KEY"), or let the user run the command. - Don't guess the workspace. It is the segment after
comet.com/opik/(or/opik/on a self-hosted Comet) in the user's Opik URL. - Don't print
~/.claude.jsonor~/.opik.config: both can hold API keys.uvx opik@latest mcp statusandclaude mcp listshow what you need, and the installer reads the config itself. - If a permission check blocks a command, don't work around it. Give the user
the command to run (in Claude Code,
!before it runs it from the prompt).
For a client the installer doesn't know, register by hand with the commands in Set it up by hand: the hosted server for Opik Cloud, the local server for the rest.
- Before registering the local server, run it with the env you will pass and
--check, withOPIK_API_KEYexported in the shell rather than written on the command:OPIK_URL=http://localhost:5173/api uvx opik-mcp@latest --check. It exits 0 and names the workspace it sees, or prints what to fix. Once registered, Claude Code reports Connected even with a wrong key, and Codex has no check. - Claude Code refuses to add over an existing
opik-mcpentry, so remove it first withclaude mcp remove opik-mcp --scope user; Codex'saddreplaces it. - After registering, in Claude Code, read only the status line:
claude mcp get opik-mcp | grep Status. The full output prints theenvblock, API key included. The hosted server shows! Needs authenticationuntilclaude mcp login opik-mcphas run. Codex has nothing that starts the server before a session;codex mcp get opik-mcpshows what was stored, with env values masked.
Set it up by hand (no Opik check, no skill pack)
The Quick start command does all of this for Claude Code, Codex, Cursor, VS Code Copilot and opencode, and also checks which Opik you use and installs the skill pack. Register by hand only for another client, or to see what the installer writes. A coding agent installing for a user runs the installer: see Install with a coding agent.
Hosted server (Opik Cloud)
Claude Code, by hand
claude mcp add --scope user --transport http opik-mcp https://www.comet.com/opik/api/v1/mcp
Then sign in from /mcp → Authenticate in a Claude Code session. It opens
a browser, so the person at the keyboard does it; from their own terminal,
claude mcp login opik-mcp does the same. --scope user makes the server available in every project; without
it, Claude Code registers it for the current directory only. Over SSH,
claude mcp login opik-mcp --no-browser prints the sign-in URL to open on your
own machine; the last step needs an interactive terminal (ssh -t).
Codex, by hand
codex mcp add opik-mcp --url https://www.comet.com/opik/api/v1/mcp
add opens the sign-in; codex mcp login opik-mcp opens it again. In
~/.codex/config.toml the same server is:
[mcp_servers.opik-mcp]
url = "https://www.comet.com/opik/api/v1/mcp"
Cursor, by hand
Use the button under the hosted server, or add to
~/.cursor/mcp.json:
{
"mcpServers": {
"opik-mcp": {
"url": "https://www.comet.com/opik/api/v1/mcp"
}
}
}
VS Code Copilot, by hand
Use the button under the hosted server, or add to
.vscode/mcp.json in your workspace or to your
user mcp.json (MCP: Open User Configuration):
{
"servers": {
"opik-mcp": {
"type": "http",
"url": "https://www.comet.com/opik/api/v1/mcp"
}
}
}
Other clients
Any client that takes a URL can use the hosted server:
npx add-mcp https://www.comet.com/opik/api/v1/mcp --name opik-mcp
A client that can only start local commands can reach it through
npx -y mcp-remote https://www.comet.com/opik/api/v1/mcp.
Opik Cloud with an API key
Where nobody can complete the browser sign-in, as when an agent runs unattended
from a script or a client has no MCP OAuth support, use an API key from
comet.com/api/my/settings/ instead,
with the local server
pointed at Opik Cloud:
claude mcp add --scope user opik-mcp \
--env OPIK_API_KEY="$OPIK_API_KEY" \
--env OPIK_WORKSPACE=<workspace> \
-- uvx opik-mcp
The other clients take the same two variables in their env block. Set
OPIK_WORKSPACE to the segment after comet.com/opik/ in your Opik URL
(https://www.comet.com/opik/acme-ai/projects → acme-ai). Left out, the
server sends default, which Comet resolves to your account's default
workspace, so reads can come from the wrong workspace without an error.
Local server (self-hosted and open-source Opik)
The examples use a local open-source Opik. For a self-hosted Comet, swap in the three variables from the table. After adding the server, start a new session and ask: "list my Opik projects".
Claude Code, by hand
claude mcp add --scope user opik-mcp --env OPIK_URL=http://localhost:5173/api -- uvx opik-mcp
On a self-hosted Comet, with the key in your shell's OPIK_API_KEY:
claude mcp add --scope user opik-mcp \
--env COMET_URL_OVERRIDE=https://<host> \
--env OPIK_WORKSPACE=<workspace> \
--env OPIK_API_KEY="$OPIK_API_KEY" \
-- uvx opik-mcp
Or edit ~/.claude.json directly:
{
"mcpServers": {
"opik-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["opik-mcp"],
"env": {
"OPIK_URL": "http://localhost:5173/api"
}
}
}
}
claude mcp get opik-mcp shows ✔ Connected once the server starts. That does
not prove the URL or key are right, because only a tool call reaches Opik;
--check (the local server) does. It also prints the env block, API key included.
Codex, by hand
codex mcp add opik-mcp --env OPIK_URL=http://localhost:5173/api -- uvx opik-mcp
Or edit ~/.codex/config.toml:
[mcp_servers.opik-mcp]
command = "uvx"
args = ["opik-mcp"]
env = { OPIK_URL = "http://localhost:5173/api" }
# On a self-hosted Comet, forward the key from the environment Codex starts in,
# so it stays out of this file:
# env_vars = ["OPIK_API_KEY"]
# Time allowed for the server to start (default 10 s); the first start
# downloads the package.
startup_timeout_sec = 30
Codex gives a local server only the variables in env and the names in
env_vars, so a key exported in your shell does not reach it otherwise.
Cursor, by hand
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project), or use
Cmd+Shift+J → Features → Model Context Protocol:
{
"mcpServers": {
"opik-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["opik-mcp"],
"env": {
"OPIK_URL": "http://localhost:5173/api"
}
}
}
}
Cursor 60s timeout. Cursor enforces a hard tool-call timeout that doesn't reset on progress notifications. See Known host limits.
VS Code Copilot, by hand
Add to .vscode/mcp.json in your workspace, or to your user mcp.json
(MCP: Open User Configuration):
{
"servers": {
"opik-mcp": {
"type": "stdio",
"command": "uvx",
"args": ["opik-mcp"],
"env": {
"OPIK_URL": "http://localhost:5173/api"
}
}
}
}
MCP Inspector (manual testing)
OPIK_URL=http://localhost:5173/api npx @modelcontextprotocol/inspector uvx opik-mcp
Coming from npx opik-mcp?
The TypeScript server (npm opik-mcp@2) is deprecated and stops serving
requests on 2026-11-15. For a new install, run the
Quick start command; uvx opik-mcp is the command a client runs
to start the server, not an installer. To move an existing config on Opik Cloud,
switch to the hosted server and drop the API key. Otherwise, in your MCP client
config, replace npx -y opik-mcp with uvx opik-mcp. Some env vars were renamed and command-line flags are no
longer read: see the migration
guide.
Support policy: DEPRECATED.md.
The TypeScript source is at the git tag legacy-typescript-final.
Tools
opik-mcp exposes a small, outcome-oriented surface that covers the full
lifecycle (read → annotate → curate → author → iterate).
| Tool | Purpose |
|---|---|
read |
Universal read by id / name / opik:// URI |
list |
Universal list with optional name filter + pagination |
write |
Universal write, log traces/spans, score, comment, save prompts, manage datasets & experiments |
schema |
Introspect write-operation schemas (used by the LLM to construct valid payloads) |
read_skill |
Read one of the Opik agent skills bundled with this server |
read
One tool for any "show me X" question. Takes an entity_type plus an id
(UUID or, for nameable types, a name) or a full opik:// URI. Composite reads
(trace, prompt, thread, agent_insights_issue) inline their children so
a single call returns the full picture.
The record you name comes back whole. Inlined children do not: their bodies
are fetched with the backend's truncate=true, so a field over ~10 KB is cut
in ClickHouse and base64 images are replaced with "[image]", one attachment
echoed across 200 spans would otherwise cost more than everything else in the
read. The answer says so in spanBodies / messageBodies, and any child is
whole again through its own read("span", id) or read("trace", trace_id),
which hit endpoints that have no truncate parameter at all.
An inlined collection is also bounded in length: 200 spans, 200 turns, 100
prompt versions. Past that, spansTruncated / messagesTruncated /
versionsTruncated is true and a moreSpans / moreMessages /
moreVersions line beside it carries the count and the exact list(...) call
that continues from where the inlined part stopped.
Supported entities: project, trace, span, dataset, dataset_item,
experiment, prompt, thread, agent_insights_issue. Name-based lookup is
available for project, experiment, prompt, dataset (slower, two API
calls, and may return multiple matches). thread and agent_insights_issue
are project-scoped: pass project_id or project_name, or a link/URI that
carries the project. dataset and dataset_item were called test_suite and
test_suite_item before; the old names still resolve, but they are not
advertised and new code should use the new ones.
read(entity_type="trace", id="7f2e3c8a-…")
read(entity_type="project", id="demo") # name lookup
read(entity_type="trace", id="opik://traces/7f2e3c8a-…")
read(entity_type="agent_insights_issue", id="<issue-uuid>", project_id="<project-uuid>")
read(
entity_type="agent_insights_issue",
id="https://www.comet.com/opik/<ws>/projects/<pid>/diagnostics?issue=<id>",
)
A link copied from the Opik UI works as the id: a thread link or a
Diagnostics page link carries the project, so no project_id is needed and
the entity type is taken from the link.
A project read answers "how is my project doing" in one call. It returns
{project, summary, vocabulary, contains, url}: the record, then the four
figures the Logs page shows as cards (trace count, error rate, average
duration, total cost) for the last 7 days against the 7 before, SDK traffic
only, as on screen. since / until move that window; since="30d" is what
the UI opens on. A rate or an average over a period with no traces comes back
as null, because 0% errors on a week with no traffic reads as a healthy week.
vocabulary is the map you need before you can ask anything else: the
project's feedback score names, its token usage keys, and the automation rules
scoring its traces. These are the names that go into a filter or into
series= below, and guessing them returns an empty page that reads like good
news. Score names and rules are capped, always report the true total, and name
the call that returns the rest; usage keys are listed in full, since nothing
else enumerates them. contains names the freshest experiment, dataset, prompt
version and optimization run, so "what has been happening here" does not need
four more calls. A part that failed to load says so instead of looking empty,
and an empty one is omitted.
An agent_insights_issue read returns {issue, example_trace_ids, details}:
the Diagnostics issue record (name, description, cause, suggested fix,
severity, status), the deduplicated ids of the traces that exhibit it (the
same sample the Diagnostics page shows, open one with read("trace", id)),
and the per-day breakdown. Trace bodies are not inlined, so the read stays one
backend call. since / until narrow the per-day rows; the default is
all-time. When the server knows the Opik URL and the session's workspace, the
read also carries url (the issue's Diagnostics page) and trace_url_template
(a deep link for any of the example traces), so the assistant can hand you
something clickable; under an OAuth session whose workspace could not be
resolved the links are omitted rather than guessed.
Traces themselves carry no URL, a link for one is not derivable from the
fields a read or list returns, and a guessed shape 404s. The session
instructions name a template for it instead,
.../v1/session/redirect/projects/?trace_id={trace_id}&path=..., so the
assistant fills in an id and hands you a link. It goes through opik-backend's
redirect, which resolves the project and the workspace from the trace, so it
works where a direct project URL cannot, an OAuth session with an unresolved
workspace included. It is the same link the Python SDK prints for a trace.