> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alpic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# User Feedbacks

> Collect feedback from your users or the LLM directly inside your plugin.

### Overview

When something doesn't work as expected, neither users nor models have a way to tell you. User Feedback adds
a `send_feedback` tool to your MCP server so both the model and the user can report issues and send you
feedback.

![User Feedback dashboard](https://mintcdn.com/alpic/Xn2W6iZnB0gwz_IL/images/user-feedback-dashboard.png?fit=max\&auto=format\&n=Xn2W6iZnB0gwz_IL\&q=85\&s=b71d2bbbba9d1eb508042cba1dfa4403)

The [`@alpic-ai/insights`](https://www.npmjs.com/package/@alpic-ai/insights) (TypeScript) and
[`alpic-ai-insights`](https://pypi.org/project/alpic-ai-insights/) (Python SDK) packages inject the feedback tool into
your server's tool list. Alpic stores the feedback for you to explore in the dashboard.

### 1. Install the package

> [tab] TypeScript
>
> `bash pnpm add @alpic-ai/insights `

> [tab] Python SDK
>
> `bash pip install alpic-ai-insights # or: uv add alpic-ai-insights `

### 2. Wire it into your server

Choose the entry point for your language and MCP framework.

> [tab] TypeScript - Skybridge v2
>
> Use `feedbackMiddleware`, it returns a Skybridge `McpMiddlewareFn` you register via `mcpMiddleware()`. Add it
> inside the Skybridge v2 `handler`, before your tool/widget registrations:
>
> ```typescript theme={null}
> import { feedbackMiddleware } from "@alpic-ai/insights";
> import { Skybridge } from "skybridge/server";
>
> const app = new Skybridge({
>   name: "my-mcp-server",
>   version: "1.0.0",
>   handler: (server) => server
>     .mcpMiddleware(feedbackMiddleware())
>     .registerTool(/* ... */),
> });
> ```

> [tab] TypeScript - Skybridge 0.36 / v1
>
> With Skybridge 0.36 or v1, add the middleware to the existing `McpServer` before registering tools:
>
> ```typescript theme={null}
> import { feedbackMiddleware } from "@alpic-ai/insights";
> import { McpServer } from "skybridge/server";
>
> const server = new McpServer({ name: "my-mcp-server", version: "1.0.0" }, { capabilities: {} })
>   .mcpMiddleware(feedbackMiddleware())
>   .registerTool(/* ... */);
> ```

> [tab] TypeScript - MCP SDK v1
>
> Use `captureFeedback`, it accepts an `McpServer` and patches the `tools/list` and `tools/call` in place.
>
> ```typescript theme={null}
> import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
> import { captureFeedback } from "@alpic-ai/insights";
>
> const server = new McpServer(
>   { name: "my-mcp-server", version: "1.0.0" },
>   { capabilities: {} },
> );
>
> server.registerTool(/* ... */);
>
> captureFeedback(server);
> ```

> [tab] Python SDK — FastMCP
>
> Register your tools first, then enable the feedback tool before starting the server:
>
> ```python theme={null}
> from alpic_ai_insights import capture_feedback
> from mcp.server.fastmcp import FastMCP
>
> mcp = FastMCP("my-mcp-server")
>
> @mcp.tool()
> def search(query: str) -> str:
>     return query
>
> capture_feedback(mcp)
> ```

> [tab] Python SDK — low-level
>
> `capture_feedback` also accepts `mcp.server.lowlevel.Server`. Register its `list_tools` and `call_tool`
> handlers first, then enable capture:
>
> ```python theme={null}
> from alpic_ai_insights import capture_feedback
> from mcp import types
> from mcp.server.lowlevel import Server
>
> server = Server("my-mcp-server")
>
> @server.list_tools()
> async def list_tools() -> list[types.Tool]:
>     return []
>
> @server.call_tool()
> async def call_tool(name, arguments):
>     return [types.TextContent(type="text", text="ok")]
>
> capture_feedback(server)
> ```

The `FastMCP` example above uses the class bundled with the official MCP Python SDK
(`mcp.server.fastmcp.FastMCP`), not the separate `fastmcp` package.

The middleware adds a `send_feedback` tool to your server at runtime. It is handled entirely by the middleware; you don't need to register it yourself.

### 3. How the LLM uses it

The tool instructs the LLM to:

* Use it **only** for feedback about your MCP server, not about other MCP servers.
* Call it **autonomously** when it detects a genuine issue (e.g. a tool that failed unexpectedly, an unhelpful response, a missing capability). No explicit user consent required.
* Strip any **Personally Identifiable Information** from the content before sending.

The tool accepts two arguments:

| Argument | Required | Description |
| - | - | - |
| `content` | Yes | The feedback content, stripped of any PII. |
| `source` | Yes | Who initiated the feedback: `"user"` if the user asked to send it, `"model"` if sent autonomously. |

### 4. Deploy

Deploy on Alpic as usual. Once the new version is live on the [production environment](https://docs.alpic.ai/build-deploy/environments.md), feedback starts flowing in.

### 5. View feedback in the dashboard

In the Alpic dashboard, open your project and click the **Insights** tab, then **Feedbacks**. Each entry shows:

* **Content:** what the feedback says
* **Source:** whether it was sent by the user or the model autonomously
* **Date:** when it was submitted

### Optional: run a custom handler alongside Alpic

Pass a `handler` to run your own logic (e.g. forwarding to Slack or your own analytics) on every captured feedback.
The handler runs **in addition to** Alpic's dashboard delivery (feedback still appears in the **Feedbacks** page) and executes inside your MCP server process:

> [tab] TypeScript — Skybridge
>
> ```typescript theme={null}
> .mcpMiddleware(
>   feedbackMiddleware({
>     handler: async ({ content, source }) => {
>       await slack.postMessage({ text: `Feedback [${source}]: ${content}` });
>     },
>   }),
> )
> ```

> [tab] TypeScript — MCP SDK v1
>
> ```typescript theme={null}
> captureFeedback(server, {
>   handler: async ({ content, source }) => {
>     await slack.postMessage({ text: `Feedback [${source}]: ${content}` });
>   },
> });
> ```

> [tab] Python SDK
>
> ```python theme={null}
> async def handle_feedback(feedback):
>     await slack.post_message(
>         text=f"Feedback [{feedback.source}]: {feedback.content}",
>     )
>
> capture_feedback(mcp, handler=handle_feedback)
> ```

### Combining with User Intents

`feedbackMiddleware`/`captureFeedback` and `intentMiddleware`/`captureIntents` are independent and can be used together:

> [tab] TypeScript — Skybridge
>
> ```typescript theme={null}
> import { feedbackMiddleware, intentMiddleware } from "@alpic-ai/insights";
> import { Skybridge } from "skybridge/server";
>
> const app = new Skybridge({
>   name: "my-mcp-server",
>   version: "1.0.0",
>   handler: (server) => server
>     .mcpMiddleware(feedbackMiddleware())
>     .mcpMiddleware(intentMiddleware())
>     .registerTool(/* ... */),
> });
> ```

> [tab] TypeScript — MCP SDK v1
>
> ```typescript theme={null}
> import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
> import { captureFeedback, captureIntents } from "@alpic-ai/insights";
>
> const server = new McpServer(
>   { name: "my-mcp-server", version: "1.0.0" },
>   { capabilities: {} },
> );
>
> server.registerTool(/* ... */);
>
> captureFeedback(server);
> captureIntents(server);
> ```

> [tab] Python SDK
>
> ```python theme={null}
> from alpic_ai_insights import capture_feedback, capture_intents
>
> capture_feedback(mcp)
> capture_intents(mcp)
> ```

`intentMiddleware`/`captureIntents` and `capture_intents` automatically skip the `send_feedback` tool so they don't
inject a `user_intent` field into the feedback tool's schema.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.