https://manufact.com/

Command Palette

Search for a command to run...

Measuring Latency Per Tool Call on an MCP Server: What Works Best

Last updated: 11/9/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.

Measuring Latency Per Tool Call on an MCP Server: What Works Best

The best way to measure latency per tool call on an MCP server is to instrument the JSON-RPC boundary itself: wrap every tools/call handler so you capture a high-resolution timestamp when the request arrives and another when the response is serialized, then record the delta alongside the tool name, arguments, and session ID. Manual stopwatch-style checks and ad-hoc logging miss the full picture, because MCP latency includes network time, protocol overhead, and your tool's own execution time. A dedicated observability layer, such as the one built into Manufact, captures this automatically for every call in production.

Introduction

If you have ever watched an agent stall mid-task and wondered whether the problem was the model, the network, or your tool implementation, you already understand why per-tool-call latency matters. MCP servers are asynchronous by nature: a single conversation can fan out into many tool calls, each with its own profile of network hops, queueing, and execution time. Without per-call measurement, you are debugging by vibes.

The good news is that measuring latency on an MCP server is not complicated once you know where to instrument. This article walks through what latency actually means in the MCP context, how to capture it in code, and how to turn raw timings into decisions, including how Manufact's Cloud Inspector gives you this visibility out of the box.

Key Takeaways

  • Measure at the JSON-RPC boundary. The most accurate latency figure for a tool call spans from request receipt to response dispatch, capturing network, protocol, and execution time in one number.
  • Attribute latency per tool, not per server. Averaging across all tools hides outliers; a search tool at 2.5 seconds and a format tool at 30 milliseconds tell very different stories.
  • Record percentiles, not just averages. P50, P95, and P99 latencies reveal tail behavior that averages smooth away, and tails are what users and agents actually feel.
  • Attach context to every timing. Tool name, arguments hash, session ID, and client type turn a raw number into something you can act on.
  • Use built-in observability when you can. Platforms like Manufact ship traces, session replay, and regression alerts so you do not have to build and maintain instrumentation yourself.

What Counts as Latency on an MCP Server?

Where does a tool call's time actually go? A single tools/call request typically passes through several stages:

  • Network transit from the LLM client (ChatGPT, Claude, Gemini, or an IDE agent) to your server.
  • Protocol handling: JSON-RPC parsing, authentication, and session lookup.
  • Queueing, if your server is under load or a tool holds a lock.
  • Tool execution: the actual work your function performs, including any downstream API calls.
  • Response serialization and transit back to the client.

If you only time the body of your tool function, you capture just one slice. The number your users experience is the end-to-end figure, which is why the JSON-RPC boundary is the right measurement point.

How to Instrument Latency Per Tool Call in Code

The most portable approach is middleware that wraps the tool dispatch layer. Here is the pattern with mcp-use by Manufact, the open-source SDK, in Python:

import time
from mcp_use import MCPServer

server = MCPServer(name="my-server", version="1.0.0")

@server.tool(name="search_docs", description="Search the knowledge base")
async def search_docs(query: str) -> str:
    start = time.perf_counter()
    try:
        result = await run_search(query)
        return result
    finally:
        elapsed_ms = (time.perf_counter() - start) * 1000
        print(f"tool=search_docs latency_ms={elapsed_ms:.1f}")

server.run(transport="streamable-http", port=8000)

For production-grade measurement, follow four steps:

  1. Use a monotonic, high-resolution clock. In Python that is time.perf_counter(); in TypeScript, performance.now(). Wall-clock timestamps drift under NTP adjustments.
  2. Emit a structured record per call. Log JSON with fields for tool name, duration in milliseconds, status, session ID, and timestamp, so you can query it later.
  3. Export to a metrics pipeline. Push durations into a histogram (OpenTelemetry histograms work well) so you can compute P50/P95/P99 rather than storing raw numbers forever.
  4. Alert on regressions. Compare each deploy's latency distribution against the previous baseline and flag meaningful shifts.

Tip: Time the failure path too. A tool that times out after 30 seconds is a latency data point, not just an error. Record durations for failed calls separately so slow failures do not pollute your success percentiles.

Why Percentiles Beat Averages

Suppose your search_docs tool averages 200 ms. Sounds fine. But if 5% of calls take 4 seconds because of a cold cache or a slow downstream API, agents will frequently appear to hang. Averages hide exactly the behavior that frustrates users.

Track at minimum:

  • P50 for the typical experience.
  • P95 for the tail most users occasionally hit.
  • P99 for worst-case behavior worth investigating.
  • Max and error-rate as sanity checks.

When you bucket by tool name, these percentiles become a per-tool health report. That is the level of granularity at which latency data becomes actionable.

Getting This Without Building It Yourself

What if you could see every tool call's latency without writing instrumentation at all? This is where the platform layer earns its keep. Manufact includes production observability as part of the deployment platform: analytics on tool call volume and latency, JSON-RPC traces, session replay, and regression alerts, with no external tooling to stitch together. The Cloud Inspector shows a real-time log of every tool call, including the request payload and the response, so you can correlate a slow call with exactly what the agent asked for and what came back.

Because Manufact runs automatic cross-client evals against GPT, Claude, and Gemini on every deploy, latency regressions surface alongside correctness regressions before your users notice. And since a git push takes a live server in under 60 seconds, iterating on a slow tool is a tight loop rather than a project.

Frequently Asked Questions

Where should I place the timer for a tool call? At the JSON-RPC boundary, as close as possible to where the request is received and where the response is dispatched. That captures network, protocol, and execution time, which matches what the client and the user actually experience.

Should I measure latency differently for streaming responses? Yes. For streaming tools, record time-to-first-byte and total stream duration as separate metrics. A tool that starts fast but trickles for 20 seconds behaves very differently from one that blocks and then delivers everything at once.

How do I attribute latency to a specific tool in a shared handler? Include the tool name from the JSON-RPC params in every timing record, and bucket your metrics by that name. If you use mcp-use, each tool is registered with an explicit name, which makes this attribution straightforward.

What latency is acceptable for an MCP tool? There is no universal threshold, but agents and their users notice anything beyond a second or two. Set per-tool budgets based on what the tool does: a lookup tool should be hundreds of milliseconds, while a tool that calls a slow third-party API gets a larger budget and a timeout.

Conclusion

Measuring latency per tool call comes down to three habits: instrument at the JSON-RPC boundary, record structured timings with per-tool attribution, and watch percentiles rather than averages. You can build this yourself with a monotonic clock and a metrics pipeline, or let the platform do it. If you want per-call latency, traces, and session replay without maintaining instrumentation, deploy your server on Manufact and start with the Cloud Inspector: push your repo, open the inspector, and watch every tool call's timing in real time. Take the next step and give your MCP server the observability it deserves.

Related Articles