Base URL
Production:https://api.agnost.ai
Custom deployments may use different base URLs.
Authentication
All API requests require an organization ID provided via theX-Org-Id header.
Never expose your organization ID in client-side code. The SDKs are designed for server-side use only.
Common Headers
All endpoints require these headers:| Header | Value | Description |
|---|---|---|
Content-Type | application/json | Request body format |
X-Org-Id | {organization_id} | Your organization identifier |
Create Session
Creates a new analytics session for tracking MCP server interactions.Description
A session represents a single connection to an MCP server. Sessions are created when:- An MCP client connects to the server
- The SDK first initializes tracking
- A new server instance starts
Request Body
Unique identifier for this session (UUID format), generated by SDK
Name or identifier of the MCP client (e.g., “claude-desktop”, “vscode”, “custom-client”)
Type of connection (reserved for future use, can be empty)
IP address of the client (reserved for future use, can be empty)
List of tool names available on this MCP server
User identification data (shape defined by
identify function). Common fields:userId(string): Unique user identifier (recommended)email(string): User’s email addressrole(string): User’s role or permission level- Additional custom fields as needed
Response
Echo of the session ID from the request
Response Codes
200 OK
Session created successfully
201 Created
Session created successfully (alternative)
400 Bad Request
Invalid request body
401 Unauthorized
Missing or invalid organization ID
500 Internal Server Error
Server error
SDK Usage
Sessions are created automatically by the SDKs when tracking is enabled:- TypeScript
- Python
- Go
Record Event
Records an analytics event for a tool, resource, or prompt execution.Description
Events track individual interactions with MCP primitives (tools, resources, prompts). Each event includes:- What was called (primitive type and name)
- Performance metrics (latency)
- Success/failure status
- Optionally, input arguments and output results
Request Body
Session ID from the session creation response
Type of primitive:
"tool", "resource", or "prompt"Name of the tool/resource/prompt that was called
Execution time in milliseconds
Whether the execution succeeded (
true) or failed (false)JSON-encoded string of input arguments. Omitted if
disableInput: trueJSON-encoded string of output/result. Omitted if
disableOutput: truePrimitive Types
| Type | Description | Example |
|---|---|---|
tool | MCP tool execution | get_weather, search_database, send_email |
resource | MCP resource access | file://readme.txt, db://users |
prompt | MCP prompt usage | code_review_template, summarize_text |
Response
Whether the event was recorded successfully
Unique identifier for this event
Response Codes
200 OK
Event recorded successfully
201 Created
Event recorded successfully (alternative)
400 Bad Request
Invalid request body
401 Unauthorized
Missing or invalid organization ID
404 Not Found
Session ID not found
500 Internal Server Error
Server error
SDK Usage
Events are recorded automatically by the SDKs when tools are called:- TypeScript
- Python
- Go
SDK Behavior
Batching and Queuing
SDKs implement intelligent batching and queuing to optimize API usage:- TypeScript
- Python
- Go
- Events are queued and sent in batches (default: 5 events per batch)
- Configurable via
batchSizeoption - Can be disabled with
enableRequestQueuing: false
Retry Logic
- TypeScript
- Python
- Go
- Configurable retry attempts (default: 3)
- Configurable retry delay (default: 1000ms)
Error Handling
All SDKs follow a fail-safe approach:Analytics failures do not disrupt MCP server operation
Failed API calls are logged but not propagated
Tool execution continues even if event recording fails
Session Caching
Sessions are cached by the SDK to avoid redundant API calls:- Session IDs are stored in memory by session key
- Same session ID is reused for the lifetime of the server instance
- Cache is cleared on SDK shutdown
Privacy Controls
SDKs respect privacy configuration to exclude sensitive data:- TypeScript
- Python
- Go
Rate Limiting
Current implementation does not enforce rate limits, but this may change in future versions.
- Use SDK’s built-in batching to reduce request volume
- Implement exponential backoff for retries
- Monitor your organization’s API usage
Troubleshooting
Common Errors
400 Bad Request
400 Bad Request
Possible causes:
- Missing required fields
- Invalid JSON format
- Invalid UUID format for
session_id
401 Unauthorized
401 Unauthorized
404 Not Found
404 Not Found
Possible causes:
- Session ID does not exist (for events)
500 Internal Server Error
500 Internal Server Error
Possible causes:
- Backend service issue
Debug Logging
Enable debug logging in SDKs to troubleshoot API issues:- Python
- Go
API Versioning
Current API version: v1
/api/v1/...
Future versions will use /api/v2/, /api/v3/, etc.
Support
For API issues or questions:- Documentation: docs.agnost.ai
- GitHub Issues: agnost-sdks/issues
- Email: [email protected]
