---
title: "Agent Feedback"
description: "Let AI agents report problems with your MCP server's tools as Sentry User Feedback."
url: https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback/
---

# Collect Agent Feedback for Node.js

`@sentry/mcp` is in beta and may be subject to breaking changes.

AI agents that use your MCP server know when a tool is missing, fails, or returns something confusing. `@sentry/mcp` adds a feedback tool to your server so agents can report that friction. Each report arrives in [User Feedback](https://docs.sentry.io/product/user-feedback.md) with tags that describe what went wrong.

This only needs a Sentry SDK initialized with a DSN. We recommend also setting up [MCP Monitoring](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring.md), so errors your tools throw are captured too, and each report links to the trace of its `submit_feedback` call.

## [Install](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#install)

```bash
npm install @sentry/mcp
```

*Other available variations of the above snippet: yarn, yarn PnP, pnpm*

## [Add the Feedback Tool](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#add-the-feedback-tool)

Call `addFeedbackTool` with your `McpServer` from `@modelcontextprotocol/server`, or from `@modelcontextprotocol/sdk` 1.23.0 or newer:

```javascript
import * as Sentry from "@sentry/node";
import { McpServer } from "@modelcontextprotocol/server";
import { addFeedbackTool } from "@sentry/mcp";

const server = Sentry.wrapMcpServerWithSentry(
  new McpServer({ name: "orders", version: "1.0.0" })
);

server.registerTool("search_orders", { ... }, handler);

addFeedbackTool(server, { serverName: "Orders" });
```

This registers a `submit_feedback` tool that agents call when one of your tools is missing, fails, or gets in the way. By default, it also adds a hint to your other tools' errors that tells agents to report them with it. Learn more in [Point Agents at the Tool](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#point-agents-at-the-tool).

Agents describe each report with:

| Field         | Values                                      |
| ------------- | ------------------------------------------- |
| `task`        | What the user asked the agent to do         |
| `kind`        | `missing`, `broken`, `confusing`, or `idea` |
| `impact`      | `blocked`, `worked_around`, or `friction`   |
| `description` | What the agent tried and what went wrong    |
| `toolName`    | The tool the report is about, if any        |

In Sentry, reports are tagged with `feedback.kind`, `feedback.impact`, and `feedback.tool`. Filler descriptions such as `N/A` or `test` are rejected, and tokens and email addresses are removed from the message.

## [Point Agents at the Tool](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#point-agents-at-the-tool)

Agents rarely go looking for a feedback tool, so `addFeedbackTool` also adds a hint to the errors of your other tools:

```text
Upstream returned 500

If this keeps failing after you adjust your request, report it to the Orders team with `submit_feedback`.
```

Only the agent sees the hint. Errors in Sentry keep their original message, and your tools' successful results and `structuredContent` don't change.

### [Choose Which Errors Get the Hint](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#choose-which-errors-get-the-hint)

By default, upstream HTTP 4xx errors (bad input, auth, rate limits) and JSON-RPC client errors (invalid params) don't get the hint, since they aren't your server's to fix.

The `errorHints` option lets you change which errors get the hint:

* To build on the defaults and narrow them down further, pass a callback that combines `shouldHintFeedback` with your own logic.
* To replace the defaults, pass a callback with your own logic.
* To turn the error hints off for all tools, pass `false`.

```javascript
import { addFeedbackTool, shouldHintFeedback } from "@sentry/mcp";

// Keep the defaults, and also skip errors of your own type
addFeedbackTool(server, {
  errorHints: (toolName, failure) =>
    shouldHintFeedback(failure) && !(failure instanceof CustomError),
});

// Replace the defaults: hint on every error except those from search_orders
addFeedbackTool(server, {
  errorHints: (toolName) => toolName !== "search_orders",
});

// Turn the error hints off for all tools
addFeedbackTool(server, { errorHints: false });
```

### [Add the Hint to Other Results](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#add-the-hint-to-other-results)

Some results aren't errors but still suggest a problem, like a search that comes back empty. Add the hint to those yourself with `withFeedbackHint`, and tell the agent when to report it:

```javascript
import { withFeedbackHint } from "@sentry/mcp";

server.registerTool("search_orders", { ... }, async ({ query }) => {
  const orders = await searchOrders(query);
  const result = {
    content: [{ type: "text", text: JSON.stringify(orders) }],
    structuredContent: { orders },
  };

  return orders.length
    ? result
    : withFeedbackHint(result, "If this stays empty after you broaden the query");
});
```

To put the hint in your own text, use `feedbackHint`, which returns just the sentence:

```javascript
import { feedbackHint } from "@sentry/mcp";

// No order ord_123. If the ID is right, report it to the Orders team with `submit_feedback`.
const text = `No order ${id}. ${feedbackHint("If the ID is right")}`;
```

If you don't say when to report it, the hint starts with "If this keeps failing after you adjust your request".

## [Options](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#options)

| Option        | Default              | Description                                                                |
| ------------- | -------------------- | -------------------------------------------------------------------------- |
| `name`        | `submit_feedback`    | The tool name, also used in the hints                                      |
| `serverName`  | none                 | Names your server in the tool description and the error hints              |
| `description` | built-in             | Replaces the tool description                                              |
| `scrub`       | none                 | Removes more sensitive data from each report, after the built-in scrubbing |
| `errorHints`  | `shouldHintFeedback` | `false`, or a function that decides per failure                            |

The report's display name includes the user ID only when [`dataCollection.userInfo`](https://docs.sentry.io/platforms/javascript/guides/node/configuration/options.md#dataCollection) is enabled.

## [Register the Tool Yourself](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#register-the-tool-yourself)

If your server registers tools through its own catalog, create the tool with `createFeedbackTool` and register it like your other tools:

```javascript
import { createFeedbackTool } from "@sentry/mcp";

const tool = createFeedbackTool({ serverName: "Orders", server });

server.registerTool(tool.name, tool.config, tool.handler);
```

`createFeedbackTool` takes the same [options](https://docs.sentry.io/platforms/javascript/guides/node/mcp-monitoring/agent-feedback.md#options) as `addFeedbackTool`. Pass it your `server` so your other tools' errors get the hint.

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
