respan-instrumentation-mcp
Respan instrumentation plugin for Model Context Protocol Python applications.
The package enables upstream OpenInference MCP transport context propagation and adds Respan spans for common mcp.ClientSession operations such as tool listing, tool calls, resource reads, and prompt fetches.
Configuration
1. Install
pip install respan-ai respan-instrumentation-mcp "mcp>=1.27,<2"
2. Set Environment Variables
| Variable | Required | Description |
|---|---|---|
RESPAN_API_KEY |
Yes | Your Respan API key. Authenticates tracing export. |
RESPAN_BASE_URL |
No | Defaults to https://api.respan.ai/api. |
Quickstart
import asyncio
import sys
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
from respan import Respan, workflow
from respan_instrumentation_mcp import MCPInstrumentor
respan = Respan(instrumentations=[MCPInstrumentor()])
@workflow(name="mcp_tool_call_workflow")
async def run_mcp_client() -> None:
server_params = StdioServerParameters(
command=sys.executable,
args=["server.py"],
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
print([tool.name for tool in tools.tools])
result = await session.call_tool(
"summarize_city",
arguments={"city": "Paris"},
)
print(result)
asyncio.run(run_mcp_client())
respan.flush()
respan.shutdown()
This release supports MCP Python SDK 1.27 or newer on the 1.x line. MCP 2.x
removed the mcp.server.fastmcp API used by the current examples and is not
yet supported.
Further Reading
See the Respan example projects for runnable MCP scripts.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file respan_instrumentation_mcp-0.1.1.tar.gz.
File metadata
- Download URL: respan_instrumentation_mcp-0.1.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
127fb17e16c694f21e8432a46de5c5e7cd247428e91f9818903b51b67f83b2a9
|
|
| MD5 |
0823d77d58b1393eacb4be169b55ac29
|
|
| BLAKE2b-256 |
8461e34fc296d258d18adf1c325e8312d274be249aa718766357cfd1c3cdff55
|
File details
Details for the file respan_instrumentation_mcp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: respan_instrumentation_mcp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ae0a5c45621008b64e135c5e1f5120b94d2c1b9181f33be8c3485f03de67f47
|
|
| MD5 |
3df4d28d230cc2c78c721f805605c7d2
|
|
| BLAKE2b-256 |
4b3c9193bf59b6d0771db6dddcddaef9d239eb9cf195086079803d84e7d0595b
|