opik-mcp
AGENTS.md219 starsChanged 2 months agoApache-2.0View on GitHub
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. 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…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 9
Every read and list answer states its size.
- Very specific: line 65
Every sentence of an entity description has a probe.
- Very specific: line 72
No telemetry from tests. tests/repo/test_telemetry_disabled_in_tests.py
- Very specific: line 81
Never author a skill outside src/opik_mcp/skills/.
- Distinctive: line 90
Start the Claude Code session inside the worktree you are changing.
- Very specific: line 103
Before a PR that changes src/, run /dogfood.
- Distinctive: line 112
Check there instead of guessing a field or an endpoint.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
opik-mcp
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=[…].
What this is
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: servessrc/opik_mcp/skills/fromskills_catalog.py.instructions.pyrenders the text a host receives oninitialize.analytics/sends product events; it is off in tests.
Commands
| 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 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 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.
Invariants (a red test here is a contract, not a flake)
- 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.tests/repo/test_ratchets.py
Gotchas
- 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
src/opik_mcp/skills/..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.
Workflow
- 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.
Opik itself
- 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/
Where to look next
- 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/.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

