Skip to content

Feat/mcp download support#843

Merged
pontusab merged 4 commits intomainfrom
feat/mcp-download-support
Mar 17, 2026
Merged

Feat/mcp download support#843
pontusab merged 4 commits intomainfrom
feat/mcp-download-support

Conversation

@pontusab
Copy link
Contributor

@pontusab pontusab commented Mar 17, 2026

Note

Medium Risk
Adds MCP tool support for generating/downloading invoice PDFs and vault-stored files (base64 resources + signed URLs), which increases payload sizes and touches storage/PDF rendering paths. Also tweaks MCP request header handling, so transport compatibility/regressions should be watched.

Overview
MCP tools can now return downloadable file content. documents_get, inbox_get, and invoices_get accept a new download flag that, when set, appends an MCP resource item containing base64-encoded file bytes (vault download for documents/inbox; on-the-fly PDF render for invoices), and they also include a signed fileUrl/pdfUrl in the JSON payload.

Adds shared MCP utilities (getVaultSignedUrl, downloadVaultFile, streamToResource, MIME type mapping) and extends McpContext with apiUrl (wired via MIDDAY_API_URL). The MCP router also normalizes the Accept header to include both application/json and text/event-stream for streamable transport.

Separately, invoice listing now includes pdfUrl per item, invoice query sorting adds invoice_number and issue_date, and OpenAPI schema descriptions/examples for sort params are clarified/standardized. Dependencies bump @hono/mcp and @modelcontextprotocol/sdk.

Written by Cursor Bugbot for commit 06703f0. This will update automatically on new commits. Configure here.

- Add pdfUrl to invoices_list and invoices_get responses with on-the-fly PDF rendering
- Add presigned URL support and file download for documents_get and inbox_get
- Add Accept header middleware to fix 406 errors from MCP clients
- Extract shared MCP utilities (downloadVaultFile, streamToResource, getVaultSignedUrl)
- Bump @hono/mcp and @modelcontextprotocol/sdk

Made-with: Cursor
The schemas had camelCase examples (e.g. createdAt) but the backend
expects snake_case (e.g. created_at), causing LLMs to send invalid
sort values via MCP.

Made-with: Cursor
Both columns were used by the dashboard but silently ignored by the
query, falling through to the default created_at sort.

Made-with: Cursor
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because Privacy Mode (Legacy) is turned on. To enable Bugbot Autofix, switch your privacy mode in the Cursor dashboard.

@pontusab pontusab merged commit b20561e into main Mar 17, 2026
5 checks 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.

1 participant