mcp-feedback 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +90 -2
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +248 -0
- package/dist/conformance-cases.d.ts +31 -0
- package/dist/conformance-cases.js +130 -0
- package/dist/drizzle.d.ts +832 -0
- package/dist/drizzle.js +43 -0
- package/dist/identity.d.ts +32 -0
- package/dist/identity.js +24 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/reader.d.ts +21 -0
- package/dist/reader.js +58 -0
- package/dist/register.d.ts +54 -0
- package/dist/register.js +173 -0
- package/dist/store.d.ts +27 -0
- package/dist/store.js +45 -0
- package/dist/stores/memory.d.ts +3 -0
- package/dist/stores/memory.js +56 -0
- package/dist/stores/postgres.d.ts +14 -0
- package/dist/stores/postgres.js +24 -0
- package/dist/stores/sql.d.ts +16 -0
- package/dist/stores/sql.js +220 -0
- package/dist/stores/sqlite.d.ts +8 -0
- package/dist/stores/sqlite.js +35 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.js +64 -0
- package/dist/tools.d.ts +169 -0
- package/dist/tools.js +141 -0
- package/dist/types.d.ts +92 -0
- package/dist/types.js +7 -0
- package/package.json +88 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 krishchow
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mcp-feedback
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Drop-in feedback for MCP servers. Add one call to a server built on the official MCP SDK and agents get a `submit_feedback` tool; what they report is stamped with the caller's identity and saved to a store you choose. A second set of tools lets a maintainer's agent read and synthesize it.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install mcp-feedback
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The language-neutral spec (record schema, tool definitions, store contract, SQL layout) and agent skills live in the [repository](https://github.com/krishchow/feedback).
|
|
10
|
+
|
|
11
|
+
## Use
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { registerFeedback, registerFeedbackReader, feedbackInstructions } from "mcp-feedback";
|
|
15
|
+
import { sqliteStore } from "mcp-feedback/sqlite";
|
|
16
|
+
|
|
17
|
+
const store = sqliteStore({ path: "./feedback.db" }); // once per process
|
|
18
|
+
|
|
19
|
+
// On the server agents use:
|
|
20
|
+
registerFeedback(server, { store });
|
|
21
|
+
|
|
22
|
+
// Optional. On a separate, maintainer-only server or endpoint:
|
|
23
|
+
registerFeedbackReader(adminServer, { store });
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The reader tools list, fetch and count feedback, and `update_feedback_triage` closes out, dismisses or reopens one or many records with a note. Pass `readOnly: true` to leave that tool out. If you would rather not expose reader tools at all, use the CLI.
|
|
27
|
+
|
|
28
|
+
## CLI
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
mcp-feedback stats --db ./feedback.db
|
|
32
|
+
mcp-feedback list --status new --tool create_meme --text
|
|
33
|
+
mcp-feedback export --since 2026-11-01 > feedback.jsonl
|
|
34
|
+
mcp-feedback get <id> --text
|
|
35
|
+
mcp-feedback close <id> <id> --note "Fixed in 1.2"
|
|
36
|
+
mcp-feedback close <id> --dismiss --note "Working as intended"
|
|
37
|
+
mcp-feedback reopen <id>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use `--postgres <url>` instead of `--db` for Postgres. That needs the `pg` package, so run the copy installed alongside your server (`npm exec mcp-feedback`, or `pnpm --filter <package> exec mcp-feedback` in a monorepo) rather than a fresh `npx` download. `MCP_FEEDBACK_DB` and `MCP_FEEDBACK_POSTGRES_URL` set the store from the environment. 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
|
+
|
|
42
|
+
Append `feedbackInstructions` to your server's `instructions` so agents know when to file. If you publish a tool catalog, merge in `feedbackToolCatalog`.
|
|
43
|
+
|
|
44
|
+
Requires Node 22.13 or later, `@modelcontextprotocol/sdk` 1.x and zod 3.25+ or 4.
|
|
45
|
+
|
|
46
|
+
## Identity
|
|
47
|
+
|
|
48
|
+
Each record carries who submitted it, read from the request, never from tool input: subject, client id, scopes, a fingerprint of the access token (not the token), session id, client name and version, user agent. For HTTP servers this depends on your auth middleware setting `req.auth`, which the SDK passes to tools as `authInfo`; without it identity fields are null.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
registerFeedback(server, {
|
|
52
|
+
store,
|
|
53
|
+
requireIdentity: true, // refuse unauthenticated submissions
|
|
54
|
+
resolveIdentity: (extra, defaults) => ({ subject: lookUpUser(extra.authInfo?.token) }),
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Options
|
|
59
|
+
|
|
60
|
+
| Option | Purpose |
|
|
61
|
+
| --- | --- |
|
|
62
|
+
| `store` | Where records go. Required. |
|
|
63
|
+
| `resolveIdentity` | Override identity fields for a request. |
|
|
64
|
+
| `requireIdentity` | Refuse submissions with no subject and no token fingerprint. |
|
|
65
|
+
| `redact` | Scrub a record before it is stored. |
|
|
66
|
+
| `limits` | Override size limits (see the spec for defaults). |
|
|
67
|
+
| `toolPrefix` | Prefix for tool and prompt names. |
|
|
68
|
+
| `serverInfo` | Server name and version to record; defaults to the server's own. |
|
|
69
|
+
| `tokenFingerprintKey` | Secret that makes token fingerprints an HMAC. Recommended; keep it stable and the same on every instance. |
|
|
70
|
+
| `onError` | Receives storage errors, which are hidden from the agent. |
|
|
71
|
+
|
|
72
|
+
## Stores
|
|
73
|
+
|
|
74
|
+
| Store | Import | Notes |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| 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. |
|
|
77
|
+
| 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. |
|
|
78
|
+
| 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`. |
|
|
79
|
+
| Memory | `mcp-feedback` | `memoryStore()`, for tests. |
|
|
80
|
+
|
|
81
|
+
To write your own, implement `FeedbackStore` and check it with the conformance suite:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { defineFeedbackStore } from "mcp-feedback";
|
|
85
|
+
import { runStoreConformance } from "mcp-feedback/testing";
|
|
86
|
+
|
|
87
|
+
const store = defineFeedbackStore({ insert, get, list, updateTriage, stats });
|
|
88
|
+
await runStoreConformance(store); // rejects on the first failing case
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The package does not rate-limit submissions; rely on your server's existing limits.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import type { FeedbackStore } from "./store.js";
|
|
3
|
+
export interface CliIo {
|
|
4
|
+
out: (line: string) => void;
|
|
5
|
+
err: (line: string) => void;
|
|
6
|
+
env: Record<string, string | undefined>;
|
|
7
|
+
/** Test seam: supply the store instead of opening one from flags. */
|
|
8
|
+
openStore?: () => Promise<FeedbackStore>;
|
|
9
|
+
}
|
|
10
|
+
/** Runs the CLI and resolves the process exit code. */
|
|
11
|
+
export declare function runCli(argv: string[], io: CliIo): Promise<number>;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Reader CLI: the same operations as the MCP reader tools, straight against
|
|
3
|
+
// the store, for setups that do not want to expose reader tools over MCP.
|
|
4
|
+
import { realpathSync } from "node:fs";
|
|
5
|
+
import { userInfo } from "node:os";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { parseArgs } from "node:util";
|
|
8
|
+
import { FeedbackInputError, listPage, normalizeFilter, triageMany } from "./reader.js";
|
|
9
|
+
import { FEEDBACK_KINDS, FEEDBACK_SEVERITIES, FEEDBACK_STATUSES, } from "./types.js";
|
|
10
|
+
const USAGE = `mcp-feedback: read and close out feedback collected by an MCP server
|
|
11
|
+
|
|
12
|
+
Usage: mcp-feedback <command> [options]
|
|
13
|
+
|
|
14
|
+
Commands:
|
|
15
|
+
stats Counts by kind, status, severity and tool
|
|
16
|
+
list One page of records, newest first
|
|
17
|
+
export Every matching record, one JSON object per line
|
|
18
|
+
get <id> One record
|
|
19
|
+
triage <id...> Set --status and/or --note
|
|
20
|
+
close <id...> Mark resolved (or --dismiss), with an optional --note
|
|
21
|
+
reopen <id...> Set status back to new
|
|
22
|
+
|
|
23
|
+
Store (one is required):
|
|
24
|
+
--db <path> SQLite file (or MCP_FEEDBACK_DB)
|
|
25
|
+
--postgres <url> Postgres connection URL (or MCP_FEEDBACK_POSTGRES_URL; needs the pg package)
|
|
26
|
+
--table <name> Table name, default mcp_feedback
|
|
27
|
+
|
|
28
|
+
Filters (stats, list, export):
|
|
29
|
+
--kind <k> --status <s> --severity <s> --subject <s> --tool <name> --tag <t>
|
|
30
|
+
--since <iso> --until <iso>
|
|
31
|
+
|
|
32
|
+
Other:
|
|
33
|
+
--limit <n> Page size for list (default 25)
|
|
34
|
+
--cursor <c> next_cursor from a previous list
|
|
35
|
+
--status <s> For triage: ${FEEDBACK_STATUSES.join(" | ")}
|
|
36
|
+
--note <text> Triage note
|
|
37
|
+
--clear-note Remove the triage note
|
|
38
|
+
--dismiss With close: mark dismissed instead of resolved
|
|
39
|
+
--by <name> Recorded as triaged_by (default: your username)
|
|
40
|
+
--text Human-readable output instead of JSON
|
|
41
|
+
`;
|
|
42
|
+
async function openStore(values, env) {
|
|
43
|
+
const table = values.table;
|
|
44
|
+
const db = values.db ?? env.MCP_FEEDBACK_DB;
|
|
45
|
+
const postgres = values.postgres ?? env.MCP_FEEDBACK_POSTGRES_URL;
|
|
46
|
+
if (db && postgres)
|
|
47
|
+
throw new FeedbackInputError("Pass either --db or --postgres, not both.");
|
|
48
|
+
if (db) {
|
|
49
|
+
const { sqliteStore } = await import("./stores/sqlite.js");
|
|
50
|
+
return sqliteStore({ path: db, table });
|
|
51
|
+
}
|
|
52
|
+
if (postgres) {
|
|
53
|
+
let pg;
|
|
54
|
+
try {
|
|
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 });
|
|
62
|
+
const { postgresStore } = await import("./stores/postgres.js");
|
|
63
|
+
// The CLI reads an existing table; it never creates one.
|
|
64
|
+
return { ...postgresStore({ client: pool, table, migrate: false }), close: () => pool.end() };
|
|
65
|
+
}
|
|
66
|
+
throw new FeedbackInputError("No store given. Pass --db <path> or --postgres <url>.");
|
|
67
|
+
}
|
|
68
|
+
function oneOf(label, value, allowed) {
|
|
69
|
+
if (value === undefined)
|
|
70
|
+
return undefined;
|
|
71
|
+
if (!allowed.includes(value))
|
|
72
|
+
throw new FeedbackInputError(`--${label} must be one of: ${allowed.join(", ")}`);
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
function summaryLine(record) {
|
|
76
|
+
const who = record.identity.subject ?? record.identity.client_id ?? record.identity.token_fingerprint ?? "anonymous";
|
|
77
|
+
return `${record.id} ${record.created_at.slice(0, 16)}Z ${record.status.padEnd(9)} ${record.kind.padEnd(15)} ${record.severity.padEnd(7)} ${who} ${record.title}`;
|
|
78
|
+
}
|
|
79
|
+
function detail(record) {
|
|
80
|
+
const lines = [summaryLine(record), "", record.body];
|
|
81
|
+
for (const [key, value] of Object.entries(record.context)) {
|
|
82
|
+
lines.push("", `${key}:`, typeof value === "string" ? value : JSON.stringify(value, null, 2));
|
|
83
|
+
}
|
|
84
|
+
if (record.tags.length)
|
|
85
|
+
lines.push("", `tags: ${record.tags.join(", ")}`);
|
|
86
|
+
if (record.triage_note || record.triaged_by) {
|
|
87
|
+
lines.push("", `triage: ${record.triage_note ?? ""} (${record.triaged_by ?? "unknown"}, ${record.updated_at})`);
|
|
88
|
+
}
|
|
89
|
+
return lines.join("\n");
|
|
90
|
+
}
|
|
91
|
+
/** Runs the CLI and resolves the process exit code. */
|
|
92
|
+
export async function runCli(argv, io) {
|
|
93
|
+
let store;
|
|
94
|
+
try {
|
|
95
|
+
let parsed;
|
|
96
|
+
try {
|
|
97
|
+
parsed = parseArgs({
|
|
98
|
+
args: argv,
|
|
99
|
+
allowPositionals: true,
|
|
100
|
+
options: {
|
|
101
|
+
db: { type: "string" },
|
|
102
|
+
postgres: { type: "string" },
|
|
103
|
+
table: { type: "string" },
|
|
104
|
+
kind: { type: "string" },
|
|
105
|
+
status: { type: "string" },
|
|
106
|
+
severity: { type: "string" },
|
|
107
|
+
subject: { type: "string" },
|
|
108
|
+
tool: { type: "string" },
|
|
109
|
+
tag: { type: "string" },
|
|
110
|
+
since: { type: "string" },
|
|
111
|
+
until: { type: "string" },
|
|
112
|
+
limit: { type: "string" },
|
|
113
|
+
cursor: { type: "string" },
|
|
114
|
+
note: { type: "string" },
|
|
115
|
+
"clear-note": { type: "boolean" },
|
|
116
|
+
dismiss: { type: "boolean" },
|
|
117
|
+
by: { type: "string" },
|
|
118
|
+
text: { type: "boolean" },
|
|
119
|
+
help: { type: "boolean", short: "h" },
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
throw new FeedbackInputError(error.message);
|
|
125
|
+
}
|
|
126
|
+
const { values, positionals } = parsed;
|
|
127
|
+
const [command, ...ids] = positionals;
|
|
128
|
+
if (values.help || !command) {
|
|
129
|
+
io.out(USAGE);
|
|
130
|
+
return command || values.help ? 0 : 2;
|
|
131
|
+
}
|
|
132
|
+
const status = oneOf("status", values.status, FEEDBACK_STATUSES);
|
|
133
|
+
const filter = normalizeFilter({
|
|
134
|
+
kind: oneOf("kind", values.kind, FEEDBACK_KINDS),
|
|
135
|
+
status,
|
|
136
|
+
severity: oneOf("severity", values.severity, FEEDBACK_SEVERITIES),
|
|
137
|
+
subject: values.subject,
|
|
138
|
+
tool: values.tool,
|
|
139
|
+
tag: values.tag,
|
|
140
|
+
since: values.since,
|
|
141
|
+
until: values.until,
|
|
142
|
+
});
|
|
143
|
+
const json = (value) => io.out(JSON.stringify(value, null, 2));
|
|
144
|
+
const needIds = () => {
|
|
145
|
+
if (!ids.length)
|
|
146
|
+
throw new FeedbackInputError(`${command} needs at least one id.`);
|
|
147
|
+
};
|
|
148
|
+
const open = async () => (store = await (io.openStore ? io.openStore() : openStore(values, io.env)));
|
|
149
|
+
const triage = async (change) => {
|
|
150
|
+
needIds();
|
|
151
|
+
const note = values["clear-note"] ? null : (values.note ?? change.note);
|
|
152
|
+
const by = values.by ?? io.env.USER ?? userInfo().username;
|
|
153
|
+
const outcome = await triageMany(await open(), ids, { status: change.status, note, by });
|
|
154
|
+
if (values.text) {
|
|
155
|
+
for (const record of outcome.updated)
|
|
156
|
+
io.out(summaryLine(record));
|
|
157
|
+
for (const id of outcome.not_found)
|
|
158
|
+
io.err(`not found: ${id}`);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
json(outcome);
|
|
162
|
+
}
|
|
163
|
+
return outcome.not_found.length ? 1 : 0;
|
|
164
|
+
};
|
|
165
|
+
switch (command) {
|
|
166
|
+
case "stats": {
|
|
167
|
+
const stats = await (await open()).stats(filter);
|
|
168
|
+
if (!values.text)
|
|
169
|
+
json(stats);
|
|
170
|
+
else {
|
|
171
|
+
io.out(`total: ${stats.total}`);
|
|
172
|
+
for (const group of ["by_status", "by_kind", "by_severity", "by_tool"]) {
|
|
173
|
+
const counts = Object.entries(stats[group]).sort((a, b) => b[1] - a[1]);
|
|
174
|
+
io.out(`${group.slice(3)}: ${counts.map(([key, count]) => `${key}=${count}`).join(", ") || "-"}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return 0;
|
|
178
|
+
}
|
|
179
|
+
case "list": {
|
|
180
|
+
const limit = values.limit === undefined ? undefined : Number(values.limit);
|
|
181
|
+
if (limit !== undefined && (!Number.isInteger(limit) || limit < 1 || limit > 1000)) {
|
|
182
|
+
throw new FeedbackInputError("--limit must be a whole number from 1 to 1000.");
|
|
183
|
+
}
|
|
184
|
+
const page = await listPage(await open(), { ...filter, limit, cursor: values.cursor });
|
|
185
|
+
if (!values.text)
|
|
186
|
+
json(page);
|
|
187
|
+
else {
|
|
188
|
+
page.items.forEach((record) => io.out(summaryLine(record)));
|
|
189
|
+
if (page.next_cursor)
|
|
190
|
+
io.out(`more: --cursor ${page.next_cursor}`);
|
|
191
|
+
}
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
case "export": {
|
|
195
|
+
const source = await open();
|
|
196
|
+
let cursor;
|
|
197
|
+
do {
|
|
198
|
+
const page = await listPage(source, { ...filter, limit: 200, cursor });
|
|
199
|
+
for (const record of page.items)
|
|
200
|
+
io.out(values.text ? summaryLine(record) : JSON.stringify(record));
|
|
201
|
+
cursor = page.next_cursor ?? undefined;
|
|
202
|
+
} while (cursor);
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
case "get": {
|
|
206
|
+
if (ids.length !== 1)
|
|
207
|
+
throw new FeedbackInputError("get takes exactly one id.");
|
|
208
|
+
const record = await (await open()).get(ids[0]);
|
|
209
|
+
if (!record)
|
|
210
|
+
throw new FeedbackInputError(`No feedback with id ${ids[0]}.`);
|
|
211
|
+
if (values.text)
|
|
212
|
+
io.out(detail(record));
|
|
213
|
+
else
|
|
214
|
+
json(record);
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
case "triage":
|
|
218
|
+
return await triage({ status });
|
|
219
|
+
case "close":
|
|
220
|
+
if (status)
|
|
221
|
+
throw new FeedbackInputError("close sets the status itself; use triage to set an arbitrary --status.");
|
|
222
|
+
return await triage({ status: values.dismiss ? "dismissed" : "resolved" });
|
|
223
|
+
case "reopen":
|
|
224
|
+
return await triage({ status: "new" });
|
|
225
|
+
default:
|
|
226
|
+
throw new FeedbackInputError(`Unknown command: ${command}. Run mcp-feedback --help.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
if (error instanceof FeedbackInputError) {
|
|
231
|
+
io.err(error.message);
|
|
232
|
+
return 2;
|
|
233
|
+
}
|
|
234
|
+
io.err(`mcp-feedback: ${error instanceof Error ? error.message : String(error)}`);
|
|
235
|
+
return 1;
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
await store?.close?.();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const invoked = process.argv[1] ? realpathSync(process.argv[1]) : "";
|
|
242
|
+
if (invoked === fileURLToPath(import.meta.url)) {
|
|
243
|
+
process.exitCode = await runCli(process.argv.slice(2), {
|
|
244
|
+
out: (line) => console.log(line),
|
|
245
|
+
err: (line) => console.error(line),
|
|
246
|
+
env: process.env,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FeedbackFilter, FeedbackRecord, FeedbackStats, FeedbackTriagePatch } from "./types.js";
|
|
2
|
+
export type StoreCase = {
|
|
3
|
+
name: string;
|
|
4
|
+
op: "list";
|
|
5
|
+
filter: FeedbackFilter;
|
|
6
|
+
limit: number;
|
|
7
|
+
expect_pages: string[][];
|
|
8
|
+
} | {
|
|
9
|
+
name: string;
|
|
10
|
+
op: "get";
|
|
11
|
+
id: string;
|
|
12
|
+
expect_found: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
name: string;
|
|
15
|
+
op: "stats";
|
|
16
|
+
filter: FeedbackFilter;
|
|
17
|
+
expect: FeedbackStats;
|
|
18
|
+
} | {
|
|
19
|
+
name: string;
|
|
20
|
+
op: "insert_duplicate";
|
|
21
|
+
id: string;
|
|
22
|
+
} | {
|
|
23
|
+
name: string;
|
|
24
|
+
op: "update_triage";
|
|
25
|
+
id: string;
|
|
26
|
+
patch: FeedbackTriagePatch;
|
|
27
|
+
/** Fields the returned and re-read record must have; null when the id is unknown. */
|
|
28
|
+
expect: Partial<FeedbackRecord> | null;
|
|
29
|
+
};
|
|
30
|
+
export declare const conformanceRecords: FeedbackRecord[];
|
|
31
|
+
export declare const conformanceCases: StoreCase[];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Store conformance vectors. spec/conformance/store-cases.json is generated
|
|
2
|
+
// from this file; every store, in any language, must pass these cases.
|
|
3
|
+
const id = (n) => `00000000-0000-7000-8000-00000000000${n}`;
|
|
4
|
+
function record(n, created_at, fields, context = {}) {
|
|
5
|
+
return {
|
|
6
|
+
schema_version: 1,
|
|
7
|
+
id: id(n),
|
|
8
|
+
created_at,
|
|
9
|
+
kind: fields.kind,
|
|
10
|
+
title: `Record ${n}`,
|
|
11
|
+
body: `Body of record ${n}`,
|
|
12
|
+
severity: fields.severity,
|
|
13
|
+
tags: fields.tags,
|
|
14
|
+
context: {
|
|
15
|
+
...context,
|
|
16
|
+
...(fields.tools.length ? { tool_calls: fields.tools.map((name) => ({ name })) } : {}),
|
|
17
|
+
},
|
|
18
|
+
identity: {
|
|
19
|
+
subject: fields.subject,
|
|
20
|
+
client_id: fields.subject ? "client-1" : null,
|
|
21
|
+
session_id: null,
|
|
22
|
+
token_fingerprint: fields.subject ? "0123456789abcdef" : null,
|
|
23
|
+
scopes: fields.subject ? ["feedback:write"] : [],
|
|
24
|
+
client_name: "conformance",
|
|
25
|
+
client_version: "1.0.0",
|
|
26
|
+
user_agent: null,
|
|
27
|
+
},
|
|
28
|
+
server: { name: "conformance-server", version: "1.0.0" },
|
|
29
|
+
status: "new",
|
|
30
|
+
triage_note: null,
|
|
31
|
+
triaged_by: null,
|
|
32
|
+
updated_at: created_at,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Records 3 and 4 share a created_at so ordering and cursors must fall back to id.
|
|
36
|
+
export const conformanceRecords = [
|
|
37
|
+
record(1, "2026-01-01T00:00:00.000Z", { kind: "bug", severity: "major", tags: ["ui"], subject: "alice", tools: ["create_meme"] }),
|
|
38
|
+
record(2, "2026-01-02T00:00:00.000Z", { kind: "tool_failure", severity: "blocker", tags: ["timeout", "ui"], subject: "bob", tools: ["create_meme", "list_templates"] }, {
|
|
39
|
+
goal: "Make a meme — with “quotes”, 'apostrophes' and emoji 🎭",
|
|
40
|
+
expected: "A job id",
|
|
41
|
+
actual: "504 after 30s",
|
|
42
|
+
repro_steps: ["call create_meme", "wait"],
|
|
43
|
+
excerpt: "line one\nline two",
|
|
44
|
+
metadata: { attempt: 2, nested: { ok: false, values: [1, "two", null] } },
|
|
45
|
+
}),
|
|
46
|
+
record(3, "2026-01-03T00:00:00.000Z", { kind: "feature_request", severity: "none", tags: [], subject: "alice", tools: [] }),
|
|
47
|
+
record(4, "2026-01-03T00:00:00.000Z", { kind: "friction", severity: "minor", tags: ["docs"], subject: null, tools: ["list_templates"] }),
|
|
48
|
+
record(5, "2026-01-04T00:00:00.000Z", { kind: "praise", severity: "none", tags: [], subject: "bob", tools: [] }),
|
|
49
|
+
record(6, "2026-01-05T00:00:00.000Z", { kind: "bug", severity: "minor", tags: ["timeout"], subject: "alice", tools: ["create_meme"] }),
|
|
50
|
+
];
|
|
51
|
+
const ids = (...numbers) => numbers.map(id);
|
|
52
|
+
// Cases run in order against one store seeded with conformanceRecords.
|
|
53
|
+
// Read-only cases come first; the triage cases at the end mutate record 1.
|
|
54
|
+
export const conformanceCases = [
|
|
55
|
+
{ name: "lists newest first with id as tiebreak", op: "list", filter: {}, limit: 10, expect_pages: [ids(6, 5, 4, 3, 2, 1)] },
|
|
56
|
+
{ name: "paginates across a created_at tie", op: "list", filter: {}, limit: 3, expect_pages: [ids(6, 5, 4), ids(3, 2, 1)] },
|
|
57
|
+
{ name: "paginates one record at a time", op: "list", filter: { subject: "alice" }, limit: 1, expect_pages: [ids(6), ids(3), ids(1)] },
|
|
58
|
+
{ name: "filters by kind", op: "list", filter: { kind: "bug" }, limit: 10, expect_pages: [ids(6, 1)] },
|
|
59
|
+
{ name: "filters by severity", op: "list", filter: { severity: "minor" }, limit: 10, expect_pages: [ids(6, 4)] },
|
|
60
|
+
{ name: "filters by status", op: "list", filter: { status: "resolved" }, limit: 10, expect_pages: [[]] },
|
|
61
|
+
{ name: "filters by subject", op: "list", filter: { subject: "alice" }, limit: 10, expect_pages: [ids(6, 3, 1)] },
|
|
62
|
+
{ name: "filters by tool", op: "list", filter: { tool: "create_meme" }, limit: 10, expect_pages: [ids(6, 2, 1)] },
|
|
63
|
+
{ name: "filters by tag", op: "list", filter: { tag: "timeout" }, limit: 10, expect_pages: [ids(6, 2)] },
|
|
64
|
+
{ name: "since is inclusive", op: "list", filter: { since: "2026-01-03T00:00:00.000Z" }, limit: 10, expect_pages: [ids(6, 5, 4, 3)] },
|
|
65
|
+
{ name: "until is exclusive", op: "list", filter: { until: "2026-01-03T00:00:00.000Z" }, limit: 10, expect_pages: [ids(2, 1)] },
|
|
66
|
+
{ name: "combines filters with AND", op: "list", filter: { kind: "bug", tag: "timeout" }, limit: 10, expect_pages: [ids(6)] },
|
|
67
|
+
{ name: "round-trips a full record", op: "get", id: id(2), expect_found: true },
|
|
68
|
+
{ name: "round-trips a record with null identity", op: "get", id: id(4), expect_found: true },
|
|
69
|
+
{ name: "get resolves null for an unknown id", op: "get", id: id(9), expect_found: false },
|
|
70
|
+
{
|
|
71
|
+
name: "stats over everything",
|
|
72
|
+
op: "stats",
|
|
73
|
+
filter: {},
|
|
74
|
+
expect: {
|
|
75
|
+
total: 6,
|
|
76
|
+
by_kind: { bug: 2, tool_failure: 1, feature_request: 1, friction: 1, praise: 1 },
|
|
77
|
+
by_status: { new: 6 },
|
|
78
|
+
by_severity: { major: 1, blocker: 1, none: 2, minor: 2 },
|
|
79
|
+
by_tool: { create_meme: 3, list_templates: 2 },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "stats honours filters",
|
|
84
|
+
op: "stats",
|
|
85
|
+
filter: { subject: "alice" },
|
|
86
|
+
expect: {
|
|
87
|
+
total: 3,
|
|
88
|
+
by_kind: { bug: 2, feature_request: 1 },
|
|
89
|
+
by_status: { new: 3 },
|
|
90
|
+
by_severity: { major: 1, none: 1, minor: 1 },
|
|
91
|
+
by_tool: { create_meme: 2 },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "stats with no matches is empty",
|
|
96
|
+
op: "stats",
|
|
97
|
+
filter: { tag: "nope" },
|
|
98
|
+
expect: { total: 0, by_kind: {}, by_status: {}, by_severity: {}, by_tool: {} },
|
|
99
|
+
},
|
|
100
|
+
{ name: "rejects a duplicate id", op: "insert_duplicate", id: id(1) },
|
|
101
|
+
{
|
|
102
|
+
name: "triage sets status and note",
|
|
103
|
+
op: "update_triage",
|
|
104
|
+
id: id(1),
|
|
105
|
+
patch: { status: "triaged", triage_note: "Known issue", triaged_by: "reader", updated_at: "2026-02-01T00:00:00.000Z" },
|
|
106
|
+
expect: { status: "triaged", triage_note: "Known issue", triaged_by: "reader", updated_at: "2026-02-01T00:00:00.000Z", created_at: "2026-01-01T00:00:00.000Z", title: "Record 1" },
|
|
107
|
+
},
|
|
108
|
+
{ name: "triaged record is found by status", op: "list", filter: { status: "triaged" }, limit: 10, expect_pages: [ids(1)] },
|
|
109
|
+
{
|
|
110
|
+
name: "omitted patch fields are left unchanged",
|
|
111
|
+
op: "update_triage",
|
|
112
|
+
id: id(1),
|
|
113
|
+
patch: { triaged_by: "reader-2", updated_at: "2026-02-02T00:00:00.000Z" },
|
|
114
|
+
expect: { status: "triaged", triage_note: "Known issue", triaged_by: "reader-2", updated_at: "2026-02-02T00:00:00.000Z" },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: "a null note clears it",
|
|
118
|
+
op: "update_triage",
|
|
119
|
+
id: id(1),
|
|
120
|
+
patch: { triage_note: null, triaged_by: "reader", updated_at: "2026-02-03T00:00:00.000Z" },
|
|
121
|
+
expect: { status: "triaged", triage_note: null },
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "triage resolves null for an unknown id",
|
|
125
|
+
op: "update_triage",
|
|
126
|
+
id: id(9),
|
|
127
|
+
patch: { status: "resolved", triaged_by: "reader", updated_at: "2026-02-04T00:00:00.000Z" },
|
|
128
|
+
expect: null,
|
|
129
|
+
},
|
|
130
|
+
];
|