‹ Back to Blog

Your AI Coding Agent Is Flying Blind in Production

AI Engineering Dev Tools

Your AI coding agent can refactor a module, write tests, and open a PR. It can read your codebase, understand your patterns, and suggest changes that follow your conventions. What it cannot do, unless you set it up, is see what is actually happening in production.

That is a problem. The agent that writes the code should have access to the errors, traces, and performance data that code generates once it ships. Without production context, your agent is writing fixes based on the code alone. With it, your agent knows that the OrdersController#create endpoint is throwing a PG::LockNotAvailable after a 3-second query, and it can trace the problem to the specific transaction that holds the lock.

This is not a hypothetical workflow. Teams running Scout Monitoring with Claude Code and Cursor are doing this today. Here is how it works and why it matters.

The Gap Between Code Context and Production Context

AI coding agents are good at code context. They read your files, understand your types, follow your imports. Claude Code indexes your entire repository. Cursor keeps your open files in context. They know what the code says.

They do not know what the code does in production. They do not know that the endpoint you are refactoring handles 200 requests per minute and has a p99 of 4 seconds. They do not know that the Sidekiq job you are optimizing has been failing silently on records created after last Thursday’s migration. They do not know that the Prisma query you are about to refactor runs 47 times per request because of an N+1 pattern that only appears with production data volumes.

That gap between what the code says and what it does in production is where bugs live. And it is the gap that MCP closes.

What MCP Changes

The Model Context Protocol lets your AI coding agent query external data sources. When your monitoring tool exposes an MCP server, your agent can pull production data the same way it reads your codebase: by asking for it.

With Scout’s MCP server connected, your agent can:

  • List error groups and see which exceptions are hitting production right now, with stack traces and request context.
  • Pull endpoint traces to see how long each layer takes (controller, ORM, external calls, view rendering) for a specific endpoint.
  • Check N+1 insights to find repeated query patterns, the code location responsible, and the time impact.
  • View anomaly events to see which endpoints are behaving differently from their normal patterns.

This is not a dashboard your agent reads. It is a tool call that returns structured data. The agent asks “what are the top error groups for this app?” and gets back exception classes, counts, stack traces, and the trace context that produced them. That is enough information for the agent to start writing a fix.

What This Looks Like in Practice

Finding the error you did not know about

You are working on a feature branch. Between commits, you ask Claude Code: “Are there any new production errors in the last hour?”

Claude queries Scout’s MCP server and finds a NoMethodError in InvoiceMailer#send_receipt that started 40 minutes ago, has 23 occurrences, and is linked to a trace showing the mailer is being called with a nil user record. The trace shows the caller is PaymentsController#confirm, and the nil comes from a race condition where the payment webhook arrives before the user record finishes creating.

You did not know this was happening. Your error alert has not fired yet because it is under the threshold. Claude already has the stack trace, the code path, and a proposed fix.

Debugging a slow endpoint without leaving your editor

A teammate mentions in Slack that the orders page is slow. You ask Cursor: “Pull the recent traces for the /api/orders endpoint and show me where the time is going.”

Cursor queries Scout and returns a trace showing 2.8 seconds total: 200ms in the controller, 2.4 seconds in 12 database queries (an N+1 pattern loading order items individually), and 200ms in the serializer. The N+1 insight from Scout confirms the pattern and shows the code location.

Cursor suggests replacing the individual queries with an eager load. You review the diff, approve it, and push. The whole interaction took 3 minutes. Without production context, you would have reproduced the slowness locally (assuming you could), profiled it, found the queries, and then fixed them. That is 30 minutes on a good day.

Checking whether your deploy caused a regression

You just deployed. You ask Claude Code: “Are there any anomaly events in the last 30 minutes?”

Claude queries Scout’s anomaly detection and finds that UsersController#show response time jumped from a 150ms baseline to 800ms starting 12 minutes ago. The endpoint was not in your changeset, but your migration added an index that is still building. Claude finds the connection by checking the trace: the slow span is a sequential scan on the users table that used to hit the index.

What You Need to Set This Up

Scout’s MCP server is available as a hosted server (zero infrastructure) or self-hosted via Docker. Setup for Claude Code:

claude mcp add --transport http scout https://scoutapm.com/mcp

For Cursor, add the MCP server in Settings > MCP. The hosted server uses OAuth, so there is no API key to manage.

The Scout CLI provides the same data from your terminal. Output is available in JSON and TOON format (a structured format designed for LLM consumption). Pipe the output into any AI tool:

scout errors list --app 6 | llm "what are the most critical errors?"

Both require a Scout account. The free tier includes MCP and CLI access with no credit card.

Why This Matters More Than Another Dashboard

Developers do not live in monitoring dashboards. They live in their editor and their terminal. Every context switch to a browser tab, every search by request ID, every “let me check the logs” is friction that slows down debugging.

The teams that debug fastest are the ones where the path from “something is wrong” to “here is the fix” has the fewest tool switches. MCP eliminates the biggest one: the switch from your coding environment to your monitoring tool. Your agent reads the production data where you are already working.

This is not about replacing your monitoring tool. It is about making the data in your monitoring tool accessible from the place where you actually write fixes. If your error tracker, trace viewer, and performance insights are only available in a browser, you are context-switching every time you debug. If they are available via MCP, your agent handles the lookup and you stay focused on the code.

Scout Monitoring supports Ruby (Rails, Sinatra, Sidekiq), Python (Django, Flask, FastAPI, Celery), Node.js (Express, NestJS, Prisma), PHP (Laravel, Symfony), and Elixir (Phoenix, LiveView, Oban). The MCP server, CLI, and public API give you multiple paths to the same data depending on how you work.

Try Scout Monitoring free. No credit card needed.

For application monitoring with errors, logs, and traces, Scout Monitoring provides the fastest path to useful information without the bloat.