Skip to content

Add MCP review drafts - #46

Merged
31b4 merged 2 commits into
mainfrom
feature/mcp-review-drafts
Aug 3, 2026
Merged

Add MCP review drafts#46
31b4 merged 2 commits into
mainfrom
feature/mcp-review-drafts

Conversation

@31b4

@31b4 31b4 commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a two-step MCP transaction workflow: prepare a preview, then create review-only drafts after explicit confirmation.
  • Store MCP draft provenance, duplicate warnings, and idempotency metadata; audit each created draft.
  • Add a separate MCP Review section with edit, confirm, and decline actions.
  • Keep unconfirmed MCP drafts out of balances, budgets, and all projected analytics.
  • Add migration, deployment signing-secret support, documentation, and test coverage.

Why

Receipt extraction and conversational entry should remain reviewable before affecting financial records. The MCP write path can only create pending drafts; the Finance Manager UI remains the only place where a transaction becomes posted.

Validation

  • npm test -w api — 56 tests
  • npm test -w mcp — 42 tests
  • npm test -w client — 20 tests
  • API, MCP, and client TypeScript/build checks passed
  • Migration SQL and deployment-script syntax verified

@31b4
31b4 marked this pull request as ready for review August 3, 2026 12:26
@31b4
31b4 requested review from Nvirs and Copilot August 3, 2026 12:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a two-step, signed MCP workflow to create review-only pending transaction drafts (prepare preview → explicit confirm → create idempotent batch), and threads the resulting review metadata through the API, database, MCP server, and client UI so MCP-created drafts remain isolated from balances and projections until manually confirmed.

Changes:

  • MCP: add prepare_mcp_transaction_drafts + create_mcp_transaction_drafts, with HMAC-signed proposal tokens, idempotency via mcp_draft_batches, duplicate warnings, and audit entries.
  • Data model/API: introduce pending_kind + MCP provenance fields (review_source, review_batch_id, review_flags) and ensure MCP review drafts are excluded from all projection queries.
  • Client: add MCP Review UI section + helpers, and ensure only pending_kind=upcoming transactions are included in projected analytics.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Updates deploy script description to include MCP review-draft capability and constraints.
mcp/wrangler.toml.example Documents MCP_PROPOSAL_SECRET secret configuration guidance.
mcp/src/types.ts Adds env secret + review-draft and metadata types.
mcp/src/tools.ts Adds MCP draft prepare/create tools and expands JSON schema validation.
mcp/src/review-drafts.ts Implements proposal hashing + HMAC signing/verification for short-lived tokens.
mcp/src/review-drafts.test.ts Tests signing, tampering/expiry, idempotency, and draft creation/audit behavior.
mcp/src/protocol.test.ts Verifies tool surface now includes the limited write tool + schema guards.
mcp/src/index.ts Updates MCP server version + model instructions for the two-step workflow.
mcp/src/finance-service.ts Implements prepare/create review draft flows; excludes MCP review drafts from projections.
mcp/src/finance-service.test.ts Adds coverage for new semantics, projections exclusion, and search metadata.
mcp/README.md Documents two-step draft workflow, security model, and secret setup/rotation.
deploy.sh Generates/stores/upload MCP_PROPOSAL_SECRET as part of MCP deployment.
client/src/lib/transaction-review.ts Adds shared helpers/types to classify pending kinds + normalize flags.
client/src/lib/transaction-review.test.ts Unit tests for review helpers and flag normalization.
client/src/hooks/useFinanceData.ts Extends Transaction type with review metadata fields.
client/src/components/dashboard-module/TransactionList.tsx Adds MCP Review section, labels, and confirm/decline messaging for MCP drafts.
client/src/components/analytics-module/types.ts Extends analytics transaction type with review metadata.
client/src/components/analytics-module/Analytics.tsx Filters projections to pending_kind=upcoming only.
client/src/App.tsx Filters pending deltas and period pending totals to pending_kind=upcoming only.
api/src/tests/upcoming-transactions.test.ts Ensures upcoming tx defaults + MCP metadata preserved across edit/confirm.
api/src/tests/transaction-review-metadata.test.ts Adds mapping/persistence tests for the new review metadata fields.
api/src/services/transaction.service.ts Sets safe defaults for new pending/review metadata on creation.
api/src/repositories/transaction.repository.ts Persists + maps new columns and parses review_flags.
api/src/models/Transaction.ts Adds new pending/review metadata types/fields.
api/src/mappers/transaction.mapper.ts Exposes normalized review metadata in response DTO mapping.
api/src/dtos/transaction.dto.ts Extends API response DTO with pending/review metadata fields.
api/migrations/009-mcp-review-drafts.sql Adds columns for pending kind/provenance + idempotency ledger and indexes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/src/repositories/transaction.repository.ts

@Nvirs Nvirs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job Ben! Lets merge it

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@31b4
31b4 merged commit 402e9cb into main Aug 3, 2026
4 checks passed
@31b4
31b4 deleted the feature/mcp-review-drafts branch August 3, 2026 13:03
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.

3 participants