Skip to main content

Agnost Analytics SDK

PyPI version Python

Analytics SDK for tracking and analyzing Model Context Protocol (MCP) server interactions. Get insights into how your MCP servers are being used, monitor performance, and optimize user experiences.

Installation

pip install agnost-mcp

Basic Usage

import agnost_mcp
from fastmcp import FastMCP

# Create FastMCP server
mcp = FastMCP("My Server")

@mcp.tool()
def calculate(operation: str, a: float, b: float) -> float:
    """Perform mathematical operations."""
    if operation == "add":
        return a + b
    elif operation == "multiply":
        return a * b
    return 0

# Enable analytics tracking
agnost_mcp.track(mcp, org_id="your-organization-id")

Analytics delivery runs on a bounded background queue so tool calls do not wait for the Agnost API. Call shutdown() during application teardown to flush queued events on a best-effort basis and close the worker:

try:
    mcp.run()
finally:
    agnost_mcp.shutdown()

Configuration

You can customize the SDK behavior using the configuration object:

import agnost_mcp

# Create a custom configuration
config = agnost_mcp.config(
    endpoint="https://api.agnost.ai",
    disable_input=False,    # Set to True to disable input tracking
    disable_output=False,   # Set to True to disable output tracking
    log_level="INFO",
)

# Apply the configuration
agnost_mcp.track(
    server=server,
    org_id="your-organization-id",
    config=config
)

Configuration Options

Option Type Default Description
endpoint str "https://api.agnost.ai" Agnost API base URL
disable_input bool False Disable tracking of input arguments
disable_output bool False Disable tracking of output results
log_level str "INFO" SDK logging level
identify callable | None None Resolve per-session user identity from request context

Without a custom identify callback, HTTP transports resolve identity from the request's Authorization: Bearer ... header, falling back to the MCP server's validated auth token when headers are unavailable. JWT claims are checked in this order: sub, user_id, userId, email, preferred_username, then username. An email claim is preserved as user metadata, and opaque bearer tokens or x-api-key credentials are represented by a stable one-way hash; raw credentials are never sent to Agnost.

The identify callback may be synchronous or asynchronous. It must return a dictionary containing userId, or None to skip attribution for that attempt. Failed or anonymous results are retried instead of being cached for the process.

Stateful Streamable HTTP and SSE calls reuse their MCP session. Stateless Streamable HTTP groups calls by OAuth token/grant ID when available, then by resolved user, then by one bounded anonymous bucket. Stdio remains scoped to the server process. Multiple server instances in one process are supported when they use the same organization and config; mismatches are rejected rather than silently misattributed.

Contact

For support or questions, contact the founders: founders@agnost.ai

Metadata

Release files for agnost-mcp 0.2.0

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

Source distribution (sdist)

Source distribution for agnost-mcp 0.2.0
File Size Uploaded Provenance
agnost_mcp-0.2.0.tar.gz 24.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for agnost-mcp 0.2.0
File Interpreter ABI Platform
agnost_mcp-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.5 kB

Release files / agnost_mcp-0.2.0.tar.gz

Download URL agnost_mcp-0.2.0.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1d13571ee0dce63f759104cd602c3afc05475eb13ea41e8f9002946054828221
BLAKE2b-256 checksum
How to use checksums
c551abdaacb4d5dae5fdc0250d9ef5e9403035003df10a5afb8d5bf403a17de4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Release files / agnost_mcp-0.2.0-py3-none-any.whl

Download URL agnost_mcp-0.2.0-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25540028f33d164056ca5e83b4540cf5fa16d4134ac3171d34429e1ac4c76705
BLAKE2b-256 checksum
How to use checksums
b2aa4397607111bf7163eeea30d70dfb50628497aa9daec269f8720fd6b1bcb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.14

Security for agnost-mcp 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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