mcp-telemetry

mcp-telemetry

Streams live progress from long-running MCP tool calls to any connected client. Instrument a tool call with mcp-telemetry-sdk, and telemetry_subscribe pushes its steps, logs, cost, and completion over notifications/progress — no polling, and a job started in one session can be watched from a different one.

Category
访问服务器

README

mcp-telemetry

CI npm (sdk) npm (server) License: MIT

Socket.IO for AI agents. Instrument any MCP server's tool calls with a few lines, and any MCP client watching (Claude Code, Cursor, or your own tooling) gets live, structured progress — no polling, no context-flooding tool calls.

mcp-telemetry demo

Your MCP server                    mcp-telemetry server         Agent
─────────────────                  ────────────────────         ─────
mcp-telemetry-sdk
  job.stepStart('build')
       │
       │ local socket (queued, persistent connection)
       ▼
  collector receives event
  store updates job state
       │
       │ MCP notifications/progress
       ▼
                                    telemetry_subscribe tool     Claude Code
                                    pushes event to agent   →   sees inline
                                                                 live status

Why this exists

MCP tool calls are synchronous: an agent calls a tool, waits, gets a result. For anything long-running, that leaves two bad options — block the whole call with no visibility, or have the agent poll a status tool in a loop (which floods the conversation with repeated tool calls and burns context for no new information).

MCP does have one legitimate way for a server to push updates mid-call: notifications/progress, keyed to a progressToken on the in-flight request. But every MCP server author ends up re-implementing the same plumbing — extracting the token, wiring a timer, tailing output, cleaning up on completion. mcp-telemetry is that plumbing, factored out once, plus a companion server so a job started in one session can be watched from a completely different one.

How it fits together

Two packages, one job each:

Package Who uses it What it does
mcp-telemetry-sdk MCP server authors Import it, call job.start() / .stepDone() / .log() from your tool handlers. Zero runtime dependencies — it's a socket writer with a persistent, queued connection and nothing else.
mcp-telemetry-server Agent users An MCP server you register once. Exposes telemetry_subscribe (blocks and streams live progress for a job), plus telemetry_jobs/telemetry_job_status for point-in-time queries.

These two packages are architecturally independent — the SDK never calls any MCP tool, and the server never imports your tool's code. They only ever meet at a local socket, so a producer with a broken connection can't take down anything, and a collector that's overwhelmed can't block your tool call.

Quickstart

1. Instrument your MCP server (mcp-telemetry-sdk)

npm install mcp-telemetry-sdk
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { MCPTelemetry } from "mcp-telemetry-sdk";

const server = new McpServer({ name: "my-deploy-server", version: "1.0.0" });
const telemetry = new MCPTelemetry(); // zero config — derives a socket path from cwd

server.tool("deploy", { env: z.string() }, async ({ env }) => {
  const job = telemetry.createJob({ task: `deploy ${env}` });

  job.start();
  job.stepStart("build");
  await runBuild();
  job.stepDone("build", { duration: 2100 });

  job.stepStart("test");
  const passed = await runTests();
  if (!passed) {
    job.stepFailed("test", "3 tests failed");
    await job.done(1);
    return { content: [{ type: "text", text: "Deploy failed at test stage" }] };
  }
  job.stepDone("test");

  await job.done(0);
  return { content: [{ type: "text", text: "Deployed successfully" }] };
});

That's the entire integration. If nothing is listening on the socket, every call is a fast no-op — your server behaves identically with or without a collector running.

2. Watch it from an agent (mcp-telemetry-server)

npm install -g mcp-telemetry-server

Register it as an MCP server, alongside your instrumented one:

{
  "mcpServers": {
    "deploy": { "command": "npx", "args": ["-y", "deploy-mcp"] },
    "telemetry": { "command": "npx", "args": ["-y", "mcp-telemetry-server"] }
  }
}

Then, in your agent session:

You:   deploy to staging
Agent: calls the deploy tool, then telemetry_subscribe with the returned job id

  ▶ deploy staging
  ↻ build
  ✓ build (duration=2100)
  ↻ test
  ✓ test
  ✓ job done (exit 0)

Agent: "Deployed to staging successfully."

No polling, no separate terminal, no context-flooding tool calls — one deploy call plus one telemetry_subscribe call, regardless of how long the job runs.

API reference

mcp-telemetry-sdk

new MCPTelemetry(opts?) Creates a telemetry client. opts.socketPath overrides the default (derived from process.cwd() via getSocketPath()). Owns one persistent, queued connection shared by every job it creates.

telemetry.createJob({ id?, task })JobHandle Starts tracking a job. id defaults to an auto-incrementing job-N.

telemetry.disconnect() Closes the underlying connection. Call on server shutdown if you want a clean teardown instead of letting it idle.

JobHandle method Emits Notes
start() job_start Call once, at the beginning of the tool handler.
stepStart(name, meta?) step_start name is any string — 'build', 'implement', whatever fits your domain.
stepDone(name, meta?) step_done meta is arbitrary key/value data (shown in telemetry_subscribe's live output).
stepFailed(name, reason?) step_failed
log(line, stream?) log stream is 'stdout' | 'stderr', optional. Rapid log lines are coalesced by the server before being pushed live — see below.
cost(amount, meta?) cost amount in USD.
done(exitCode?) job_done Async. This is the terminal event — nothing else may be sent after it, so it actively retries delivery for up to 1.5s instead of relying on a future send() to recover from a transient connection failure. Safe to call without await.

getSocketPath(root?) is also exported, for advanced cases where you need to compute the same path a producer and a server will independently derive.

mcp-telemetry-server

Exposes three MCP tools:

Tool Behavior
telemetry_subscribe({ jobId?, timeoutMs? }) Blocks and streams live notifications/progress for the given job (or the next job to start, if jobId is omitted) until it finishes or timeoutMs elapses (default 5 min). This is the tool your agent calls to watch a job.
telemetry_jobs() Lists all jobs the server currently knows about, with status and cost.
telemetry_job_status({ jobId }) Full state of one job — every step, cost, and any failure reason.

Comparison

Three genuinely different categories of approach exist near this space — none of them solve the same problem:

mcp-telemetry Async job runners Completion notifiers OpenTelemetry MCP instrumentation
Mechanism Push (notifications/progress) Poll (call a status/tail tool yourself) Push, but only at completion (webhook/sound) Traces/metrics to an observability backend
Live step-by-step progress Yes No — you ask, it answers No — only "it's done" No — post-hoc analysis
Watch from a different session Yes No — tied to the session that started it Partial (a webhook can fire anywhere) N/A — not agent-facing
Who it's for Any MCP server author + any agent Anyone needing async shell execution specifically Anyone wanting a completion ping Server operators monitoring their own deployment

Relationship to SEP-1686 (MCP Tasks): the MCP spec's own answer to this problem — Accepted into the spec (not just proposed), giving requests a durable task handle (taskId) with tasks/get polling and a progressToken valid for the task's whole lifetime. It's the eventual "correct" fix, backed by real production cases (Amazon cites healthcare data pipelines, CI/CD wrapping, and multi-agent systems in the SEP itself). The catch: it's labeled awaiting-sdk-change — the standard is settled, but client/server SDKs haven't implemented it yet, so it isn't something you can rely on today. mcp-telemetry solves the same problem now, on the current stable protocol — a working bridge you can adopt today and retire once Tasks lands in the SDKs you depend on, not a competing standard.

Design notes worth knowing before you rely on this

  • The producer→server connection is a persistent, queued socket, not one connection per event. Events are flushed in order once connected; a burst that arrives before the connection finishes establishing is queued and delivered in order once it does.
  • Delivery is best-effort, not guaranteed, with one exception: done(). Every other event silently drops if the collector isn't reachable and nothing else triggers a retry — this is deliberate (telemetry should never be able to block or crash your actual tool call). done() is the one event that actively retries for a bounded window, since it's usually the last thing a job ever sends.
  • telemetry_subscribe only shows live-forward events — it doesn't replay history. If a job already finished before you subscribed, use telemetry_job_status instead.
  • This is not a distributed job queue. There's no persistence across a collector restart, no cross-machine delivery, and no retry policy beyond what's described above. If you need that, you want a real message queue — this is deliberately just enough to solve "watch a local MCP tool call live," nothing more.

Development

git clone https://github.com/arnavranjan005/mcp-telemetry.git
cd mcp-telemetry
npm install
npm run build
npm test

See CONTRIBUTING.md for the full setup, monorepo layout, and PR expectations.

License

MIT © Arnav Ranjan

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选