Skip to main content

Install

pip install agnost-mcp
uv add agnost-mcp

Integrate

Call track after defining your server and handlers, before running:
from mcp.server import Server
from agnost_mcp import track, config

server = Server("your-server-name")

# ... your list_tools and call_tool handlers ...

track(server, "your-org-id", config(
    endpoint="https://api.agnost.ai",
    disable_input=False,
    disable_output=False,
))
Get your org ID from app.agnost.ai.

Identify users

Pass an identify function to resolve a user from the incoming request context. It receives the raw request object and the process environment, and should return a dict with at least a userId key:
from agnost_mcp import track, config

track(server, "your-org-id", config(
    identify=lambda req, env: {
        "userId": req.get("headers", {}).get("x-user-id") or env.get("USER_ID", "anonymous"),
        "email":  req.get("headers", {}).get("x-user-email") or env.get("USER_EMAIL"),
        "role":   req.get("headers", {}).get("x-user-role")  or env.get("USER_ROLE", "user"),
    }
))
The function can also be async. Return None to skip user attribution for a request. Prefer stable pseudonymous IDs and non-sensitive traits. Avoid forwarding raw emails, names, or other personal data unless your team has approved that data flow.

Options

FieldTypeDefaultDescription
endpointstrhttps://api.agnost.aiAPI endpoint
disable_inputboolFalseSkip capturing tool input arguments
disable_outputboolFalseSkip capturing tool output / result
log_levelstr"INFO"Log verbosity: DEBUG, INFO, WARNING, ERROR
identifyCallableNoneFunction (request, env) → UserIdentity to resolve user identity per request
UserIdentity is a Dict[str, Any] that must contain a userId key. Other fields are optional and forwarded as user traits. If tool inputs or outputs may contain sensitive data, set disable_input=True or disable_output=True, or redact values before the tool returns them. See Data Governance.

Checkpoints

Per-step latency checkpoints are currently available only in the TypeScript SDK. Tool-level latency is captured automatically across all SDKs.

What appears in Agnost

  • Tools for MCP tool invocations.
  • Raw logs for every tracked call.
  • Errors when a tool call fails.

Verify

Call one MCP tool from your Anthropic client, then open app.agnost.ai. Check Raw logs first, then Tools.

Troubleshooting

  • Call track(...) after registering handlers and before serving.
  • Confirm the org ID is correct.
  • Use disable_input / disable_output if tool args or results are sensitive.