Installing the server to use it? Follow README.md; this file is for changing the code.
IMPORTANT: every token this server puts into a host's context has to pay for itself. Before adding output, a tool, a field or description text, say what it costs (bytes on the surface, tokens in a typical answer) and what the user gets for it. See ADR 0001.
- The advertised surface has a hard byte budget.
- Every
readandlistanswer states its size. - The caller can always narrow: a span, a filter, a window,
fields=[…].
An MCP server that lets an AI agent (Claude Code, Cursor, claude.ai) work with
a user's Opik data: traces, spans, threads, projects, experiments, datasets,
prompts and Diagnostics issues. The agent can answer "how is my project doing"
or "what broke", and make small changes like scoring or closing a thread. It
also authors the agent skills published as comet-ml/opik-skills.
How it ships: the opik-mcp package on PyPI (stdio, local API key), and a
Docker image served at https://www.comet.com/opik/api/v1/mcp (Streamable
HTTP, the user's OAuth token or API key passed through to the backend).
Stack: Python 3.13, uv, the official MCP python-sdk (FastMCP, pinned
<2), httpx to the Opik REST API, Pydantic.
How a call flows:
read/list:server/tools/→read_list/read_tool.pyorlist_tool.py→ the entity'sEntityHandlerfromread_list/registry.py→ its module inread_list/entities/→client/→ Opik backend.write:writes/write_tool.py→writes/dispatch.py, which runs the operation fromwrites/registry.pythrough its hooks inwrites/operations/→client/→ backend.schema(operation)returns one operation's input on demand.read_skill: serves the skills fromskills_catalog.py. They are authored inplugins/opik/skills/(the Claude Code plugin) and shipped in the wheel asopik_mcp/skills.instructions.pyrenders the text a host receives oninitialize.analytics/sends product events; it is off in tests.
| Command | Proves | Run by CI |
|---|---|---|
make check |
lint + mypy + unit and conformance tests | yes |
make hermetic |
the real server process over stdio and HTTP, against a stub backend; not part of make check |
yes, own job |
make slow |
the tests that spawn hooks, scripts, git, ruff and mypy; not part of make check |
yes |
make skills-verify-source |
installing from this repo resolves exactly the authored skills | yes |
make plugin-validate |
claude plugin validate --strict passes on the marketplace and plugins/opik |
yes |
make conformance |
the MCP wire contract only, for fast iteration | inside check |
make live |
the tools against a seeded real Opik; needs OPIK_URL |
yes, live.yaml |
make user-flows |
real agent (OPIK-8491) | not yet |
make install-branch |
installs this worktree as MCP server opik-<ticket> |
no |
make record-shapes |
regenerates read_list/record_shapes.json from opik's OpenAPI spec |
daily, record-shapes.yaml opens a PR |
make runs mypy over src/, tests/ and the scripts, and ruff over
everything, as CI does. Running them on src/ alone misses test and script
errors.
- The tool set is pinned, and the tool surface and the
initializeinstructions each have a byte budget; the instructions load even when a host defers tools. Record each change in the comment next to the budget.tests/conformance/test_tool_inventory.py - Input schemas change only on purpose:
UPDATE_SNAPSHOTS=1, and the PR says why.tests/conformance/test_schema_snapshots.py - Every sentence of an entity description has a probe.
tests/hermetic/test_description_claims.py - One copy of each answer, no
structuredContent.tests/conformance/test_no_duplicate_payload.py - Entity and operation logic stays in its namespace; root modules may not
gain entity names.
tests/read_list/test_modular.py,tests/writes/test_dispatch_stays_generic.py - No telemetry from tests.
tests/repo/test_telemetry_disabled_in_tests.py - The lint and type baselines in
pyproject.tomlexcuse findings that predate the rules and only shrink; a new file meets the full rules, except a module of Pydantic models only, which may join the explicit-Anybaseline.tests/repo/test_ratchets.py
- A new module-level cache or flag needs a reset in the autouse fixture in
tests/conftest.py, or tests pass or fail by run order. - Never author a skill outside
plugins/opik/skills/.src/opik_mcp/skillsis a symlink to it for the editable install..claude/skills/and.agents/skills/are read bynpx skills addand would ship to users. A hook andEdit(...)deny rules block Edit, Write,teeand>redirects there (checked live), but notcpor a script;make skills-verify-sourcein CI is the real check. The one deliberate exception is the cost intelligence guide,src/opik_mcp/cost_intelligence/cost-intelligence.md: served only in an AI Spend workspace, never published. Don't move it. - Permission deny rules are guard rails, not a boundary (
git -C . pushgets past them). Branch protection onmainis the real guard. - Start the Claude Code session inside the worktree you are changing. Hooks, rules, agents and commands load from the session's project, not from the files you edit.
- The package's
_version.pyis generated bymake version. Changeversion.txt. docs/tracks onlyREADME.md,docs/<feature>/design-doc.mdanddocs/decisions/. Anything else there is ignored and never reaches a PR. The repo is public.
- Plan locally before implementing; plans are not committed.
- A PR that changes a feature's behaviour updates its
design-doc.md. - Before a PR that changes
src/, run/dogfood; then/create-pr. - Writing (commits, PRs, comments, docs) is short and plain. See
.claude/rules/git-workflow.md.
- API contract and backend code: https://github.com/comet-ml/opik. The OpenAPI
spec is
apps/opik-documentation/documentation/fern/openapi/opik.yaml; endpoints are underapps/opik-backend/src/main/java/com/comet/opik/api/resources/v1/. Check there instead of guessing a field or an endpoint. - Product and feature context: https://www.comet.com/docs/opik/
- Rules load by path from
.claude/rules/:python,architecture,tool-surface,tests,skills,docs,agent-config;securityandgit-workflowalways load. - Subagents:
code-reviewer,understand,test-runner. - Commands:
/install-branch,/dogfood,/create-pr,/address-pr-comments. - Design docs: docs/README.md, one per feature.
- Decisions: docs/decisions/.