Skip to content

feat(mcp): user-initiated correction prompt#7

Merged
chrishonson merged 1 commit into
mainfrom
feat/correction-prompt
Jul 11, 2026
Merged

feat(mcp): user-initiated correction prompt#7
chrishonson merged 1 commit into
mainfrom
feat/correction-prompt

Conversation

@chrishonson

Copy link
Copy Markdown
Owner

Summary

  • Registers a new MCP Prompt named correct_memory (via server.registerPrompt) that structurally enforces the "correction as a user-initiated action" design from metacortexplan.md INVEST fix(deploy): catch missing prod alias before functions deploy #4: prompts are user-controlled per the MCP protocol, so the agent can never invoke a correction autonomously the way it can a tool.
  • The prompt takes incorrect_memory_id and corrected_content (required), plus optional topic, valid_from, valid_until (all strings, per the MCP prompt-argument spec), and returns a single user-role message instructing the caller to: (1) call remember_context with the corrected content, (2) call deprecate_context on the old id with supersession_reason: "corrected" and initiator: "user", (3) report both ids back. It's registered unconditionally for every client — the underlying remember_context/deprecate_context tools stay gated by each client's allowedTools.
  • Adds optional valid_from/valid_until (epoch-ms numbers) to the remember_context tool's Zod input schema. service.rememberContext() already threaded these through to metadata (from the prior temporal-validity PR feat(memory): temporal validity and supersession reasons #6) — they were just missing from the MCP-facing schema.
  • Updates CLAUDE.md (MCP Prompts section, remember_context note, mcpServer.ts line count) and metacortexplan.md (INVEST fix(deploy): catch missing prod alias before functions deploy #4 status → Implemented 2026-07-11).

Test plan

  • npm --prefix functions run build — compiles clean
  • npm --prefix functions test — 59/59 passing, 74% overall coverage (≥60% required)
  • New integration tests in mcp.integration.test.ts:
    • prompts/list returns correct_memory with correctly required/optional arguments
    • prompts/get with arguments returns the composed user message embedding all arguments verbatim
    • the prompt is present even for a tool-scoped client (allowedTools: ["search_context"]), proving unconditional registration
    • remember_context accepts valid_from/valid_until over MCP and search_context + valid_at honors the stored window (existing tests show buildPublicMetadata() doesn't surface these fields directly, so behavior is verified functionally, matching the established pattern for the deprecate path)

🤖 Generated with Claude Code

Structurally enforce that only a user can trigger a memory correction
(a belief-axis retraction, not a fact that merely changed) by exposing
correct_memory as an MCP Prompt rather than a Tool — prompts are
user-controlled by the protocol, so the agent can never invoke one
autonomously. The prompt composes the existing remember_context and
deprecate_context tools (supersession_reason: "corrected", initiator:
"user") and is registered unconditionally for every client, since the
underlying tools stay gated by each client's allowedTools.

Also expose valid_from/valid_until on remember_context's MCP schema —
the service layer already threaded them through metadata, they were
just missing from the tool's Zod input schema.

Implements INVEST #4 from metacortexplan.md.
@chrishonson chrishonson merged commit 0cd1c7f into main Jul 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants