Skip to main content

Respan instrumentation plugin for Model Context Protocol (MCP)

Project description

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

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()

Further Reading

See the Respan example projects for runnable MCP scripts.

Project details


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.0.tar.gz (4.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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: respan_instrumentation_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0

File hashes

Hashes for respan_instrumentation_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ab5c60648430fdb9c00424c0c4eddf11757e1b64144e3f305b7591a216b38447
MD5 83eceeda624ed31a90086809463ed299
BLAKE2b-256 740c416f36c746797d4d4abac05115b56bb3916f280d1a93b1691333eae55885

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for respan_instrumentation_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe3958ee506c791dbe3879836bd1d4a428fcb53d7bda8e9adc77dcd3ed76952
MD5 2349ca88bfba3e7e414a93e440afb547
BLAKE2b-256 044e21ee13cd5b615412531b8df8ae56e9f82763d80d0fd32a70afefda6e6248

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page