Skip to main content

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

respan_instrumentation_mcp-0.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

respan_instrumentation_mcp-0.1.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file respan_instrumentation_mcp-0.1.1.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 127fb17e16c694f21e8432a46de5c5e7cd247428e91f9818903b51b67f83b2a9
MD5 0823d77d58b1393eacb4be169b55ac29
BLAKE2b-256 8461e34fc296d258d18adf1c325e8312d274be249aa718766357cfd1c3cdff55

See more details on using hashes here.

File details

Details for the file respan_instrumentation_mcp-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae0a5c45621008b64e135c5e1f5120b94d2c1b9181f33be8c3485f03de67f47
MD5 3df4d28d230cc2c78c721f805605c7d2
BLAKE2b-256 4b3c9193bf59b6d0771db6dddcddaef9d239eb9cf195086079803d84e7d0595b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page