Skip to main content

Complete Observability for MCP servers

Project description

Logo

Shinzo Python SDK: Complete Observability for MCP Servers

Stars Forks Build contributors welcome Discord

The SDK provides OpenTelemetry-compatible instrumentation for Python MCP servers. Gain insight into agent usage patterns, contextualize tool calls, and analyze performance of your servers across platforms. Instrumentation can be installed in servers in just a few steps with an emphasis on ease of use and flexibility.

Explore the docs »

Installation

The Shinzo Python instrumentation library works with Python MCP servers built with the core MCP SDK or FastMCP. Simply install the base package:

pip install shinzo

Quick Start

Choose the example that matches your MCP SDK:

FastMCP Example

from mcp.server.fastmcp import FastMCP
from shinzo import instrument_server

# Create FastMCP server
mcp = FastMCP(name="my-mcp-server")

# Instrument it with Shinzo
observability = instrument_server(
    mcp,
    config={
        "server_name": "my-mcp-server",
        "server_version": "1.0.0",
        "exporter_auth": {
            "type": "bearer",
            "token": "your-api-token"
        }
    }
)

# Define your tools
@mcp.tool()
def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Weather for {city}: Sunny"

# Run the server
if __name__ == "__main__":
    mcp.run()

MCP SDK Example

from mcp.server import Server
from shinzo import instrument_server

# Create your MCP server
server = Server("my-mcp-server")

# Instrument it with Shinzo
observability = instrument_server(
    server,
    config={
        "server_name": "my-mcp-server",
        "server_version": "1.0.0",
        "exporter_auth": {
            "type": "bearer",
            "token": "your-api-token"
        }
    }
)

# Define your tools
@server.call_tool()
async def get_weather(city: str) -> str:
    return f"Weather for {city}: Sunny"

# Clean shutdown
async def shutdown():
    await observability.shutdown()

SDK Compatibility

Shinzo automatically detects and instruments your MCP server regardless of which SDK you use:

SDK Detection Method Decorator Use Case
FastMCP server.tool attribute @mcp.tool() Simpler API, modern Python patterns, recommended for new projects
Traditional MCP server.call_tool attribute @server.call_tool() Standard MCP specification, more configuration options

Both SDKs receive the same comprehensive instrumentation with no additional configuration needed.

Features

  • 🔍 Automatic Instrumentation - Zero-code changes for basic tracing across both FastMCP and Traditional MCP
  • 📊 Rich Metrics - Track request duration, error rates, and custom metrics
  • 🔐 PII Sanitization - Built-in sensitive data protection
  • 🎯 Session Tracking - Correlate all requests in a user session
  • High Performance - Minimal overhead with efficient batching
  • 🛠️ Flexible Configuration - Customize sampling, exporters, and processors

Configuration

Setting Required Type Default Description
server_name str - Name of your MCP server
server_version str - Version of your MCP server
exporter_endpoint str "https://api.app.shinzo.ai/telemetry/ingest_http" OTLP endpoint URL for telemetry export
exporter_auth AuthConfig None Authentication configuration for the exporter
exporter_type "otlp-http" | "console" "otlp-http" Type of exporter to use
sampling_rate float 1.0 Trace sampling rate (0.0-1.0)
enable_metrics bool True Enable metrics collection
enable_tracing bool True Enable distributed tracing
enable_pii_sanitization bool False Enable automatic PII sanitization
enable_argument_collection bool True Collect and include tool arguments in telemetry
metric_export_interval_ms int 60000 Interval for exporting metrics (milliseconds)
batch_timeout_ms int 30000 Timeout for batching telemetry data (milliseconds)
data_processors list[Callable] None Custom data processors for telemetry attributes
pii_sanitizer PIISanitizer None Custom PII sanitizer instance

Authentication Configuration (exporter_auth)

Setting Required Type Description
type "bearer" | "apiKey" | "basic" Authentication method
token str Bearer token (required when type="bearer")
api_key str API key (required when type="apiKey")
username str Username (required when type="basic")
password str Password (required when type="basic")

Testing

Run the test suite to verify the library's behavior:

# Run all tests
python -m pytest tests/

# Run with coverage report
python -m pytest tests/ --cov=shinzo --cov-report=term-missing

# Run specific test file
python -m pytest tests/test_config.py -v

The test suite validates:

  • ✅ Configuration validation and error handling
  • ✅ PII sanitization for emails and sensitive data
  • ✅ Authentication configuration (bearer, basic, API key)
  • ✅ Sampling rate validation

License

MIT License - see LICENSE file for details

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

shinzo-1.0.3.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

shinzo-1.0.3-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file shinzo-1.0.3.tar.gz.

File metadata

  • Download URL: shinzo-1.0.3.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for shinzo-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9c6c33e43acc599a45c81e2439728afba62ec9aaa261c7d51eefb92d7f58c843
MD5 5089eb136de7ce4d5d28c10c7697a77a
BLAKE2b-256 33d0b58d46fe980978a22c7c40b5f05dbe81489a3055a2b60d5bf75938c6fe67

See more details on using hashes here.

File details

Details for the file shinzo-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: shinzo-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for shinzo-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c96b892bdf9aad0eed9fe400337410b996f09926c8cb48b1773adafbab9d83da
MD5 c6846a37df93d85c5184c6ca03cb5d67
BLAKE2b-256 bfcca24c508d21689e9818864cc208bb55877a4549d31ebfd442adc03e88168a

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