mcp-feedback 0.1.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/dist/cli.js +71 -27
- package/dist/client.d.ts +33 -0
- package/dist/client.js +59 -0
- package/dist/conformance-cases.js +0 -1
- package/dist/drizzle.d.ts +832 -0
- package/dist/drizzle.js +43 -0
- package/dist/identity.d.ts +6 -3
- package/dist/identity.js +10 -7
- package/dist/index.js +0 -1
- package/dist/reader.js +0 -1
- package/dist/register.d.ts +5 -0
- package/dist/register.js +3 -3
- package/dist/store.js +0 -1
- package/dist/stores/memory.js +0 -1
- package/dist/stores/postgres.js +0 -1
- package/dist/stores/sql.js +8 -5
- package/dist/stores/sqlite.js +0 -1
- package/dist/testing.js +0 -1
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +0 -1
- package/dist/types.js +0 -1
- package/package.json +20 -5
- package/dist/cli.js.map +0 -1
- package/dist/conformance-cases.js.map +0 -1
- package/dist/identity.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reader.js.map +0 -1
- package/dist/register.js.map +0 -1
- package/dist/store.js.map +0 -1
- package/dist/stores/memory.js.map +0 -1
- package/dist/stores/postgres.js.map +0 -1
- package/dist/stores/sql.js.map +0 -1
- package/dist/stores/sqlite.js.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/tools.js.map +0 -1
- package/dist/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -27,8 +27,17 @@ The reader tools list, fetch and count feedback, and `update_feedback_triage` cl
|
|
|
27
27
|
|
|
28
28
|
## CLI
|
|
29
29
|
|
|
30
|
+
The CLI reads either through a server's reader endpoint (the reader tools, mounted behind a maintainer credential) or straight from the store.
|
|
31
|
+
|
|
30
32
|
```sh
|
|
31
|
-
|
|
33
|
+
# Through a reader endpoint: needs its URL and credential, no database access.
|
|
34
|
+
export MCP_FEEDBACK_URL=https://example.com/mcp/feedback # or --mcp <url>
|
|
35
|
+
export MCP_FEEDBACK_TOKEN=... # sent as a bearer token
|
|
36
|
+
npx -y mcp-feedback stats
|
|
37
|
+
|
|
38
|
+
# Or straight from the store.
|
|
39
|
+
npx -y mcp-feedback stats --db ./feedback.db # or --postgres <url>
|
|
40
|
+
|
|
32
41
|
mcp-feedback list --status new --tool create_meme --text
|
|
33
42
|
mcp-feedback export --since 2026-11-01 > feedback.jsonl
|
|
34
43
|
mcp-feedback get <id> --text
|
|
@@ -37,7 +46,7 @@ mcp-feedback close <id> --dismiss --note "Working as intended"
|
|
|
37
46
|
mcp-feedback reopen <id>
|
|
38
47
|
```
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
`MCP_FEEDBACK_DB` and `MCP_FEEDBACK_POSTGRES_URL` set the store from the environment. With a reader endpoint, pass `--prefix` if the server set a `toolPrefix`; `--by` does not apply, because the server records who triaged from the credential. The same client is available in code as `connectFeedbackReader` from `mcp-feedback/client`. Output is JSON unless you pass `--text`. Exit code 2 means bad input; 1 means a failure or an id that was not found.
|
|
41
50
|
|
|
42
51
|
Append `feedbackInstructions` to your server's `instructions` so agents know when to file. If you publish a tool catalog, merge in `feedbackToolCatalog`.
|
|
43
52
|
|
|
@@ -66,6 +75,7 @@ registerFeedback(server, {
|
|
|
66
75
|
| `limits` | Override size limits (see the spec for defaults). |
|
|
67
76
|
| `toolPrefix` | Prefix for tool and prompt names. |
|
|
68
77
|
| `serverInfo` | Server name and version to record; defaults to the server's own. |
|
|
78
|
+
| `tokenFingerprintKey` | Secret that makes token fingerprints an HMAC. Recommended; keep it stable and the same on every instance. |
|
|
69
79
|
| `onError` | Receives storage errors, which are hidden from the agent. |
|
|
70
80
|
|
|
71
81
|
## Stores
|
|
@@ -73,7 +83,8 @@ registerFeedback(server, {
|
|
|
73
83
|
| Store | Import | Notes |
|
|
74
84
|
| --- | --- | --- |
|
|
75
85
|
| SQLite | `mcp-feedback/sqlite` | Default. Uses Node's built-in `node:sqlite`, so there is no native module to install. On Node versions where that module is still experimental, Node prints a warning. |
|
|
76
|
-
| Postgres | `mcp-feedback/postgres` | `postgresStore({ client: pool })` with any client that has `query(text, params)`, such as a `pg.Pool`. Pass `migrate: false` if
|
|
86
|
+
| Postgres | `mcp-feedback/postgres` | `postgresStore({ client: pool })` with any client that has `query(text, params)`, such as a `pg.Pool`. Timestamps are `TIMESTAMPTZ`. Pass `migrate: false` if the table is created by your own migrations. |
|
|
87
|
+
| Drizzle schema | `mcp-feedback/drizzle` | `mcpFeedbackTable` (or `feedbackTable(name)`) to export from your Drizzle schema, so `drizzle-kit` creates the table and never drops it. Use with `postgresStore({ client: pool, migrate: false })`. Tests keep it identical to `spec/sql/postgres.sql`. |
|
|
77
88
|
| Memory | `mcp-feedback` | `memoryStore()`, for tests. |
|
|
78
89
|
|
|
79
90
|
To write your own, implement `FeedbackStore` and check it with the conformance suite:
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Reader CLI: the same operations as the MCP reader tools, straight
|
|
3
|
-
// the store
|
|
2
|
+
// Reader CLI: the same operations as the MCP reader tools, either straight
|
|
3
|
+
// against the store or through a server's reader endpoint (--mcp).
|
|
4
4
|
import { realpathSync } from "node:fs";
|
|
5
5
|
import { userInfo } from "node:os";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -20,10 +20,13 @@ Commands:
|
|
|
20
20
|
close <id...> Mark resolved (or --dismiss), with an optional --note
|
|
21
21
|
reopen <id...> Set status back to new
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Source (one is required):
|
|
24
|
+
--mcp <url> A server's reader endpoint (or MCP_FEEDBACK_URL). Sends
|
|
25
|
+
MCP_FEEDBACK_TOKEN from the environment as a bearer token.
|
|
26
|
+
--prefix <p> The server's tool prefix, if it set one (with --mcp)
|
|
24
27
|
--db <path> SQLite file (or MCP_FEEDBACK_DB)
|
|
25
|
-
--postgres <url> Postgres connection URL (or MCP_FEEDBACK_POSTGRES_URL
|
|
26
|
-
--table <name> Table name, default mcp_feedback
|
|
28
|
+
--postgres <url> Postgres connection URL (or MCP_FEEDBACK_POSTGRES_URL)
|
|
29
|
+
--table <name> Table name, default mcp_feedback (with --db or --postgres)
|
|
27
30
|
|
|
28
31
|
Filters (stats, list, export):
|
|
29
32
|
--kind <k> --status <s> --severity <s> --subject <s> --tool <name> --tag <t>
|
|
@@ -36,7 +39,8 @@ Other:
|
|
|
36
39
|
--note <text> Triage note
|
|
37
40
|
--clear-note Remove the triage note
|
|
38
41
|
--dismiss With close: mark dismissed instead of resolved
|
|
39
|
-
--by <name> Recorded as triaged_by (default: your username
|
|
42
|
+
--by <name> Recorded as triaged_by (default: your username; with --mcp
|
|
43
|
+
the server records the credential's identity instead)
|
|
40
44
|
--text Human-readable output instead of JSON
|
|
41
45
|
`;
|
|
42
46
|
async function openStore(values, env) {
|
|
@@ -44,26 +48,66 @@ async function openStore(values, env) {
|
|
|
44
48
|
const db = values.db ?? env.MCP_FEEDBACK_DB;
|
|
45
49
|
const postgres = values.postgres ?? env.MCP_FEEDBACK_POSTGRES_URL;
|
|
46
50
|
if (db && postgres)
|
|
47
|
-
throw new FeedbackInputError("Pass
|
|
51
|
+
throw new FeedbackInputError("Pass one of --mcp, --db or --postgres.");
|
|
48
52
|
if (db) {
|
|
49
53
|
const { sqliteStore } = await import("./stores/sqlite.js");
|
|
50
54
|
return sqliteStore({ path: db, table });
|
|
51
55
|
}
|
|
52
56
|
if (postgres) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const name = "pg";
|
|
56
|
-
pg = await import(name);
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
throw new FeedbackInputError("--postgres needs the pg package: npm install pg");
|
|
60
|
-
}
|
|
61
|
-
const pool = new (pg.default ?? pg).Pool({ connectionString: postgres });
|
|
57
|
+
const { default: pg } = await import("pg");
|
|
58
|
+
const pool = new pg.Pool({ connectionString: postgres });
|
|
62
59
|
const { postgresStore } = await import("./stores/postgres.js");
|
|
63
60
|
// The CLI reads an existing table; it never creates one.
|
|
64
61
|
return { ...postgresStore({ client: pool, table, migrate: false }), close: () => pool.end() };
|
|
65
62
|
}
|
|
66
|
-
throw new FeedbackInputError("No
|
|
63
|
+
throw new FeedbackInputError("No source given. Pass --mcp <url>, --db <path> or --postgres <url>.");
|
|
64
|
+
}
|
|
65
|
+
/** The same reader operations over a store the CLI opened itself. */
|
|
66
|
+
function storeReader(store, by) {
|
|
67
|
+
return {
|
|
68
|
+
stats: (filter) => store.stats(filter),
|
|
69
|
+
list: (query) => listPage(store, query),
|
|
70
|
+
get: async (id) => {
|
|
71
|
+
const record = await store.get(id);
|
|
72
|
+
if (!record)
|
|
73
|
+
throw new FeedbackInputError(`No feedback with id ${id}.`);
|
|
74
|
+
return record;
|
|
75
|
+
},
|
|
76
|
+
triage: (ids, change) => triageMany(store, ids, { ...change, by }),
|
|
77
|
+
close: async () => store.close?.(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
async function openReader(values, io) {
|
|
81
|
+
const by = values.by ?? io.env.USER ?? userInfo().username;
|
|
82
|
+
if (io.openStore)
|
|
83
|
+
return storeReader(await io.openStore(), by);
|
|
84
|
+
const url = values.mcp ?? io.env.MCP_FEEDBACK_URL;
|
|
85
|
+
if (!url) {
|
|
86
|
+
if (values.prefix !== undefined)
|
|
87
|
+
throw new FeedbackInputError("--prefix only applies with --mcp.");
|
|
88
|
+
return storeReader(await openStore(values, io.env), by);
|
|
89
|
+
}
|
|
90
|
+
if (values.db !== undefined || values.postgres !== undefined)
|
|
91
|
+
throw new FeedbackInputError("Pass one of --mcp, --db or --postgres.");
|
|
92
|
+
if (values.table !== undefined)
|
|
93
|
+
throw new FeedbackInputError("--table does not apply with --mcp.");
|
|
94
|
+
if (values.by !== undefined)
|
|
95
|
+
throw new FeedbackInputError("--by does not apply with --mcp: the server records who triaged from the credential.");
|
|
96
|
+
const token = io.env.MCP_FEEDBACK_TOKEN;
|
|
97
|
+
const { connectFeedbackReader, FeedbackReaderError } = await import("./client.js");
|
|
98
|
+
try {
|
|
99
|
+
return await connectFeedbackReader({
|
|
100
|
+
url,
|
|
101
|
+
headers: token ? { Authorization: `Bearer ${token}` } : undefined,
|
|
102
|
+
toolPrefix: values.prefix,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof FeedbackReaderError && error.status === 401 && !token) {
|
|
107
|
+
throw new FeedbackReaderError(`${error.message} MCP_FEEDBACK_TOKEN is not set; set it to the endpoint's maintainer credential.`, 401);
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
67
111
|
}
|
|
68
112
|
function oneOf(label, value, allowed) {
|
|
69
113
|
if (value === undefined)
|
|
@@ -90,7 +134,7 @@ function detail(record) {
|
|
|
90
134
|
}
|
|
91
135
|
/** Runs the CLI and resolves the process exit code. */
|
|
92
136
|
export async function runCli(argv, io) {
|
|
93
|
-
let
|
|
137
|
+
let reader;
|
|
94
138
|
try {
|
|
95
139
|
let parsed;
|
|
96
140
|
try {
|
|
@@ -98,6 +142,8 @@ export async function runCli(argv, io) {
|
|
|
98
142
|
args: argv,
|
|
99
143
|
allowPositionals: true,
|
|
100
144
|
options: {
|
|
145
|
+
mcp: { type: "string" },
|
|
146
|
+
prefix: { type: "string" },
|
|
101
147
|
db: { type: "string" },
|
|
102
148
|
postgres: { type: "string" },
|
|
103
149
|
table: { type: "string" },
|
|
@@ -145,12 +191,13 @@ export async function runCli(argv, io) {
|
|
|
145
191
|
if (!ids.length)
|
|
146
192
|
throw new FeedbackInputError(`${command} needs at least one id.`);
|
|
147
193
|
};
|
|
148
|
-
const open = async () => (
|
|
194
|
+
const open = async () => (reader ??= await openReader(values, io));
|
|
149
195
|
const triage = async (change) => {
|
|
150
196
|
needIds();
|
|
151
197
|
const note = values["clear-note"] ? null : (values.note ?? change.note);
|
|
152
|
-
|
|
153
|
-
|
|
198
|
+
if (change.status === undefined && note === undefined)
|
|
199
|
+
throw new FeedbackInputError("Provide a status, a note, or both.");
|
|
200
|
+
const outcome = await (await open()).triage([...new Set(ids)], { status: change.status, note });
|
|
154
201
|
if (values.text) {
|
|
155
202
|
for (const record of outcome.updated)
|
|
156
203
|
io.out(summaryLine(record));
|
|
@@ -181,7 +228,7 @@ export async function runCli(argv, io) {
|
|
|
181
228
|
if (limit !== undefined && (!Number.isInteger(limit) || limit < 1 || limit > 1000)) {
|
|
182
229
|
throw new FeedbackInputError("--limit must be a whole number from 1 to 1000.");
|
|
183
230
|
}
|
|
184
|
-
const page = await
|
|
231
|
+
const page = await (await open()).list({ ...filter, limit: limit ?? 25, cursor: values.cursor });
|
|
185
232
|
if (!values.text)
|
|
186
233
|
json(page);
|
|
187
234
|
else {
|
|
@@ -195,7 +242,7 @@ export async function runCli(argv, io) {
|
|
|
195
242
|
const source = await open();
|
|
196
243
|
let cursor;
|
|
197
244
|
do {
|
|
198
|
-
const page = await
|
|
245
|
+
const page = await source.list({ ...filter, limit: 200, cursor });
|
|
199
246
|
for (const record of page.items)
|
|
200
247
|
io.out(values.text ? summaryLine(record) : JSON.stringify(record));
|
|
201
248
|
cursor = page.next_cursor ?? undefined;
|
|
@@ -206,8 +253,6 @@ export async function runCli(argv, io) {
|
|
|
206
253
|
if (ids.length !== 1)
|
|
207
254
|
throw new FeedbackInputError("get takes exactly one id.");
|
|
208
255
|
const record = await (await open()).get(ids[0]);
|
|
209
|
-
if (!record)
|
|
210
|
-
throw new FeedbackInputError(`No feedback with id ${ids[0]}.`);
|
|
211
256
|
if (values.text)
|
|
212
257
|
io.out(detail(record));
|
|
213
258
|
else
|
|
@@ -235,7 +280,7 @@ export async function runCli(argv, io) {
|
|
|
235
280
|
return 1;
|
|
236
281
|
}
|
|
237
282
|
finally {
|
|
238
|
-
await
|
|
283
|
+
await reader?.close();
|
|
239
284
|
}
|
|
240
285
|
}
|
|
241
286
|
const invoked = process.argv[1] ? realpathSync(process.argv[1]) : "";
|
|
@@ -246,4 +291,3 @@ if (invoked === fileURLToPath(import.meta.url)) {
|
|
|
246
291
|
env: process.env,
|
|
247
292
|
});
|
|
248
293
|
}
|
|
249
|
-
//# sourceMappingURL=cli.js.map
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TriageOutcome } from "./reader.js";
|
|
2
|
+
import type { FeedbackFilter, FeedbackPage, FeedbackRecord, FeedbackStats, FeedbackStatus } from "./types.js";
|
|
3
|
+
/** The reader tools cap a page at this size; larger requests are clamped and continue by cursor. */
|
|
4
|
+
export declare const READER_PAGE_LIMIT = 100;
|
|
5
|
+
/** A failure reaching the reader endpoint or reported by its tools. `status` is the HTTP status, when there was one. */
|
|
6
|
+
export declare class FeedbackReaderError extends Error {
|
|
7
|
+
readonly status?: number | undefined;
|
|
8
|
+
constructor(message: string, status?: number | undefined);
|
|
9
|
+
}
|
|
10
|
+
export interface FeedbackReaderClient {
|
|
11
|
+
stats(filter: FeedbackFilter): Promise<FeedbackStats>;
|
|
12
|
+
list(query: FeedbackFilter & {
|
|
13
|
+
limit: number;
|
|
14
|
+
cursor?: string;
|
|
15
|
+
}): Promise<FeedbackPage>;
|
|
16
|
+
/** Rejects with FeedbackReaderError when the id is unknown. */
|
|
17
|
+
get(id: string): Promise<FeedbackRecord>;
|
|
18
|
+
/** The server records who triaged from the credential, and sets updated_at. */
|
|
19
|
+
triage(ids: string[], change: {
|
|
20
|
+
status?: FeedbackStatus;
|
|
21
|
+
note?: string | null;
|
|
22
|
+
}): Promise<TriageOutcome>;
|
|
23
|
+
close(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export interface FeedbackReaderClientOptions {
|
|
26
|
+
/** Streamable HTTP URL of the endpoint that has the reader tools mounted. */
|
|
27
|
+
url: string | URL;
|
|
28
|
+
/** Sent on every request, e.g. `{ Authorization: "Bearer …" }`. */
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
/** The server's toolPrefix, if it set one. */
|
|
31
|
+
toolPrefix?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function connectFeedbackReader(options: FeedbackReaderClientOptions): Promise<FeedbackReaderClient>;
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Reads and triages feedback through a server's reader tools, so maintainers
|
|
2
|
+
// need the reader endpoint's credential rather than database access.
|
|
3
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
5
|
+
import { READER_TOOLS } from "./tools.js";
|
|
6
|
+
/** The reader tools cap a page at this size; larger requests are clamped and continue by cursor. */
|
|
7
|
+
export const READER_PAGE_LIMIT = 100;
|
|
8
|
+
/** A failure reaching the reader endpoint or reported by its tools. `status` is the HTTP status, when there was one. */
|
|
9
|
+
export class FeedbackReaderError extends Error {
|
|
10
|
+
status;
|
|
11
|
+
constructor(message, status) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.status = status;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const HTTP_HINTS = {
|
|
17
|
+
401: "the credential is missing or was refused",
|
|
18
|
+
403: "the credential is not allowed to use this endpoint",
|
|
19
|
+
404: "no MCP endpoint at this URL",
|
|
20
|
+
405: "no MCP endpoint at this URL",
|
|
21
|
+
};
|
|
22
|
+
export async function connectFeedbackReader(options) {
|
|
23
|
+
const url = new URL(options.url);
|
|
24
|
+
const prefix = options.toolPrefix ?? "";
|
|
25
|
+
const client = new Client({ name: "mcp-feedback", version: "1" });
|
|
26
|
+
try {
|
|
27
|
+
await client.connect(new StreamableHTTPClientTransport(url, { requestInit: { headers: options.headers } }));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// The SDK's StreamableHTTPError carries the HTTP status as `code`.
|
|
31
|
+
const status = typeof error.code === "number" ? error.code : undefined;
|
|
32
|
+
const reason = status !== undefined && HTTP_HINTS[status] ? `HTTP ${status}, ${HTTP_HINTS[status]}` : error instanceof Error ? error.message : String(error);
|
|
33
|
+
throw new FeedbackReaderError(`Could not connect to ${url}: ${reason}.`, status);
|
|
34
|
+
}
|
|
35
|
+
const call = async (tool, args) => {
|
|
36
|
+
const name = prefix + tool.name;
|
|
37
|
+
// An unknown tool usually means the server registered the reader tools with a prefix.
|
|
38
|
+
// SDK versions differ on whether that arrives as a thrown error or an error result.
|
|
39
|
+
const fail = (message) => new FeedbackReaderError(/Tool \S+ not found/.test(message) ? `${message}. If the server uses a tool prefix, pass it.` : message);
|
|
40
|
+
let response;
|
|
41
|
+
try {
|
|
42
|
+
response = await client.callTool({ name, arguments: args });
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw fail(error instanceof Error ? error.message : String(error));
|
|
46
|
+
}
|
|
47
|
+
const text = response.content?.find((c) => c.type === "text")?.text;
|
|
48
|
+
if (response.isError)
|
|
49
|
+
throw fail(text ?? `${name} failed.`);
|
|
50
|
+
return (response.structuredContent ?? JSON.parse(text ?? "null"));
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
stats: (filter) => call(READER_TOOLS.stats, { ...filter }),
|
|
54
|
+
list: ({ limit, ...rest }) => call(READER_TOOLS.list, { ...rest, limit: Math.min(limit, READER_PAGE_LIMIT) }),
|
|
55
|
+
get: (id) => call(READER_TOOLS.get, { id }),
|
|
56
|
+
triage: (ids, change) => call(READER_TOOLS.triage, { ids, status: change.status, note: change.note }),
|
|
57
|
+
close: () => client.close(),
|
|
58
|
+
};
|
|
59
|
+
}
|