agentleFS
comet-mlcomet-ml/opik-mcp/AGENTS.md

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.

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
  1. Very specific:

    Every read and list answer states its size.

    line 9
  2. Very specific:

    Every sentence of an entity description has a probe.

    line 65
  3. Very specific:

    No telemetry from tests. tests/repo/test_telemetry_disabled_in_tests.py

    line 72
  4. Very specific:

    Never author a skill outside src/opik_mcp/skills/.

    line 81
  5. Distinctive:

    Start the Claude Code session inside the worktree you are changing.

    line 90
  6. Very specific:

    Before a PR that changes src/, run /dogfood.

    line 103
  7. Distinctive:

    Check there instead of guessing a field or an endpoint.

    line 112

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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 read and list answer 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.py or list_tool.py → the entity's EntityHandler from read_list/registry.py → its module in read_list/entities/ → client/ → Opik backend.
  • write: writes/write_tool.py → writes/dispatch.py, which runs the operation from writes/registry.py through its hooks in writes/operations/ → client/ → backend. schema(operation) returns one operation's input on demand.
  • read_skill: serves src/opik_mcp/skills/ from skills_catalog.py.
  • instructions.py renders the text a host receives on initialize. analytics/ sends product events; it is off in tests.

Commands

CommandProvesRun by CI
make checklint + mypy + unit and conformance testsyes
make hermeticthe real server process over stdio and HTTP, against a stub backend; not part of make checkyes, own job
make slowthe tests that spawn hooks, scripts, git, ruff and mypy; not part of make checkyes
make skills-verify-sourceinstalling from this repo resolves exactly the authored skillsyes
make conformancethe MCP wire contract only, for fast iterationinside check
make livethe tools against a seeded real Opik; needs OPIK_URLyes, live.yaml
make user-flowsreal agent (OPIK-8491)not yet
make install-branchinstalls 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 initialize instructions 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.toml excuse 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 by npx skills add and would ship to users. A hook and Edit(...) deny rules block Edit, Write, tee and > redirects there (checked live), but not cp or a script; make skills-verify-source in 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 . push gets past them). Branch protection on main is 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.py is generated by make version. Change version.txt.
  • docs/ tracks only README.md, docs/<feature>/design-doc.md and docs/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 under apps/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; security and git-workflow always 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/.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.