MCP Integration
Connect with user OAuth, discover permitted NeatLogs actions, and distinguish user MCP from legacy project-key tools.
User-scoped MCP lets an AI client discover and use NeatLogs operations as the signed-in person. Current organization/project roles, OAuth scopes, enabled capabilities and limits still apply to every action. Signing in does not grant additional roles.
This guide covers native remote setup once it is enabled and qualified in your deployment. Use the connection instructions shown by Home → Connect MCP for your deployment. Until that flow is enabled and qualified, follow its existing proxy instructions. The native clients covered here are Codex, Claude Code, Cursor, current VS Code, Gemini CLI and the current Devin Local generation of Windsurf. Each still requires live acceptance on the deployed regional endpoint; legacy Windsurf/Cascade requires an upgrade for this native flow.
User OAuth connection
For ordinary work, connect your AI client directly to the regional /mcp/user endpoint, approve access in your browser, then choose an accessible organization or project. You do not need to install the NeatLogs CLI, create an OAuth application, find your user ID or paste a project API key.
Your AI client manages its OAuth credentials and refresh. Existing roles, scopes, confirmations, feature availability and limits still control every action. Credential-producing actions use the optional local custody companion described below.
Get the correct connection instructions
Open Home → Connect MCP. Copy the server URL and commands supplied there. The URL identifies the deployment and region; use it for an EU or dedicated deployment instead of guessing a host.
The examples below use the US endpoint. Replace it with your setup's URL when different. The new connection is named neatlogs-remote, separate from an existing legacy neatlogs or proxy neatlogs-user entry. Inspect existing connections before adding the same name: a client may replace its configuration, including tool restrictions and approval settings.
Codex
Use a current Codex release with CIMD support. If sign-in reports Dynamic client registration not supported, update your Codex installation and retry. No NeatLogs CLI installation is required for this connection.
Run in your terminal and complete browser consent when prompted:
codex mcp add neatlogs-remote --url https://ingest.neatlogs.com/mcp/userCodex can start OAuth during mcp add. Only if sign-in did not complete, run:
codex mcp login neatlogs-remoteThen inspect the connection and open Codex:
codex mcp list
codexInside Codex, /mcp shows the active connection. On later days, open Codex normally; reconnect or sign in again when required. Source: Codex MCP documentation.
Claude Code
Run in an interactive terminal:
claude mcp add --transport http --scope user neatlogs-remote https://ingest.neatlogs.com/mcp/user
claude mcp login neatlogs-remote
claude mcp list
claudeApprove access in the browser. You can also authenticate from /mcp inside Claude Code. If a coding agent cannot complete interactive sign-in, the user performs that step in their own terminal. --scope user saves the client configuration across projects on this machine; it does not change NeatLogs account roles. Source: Claude Code MCP documentation.
Cursor
Merge into ~/.cursor/mcp.json (personal) or .cursor/mcp.json (project):
{"mcpServers":{"neatlogs-remote":{"url":"https://ingest.neatlogs.com/mcp/user","auth":{"CLIENT_ID":"neatlogs-native/v1/cursor","scopes":["context:read","observability:read","offline_access"]}}}}Open Customize → MCPs, enable the server and sign in. The public client ID is not a credential. Cursor uses http://localhost:8787/callback on desktop and https://www.cursor.com/agents/mcp/oauth/callback on web. No fabricated cursor mcp add command is needed. Source: Cursor MCP documentation.
Windsurf / current Devin Local
The current Windsurf documentation redirects to Devin Local. Merge into ~/.config/devin/mcp_config.json (personal; Windows: %APPDATA%\devin\mcp_config.json) or .devin/mcp_config.json (project):
{"mcpServers":{"neatlogs-remote":{"url":"https://ingest.neatlogs.com/mcp/user","transport":"http","oauthClientId":"neatlogs-native/v1/windsurf","oauthScopes":["context:read","observability:read","offline_access"]}}}Open Customize → MCPs → Authenticate. The current local harness uses an ephemeral http://127.0.0.1:PORT/callback receiver. For Devin CLI, the equivalent commands are:
devin mcp add --scope user neatlogs-remote https://ingest.neatlogs.com/mcp/user --oauth-client-id neatlogs-native/v1/windsurf --scopes context:read,observability:read,offline_access
devin mcp login neatlogs-remote
devin mcp list
devinThese commands require Devin CLI; do not run them as a windsurf command. Legacy Cascade's serverUrl format and DCR-only flow are not this supported generation: upgrade to current Devin Local rather than installing a mandatory bridge or copying a bearer token. Sources: current Devin Local customization, pre-registered OAuth clients, command reference.
VS Code / GitHub Copilot
Use a current VS Code with oauth.clientId support (documented in 1.123). Merge into .vscode/mcp.json, or use MCP: Open User Configuration for personal configuration:
{"servers":{"neatlogs-remote":{"type":"http","url":"https://ingest.neatlogs.com/mcp/user","oauth":{"clientId":"neatlogs-native/v1/vscode"}}}}Run MCP: List Servers, start/trust NeatLogs, sign in and enable its tools in Copilot agent chat. URL-only Add Server is insufficient for this pre-registered client. No client secret is required. Use the desktop flow. Browser-only VS Code requires separate regional OAuth and CORS qualification; the native URL-handler fallback is not a claim of browser-hosted support. Sources: configuration reference, static client support, OAuth callback implementation.
Gemini CLI
Merge into ~/.gemini/settings.json (personal) or .gemini/settings.json (project):
{"mcpServers":{"neatlogs-remote":{"httpUrl":"https://ingest.neatlogs.com/mcp/user","oauth":{"enabled":true,"clientId":"neatlogs-native/v1/gemini-cli","scopes":["context:read","observability:read","offline_access"]}}}}Then run:
gemini mcp list
geminiInside Gemini:
/mcp auth neatlogs-remote
/mcp listThe CLI add command alone does not configure this pre-registered client ID; use the manual configuration rather than inventing an OAuth flag. Endpoint discovery remains enabled. Do not set an explicit issuer requiring an iss response that NeatLogs does not advertise. The callback is http://localhost:PORT/oauth/callback. Source: Gemini CLI OAuth documentation.
The examples with explicit scope lists request a read-oriented starting grant. VS Code discovers the resource scopes and can request write scopes when the configured ceiling permits them; inspect the browser consent screen before approval. Home → Connect MCP supplies the current approved scopes for other permitted actions. A public OAuth client ID is not a secret or a user identity. All six native remote clients use browser authorization with S256 PKCE; the existing CLI device flow remains separate.
Manual setup for Codex and Claude Code
Codex can merge this into ~/.codex/config.toml, then run codex mcp login neatlogs-remote if needed:
[mcp_servers.neatlogs-remote]
url = "https://ingest.neatlogs.com/mcp/user"Claude Code can merge this into project .mcp.json, accept the project-server trust prompt and sign in through /mcp:
{"mcpServers":{"neatlogs-remote":{"type":"http","url":"https://ingest.neatlogs.com/mcp/user"}}}Keep other servers and existing tool approvals when merging a configuration. Use the URL and current scopes from setup for the selected deployment.
Verify identity, context and one operation
Ask:
Use NeatLogs to list my projects, then ask which project to use.This first check uses context:read. If the grant also includes observability:read, select a project and ask for its failed traces from the last 24 hours.
The agent discovers an action, reads its descriptor, prepares it and uses the declared execution tool. The descriptor supplies required inputs, scopes, permissions, limits, confirmation and recovery. A successful read should match the equivalent native Public API/CLI request. Copying commands or marking a Home step done does not verify a connection.
Optional local secret custody
For credential-producing actions, choose your client in Home → Connect MCP, then open Advanced → View local companion setup. When a compatible published companion version is configured, it supplies a version-pinned npx command, approved companion client ID, endpoint, issuer and consent scopes. Production uses a qualified stable published pin such as neatlogs-cli@0.2.2. After the updated backend is serving, a missing pin or prerelease candidate leaves the companion unavailable; native remote MCP remains available. Follow the availability message instead of using a developer test package. Package publication alone does not qualify a deployment. Node.js 22 or 24 is needed for this companion path. The remote client and companion have separate OAuth bindings.
Run the supplied companion sign-in command, then its Codex or Claude Code add command. The client launches neatlogs mcp proxy as a local child process. The proxy keeps wrapped-secret results outside the model and returns an invocation or local receipt ID.
Copy the supplied reveal command, replace INVOCATION_ID with that receipt ID and run it yourself in a local terminal. Never paste the revealed secret, access token or refresh token into a conversation or configuration. A browser chat cannot launch a companion on your computer. See the optional companion reference for commands and credential-vault behavior.
Disconnect and revoke access
For Codex:
codex mcp logout neatlogs-remote
codex mcp remove neatlogs-remoteThe inspected Codex CLI version removes local OAuth credentials during logout; it does not call the NeatLogs revocation endpoint. Removing configuration also does not prove server-side revocation. If immediate server revocation is required, arrange it with the authorized operator before discarding the credentials. This rollout does not add an account-level remote-grant revoke screen.
For Claude Code:
claude mcp logout neatlogs-remote
claude mcp remove neatlogs-remote --scope userClaude Code documents issuer revocation during logout. Verify that outcome for the deployed regional endpoint before treating access as revoked.
For the optional companion, use the supplied npx ... mcp logout command with the same endpoint, issuer and companion client ID used for sign-in. A server/network failure retains the local credential and reports an error. Companion logout cannot revoke a separate remote client's grant; ordinary CLI auth logout also manages a different credential binding.
Signing out does not cancel accepted jobs, delete saved results or roll back completed actions. Inspect accepted work through its declared lifecycle.
How CLI, Public API and MCP connect
Person/script → CLI → Public REST API ──────────────────┐
├→ Registered policies/handlers → Feature services
AI host → remote HTTP / optional local proxy → /mcp/user → Executor ───────┘ ↓
Databases, queues, workers
Backend operation definitions → live catalog → CLI discovery / MCP search and describeThe CLI is a terminal interface for explicit commands and scripts. MCP is a protocol through which an AI host discovers and calls tools. The CLI package includes an optional MCP bridge, neatlogs mcp proxy, for local custody. Ordinary remote connections go directly from the AI host to /mcp/user. Both interfaces reuse registered product behavior; MCP dispatches internally instead of making an HTTP loopback request.
The user MCP catalog reference explains discovery, credential exclusions, execution and recovery. Public API/CLI and MCP share contracts, while authentication, transport, secret custody and applicable limits can differ. The action list is deployment- and credential-dependent; discovery is not execution permission.
Activity and recovery
Applicable canonical operation attempts are recorded in access auditing with actor, operation, context, request ID and outcome. Feature and credential lifecycle audits record their own events. Audit visibility still requires its normal entitlement and role. This is not a complete transcript of your conversation, every metadata lookup or every rejected pre-authentication request.
Short-lived invocation state supports coordination and recovery; it is separate from durable activity auditing. After a lost response, inspect the original invocation or use its declared durable recovery path. Do not create a new mutation or job merely because a client timed out. A cancellation request does not prove that accepted work rolled back.
An explicit pre-preparation capacity rejection can be resumed after normal expiry. Do not clear accounting/receipt ledgers, change identities or switch projects to bypass a limit. Large results use the declared complete-result/chunk protocol, not silent truncation.
Legacy project-key MCP
The remaining sections document the existing /mcp project-key connection and its named tools. Keep an existing legacy configuration if you still use that interface. It is separate from /mcp/user; adding OAuth support does not silently migrate project-key configurations. The legacy wizard below is not the user-OAuth setup flow.
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 an MCP server that lets coding agents and IDE plugins access observability data, search traces, author detections, and work on the fixes behind incidents directly from an agent workflow.
What You Can Do
With Neatlogs MCP, your agents can:
- Search production traces - Free-text query with filters for workflow, framework, model, detection, duration, token count, errored spans, and cost
- Get full trace context - Fetch a trace's spans with inputs, outputs, code locations, detections, and evaluations
- Read analytics - Pull dashboard KPIs, cost, errors, latency, and tool breakdowns for a time window
- List detections - See which detections (Hallucination, Jailbreak, Task Failure, …) the project runs
- Track detection trends - Analyze hourly/daily/weekly occurrence rates
- Author detections - Dry-run a regex or conditional rule, then create the detection with a 14-day backfill
- Read fixes - List the fixes behind incidents, with root cause, evidence, and recommended actions
- Manage fixes - Accept, dismiss, update status, and edit fix fields
- Review fix history - List, fetch, and restore saved content versions
- Log agent work - Push traces back to Neatlogs from your agent's execution
- Investigate - Reload the investigation trail that produced a fix
In the dashboard, fixes appear with their incidents on the Incidents page. The MCP tools that work with them keep legacy names: the triage_ prefix, triage_id parameters, and "fix" in descriptions and errors.
Getting Started
Step 1: Get Your API Key
Each Neatlogs project has its own API key. Open Settings → Project → API keys in the dashboard with the project selected, and copy its key.
A project API key reads your project's data, and through MCP it can also log traces, create detections, and update fixes. 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
The fastest path is the wizard, which wires the MCP server into Claude Code or Cursor for you:
npx @neatlogs/wizard@latest mcpIt prompts for the project API key. For an EU project, add --region eu.
To connect manually, add a neatlogs entry to your client's MCP config (.mcp.json for Claude Code, .cursor/mcp.json for Cursor):
{
"mcpServers": {
"neatlogs": {
"type": "http",
"url": "https://ingest.neatlogs.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_PROJECT_KEY"
}
}
}
}The MCP server lives at /mcp on the same host as your SDK endpoint: https://ingest.neatlogs.com/mcp in the US region, https://eu.ingest.neatlogs.com/mcp in the EU region, or your dedicated deployment's ingest host.
Authentication: Include the key in either header:
Authorization: Bearer <your-api-key>(preferred — what most MCP clients send)x-api-key: <your-api-key>(legacy, still accepted)
Step 3: Verify and Start Using Tools
Restart your editor and the Neatlogs tools appear in your agent's tool list. Ask the agent to call ping to verify the connection, and whoami to confirm which project the session is bound to. From there it can call any tool — for example, search traces for a specific error.
Connection Methods
Best for: Claude Code, Cursor, agents, IDE plugins
Stateful sessions that you can reuse for multiple requests. The first initialize request creates a session; the server returns its id in the mcp-session-id response header.
POST https://ingest.neatlogs.com/mcp
Authorization: Bearer <your-api-key>
Content-Type: application/json
Accept: application/json, text/event-stream
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": { "name": "my-agent", "version": "1.0" }
}
}Then call tools on the session, passing the id back in the mcp-session-id header:
POST https://ingest.neatlogs.com/mcp
Authorization: Bearer <your-api-key>
Content-Type: application/json
Accept: application/json, text/event-stream
mcp-session-id: <session-id-from-initialize>
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "search_traces",
"arguments": {
"query": "timeout"
}
}
}Features:
- Stateful sessions (reuse connections)
- Include
mcp-session-idheader to resume - GET, POST, DELETE supported
- POST bodies must be
Content-Type: application/json, up to 1 MB - Tool calls count toward the project's rate limit
- Best for agents and IDEs
Best for: Legacy clients that don't speak streamable HTTP
Event-based streaming with persistent connections.
GET https://ingest.neatlogs.com/mcp/sse
Authorization: Bearer <your-api-key>
# Connection opens, receives events
# Then POST messages to:
POST https://ingest.neatlogs.com/mcp/messages?sessionId=<session-id>Features:
- Server-sent events (SSE)
- Keep connection alive for streaming
- The GET stream is not rate-limited (won't break long-lived connections); tool calls posted to
/mcp/messagesare
Authentication Patterns
Bearer Token (Standard)
Authorization: Bearer <your-project-api-key>Preferred by MCP clients. Works with any integration.
Legacy Header (x-api-key)
x-api-key: <your-project-api-key>Older integrations. Still supported for backward compatibility.
Scope
API keys are unique per project. Each key grants access to one project only - the session sees only that project's traces, detections, and fixes.
Service accounts
An organization service-account token (nlsa_ prefix) can also open a session. Send the target project in an x-project-id header. These sessions expose only read tools, each checked against the account's permissions and scopes. See the MCP Tools Reference.
Session Management
Creating a Session
The initialize request creates a new session:
POST https://ingest.neatlogs.com/mcp
Authorization: Bearer <your-api-key>The server returns the session id in the mcp-session-id response header. Store this for subsequent calls.
Resuming a Session
Reuse an existing session by including the header:
POST https://ingest.neatlogs.com/mcp
Authorization: Bearer <your-api-key>
mcp-session-id: a1b2c3d4-e5f6-7890-abcd-ef1234567890Same session, same tools advertised, same context. Sessions are bound to the project and key that created them - reusing a session id with a different key returns 403.
Cleaning Up
Send DELETE to tear down a session:
DELETE https://ingest.neatlogs.com/mcp
Authorization: Bearer <your-api-key>
mcp-session-id: a1b2c3d4-e5f6-7890-abcd-ef1234567890Sessions also close when the underlying connection closes or after 10 minutes without requests. If a session id stops resolving (404 Session not found), initialize a new one.
Capacity
Neatlogs caps concurrent sessions at 128 per project and 256 per organization. Beyond that, new sessions get 429 with a Retry-After header. Reuse sessions instead of opening one per request.
Rate Limiting
- Limit: 60 tool calls per 60 seconds per project by default
- Shared by: every session and key for the project
- Counts:
tools/callrequests, exceptping - Doesn't count:
initialize,tools/list, session teardown, and GET/SSE streams - Response:
429with codeMCP_TOOL_CALL_RATE_LIMITED,retryAfterSeconds, and aRetry-Afterheader. Responses also carryRateLimit-Limit,RateLimit-Remaining, andRateLimit-Resetheaders.
Retry after the indicated delay, with backoff. Each tool call has a 15-second time limit.
Tool Overview
The default project-key catalog includes the 26 tools below. Deployments and authentication scope can change which tools are available; use the authenticated session's tools/list as the source of truth.
| Tool | Purpose | Use Case |
|---|---|---|
| ping | Health check | Verify connection |
| whoami | Get project ID | Confirm authentication |
| search_traces | Keyword or semantic search | Find errors, slow or expensive traces |
| get_trace_context | Fetch a trace's spans and metrics | View execution details |
| get_trace_evaluations | Read evaluation answers and judge runs | Check how a run was scored |
| log_trace | Push traces | Agent reports its work |
| get_project_analytics | Dashboard aggregates | KPIs, cost, errors for a window |
| list_detections | List detections | See what's being monitored |
| get_detection_trend | Trend analysis | Track detection frequency |
| get_detection_status | Detection state | Check activation and backfill |
| get_detection_capabilities | Detection engines and schemas | Plan a new detection |
| list_detection_groups | List detection groups | Pick a group_id |
| create_detection_group | Create a group | When no group fits |
| preview_detection | Dry-run a rule | Check matches before creating |
| create_detection | Create a detection | Start monitoring with a 14-day backfill |
| triage_list | List fixes | See open work |
| 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_list_versions | List fix versions | Browse saved content versions |
| triage_get_version | Fetch fix version | Read one version snapshot by number |
| triage_restore_version | Restore fix version | Roll content back to an older version |
| triage_accept | Accept fix | Move a draft onto the board |
| triage_dismiss | Dismiss fix | Archive a false positive |
| triage_update_status | Change status | Move across in_progress / resolved / archived |
| triage_update | Edit fix fields | Update title, severity, label, content |
See the MCP Tools Reference 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(query: "timeout", min_duration: 5000) 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(query: error_message)
3. Fetches matching production traces
4. Shows top detections via list_detections()
5. Links to the matching incident in NeatlogsWorkflow 3: Agent Working on a Fix
1. Agent calls triage_list(status: "draft") and finds five drafts
2. Calls triage_get(triage_id) to review root cause
3. Asks the user for their team email, then calls triage_accept(triage_id, user_email)
4. Calls triage_update_status(triage_id, user_email, "in_progress") and implements the change
5. After deployment, calls triage_update_status(triage_id, user_email, "resolved", resolution_note)Workflow 4: Monitoring Regressions
1. Agent calls list_detections()
2. Picks a detection to watch, e.g. "Hallucination"
3. Calls get_detection_trend(detection_name: "hallucination", period: "7d", granularity: "day")
4. If trending up, digs into matching traces via search_traces(detection_name: "hallucination")Workflow 5: Creating a Detection
1. Agent calls list_detection_groups() and picks a group_id (or create_detection_group)
2. Calls preview_detection(type: "regex", config: { output_pattern: "payment failed" })
3. If total_count > 0, calls create_detection(display_name, group_id, type, config)
4. Calls get_detection_status(detection_id) to follow the 14-day backfillError Handling
Authentication Errors
| Status | Reason | Fix |
|---|---|---|
| 401 | Missing API key | Include the Authorization header |
| 401 | Invalid API key | Check the key against Settings → Project → API keys |
| 403 | Session belongs to a different project or key | Use the key that created the session, or initialize a new one |
Validation Errors
| Status | Reason | Fix |
|---|---|---|
| 400 | Missing mcp-session-id on DELETE | Include the session header |
| 404 | Unknown session id | Initialize a new session |
| 415 | POST without Content-Type: application/json | Send JSON with that content type |
Server Errors
| Status | Reason | Fix |
|---|---|---|
| 429 | Tool-call rate limit or session capacity exceeded | Wait for Retry-After, then retry |
| 503 | Server draining or capacity temporarily unavailable | Retry after Retry-After |
| 500 | Internal server error | Retry with backoff; contact support if persistent |
Transport errors return JSON with an error field. A tool that fails returns a normal result with isError: true and an errorCode such as invalid_argument, not_found, or not_enabled; see Errors. Calling a tool that isn't enabled returns a JSON-RPC error - disabled tools are never advertised in tools/list, so a well-behaved client won't hit this.
Best Practices
Do's:
- Store API keys securely (env vars, secrets manager)
- Reuse sessions when making multiple calls
- Verify the connection with
ping/whoamibefore relying on it - Set reasonable client timeouts (15-30 seconds)
- Ask the user before calling write tools, which record their email as the actor
- Log tool calls for debugging
Don'ts:
- Hardcode API keys in code
- Create a new session for each request
- Assume a tool is available — check the advertised
tools/listfor the session - Make synchronous requests that block your workflow
- Share API keys across teams (each key exposes its whole project)
Troubleshooting
"API key required"
Missing or malformed Authorization header. Ensure the header is present and the format is correct.
"Invalid API key"
Key doesn't match any project. Copy it again from Settings → Project → API keys, and check that the MCP URL matches the project's region.
"Too many requests"
The project's tool-call budget (60 per minute by default) is used up, across all of its sessions. Wait for Retry-After and reduce call frequency.
"Session not found" / "Unknown sessionId"
Session was torn down, expired after 10 idle minutes, or the connection closed. Initialize a new session (omit the mcp-session-id header on the next initialize).
"Session belongs to a different project"
The session was created with a different key. Create a new session with the key you're using now.
A tool or parameter returns not_enabled
Some advertised parameters, such as fields on search_traces and selective-context options on get_trace_context, are not enabled yet. Omit them.
A tool is missing from tools/list
Tools are enabled per deployment and authentication scope. Initialize an authenticated session and call tools/list to see the tools that session can use. Call ping to check connectivity. Refresh your client if it is pinned to an older tool list; the hosted /mcp/health endpoint is not a public, unauthenticated check.
Next Steps
- Read the MCP Tools Reference for detailed tool schemas
- Check Span Kinds for MCP_TOOL documentation
- See Long-Running Sessions to follow a Cursor cloud agent run from an incident until it opens a pull request
