@codetelemetry/mcp
The CodeTelemetry MCP server. It lets a coding agent onboard a user to
CodeTelemetry in one instruction — authenticate,
obtain an ingest key, write the Claude Code OTEL config, send a test event, and
confirm telemetry landed — without the plaintext key ever entering the model's
context.
This repository contains the complete source that executes in the published npm
artifact. The CodeTelemetry web application, storage, and infrastructure are not
part of this package. See PUBLICATION.md for the enforced
publication boundary.
The zero-config Connect CLI is published independently so onboarding does not
depend on the MCP sizing release:
npx -y @codetelemetry/connect login
# Add --codex when configuring OpenAI Codex.
# Add --client cursor for Cursor: see "Cursor" below.
Install (Claude Code)
claude mcp add codetelemetry -- npx -y --package=@codetelemetry/mcp codetelemetry-mcp
or in .mcp.json — pinning the version you expect, so what a client launches is
deterministic (see Releases & discovery):
{
"mcpServers": {
"codetelemetry": { "command": "npx", "args": ["-y", "--package=@codetelemetry/mcp@0.9.0", "codetelemetry-mcp"] }
}
}
Then just ask the agent: "Connect me to CodeTelemetry."
Join an existing organization
After accepting an invitation, choose Explore the team’s work to review existing
sessions without local setup, or Connect my coding tool to record your own work.
Run the project connection command from the repository you choose:
npx -y @codetelemetry/connect@0.5.0 join --organization-id tm_example --client codex --project .
# For Claude Code, use --client claude.
Join uses the existing organization's ID and your own device approval. It resumes
a saved connection after interruption, enables prompt/tool capture and repository
observation for new connections, and preserves existing capture choices. Pass
--no-enrich when making a new connection to opt out. It never creates an organization,
purchases credits/seats, or executes optional Grader, Terraform or GitHub steps from
an older bootstrap plan. A conflicting project destination is an error.
Setup prints a saved workspace name and its launch instructions. Claude uses local
project settings; Codex uses connect run <name> to select its named config-file
profile. An already-open client does not adopt that profile automatically. The
browser progress link checks your real session, captured prompt, and project
identity separately from the connection test. Imported history cannot satisfy live
verification. My sessions is scoped to your authenticated ingest ownership;
Team sessions shows the selected organization's activity.
Optional history import uses the saved project and credentials, without a key argument:
npx -y @codetelemetry/connect@0.5.0 import --workspace <name> --preview
# Choose numbers from that preview; no session content uploads until confirmation:
npx -y @codetelemetry/connect@0.5.0 import --workspace <name> --select 1,2 --confirm
Preview is local-only and defaults to the last 30 days. It keeps at most 100 session
plans in a private file bounded to 64 KiB and valid for 24 hours. Discovery examines
at most 10,000 directory entries, parsing reads at most 128 MiB with 64 MiB per session,
and one scan is bounded to two minutes. Import rechecks destination and exact selected
plans before uploading, preserves the saved content choice, and reuses deduplication
and resumable delivery. Narrow --since and preview again if a bound is reached.
Preview files contain identifiers and counts, never credentials or session content.
Persistent organization workspaces
Ask the agent: Create a Acme workspace for this repository and configure its Grader.
It calls bootstrap_workspace with a stable local context name, the repository path,
and either organizationName (new) or organizationId (existing). Select checks
with seed_grader_config and pass the reviewed checks and features; publish
explicitly publishes them, and terraform leaves an IaC artifact.
The first call returns one browser approval URL. The page identifies the signed-in
account and destination, supports changing account, and creates a requested new
organization. Resume with just the same name. The private checkpoint survives
MCP restarts, expired device codes and interrupted responses. Creation uses the
same operation ID on retries; existing organizations are selected by ID, never name.
npx -y @codetelemetry/connect bootstrap acme \
--organization-name "Acme" --client codex --project /path/to/repository
# After approval (or funding), resume the exact saved plan:
npx -y @codetelemetry/connect bootstrap acme
npx -y @codetelemetry/connect workspace list
New workspace setups capture prompts and tool content by default so session titles,
replay and command evidence work immediately. Pass enrich: false to
bootstrap_workspace, or --no-enrich to Connect bootstrap, to opt out. The choice
is saved in the setup plan; resuming preserves explicit opt-outs, existing saved
client choices and legacy checkpoints. A new named Codex profile also defaults to
capture when no earlier capture choice exists. This does not change personal
onboarding defaults or another workspace's configuration. Captured team-scoped
content follows the organization's visibility policy; new organizations disclose
member visibility during creation, and administrators can change it in settings.
--plan file.json supplies the same bootstrap fields as the MCP tool, including
selected Grader checks. CLI exit 2 means setup is waiting for the returned action;
exit 0 means the requested checks completed. Funding is checked before client
configuration. No credits or seats are purchased. Capture follows the saved choice;
repository observation remains a separate setup option (enabled by project join).
With repository observation enabled, Connect reports the canonical URL of a
GitHub checkout when its origin is an unambiguous HTTPS or SSH clone URL.
Codex history imports can use the origin and parent ID from the rollout
header. To preview just the repository metadata for previously recorded
sessions, run codetelemetry-connect repository-metadata <rollout files>.
To deliver the displayed observations to your account, supply its
CODETELEMETRY_INGEST_KEY and append --send. This command reads only the
first record of each selected file and sends no prompts, calls or usage.
If Codex has retained the Git origin in its SQLite thread database, preview
selected thread IDs with repository-metadata --state <database> <thread IDs>.
This mode needs Node's built-in SQLite module and performs read-only lookups.
Credentials are private version-1 JSON files under
$CODETELEMETRY_CONTEXT_HOME/<name>.json, defaulting to
$XDG_CONFIG_HOME/codetelemetry/workspaces or
~/.config/codetelemetry/workspaces. Files are owned, mode 0600 on POSIX, atomically
replaced, and bounded to 64 KiB. There are at most 64 contexts and 192 directory
entries including checkpoints/locks. Unsafe versions, symlinks, mismatched account,
organization, billing account or origin fail closed. Failed authorization never
falls back to personal scope. Expired credentials can be replaced with
bootstrap_workspace using reauthorize: true; the replacement must attest the
same identity. Remove an unused named context/checkpoint explicitly to free capacity.
The repository's .codetelemetry/workspace.json contains only the context name,
service origin and scope. It can be committed; never commit the private context,
client config, Terraform state or plan. Bindings are found from subdirectories up
to the repository root. CODETELEMETRY_WORKSPACE selects a context explicitly but
must agree with an existing repository binding. MCP verifies scope at restore and
before use; governance requests also carry the expected scope so a key rescope
cannot race a check and change personal configuration.
For existing auth, call workspace_context with action: "save", a name and
repositoryPath. action: "use" selects an already-saved context. Rebinding a
repository requires explicitly removing its previous binding. Unbound clients
retain the legacy login behavior.
Bootstrap writes Claude settings inside the repository. Codex ignores project-local
otel, so bootstrap writes a dedicated user-level profile
$CODEX_HOME/codetelemetry-<name>.config.toml (or the default ~/.codex directory).
Launch with codetelemetry-connect run <name> -- <arguments> or
codex --profile codetelemetry-<name> in the bound repository. The profile retains
your base sign-in/settings while overriding telemetry and its explicit content
opt-in. It does not rewrite the base config or copy auth tokens. The profile also registers the version-pinned workspace MCP server and disables
the standard global CodeTelemetry MCP entry for that profile. Claude receives a
project .mcp.json entry bound to the same context. Optional Codex observation
hooks live in the profile and run only when it is selected.
Codex combines global and profile hooks. Bootstrap upgrades recognized older
CodeTelemetry observation helpers so they abstain in named workspaces; global
hook definitions and personal reporting are preserved. Modified helpers require
review before configuration continues. When opting into new observation hooks,
review and trust them in Codex's /hooks interface before expecting observations.
See OpenAI configuration reference
and hooks.
Secret-bearing project paths are added to .gitignore before configuration.
A requested GitHub gate produces its generated workflow locally. Bootstrap then
reads GitHub through the existing gh authentication and checks the default-branch
workflow, required check, and a real organization-scoped PR decision for the local
HEAD and published policy after setup started. It reports pending repository
work explicitly. It does not claim a PR passed merely because a probe landed.
A verified gate decision retains its actual success/failure verdict and score.
Terraform artifact generation is reported separately from applying Terraform.
The public service must deploy /api/device/code/bootstrap-v1 and the matching
approval route before clients use new-organization creation. Older deployments
refuse the versioned request rather than creating a personal key. Existing-org
contexts use the established scope-v1 device flow.
Cursor
Cursor has no OpenTelemetry settings to write. Connect installs six hooks and a
background collector instead:
npx -y @codetelemetry/connect login --client cursor
# With a key you already hold: npx -y @codetelemetry/connect <cot_key> --client cursor
Run it on the machine where the workspace lives. With Remote-SSH, WSL or a Dev
Container that is the remote host, the WSL distribution or the container, not your
laptop: Cursor reads ~/.cursor/hooks.json and runs hooks there. It requires
Node.js 24 or newer. Verified on Linux. macOS is in preview. Windows is not
supported: the command refuses to install there.
The command checks the machine before it requests a key: the platform, the Node.js
version, a per-user service manager, the paths it would use, and whether
~/.cursor/hooks.json can take the entries. A refusal names its reason and writes
nothing. After approval it asks the ingest endpoint whether it accepts Cursor
records, and stores nothing when the answer is no. Then, in this order, it writes
its settings, installs the hook program, starts the collector (a systemd user
service on Linux, a LaunchAgent on macOS) and adds one entry under each of six
events in ~/.cursor/hooks.json. Your other hooks are kept, and the file is copied
once to hooks.json.codetelemetry-backup before the first edit. An install that
fails part-way removes what it wrote, or puts the previous installation back. The
command then sends a test event, waits for it to arrive, and prints what it
installed, where, the capture mode and how to remove it. The Cursor IDE picks the hooks up at once; restart any running
cursor-agent session.
| Option |
What is sent |
| none (default) |
Metadata only: prompt length, tool names, durations, exit codes, sizes, models and token counts. A session then shows no repository and no developer. |
--enrich |
Also prompt text, the input of shell, read, write, search and task calls (commands, file paths, patterns and their options) and the workspace path, which gives a session its repository. Credential scrubbing is best effort: text in a known credential shape (key blocks, bearer and authorization values, assignments to secret-named variables, common token formats, passwords in URLs) is removed from prompts, and a tool input that holds such text, or a command that passes a password option, is withheld whole. A secret in a shape the patterns do not know is sent as typed, so leave --enrich off where prompts or commands may carry secrets. |
--identity |
Also your Cursor account email, which puts your sessions under your name. |
File contents, command output, model replies and reasoning are never collected.
--no-enrich and --no-identity turn an option off; with neither flag the current
choice is kept. Records captured while an option was on and not yet sent are
reduced before they are sent. Headless runs (cursor-agent -p) report tools and
durations, but no prompts and no tokens. Cursor's cloud and background agents do
not run user-level hooks, so they report nothing.