- Python
- TypeScript
- Go
Configuration Options
- Python
- TypeScript
- Go
| Field | Type | Default | Description |
|---|---|---|---|
endpoint | str | "https://api.agnost.ai" | API endpoint URL for analytics data |
disable_input | bool | False | Whether to disable tracking of input parameters |
disable_output | bool | False | Whether to disable tracking of output responses |
identify | function | None | Function to identify users from request context |
User Identification
All SDKs support user identification to track analytics per user. This helps you understand usage patterns across different users and roles.- Python
- TypeScript
- Go
Basic User Identification
Advanced User Identification
User Identity Dictionary
The identify function should return a dictionary with at least auserId field:Identify Function Parameters
-
req: The incoming MCP request dictionary containing:headers: HTTP-style headers (e.g.,x-user-id,authorization)params: Request parameters including tool name and arguments- Other request metadata from the MCP protocol
-
env: Environment variables dictionary (fromos.environ), useful for:- Reading user info from environment variables
- Accessing configuration secrets
- Getting deployment-specific user context
Common Usage Patterns
1. Header-based Identification
2. Environment Variable Identification
3. Token-based Identification
Important Notes
- The
userIdfield is required in the returned user identity object - If identification fails, return
null,None, or{ userId: 'anonymous' } - User identification happens once per session and is cached
- Any errors in the identify function are logged and fallback to anonymous tracking
- Additional fields beyond
userIdare included in analytics for segmentation
