# Bulk resolving errors using MCP tools

The Better Stack [MCP server](https://betterstack.com/docs/ai-sre/mcp-server-comparison/) allows your AI coding agent to interact with your error data directly from your terminal.

This enables you to **automate your debugging workflow**, from fetching error details to creating pull requests and resolving the issues in Better Stack without opening the browser.

<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
  <iframe 
    style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;" 
    src="https://www.youtube.com/embed/u2tqAXKkb4c" 
    title="YouTube video player" 
    frameborder="0" 
    allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" 
    referrerpolicy="strict-origin-when-cross-origin" 
    allowfullscreen>
  </iframe>
</div>

The entire workflow, from identifying an error to resolving it, can be handled by an AI agent in your terminal. This includes:

-   Fetching **error details and stack traces** for an application.
-   **Finding related errors** to be fixed together.
-   Creating a feature branch and a **pull request with the fix**.
-   Verifying that the fix has been deployed.
-   **Resolving the error** and all its occurrences in Better Stack.

## Try it out in 10 minutes

First, make sure you have [an application sending errors to Better Stack](https://betterstack.com/docs/errors/start/#integrate-in-less-than-5-minutes), and and AI agent such as Claude Code with [Better Stack MCP server integrated](https://betterstack.com/docs/getting-started/integrations/mcp/#getting-started).

### Step 1: List your errors

Navigate to your project's directory and ask your AI agent to list the current errors for your application.

```
[label Example prompt]
Give me all the error details for this application.
```

Your agent will use the MCP tools to find the correct application based on your current directory and return a summary of the latest errors.

### Step 2: Investigate the error

Pick an error from the list and ask your agent for its full details. You can also ask it to find related errors that can be fixed at the same time.

```
[label Example prompt]
Get the details of the security error. Are there any other errors
related to this one so they can be fixed together?
```

The agent will return the root cause of the issue, often with a suggested fix.

### Step 3: Create a pull request

Once you have enough information, instruct your agent to create a new branch and open a pull request with a fix.

```
[label Example prompt]
Fix the security issue in a new feature branch and create a pull request.
```

The agent will write the code and provide a link to the newly created pull request.

### Step 4: Review and merge

This is a manual step. Open the pull request, review the proposed changes, test them locally to ensure the bug is fixed, and then merge the PR into your main branch.

### Step 5: Resolve the issue in Better Stack

After merging the fix, pull the latest changes into your local branch. Then, you can ask your agent to confirm the fix is present and resolve the corresponding issue in Better Stack.

```
[label Example prompt]
Check that the fix is in place and if it is, resolve the issue
in Better Stack.
```

The agent will confirm the code changes and then use the MCP tools to mark the error and all its previous occurrences as **Resolved** in the Better Stack UI. You can repeat this process until all your application's errors are fixed.
