Skip to main content

Python SDK for tool usage logging and monitoring

Project description

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

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

mcp_logger-0.1.20.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

mcp_logger-0.1.20-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_logger-0.1.20.tar.gz.

File metadata

  • Download URL: mcp_logger-0.1.20.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for mcp_logger-0.1.20.tar.gz
Algorithm Hash digest
SHA256 959e8f7ffdcb2cb899d03ed8a206b9c153e83d2ce7defd9a8ddb04d88c021f1e
MD5 74e3b53f4815ab70fc8442ecddb6bcd9
BLAKE2b-256 fd218860c5bfd2bfbf0f61f1c119d47de0f129fdb2f9971e545d6a10b756d088

See more details on using hashes here.

File details

Details for the file mcp_logger-0.1.20-py3-none-any.whl.

File metadata

  • Download URL: mcp_logger-0.1.20-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for mcp_logger-0.1.20-py3-none-any.whl
Algorithm Hash digest
SHA256 ecfd98dcdfecf19b5d604916781476c6149c8d8bffd8d5f4696f8c79b22844b7
MD5 0dca5598ef03b2894b28f1c901f69eae
BLAKE2b-256 ffcaa3abb6aadeb162a52389f883b1cc6dbbe93e0f9cddc592d0e6542e72bf37

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