mcp-feedback 0.3.1 → 0.4.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/README.md +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/register.d.ts +5 -0
- package/dist/register.js +6 -2
- package/dist/tools.d.ts +13 -0
- package/dist/tools.js +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ registerFeedback(server, {
|
|
|
70
70
|
| --- | --- |
|
|
71
71
|
| `store` | Where records go. Required. |
|
|
72
72
|
| `resolveIdentity` | Override identity fields for a request. |
|
|
73
|
+
| `requireConfirmation` | Tell agents to file only after the user confirms the exact feedback. Use `feedbackConfirmInstructions` in place of `feedbackInstructions`, and `feedbackToolCatalogFor(options)` for catalogs. |
|
|
73
74
|
| `requireIdentity` | Refuse submissions with no subject and no token fingerprint. |
|
|
74
75
|
| `redact` | Scrub a record before it is stored. |
|
|
75
76
|
| `limits` | Override size limits (see the spec for defaults). |
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { defineFeedbackStore, toolNamesOf, encodeCursor, decodeCursor, compareNe
|
|
|
3
3
|
export { defaultResolveIdentity, fingerprintToken, type ClientImplementation, type FeedbackRequestExtra, type ResolveIdentity, } from "./identity.js";
|
|
4
4
|
export { registerFeedback, registerFeedbackReader, DEFAULT_FEEDBACK_LIMITS, type FeedbackLimits, type FeedbackOptions, type FeedbackReaderOptions, } from "./register.js";
|
|
5
5
|
export { FeedbackInputError, listPage, normalizeFilter, triageMany, type TriageOutcome } from "./reader.js";
|
|
6
|
-
export { feedbackInstructions, feedbackToolCatalog, feedbackReaderToolCatalog } from "./tools.js";
|
|
6
|
+
export { feedbackInstructions, feedbackConfirmInstructions, feedbackToolCatalog, feedbackToolCatalogFor, feedbackReaderToolCatalog, } from "./tools.js";
|
|
7
7
|
export { memoryStore } from "./stores/memory.js";
|
package/dist/index.js
CHANGED
|
@@ -3,5 +3,5 @@ export { defineFeedbackStore, toolNamesOf, encodeCursor, decodeCursor, compareNe
|
|
|
3
3
|
export { defaultResolveIdentity, fingerprintToken, } from "./identity.js";
|
|
4
4
|
export { registerFeedback, registerFeedbackReader, DEFAULT_FEEDBACK_LIMITS, } from "./register.js";
|
|
5
5
|
export { FeedbackInputError, listPage, normalizeFilter, triageMany } from "./reader.js";
|
|
6
|
-
export { feedbackInstructions, feedbackToolCatalog, feedbackReaderToolCatalog } from "./tools.js";
|
|
6
|
+
export { feedbackInstructions, feedbackConfirmInstructions, feedbackToolCatalog, feedbackToolCatalogFor, feedbackReaderToolCatalog, } from "./tools.js";
|
|
7
7
|
export { memoryStore } from "./stores/memory.js";
|
package/dist/register.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ interface SharedOptions {
|
|
|
30
30
|
onError?: (error: unknown, tool: string) => void;
|
|
31
31
|
}
|
|
32
32
|
export interface FeedbackOptions extends SharedOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Tell agents to file only after the user confirms the exact feedback. Pair it with
|
|
35
|
+
* `feedbackConfirmInstructions` in the server's instructions.
|
|
36
|
+
*/
|
|
37
|
+
requireConfirmation?: boolean;
|
|
33
38
|
/** Refuse submissions that carry neither a subject nor a token fingerprint. */
|
|
34
39
|
requireIdentity?: boolean;
|
|
35
40
|
/** Last chance to scrub a record before it is stored. */
|
package/dist/register.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import { defaultResolveIdentity, } from "./identity.js";
|
|
3
3
|
import { FeedbackInputError, listPage, normalizeFilter, triageMany } from "./reader.js";
|
|
4
|
-
import { READER_TOOLS, SUBMIT_TOOL, SYNTHESIZE_PROMPT, feedbackStatsShape, getFeedbackShape, listFeedbackShape, submitFeedbackShape, synthesizeFeedbackArgsShape, synthesizePromptText, updateFeedbackTriageShape, } from "./tools.js";
|
|
4
|
+
import { READER_TOOLS, SUBMIT_TOOL, submitToolDescription, SYNTHESIZE_PROMPT, feedbackStatsShape, getFeedbackShape, listFeedbackShape, submitFeedbackShape, synthesizeFeedbackArgsShape, synthesizePromptText, updateFeedbackTriageShape, } from "./tools.js";
|
|
5
5
|
import { FEEDBACK_SCHEMA_VERSION, } from "./types.js";
|
|
6
6
|
export const DEFAULT_FEEDBACK_LIMITS = {
|
|
7
7
|
titleChars: 200,
|
|
@@ -30,6 +30,10 @@ function checkLimits(input, limits) {
|
|
|
30
30
|
throw new FeedbackInputError(`${label} has ${value.length} entries; the limit is ${limits.maxItems}.`);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
for (const field of ["title", "body"]) {
|
|
34
|
+
if (!input[field].trim())
|
|
35
|
+
throw new FeedbackInputError(`${field} is blank. Describe the problem and resubmit.`);
|
|
36
|
+
}
|
|
33
37
|
text("title", input.title, limits.titleChars);
|
|
34
38
|
text("body", input.body, limits.bodyChars);
|
|
35
39
|
items("tags", input.tags);
|
|
@@ -86,7 +90,7 @@ export function registerFeedback(server, options) {
|
|
|
86
90
|
const name = prefix + SUBMIT_TOOL.name;
|
|
87
91
|
server.registerTool(name, {
|
|
88
92
|
title: SUBMIT_TOOL.title,
|
|
89
|
-
description:
|
|
93
|
+
description: submitToolDescription(options.requireConfirmation),
|
|
90
94
|
inputSchema: submitFeedbackShape,
|
|
91
95
|
annotations: SUBMIT_TOOL.annotations,
|
|
92
96
|
}, (args, extra) => guard(name, async () => {
|
package/dist/tools.d.ts
CHANGED
|
@@ -158,11 +158,24 @@ export declare function synthesizePromptText(prefix: string, args: {
|
|
|
158
158
|
}): string;
|
|
159
159
|
/** Text a host can append to its server `instructions` so agents know when to file feedback. */
|
|
160
160
|
export declare const feedbackInstructions: string;
|
|
161
|
+
/** Appended to the submit tool's description when the host sets `requireConfirmation`. */
|
|
162
|
+
export declare const CONFIRMATION_REQUIRED: string;
|
|
163
|
+
/** The `feedbackInstructions` counterpart for hosts that set `requireConfirmation`. */
|
|
164
|
+
export declare const feedbackConfirmInstructions: string;
|
|
165
|
+
export declare function submitToolDescription(requireConfirmation?: boolean): string;
|
|
161
166
|
/** `{ name, description }` entries for hosts that publish a tool catalog. */
|
|
162
167
|
export declare const feedbackToolCatalog: {
|
|
163
168
|
name: "submit_feedback";
|
|
164
169
|
description: string;
|
|
165
170
|
}[];
|
|
171
|
+
/** The catalog entry exactly as registerFeedback advertises it with these options. */
|
|
172
|
+
export declare function feedbackToolCatalogFor(options?: {
|
|
173
|
+
requireConfirmation?: boolean;
|
|
174
|
+
toolPrefix?: string;
|
|
175
|
+
}): {
|
|
176
|
+
name: string;
|
|
177
|
+
description: string;
|
|
178
|
+
}[];
|
|
166
179
|
export declare const feedbackReaderToolCatalog: {
|
|
167
180
|
name: "list_feedback" | "get_feedback" | "update_feedback_triage" | "feedback_stats";
|
|
168
181
|
description: string;
|
package/dist/tools.js
CHANGED
|
@@ -133,8 +133,22 @@ export function synthesizePromptText(prefix, args) {
|
|
|
133
133
|
export const feedbackInstructions = "If one of this server's tools fails, behaves unexpectedly, is confusing, or cannot do what the user needed, " +
|
|
134
134
|
"call submit_feedback once you have handled or been blocked on the user's request. Describe the goal, what you " +
|
|
135
135
|
"expected, what happened and the tool calls involved, without secrets or personal data, and tell the user you filed it.";
|
|
136
|
+
/** Appended to the submit tool's description when the host sets `requireConfirmation`. */
|
|
137
|
+
export const CONFIRMATION_REQUIRED = " Only call it after showing the user the exact feedback you intend to submit and receiving their explicit " +
|
|
138
|
+
"confirmation; a complaint or request is not by itself permission.";
|
|
139
|
+
/** The `feedbackInstructions` counterpart for hosts that set `requireConfirmation`. */
|
|
140
|
+
export const feedbackConfirmInstructions = "If one of this server's tools fails, behaves unexpectedly, is confusing, or cannot do what the user needed, " +
|
|
141
|
+
"offer to file feedback: show the user the exact kind, title, body and context you would submit, and call " +
|
|
142
|
+
"submit_feedback only after they explicitly confirm. Leave out secrets and personal data.";
|
|
143
|
+
export function submitToolDescription(requireConfirmation = false) {
|
|
144
|
+
return SUBMIT_TOOL.description + (requireConfirmation ? CONFIRMATION_REQUIRED : "");
|
|
145
|
+
}
|
|
136
146
|
/** `{ name, description }` entries for hosts that publish a tool catalog. */
|
|
137
147
|
export const feedbackToolCatalog = [{ name: SUBMIT_TOOL.name, description: SUBMIT_TOOL.description }];
|
|
148
|
+
/** The catalog entry exactly as registerFeedback advertises it with these options. */
|
|
149
|
+
export function feedbackToolCatalogFor(options = {}) {
|
|
150
|
+
return [{ name: (options.toolPrefix ?? "") + SUBMIT_TOOL.name, description: submitToolDescription(options.requireConfirmation) }];
|
|
151
|
+
}
|
|
138
152
|
export const feedbackReaderToolCatalog = Object.values(READER_TOOLS).map(({ name, description }) => ({
|
|
139
153
|
name,
|
|
140
154
|
description,
|
package/package.json
CHANGED