MCP SDK
Install @mostlovedproduct/mcp, register the submit_feedback tool, choose a profile, pass trusted context and add a kill switch.
PreviewView as Markdown
@mostlovedproduct/mcp adds one standard tool, submit_feedback, to your MCP server. Agents use it to tell your team when one of your tools errored, misled them, or lacked something the task needed.
It is built for servers in production: TypeScript, no Node-only dependencies, safe on Cloudflare Workers and Lambda, and it never makes the user’s task fail or wait.
Install
npm i @mostlovedproduct/mcp
Create a server key (mlp_sk_…) and store it as a secret. Server keys are write-only.
Three ways to integrate
1. Official MCP SDK adapter
import { registerFeedbackTool } from "@mostlovedproduct/mcp/sdk";
registerFeedbackTool(server, {
key: env.MLP_SERVER_KEY,
product: "Acme",
profile: "proactive",
});
The root entry does not import the official MCP SDK; only @mostlovedproduct/mcp/sdk does.
2. Definition and handler (any server)
For hand-written JSON-RPC handlers and other frameworks. The definition is plain JSON Schema.
import { createFeedbackHandler } from "@mostlovedproduct/mcp";
const feedback = createFeedbackHandler({ key: env.MLP_SERVER_KEY, product: "Acme" });
// tools/list
const tools = [...yourTools, feedback.tool];
// tools/call
if (name === feedback.tool.name) return feedback.call(args, callInfo);
feedback.tool (or feedbackTool(opts) on its own) is { name, title, description, inputSchema, annotations }. feedback.call(args, callInfo) returns an MCP CallToolResult, never throws, and resolves within timeoutMs (default 3 s) plus a small margin.
3. Server instructions (optional)
For hosts that surface server instructions, feedbackInstructions(opts) returns one line:
If a Acme tool fails, misleads you or lacks something the task needs, you can tell the Acme team with submit_feedback after finishing the affected step.
Proactive profile only. The conservative profile adds no instructions.
Profiles
One schema, two descriptions. Pick per server, or per host when you can detect it.
| Profile | For | When the agent files |
|---|---|---|
proactive (default) |
Developer and API products, coding agents, internal agents | On its own, after hitting a problem |
conservative |
Consumer hosts (ChatGPT, Claude apps) and anything under directory review | Only when the user asks, or a tool clearly failed and the user has been told |
You may append one sentence of product-specific guidance with extraGuidance (up to 300 characters). You can’t replace the description body: the shared wording is what we measure and improve for every customer. The full wording is in the spec.
Context and trust
The model never supplies identity or metadata. Your server attaches trusted context per call:
createFeedbackHandler({
key: env.MLP_SERVER_KEY,
product: "Acme",
profile: "proactive",
enabled: () => !env.FEEDBACK_KILL_SWITCH,
context: (call) => ({
trust: call.signedIn ? "authenticated" : call.knownHost ? "known_host" : "anonymous",
client: { name: call.hostName },
user: { id: call.opaqueUserId, tier: call.plan },
app: { version: BUILD_SHA, env: "production" },
flags: call.experiments,
}),
});
trust:authenticated(signed-in caller),known_host(traffic you identify as a known host) oranonymous. Only server keys can attest trust.user.id: your own opaque ID. Don’t send emails or names.flags: experiment variants and feature flags, so issues can be split by variant.
context runs on every call. If it throws or takes longer than 500 ms, the report is still sent without it.
Kill switch and rate limits
Give feedback its own controls, separate from your other tools:
- Kill switch:
enabled: () => booleanis checked on every call. When it returnsfalse, the tool replies with the standard “could not be recorded” message and the task continues. - Rate limit bucket: limit
submit_feedbackseparately from your read and write tools, so a burst of reports can’t affect them.
What the agent gets back
On success:
Recorded for the Acme team (ref 01a1d56f). Continue with the user's task. Nothing else is needed and you should not call this tool again for the same problem.
On any failure (timeout, rate limit, kill switch), with isError: false so a feedback failure never looks like a task failure:
The report could not be recorded right now. That's fine: continue with the user's task and do not retry.
Invalid arguments are the one case that returns isError: true, naming the field, so the model can correct a malformed call once.
Annotations
readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false. The tool writes, so it is never marked read-only. See ChatGPT and Claude apps for host review notes.
Before production
- Pick a profile. Use
conservativefor anything listed in a consumer directory. - Wire the kill switch and a separate rate-limit bucket.
- Update your privacy notice before production traffic. We provide template language.
- Call the tool once from an MCP inspector and confirm the report arrives.
Something wrong or missing on this page?