Add MCP review drafts - #46
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 viamcp_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=upcomingtransactions 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.
Nvirs
approved these changes
Aug 3, 2026
Nvirs
left a comment
Collaborator
There was a problem hiding this comment.
Good job Ben! Lets merge it
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 testsnpm test -w mcp— 42 testsnpm test -w client— 20 tests