MCP (Model Context Protocol)

Trace MCP server and tool interactions with Respan.
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page

Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://docs.respan.ai/mcp"
5 }
6 }
7}

What is MCP?

Model Context Protocol (MCP) is an open standard by Anthropic for connecting AI models with external data sources and tools. It provides a standardized way for LLM applications to access context from files, databases, APIs, and other services.

Setup

1

Install packages

$pip install respan-ai openinference-instrumentation-mcp mcp
2

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
3

Initialize and run

1import os
2import asyncio
3from dotenv import load_dotenv
4
5load_dotenv()
6
7from respan import Respan
8from respan_instrumentation_openinference import OpenInferenceInstrumentor
9from openinference_instrumentation_mcp import MCPInstrumentor
10from mcp import ClientSession, StdioServerParameters
11from mcp.client.stdio import stdio_client
12
13# Initialize Respan with MCP instrumentation
14respan = Respan(
15 instrumentations=[
16 OpenInferenceInstrumentor(instrumentor=MCPInstrumentor())
17 ]
18)
19
20async def main():
21 # Connect to an MCP server
22 server_params = StdioServerParameters(
23 command="python",
24 args=["your_mcp_server.py"],
25 )
26
27 async with stdio_client(server_params) as (read, write):
28 async with ClientSession(read, write) as session:
29 await session.initialize()
30
31 # List available tools
32 tools = await session.list_tools()
33 print(f"Available tools: {[t.name for t in tools.tools]}")
34
35 # Call a tool
36 result = await session.call_tool("your_tool", arguments={"query": "hello"})
37 print(result)
38
39 respan.flush()
40
41asyncio.run(main())
4

View your trace

Open the Traces page to see your MCP interactions with tool invocations, resource access, and server communication.

What gets traced

All MCP operations are auto-instrumented:

  • MCP tool invocations and results
  • Resource access and retrieval
  • Server-client communication
  • LLM calls with model, tokens, and input/output
  • Context window operations

Traces appear in the Traces dashboard.

Learn more