@alpic-ai/insights 0.0.0-dev.290da08 → 0.0.0-dev.2916881

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/dist/index.d.mts CHANGED
@@ -47,28 +47,4 @@ declare function userPromptMiddleware(options?: UserPromptMiddlewareOptions): Mc
47
47
  */
48
48
  declare const captureUserPrompts: (server: McpServer | Server, options?: UserPromptMiddlewareOptions) => void;
49
49
  //#endregion
50
- //#region src/feedback-middleware.d.ts
51
- interface FeedbackData {
52
- toolName?: string;
53
- message: string;
54
- }
55
- interface FeedbackMiddlewareOptions {
56
- /** Tool name to register. Defaults to `send_feedback`. */
57
- toolName?: string;
58
- /**
59
- * Custom handler invoked with the user's feedback. When provided, the middleware does NOT
60
- * attach data to the response `_meta` — the handler takes full ownership of delivery.
61
- * Mirrors `userPromptMiddleware`'s `handler` semantics.
62
- */
63
- handler?: (feedback: FeedbackData) => Promise<void> | void;
64
- }
65
- /**
66
- * Lets MCP server builders collect qualitative feedback from end users about their
67
- * tool/server. Injects a `send_feedback` tool at `tools/list` time and intercepts calls
68
- * to it at `tools/call` time. The tool has no handler on the server — the middleware
69
- * short-circuits the call and either invokes the provided `handler` or attaches the
70
- * feedback to the response `_meta` under the key named by `process.env.ALPIC_FEEDBACK_META_KEY`.
71
- */
72
- declare function feedbackMiddleware(options?: FeedbackMiddlewareOptions): McpMiddlewareFn;
73
- //#endregion
74
- export { type FeedbackData, type FeedbackMiddlewareOptions, type McpMiddlewareFn, type PromptData, type UserPromptMiddlewareOptions, captureUserPrompts, feedbackMiddleware, userPromptMiddleware };
50
+ export { type McpMiddlewareFn, type PromptData, type UserPromptMiddlewareOptions, captureUserPrompts, userPromptMiddleware };
package/dist/index.mjs CHANGED
@@ -98,87 +98,4 @@ const captureUserPrompts = (server, options) => {
98
98
  handlers.set = (method, handler) => originalSet(method, wrap(method, handler));
99
99
  };
100
100
  //#endregion
101
- //#region src/feedback-middleware.ts
102
- const DEFAULT_FEEDBACK_TOOL_NAME = "send_feedback";
103
- const FEEDBACK_TOOL_DESCRIPTION = "Send the user's feedback about this MCP server to its operators. Use this tool ONLY for feedback about this MCP server itself — never about other tools, services, or the host. You MUST ask the user for explicit consent before calling this tool. You can proactively suggest sending feedback when something didn't work well, but never call without consent. ";
104
- const FEEDBACK_RESPONSE_TEXT = "Feedback received. Thanks!";
105
- /**
106
- * Lets MCP server builders collect qualitative feedback from end users about their
107
- * tool/server. Injects a `send_feedback` tool at `tools/list` time and intercepts calls
108
- * to it at `tools/call` time. The tool has no handler on the server — the middleware
109
- * short-circuits the call and either invokes the provided `handler` or attaches the
110
- * feedback to the response `_meta` under the key named by `process.env.ALPIC_FEEDBACK_META_KEY`.
111
- */
112
- function feedbackMiddleware(options) {
113
- const feedbackToolName = options?.toolName ?? DEFAULT_FEEDBACK_TOOL_NAME;
114
- const metaKeyName = process.env.ALPIC_FEEDBACK_META_KEY;
115
- return async (request, _extra, next) => {
116
- if (request.method === "tools/list") {
117
- const rawResult = await next();
118
- const parsed = ListToolsResultSchema.safeParse(rawResult);
119
- if (!parsed.success) return rawResult;
120
- if (parsed.data.tools.some((tool) => tool.name === feedbackToolName)) return parsed.data;
121
- parsed.data.tools.push({
122
- name: feedbackToolName,
123
- description: FEEDBACK_TOOL_DESCRIPTION,
124
- inputSchema: {
125
- type: "object",
126
- properties: {
127
- tool_name: {
128
- type: "string",
129
- description: "Name of the tool the feedback is about, when applicable."
130
- },
131
- message: {
132
- type: "string",
133
- description: "The user's feedback content. Remove any PII (Personal Identifiable Information)."
134
- }
135
- },
136
- required: ["message"]
137
- }
138
- });
139
- return parsed.data;
140
- }
141
- if (request.method !== "tools/call") return next();
142
- const parsedRequest = CallToolRequestSchema.safeParse(request);
143
- if (!parsedRequest.success || parsedRequest.data.params.name !== feedbackToolName) return next();
144
- const args = parsedRequest.data.params.arguments ?? {};
145
- const message = typeof args.message === "string" ? args.message.trim() : void 0;
146
- const rawToolName = typeof args.tool_name === "string" ? args.tool_name.trim() : "";
147
- const toolName = rawToolName.length > 0 ? rawToolName : void 0;
148
- if (message === void 0 || message.length === 0) return {
149
- content: [{
150
- type: "text",
151
- text: "Feedback ignored — `message` is required."
152
- }],
153
- isError: true
154
- };
155
- const feedback = toolName !== void 0 ? {
156
- toolName,
157
- message
158
- } : { message };
159
- if (options?.handler) {
160
- try {
161
- await options.handler(feedback);
162
- } catch (error) {
163
- console.error("Error calling feedback handler", error);
164
- }
165
- return { content: [{
166
- type: "text",
167
- text: FEEDBACK_RESPONSE_TEXT
168
- }] };
169
- }
170
- if (metaKeyName) return {
171
- content: [{
172
- type: "text",
173
- text: FEEDBACK_RESPONSE_TEXT
174
- }],
175
- _meta: { [metaKeyName]: feedback }
176
- };
177
- return { content: [{
178
- type: "text",
179
- text: FEEDBACK_RESPONSE_TEXT
180
- }] };
181
- };
182
- }
183
- //#endregion
184
- export { captureUserPrompts, feedbackMiddleware, userPromptMiddleware };
101
+ export { captureUserPrompts, userPromptMiddleware };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alpic-ai/insights",
3
- "version": "0.0.0-dev.290da08",
3
+ "version": "0.0.0-dev.2916881",
4
4
  "description": "User insights middlewares for Alpic-hosted MCP servers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",