MCP Integration
Connect AI agents and IDEs to Neatlogs via the Model Context Protocol. Query traces, manage fixes, and integrate observability into your workflows.
The Model Context Protocol (MCP) is a standard that allows AI agents and IDEs to interact with external systems through a unified tool interface. Neatlogs exposes a complete MCP server that lets Claude, coding agents, and IDE plugins access observability data, search traces, and manage fixes directly from your agent workflows.
What You Can Do
With Neatlogs MCP, your agents can:
- Search production traces — Query by text, framework, error type, latency, cost
- Get full trace context — Fetch complete span trees with inputs, outputs, code locations
- List detections — See what anomalies, regressions, and errors are active
- Track detection trends — Analyze hourly/daily occurrence rates
- Read fixes — List all suggestions/fixes with root cause and recommended actions
- Manage fixes — Accept, dismiss, update status, and mark as deployed
- Log agent work — Push traces back to Neatlogs from your agent's execution
- Investigate fixes — Review investigation steps and collaborate on solutions
Getting Started
Step 1: Get Your API Key
- Go to Settings → API Keys in Neatlogs
- Click Create API Key
- Copy the key and store securely
Your API key grants full access to your project data and tools. Treat it like a password and never commit it to version control. Store it in environment variables or a secrets manager.
Step 2: Connect Your Agent or IDE
Use the API key to authenticate with the MCP server at:
https://neatlogs.com/mcpAuthentication: Include the key in either header:
Authorization: Bearer <your-api-key>x-api-key: <your-api-key>
Step 3: Start Using Tools
Once connected, your agent can call any enabled tool. Example: search traces for a specific error.
Check which tools are available on your deployment by calling the unauthenticated /health endpoint. It returns the list of enabled tools without requiring credentials.
Connection Methods
Best for: Claude Code, agents, IDE plugins
Stateful sessions that you can reuse for multiple requests.
POST https://neatlogs.com/mcp
Authorization: Bearer <your-api-key>
Content-Type: application/json
mcp-session-id: <optional-session-id>
{
"jsonrpc": "2.0",
"id": 1,
"method": "call_tool",
"params": {
"name": "search_traces",
"arguments": {
"query": "timeout"
}
}
}Features:
- Stateful sessions (reuse connections)
- Include
mcp-session-idheader to resume - GET, POST, DELETE supported
- Rate limited: 60 requests/minute
- Best for agents and IDEs
Best for: Long-lived connections, real-time updates
Event-based streaming with persistent connections.
GET https://neatlogs.com/mcp/sse
Authorization: Bearer <your-api-key>
# Connection opens, receives events
# Then POST messages to:
POST https://neatlogs.com/mcp/messages?sessionId=<session-id>Features:
- Server-sent events (SSE)
- Keep connection alive for streaming
- Legacy clients and real-time use cases
- Not rate-limited (won't break long-lived connections)
Best for: Verifying deployment status, discovering available tools
No authentication required. Public endpoint.
GET https://neatlogs.com/mcp/health
Response:
{
"status": "ok",
"tools_enabled": [
"ping",
"whoami",
"log_trace",
"search_traces",
"triage_list",
...
]
}Use cases:
- Check if MCP server is up
- Discover which tools are enabled
- No credentials needed
Authentication Patterns
Bearer Token (Standard)
Authorization: Bearer sk_proj_abc123def456...Preferred by MCP clients. Works with any integration.
Legacy Header (x-api-key)
x-api-key: sk_proj_abc123def456...Older integrations. Still supported for backward compatibility.
API Key Format
Keys start with sk_proj_ and are unique per project. Each key grants access to one project only.
Session Management
Creating a Session
First request creates a new session automatically:
POST https://neatlogs.com/mcp
Authorization: Bearer <your-api-key>Server returns mcp-session-id header. Store this for resuming.
Resuming a Session
Reuse an existing session by including the header:
POST https://neatlogs.com/mcp
Authorization: Bearer <your-api-key>
mcp-session-id: a1b2c3d4-e5f6-7890-abcd-ef1234567890Same session, same tools advertised, same context.
Cleaning Up
Send DELETE to tear down a session:
DELETE https://neatlogs.com/mcp
Authorization: Bearer <your-api-key>
mcp-session-id: a1b2c3d4-e5f6-7890-abcd-ef1234567890Sessions also auto-cleanup after inactivity.
Rate Limiting
- Limit: 60 requests per 60 seconds per API key
- Applies to: POST and DELETE only
- Excludes: GET (SSE streaming) to avoid breaking long-lived connections
- Response: 429 Too Many Requests if exceeded
Retry with exponential backoff. Most tools complete in under 1 second so 60 req/min is generous for typical workflows.
Tool Overview
| Tool | Purpose | Use Case |
|---|---|---|
| ping | Health check | Verify connection |
| whoami | Get project ID | Confirm authentication |
| search_traces | Full-text search | Find errors, latency spikes |
| get_trace_context | Fetch span tree | View execution details |
| list_detections | List active issues | See what's being monitored |
| get_detection_trend | Trend analysis | Track detection frequency |
| log_trace | Push traces | Agent reports its work |
| triage_list | List fixes | See all suggestions |
| triage_get | Fix details | Review root cause + action |
| triage_get_investigation | Investigation context | Read investigation thread |
| triage_list_steps | Investigation steps | See agent's analysis steps |
| triage_accept | Accept fix | Move to Kanban board |
| triage_dismiss | Reject fix | Mark as false positive |
| triage_update_status | Change status | Move through workflow |
| triage_update | Edit fix fields | Update title, severity, etc. |
See /reference/mcp-tools.mdx for detailed schemas and examples.
Common Workflows
Workflow 1: Agent Debugging Its Own Output
1. Agent completes a task
2. Calls log_trace() to push execution trace
3. Calls search_traces("latency > 5s") to find similar slow traces
4. Calls get_trace_context(trace_id) to compare
5. Uses context to improve next attemptWorkflow 2: IDE Plugin Finding Root Causes
1. Developer sees error in IDE
2. Plugin calls search_traces(error_message)
3. Fetches matching production traces
4. Shows top detections via list_detections()
5. Links to Neatlogs fixes panelWorkflow 3: Agent Managing Fixes
1. Agent sees triage_list() shows 5 draft fixes
2. Calls triage_get(fix_id) to review root cause
3. Dispatches fix to Claude Code
4. Calls triage_update_status(fix_id, "in_progress")
5. After deployment, calls triage_update_status(fix_id, "resolved")Workflow 4: Monitoring Regressions
1. Agent calls list_detections()
2. Filters for "prompt_regression"
3. Calls get_detection_trend("prompt_regression", "day")
4. If trending up, creates alert or investigationError Handling
Authentication Errors
| Status | Reason | Fix |
|---|---|---|
| 401 | Missing API key | Include Authorization header |
| 401 | Invalid API key | Check key spelling/expiration |
| 403 | Session belongs to different project | Use correct API key for session |
Validation Errors
| Status | Reason | Fix |
|---|---|---|
| 400 | Missing required parameter | Check tool schema in reference |
| 400 | Invalid UUID format | Ensure IDs are valid UUIDs |
| 400 | Unknown tool name | Verify tool is enabled via /health |
Server Errors
| Status | Reason | Fix |
|---|---|---|
| 429 | Rate limit exceeded | Wait before retrying |
| 500 | Internal server error | Retry with backoff; contact support if persistent |
All error responses include an error field with details.
Best Practices
Do's:
- Store API keys securely (env vars, secrets manager)
- Reuse sessions when making multiple calls
- Include descriptive error handling
- Set reasonable timeouts (15-30 seconds)
- Log tool calls for debugging
Don'ts:
- Hardcode API keys in code
- Create a new session for each request
- Assume tools are always enabled (check
/healthfirst) - Make synchronous requests that block your workflow
- Share API keys across teams (create one per integration)
Troubleshooting
"API key required"
Missing or malformed Authorization header. Ensure header is present and format is correct.
"Invalid API key"
Key doesn't exist or is revoked. Regenerate in Settings → API Keys.
"Too many requests"
Hit rate limit (60/min). Implement exponential backoff or reduce call frequency.
"Unknown sessionId"
Session expired or doesn't exist. Create a new session by omitting the header.
"Session belongs to different project"
Using API key from one project to access another project's session. Create new session with correct key.
Tools not appearing in /health
Tool is disabled in backend tools.yaml. Contact your ops team to enable it.
Next Steps
- Read the MCP Tools Reference for detailed tool schemas
- Check Span Kinds for MCP_TOOL documentation
- See Long-Running Sessions for session monitoring from agents