Add feedback
Feedback is optional and works with every starter. Choose the starter that fits your tool, API, database, SOAP, progress, or user interface. Then install:
npm install @emseepea/feedbackNative reply monitoring is optional. Before enabling it, check client availability and the remaining production responsibilities. Feedback tools and automatic event-triggered execution have different client support.
Choose the smaller feedback mode
Section titled “Choose the smaller feedback mode”Use a detailed submission when the team needs one useful observation but does not need to reply. Use a protected conversation when support must reply and the AI must bring the response back to the user.
Both modes record explicit, bounded content. They do not automatically capture chat history, raw tool inputs or results, credentials, or application payloads.
Add one-way feedback
Section titled “Add one-way feedback”import { defineFeedbackSubmission } from "@emseepea/feedback";import { createPostgresFeedbackSubmissionBackend } from "@emseepea/feedback/postgres";
const feedback = defineFeedbackSubmission({ access: "public", scope: "pea-guide", backend: createPostgresFeedbackSubmissionBackend({ pool }),});
const app = await createToolServer({ additionalTools: [feedback],});The tool description tells the AI when feedback is notable. This includes an error, friction, annoyance, unnecessary difficulty, confusion, repetition, surprising good or bad results, a capability mismatch, a suggestion, or clear success.
It also tells the AI to record one observation without asking a separate permission question, then openly tell the user what it recorded in the same response. It must avoid normal uneventful operation and duplicates, and stop if the user objects. These are model behaviours, so test them with every supported AI client.
The successful structured result includes nextAction. It reminds the AI to
finish every part of the user’s original request before briefly stating the
specific feedback recorded. A routine successful tool call, structured result,
or expected number of steps is not feedback-worthy.
Describe feedback for your application
Section titled “Describe feedback for your application”defineFeedbackSubmission accepts an optional description string. It replaces
only the published tool description. Omit it to use the operation-specific
default. Empty or whitespace-only descriptions fail during configuration.
For example, an application that retains calculator feedback indefinitely in Firestore can use the following description. Use it only if those storage and retention statements match your deployment:
const feedback = defineFeedbackSubmission({ access: "public", scope: "calculator-feedback", backend, description: "Record one actionable product-feedback observation about the AU Home Loan Calculator operation being performed: an error, confusing explanation, unnecessary step, capability mismatch, suggestion, unexpected result or notable success. " + "Describe the calculator issue or improvement in your own words. A qualifying observation may come from the user's message or a calculator tool result; do not collect unrelated conversation or general user behavior. " + "For a qualifying observation, call this tool before answering without asking a separate permission question. " + "Do not say you recorded feedback unless this tool returned a successful receipt. After a successful receipt, fully answer the original request and briefly disclose the specific observation recorded in the same reply. " + "Skip routine successes, expected empty results, session opening or closing and duplicates. Do not record after the user objects. " + "Exclude identity, personal or financial details, credentials, surrounding conversation and raw calculator inputs or results. " + "No conversation or identity context is automatically attached. Feedback is retained indefinitely by the application operator in Google Cloud Firestore; model instructions do not guarantee arbitrary free-form text contains no private information.",});Here, backend is your configured submission backend. Keep the actual collection
triggers, success disclosure, objection handling and privacy guidance in any
replacement description. State your actual storage and retention policy. Do not
use wording to hide collection or imply that model instructions remove private
information from arbitrary text.
The native input and output schemas, authorization, annotations, backend calls, hooks and durable receipt behavior stay the same. A successful receipt still requires the backend to finish recording. Configure annotations separately when your backend or hooks add effects.
The default now limits feedback to the application operation being performed. It excludes unrelated conversation and general user behavior, retains automatic qualifying user-message and tool-result triggers, and tells the AI to answer the original request and disclose recorded feedback only after success.
In issue #179, this calculator-specific wording passed one application’s production metadata scan. That result does not establish acceptance for another application, automatic invocation behavior, or privacy of stored content.
Test the native journey with your supported clients; a description option does not change collection behavior or guarantee marketplace acceptance.
Separate customer and internal feedback
Section titled “Separate customer and internal feedback”A collection is a deployment-configured authorization partition, such as
customer or internal. It fixes where feedback goes; it does not identify
the account or person. Configure submission, monitoring, and operator roles
separately.
- Customer-facing MCP: submits customer feedback only, with no monitor or operator capabilities.
- Internal MCP: submits explicitly internal feedback and monitors or reads internal, customer, or both authorized collections.
The support backend owns the authoritative feedback record and its assignment, status, replies, notifications, and private notes. Em See Pea retrieves exact records there rather than creating a second support inbox.
Use defineFeedbackCollections and defineFeedbackCollectionSubmissions to
create fixed-destination tools. A customer configuration declares only the
customer submission role and exposes submit-customer-feedback. An internal
configuration declares the internal submission role and exposes
submit-internal-feedback. Tool inputs cannot change the destination.
Add defineFeedbackCollectionOperators only to the protected internal MCP.
Its list-feedback-submissions tool accepts a collection and bounded page
options. Its get-feedback-submission tool retrieves the exact
{ collection, submissionId }. Each call checks collection permissions and
the authenticated account scope before returning validated feedback fields.
Trigger operator work when feedback arrives
Section titled “Trigger operator work when feedback arrives”Configure createFeedbackSubmittedEventsOptions from
@emseepea/feedback/mcp-events with explicit monitor roles, current collection
authorization, health, and a durable MCP Events store.
Operators can subscribe to any of these authorized selections:
{ "collections": ["internal"] }{ "collections": ["customer"] }{ "collections": ["customer", "internal"] }The selection must be non-empty and unique, with at most 32 configured collections. Discovery, subscription, refresh, and delivery independently check current access.
After persistence, publishFeedbackSubmittedEvent(app, event, { scope })
publishes feedback.submitted with only collection, submissionId, and
sourceEventId. The operator retrieves the exact authoritative record before
acting on its content. Repeated publication can carry the same sourceEventId.
Use the same stable authenticated account scope for submission and operator
adapters and the event ownerKey. Collection names alone do not isolate
accounts. Resolve the account from verified authentication; do not treat an
access token or OAuth client ID as an account identity. The publisher sends
only to subscriptions owned by that scope, even when another account monitors
the same collection.
Supply a durable collection backend that enforces the scope on every operation and cursor. Hooks are best-effort; use a transactional outbox for reliable publication. The in-memory collection backend is process-local reference storage. No monitor roles means no MCP Events capability.
Follow the customer and internal configuration examples for the complete tool and event setup and the application-owned interfaces.
Store one-way feedback as Markdown
Section titled “Store one-way feedback as Markdown”For an opt-in local file destination, use
createMarkdownFeedbackSubmissionBackend({ directory }) from
@emseepea/feedback/markdown as the backend of defineFeedbackSubmission.
Use an absolute path to a dedicated folder, such as docs/feedback resolved
from your repository root when dogfood testing locally.
Each submission becomes a separate Markdown file. Inside a Git repository, the
adapter creates a .gitignore in that folder before writing feedback. The rule
ignores generated files; it does not protect already tracked or staged files,
or files force-added to Git. Check those before sharing your repository.
This destination has no team reply path. Choose a conversation backend when users need responses.
Match annotations to composed effects
Section titled “Match annotations to composed effects”Override feedback tool annotations when your backend or hooks change a tool’s effects. Existing defaults remain unchanged.
const submission = defineFeedbackSubmission({ access: "public", annotations: { destructiveHint: true }, backend: feedbackBackend, hooks: [sendSubmissionEmail],});
const feedbackTools = defineFeedbackConversation({ requiredScopes: ["feedback"], annotations: { reply: { destructiveHint: true }, list: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false, }, get: { destructiveHint: true, idempotentHint: false, openWorldHint: false, }, }, backend: conversationBackend, hooks: [sendConversationEmail],});Classify the complete operation, not only the feedback package’s built-in persistence step. Include backend writes, lifecycle hooks, queues, notifications, and external services.
- A
listorgetoperation that changes lifecycle state is not read-only. SetreadOnlyHint: false. - If the operation cancels notification state, set
destructiveHint: true. - If repeating the operation can produce a different state transition, set
idempotentHint: false. - A
replyor submission operation that can send email must setdestructiveHint: true. - Set
openWorldHinttotruewhen the complete operation can interact with an external domain beyond the operation’s declared bounds. Otherwise set it tofalse.
Internet connectivity alone does not make an operation open-world. A bounded private account can remain closed-world even when it uses a remote service.
Overrides accept only the four boolean flags shown above. Omitted or
undefined flags retain current defaults. Invalid flag values or operation
keys fail at definition time, and later mutation does not change discovery.
The exported types are FeedbackToolAnnotationOverrides and
FeedbackConversationAnnotationOverrides. Collection and operator helpers
keep their existing annotation contracts.
Tool annotations help MCP clients describe and confirm an operation. They do not grant access or replace authentication and authorization. MCP discovery reports each configured override while unchanged operations keep the package defaults.
Add a support conversation
Section titled “Add a support conversation”import { defineFeedbackConversation, defineFeedbackSubmission,} from "@emseepea/feedback";import { createGitHubFeedbackBackend } from "@emseepea/feedback/github";
const feedbackBackend = createGitHubFeedbackBackend({ owner: "your-organisation", repository: "support", token: () => getGitHubToken(),});const feedbackScope = (principal) => accountScopeForPrincipal(principal);const feedbackTools = [ defineFeedbackSubmission({ access: "protected", requiredScopes: ["feedback"], scope: feedbackScope, backend: { async submit({ observation, detail }, context) { const result = await feedbackBackend.createThread({ subject: observation, message: detail, }, context); return { id: result.conversation.id, recordedAt: result.conversation.createdAt, events: result.events, }; }, }, }), ...defineFeedbackConversation({ requiredScopes: ["feedback"], scope: feedbackScope, backend: feedbackBackend, }),];
const app = await createToolServer({ additionalTools: feedbackTools, authentication,});The conversation helper adds reply, list, and get operations. Use
defineFeedbackSubmission and submit-feedback to create every new feedback
conversation. create-feedback-thread has been removed.
Except for the GitHub reference-format change described below, existing stored thread IDs remain valid for reply and get operations, and those threads remain available in list results.
The ID returned by submit-feedback is the canonical thread ID for reply and
get. List returns that thread under the same authorized scope.
Legacy callers should set the required observation field to one of the allowed
category values. Set detail to Subject: <subject>\n\n<message>.
The complete constructed detail value, including the prefix and line breaks,
must not exceed 4,000 characters. The framework rejects an over-limit detail
value and does not truncate the subject or message content.
The submission result provides the stable thread ID and recording time rather than the full newly created conversation.
Conversations are protected and client-scoped by default. When a new
submission will later be retrieved or replied to, give both helpers the same
scope(principal) mapping. A public submission’s default public scope does
not automatically match a protected conversation’s client-derived default.
Messages are append-only. A support reply never replaces an earlier reply.
When a reply is included in a validated tool result, the backend can record
offeredToClientAt. This proves only that the reply was available to the AI.
It does not prove the user read or understood it, and the user does not need to
press a button or send an acknowledgement.
Notify the AI when a team reply is ready
Section titled “Notify the AI when a team reply is ready”Protected conversations can optionally use MCP Events
to prompt a subscribed AI client to read a team reply. The event includes the
account or client scope and stable IDs, not the reply text. The client should
call get-feedback-thread and present the reply to the person.
Check native client availability before setup. If monitoring is missing, follow Events discovery and connection recovery. Successful testing in Work does not prove that ordinary ChatGPT chat supports monitoring. Codex tool access does not provide native Events subscriptions.
Set up createFeedbackReplyEventsOptions from
@emseepea/feedback/mcp-events with the same stable account or client scope
as the feedback tools. Check access to the exact thread both when subscribing
and before delivery.
After saving a team reply, call
publishFeedbackTeamReplyEvent from a transactional outbox (a saved queue
retried after failures) or a provider webhook whose signature, payload, scope,
and duplicate status you verify.
The one-way Markdown destination has no team reply path. Event delivery or a reply offered to an AI does not prove that a person saw it. Test the complete reply journey in your own client and deployment.
Choose where support works
Section titled “Choose where support works”- PostgreSQL stores scoped threads, ordered messages, offer receipts, and an optional transactional outbox.
- Firestore stores the same model in separate scope trees with transaction-backed sequence and receipt updates.
- GitHub Issues keeps issues, comments, labels, assignees, milestones, close and reopen actions, reactions, and notifications native.
- Zendesk keeps tickets, public replies, assignment, tags, status, views, triggers, email, and private notes native. Private notes never reach the user.
GitHub-backed feedback uses provider-neutral references such as feedback-123,
feedback-123-body and message-456. Webhook event references use
event:<delivery>. Issue and comment numbers remain visible.
After upgrading,
previously saved identifiers and reply-event subscriptions stop working. Call
list-feedback-threads to obtain current conversation references, then recreate
reply-event subscriptions with those references.
A submission-only client can obtain a new reference only by making a new submission; do not resubmit old feedback just to replace a reference. Existing authorization and scope checks still apply.
GitHub and Zendesk stay authoritative. Em See Pea does not mirror them into a second conversation database.
Use the checked webhook helpers when provider changes must trigger your event hooks. They verify the provider signature, raw-body size, configured account or repository, payload schema, scope, deadline, and stable delivery ID before returning a typed event. Your application supplies the small store used to resolve a scope hash and atomically reject duplicate events.
Use a randomly generated, high-entropy webhook secret of at least 32 UTF-8 bytes and store it outside source control.
Configure assignment, categories, milestones, status, notifications, and email in the provider account where you deploy the adapter.
Send email or other events
Section titled “Send email or other events”Pass one or more feedback hooks. Each hook receives a typed event containing stable IDs and an opaque scope, but no feedback body, email address, raw vendor payload, request, response, credential, or provider error.
Hooks run after persistence. They are best-effort and must honor the request’s cancellation signal and deadline. For reliable email or queue delivery, use the PostgreSQL or Firestore transactional outbox. With GitHub or Zendesk, prefer the provider’s native notifications and automation.
Read the complete @emseepea/feedback API and limits.