Skip to content

feat: add MCP and REST access to business records - #9

Open
maxehmoon wants to merge 3 commits into
mainfrom
feat/mcp-server
Open

maxehmoon wants to merge 3 commits into
mainfrom
feat/mcp-server

Conversation

@maxehmoon

@maxehmoon maxehmoon commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Folio can now be used by assistants, scripts and external applications through authenticated MCP and HTTP APIs. Both interfaces use the same business operations, validation and invoice/payment services.

Changes

  • Add /api/mcp with 60 tools covering customers, items, expenses, invoices, payments, recurring billing, reporting and business settings, plus PDF resources and workflow prompts.
  • Add /api/v1 with 61 REST routes covering those operations, ordinary JSON responses, native PDF/CSV downloads and a generated OpenAPI reference at /api/v1/openapi.json.
  • Add Settings controls for named, expiring and revocable business access tokens. Tokens work with both interfaces, are stored as hashes, and grant read-only or read/write access.
  • Preserve financial validation, business isolation, invoice revisions, optimistic concurrency and explicit confirmation for destructive actions. Validate strict request fields and enforce bounded request/download sizes.
  • Fix partial business-settings updates for legacy records with no country: a name-only change now preserves omitted nullable settings.
  • Document connection setup, endpoint coverage, pagination, integer units, invoice/payment examples and retry behaviour.

Validation

  • bun run typecheck and bun run lint pass.
  • bun run test: 394 passed, one optional PostgreSQL test skipped because no test database is configured.
  • bun run build passes, with the existing two Next.js file-tracing warnings.
  • bun run test:e2e: all four browser scenarios pass, including shared API/MCP token creation, permissions, revocation and authenticated REST requests.
  • Settings checked at desktop and narrow widths in light and dark themes.

SQLite migration, token lifecycle, cross-business isolation, HTTP/SDK protocol handling, invoice/payment workflows, real PDF rendering, CSV pagination and the nullable-country regression have automated coverage. PostgreSQL execution remains unverified locally.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T16:49:27.192767Z 436d5d0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 987d769d7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcp/reporting.ts Outdated
Comment on lines +257 to +259
const merged = Object.fromEntries(Object.entries({ ...businessSettings(business), ...input })
.map(([key, value]) => [key, value ?? ""]));
const profile = settingsBusinessProfileSchema.parse(merged);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow partial updates when the stored country is null

For businesses created by scripts/seed.ts, ensureBusinessForUser stores country_code: null; this merge converts that value to "" and then validates the entire record with the required countryCode schema. Consequently, even an unrelated call such as { "name": "New name" } fails validation until the caller also supplies a country, contradicting the tool's partial-update contract. Validate and update only submitted fields, or otherwise preserve nullable legacy values during the merge.

Useful? React with 👍 / 👎.

@maxehmoon maxehmoon changed the title feat(mcp): add authenticated invoicing tools feat: add MCP and REST access to business records Oct 10, 2026
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