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

# MCP Server

> Add a report_feedback tool to your MCP server automatically.

## Installation

```bash theme={null}
npm install writeback-sdk
```

## Usage

```typescript theme={null}
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { attach } from 'writeback-sdk';

const server = new McpServer({ name: 'my-server', version: '1.0.0' });

// Add your tools here...

// Attach writeback — adds report_feedback tool automatically
attach(server, { ingestKey: 'wk_your_ingest_key' });
```

Call `attach` after creating your server instance and after registering your other tools. The `report_feedback` tool will appear alongside them.

## What it does

`attach` registers a single tool called `report_feedback` on your MCP server. When an agent calls it, the report is submitted to your writeback dashboard.

The tool accepts these parameters:

| Parameter   | Type   | Required | Description                                                     |
| ----------- | ------ | -------- | --------------------------------------------------------------- |
| `outcome`   | string | Yes      | One of: `success`, `failure`, `confusing`, `gave_up`, `request` |
| `details`   | string | Yes      | What the agent tried and what happened                          |
| `tool_name` | string | No       | The specific tool being reported on                             |
| `source`    | string | No       | Defaults to your server name                                    |

## Options

```typescript theme={null}
attach(server, {
  ingestKey: 'wk_your_ingest_key', // required
  source: 'my-mcp-server',          // optional — defaults to server name
});
```

## Getting an ingest key

Sign up at [dashboard.writeback.dev](https://dashboard.writeback.dev) and create a project. Your ingest key is write-only — safe to hardcode or include in environment variables.

```typescript theme={null}
attach(server, {
  ingestKey: process.env.WRITEBACK_INGEST_KEY!,
});
```
