Skip to content

[bot] Instrument mcp (256K weekly downloads) #212

Description

@braintrust-bot

Summary

The mcp gem — the official Ruby SDK for the Model Context Protocol, maintained by the Model Context Protocol org — is not instrumented by this SDK. It provides the core execution surface for building MCP servers (that expose tools, prompts, and resources) and MCP clients (that connect to any MCP server and invoke its tools), and is actively released (v1.5.1, 2026-09-09).

This is distinct from the already-tracked gap in #195, which covers the mcp_servers/container request parameters on Anthropic's own Messages API (i.e., Claude calling out to a remote MCP connector mid-generation). This issue is about instrumenting the standalone mcp gem itself — the protocol implementation applications use to build and run MCP servers/clients and execute tool calls, independent of any specific model provider.

What is missing

No instrumentation exists for any mcp execution surface. Key APIs that should be instrumented:

Server-side tool execution

  • MCP::Tool.call(**args, server_context:) — the handler invoked when a client calls a tool on an MCP::Server. Each invocation is a discrete unit of agent tool execution with structured input (per the tool's input_schema) and a structured MCP::Tool::Response.
  • MCP::Server.new(name:, tools:, ...) — registers the set of tools/prompts/resources a server exposes; request routing for tools/call, tools/list, resources/*, and prompts/* JSON-RPC methods happens inside the server/transport layer.

Client-side tool invocation

  • MCP::Client#call_tool(tool:, arguments:) — the core client-side execution call: sends a tools/call request to a connected MCP server and returns the result. This is the primary point where an agent decides to execute an external tool via MCP.
  • MCP::Client#tools — lists available tools from the connected server (discovery step preceding execution).
  • MCP::Client#connect — performs the MCP initialization handshake over a transport (MCP::Client::Stdio, MCP::Client::HTTP).

Expected instrumentation

Tool call spans (both server-side Tool.call and client-side Client#call_tool) should capture:

  • Input: tool name, arguments
  • Metadata: server/client identity, transport type (stdio/HTTP)
  • Output: MCP::Tool::Response content (or error, for MCP::Tool::Response.new(..., is_error: true))

Braintrust docs status

not_found — Checked https://www.braintrust.dev/docs/integrations/sdk-integrations and https://www.braintrust.dev/docs/integrations, neither mentions instrumenting the modelcontextprotocol/ruby-sdk gem. The only MCP-related integration listed, https://www.braintrust.dev/docs/integrations/developer-tools/mcp ("Braintrust MCP"), is a hosted MCP server that lets AI assistants (Claude Code, Cursor, Codex, etc.) query Braintrust's own platform data — an unrelated, opposite-direction integration. It does not cover tracing applications built with the Ruby MCP SDK.

Upstream sources

Local repo files inspected

  • lib/braintrust/contrib.rb — registers only 4 integrations: OpenAI, RubyOpenAI, RubyLLM, Anthropic. No MCP integration.
  • lib/braintrust/contrib/ — contains only openai/, ruby_openai/, ruby_llm/, anthropic/, and rails/ directories. No mcp/ directory.
  • Appraisals — no appraisal scenarios for mcp
  • braintrust.gemspec — no mention of mcp
  • Grep for mcp (case-insensitive) across lib/braintrust/ returns zero matches

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions