Skip to main content

Observe Python SDK

A Python SDK for MCP tool and prompt usage logging and monitoring.

Installation

pip install observee

Usage

You can set the MCP server name either globally or per decorator:

Global Configuration

from observee import ObserveeConfig, observee_usage_logger

# Set the MCP server name globally
ObserveeConfig.set_mcp_server_name("your-mcp-server-name")

# Auto-detection based on function name
@observee_usage_logger
async def your_tool_function():
    # Your tool code here
    pass

@observee_usage_logger
async def generate_prompt():
    # Your prompt code here - auto-detected as prompt
    pass

API Key Configuration (Developers and Enterprise Customers)

from observee import ObserveeConfig

# Set your API key
ObserveeConfig.set_api_key("your-api-key")

Unified Usage Logging

from observee import ObserveeConfig, observee_usage_logger

# Auto-detection based on function name (recommended)
@observee_usage_logger()
async def your_tool_function():
    # Your tool code here
    pass

@observee_usage_logger()
async def generate_prompt():
    # Your prompt code here
    pass

Features

  • Unified decorator for both tool and prompt usage logging with async support
  • Auto-detection of usage type based on function names (or explicit specification)
  • Automatic logging of:
    • Tool/prompt name
    • Input parameters
    • Response data
    • Execution duration (for tools only)
    • Error information (if any)
  • Configurable logging endpoint (defaults to Observe API)
  • Error handling and reporting
  • Performance tracking (for tools only)
  • Flexible MCP server name configuration
  • API key support for enhanced features
  • Privacy protection: Input/response data only logged when API key is provided

Logging Details

Unified Usage Logging

The SDK uses a single @observee_usage_logger() decorator that can automatically detect whether you're logging a tool or prompt based on the function name, or you can specify explicitly:

Auto-detection: Functions containing keywords like 'prompt', 'template', or 'message' in their name are detected as prompts. All others are treated as tools.

Tool logging includes:

  • MCP server name
  • Tool name (derived from function name)
  • Tool input parameters (as JSON)
  • Tool response
  • Execution duration in milliseconds
  • Any errors that occur during execution

Prompt logging includes:

  • MCP server name
  • Prompt name (derived from function name)
  • Prompt input parameters (as JSON)
  • Prompt response
  • Any errors that occur during execution

Privacy Protection

For privacy protection, detailed input and response data is only logged when an API key is configured. Without an API key, only basic metadata is logged:

  • For tools: server name, tool name, and execution duration
  • For prompts: server name and prompt name

Logs are sent asynchronously to avoid impacting tool/prompt performance.

Requirements

  • Python 3.8 or higher
  • Dependencies:
    • httpx
    • pydantic

License

GPL v3 - see LICENSE file for details

Release files for mcp-logger 0.1.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcp-logger 0.1.23
File Size Uploaded
mcp_logger-0.1.23.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mcp-logger 0.1.23
File Interpreter ABI Platform
mcp_logger-0.1.23-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / mcp_logger-0.1.23.tar.gz

Download URL mcp_logger-0.1.23.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f489b23019d4ebb3b853a775e82b92e08445024812d79afebf70868453dd5593
BLAKE2b-256 checksum
How to use checksums
7848909594b96d44f0cbfa8cb16d8cedd7fb688bb352b443ded45c864b591c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / mcp_logger-0.1.23-py3-none-any.whl

Download URL mcp_logger-0.1.23-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f92fc141d3260a09b01dbf3ef8b510db82d67f227d8ab23ce21ce23018dcd10
BLAKE2b-256 checksum
How to use checksums
346635d9d330845b32c625bbbb90e037ba2964fa6707ff55ad11a241313099a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release history Release notifications | RSS feed

This release

0.1.23 This release

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

1 release file

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