Labsco
rajurayhan logo

Laravel QuickBooks MCP

β˜… 9

from rajurayhan

A first-party PHP/Laravel Composer package that exposes QuickBooks Online (QBO) as a Model Context Protocol (MCP) server.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup

Laravel QuickBooks MCP

A first-party PHP/Laravel Composer package that exposes QuickBooks Online (QBO) as a Model Context Protocol (MCP) server. AI clients β€” Claude, Cursor, n8n, and others β€” connect over HTTP and perform full CRUD operations on QBO entities using natural language.

This is the first PHP/Laravel QuickBooks MCP implementation in the ecosystem.

Features

  • 50 MCP tools covering 11 QBO entities (customers, vendors, invoices, bills, estimates, purchases, employees, items, accounts, journal entries, and bill payments)

  • Remote HTTP transport β€” not local stdio, so it works with any hosted AI client

  • Multi-tenant β€” multiple QBO companies per Laravel installation

  • Name-to-ID resolution β€” agents pass human-readable names; ID lookups happen automatically

  • Full OAuth 2.0 flow β€” any SaaS user can connect their own QBO company

  • Production-ready from day one (sandbox also supported)

  • Laravel-native auth β€” works with Passport or Sanctum, no assumptions made

OAuth Flow

Once installed, a SaaS user connects their QBO company through your application:

Copy & paste β€” that's it
1. User visits GET /quickbooks/connect
 β†’ Redirected to Intuit consent screen
 β†’ Grants access to their QBO company
 β†’ Redirected back to GET /quickbooks/callback

2. Callback handler:
 β†’ Exchanges auth code for tokens (stored by spinen in quickbooks_tokens)
 β†’ Package records connection in quickbooks_connections (realm_id + company_name)

3. User authenticates your app with their existing Bearer token (Passport or Sanctum)

4. AI client is configured with:
 MCP URL: https://yourdomain.com/mcp/quickbooks
 Header: Authorization: Bearer 

5. Every MCP tool call thereafter:
 β†’ Guard authenticates the Bearer token
 β†’ ResolveQuickBooksRealm finds the user's active QBO connection
 β†’ RefreshQuickBooksToken silently refreshes QBO tokens near expiry
 β†’ Tool runs β€” zero extra params needed from the AI agent

Connection management routes

Method Route Description GET /quickbooks/connect Redirect to Intuit OAuth consent screen GET /quickbooks/callback Handle OAuth callback and store tokens DELETE /quickbooks/disconnect Revoke QBO tokens and remove connection GET /quickbooks/connections List active QBO connections for the user

Available Tools

Account (3 tools)

Tool Description create_account Create a new account in the chart of accounts search_accounts Search accounts by name or type update_account Update an existing account

Bill (5 tools)

Tool Description create_bill Create a new accounts payable bill get_bill Get a bill by ID search_bills Search bills by vendor, date range, or unpaid status update_bill Update an existing bill delete_bill Permanently delete a bill

Bill Payment (5 tools)

Tool Description create_bill_payment Pay one or more open bills get_bill_payment Get a bill payment by ID search_bill_payments Search bill payments by vendor or date range update_bill_payment Update an existing bill payment delete_bill_payment Permanently delete a bill payment

Customer (5 tools)

Tool Description create_customer Create a new customer get_customer Get a customer by ID search_customers Search customers by name, email, or company update_customer Update an existing customer delete_customer Deactivate a customer (QBO soft-delete)

Employee (4 tools)

Tool Description create_employee Create a new employee record get_employee Get an employee by ID search_employees Search employees by name or email update_employee Update an existing employee

Estimate (5 tools)

Tool Description create_estimate Create a new estimate / quote get_estimate Get an estimate by ID search_estimates Search estimates by customer, status, or date range update_estimate Update or change the status of an estimate delete_estimate Permanently delete an estimate

Invoice (4 tools)

Tool Description create_invoice Create a new invoice read_invoice Read a full invoice with all line items search_invoices Search invoices by customer, date range, or payment status update_invoice Update an existing invoice

Invoices cannot be permanently deleted in QBO.

Item (4 tools)

Tool Description create_item Create a new product or service item read_item Read a full item record with pricing and account assignments search_items Search items by name or type update_item Update an existing item (set active: false to deactivate)

Items cannot be permanently deleted in QBO.

Journal Entry (5 tools)

Tool Description create_journal_entry Create a journal entry (debits must equal credits) get_journal_entry Get a journal entry by ID search_journal_entries Search journal entries by date range or document number update_journal_entry Update an existing journal entry delete_journal_entry Permanently delete a journal entry

Purchase (5 tools)

Tool Description create_purchase Create a purchase / expense transaction get_purchase Get a purchase by ID search_purchases Search purchases by payment type or date range update_purchase Update an existing purchase delete_purchase Permanently delete a purchase

Vendor (5 tools)

Tool Description create_vendor Create a new vendor get_vendor Get a vendor by ID search_vendors Search vendors by name, email, or company update_vendor Update an existing vendor delete_vendor Deactivate a vendor (QBO soft-delete)

Name Resolution

Tools that reference related entities (vendor, customer, account, item) accept either a name or a numeric ID. The package resolves names to IDs automatically before calling the QBO API.

Copy & paste β€” that's it
# These are equivalent when calling create_bill:
vendor: "Office Depot"
vendor: "42"

If a name cannot be found, the tool returns a descriptive error with a suggestion to use the corresponding search tool first.

Delete Behaviour

QBO has two categories of delete:

Behaviour Entities Soft-delete β€” sets Active = false Customer, Vendor, Employee, Item, Account Hard-delete β€” permanently removed Bill, BillPayment, Estimate, JournalEntry, Purchase Cannot be deleted Invoice, Item (use update_item with active: false)

Multi-Tenant Architecture

Each authenticated user has exactly one active QBO connection tracked in the quickbooks_connections table. The ResolveQuickBooksRealm middleware automatically scopes every tool call to the correct QBO company β€” no realm_id parameter is ever needed from the AI agent.

Package Architecture

Copy & paste β€” that's it
src/
β”œβ”€β”€ QuickBooksMcpServiceProvider.php β€” registers service, publishes assets
β”œβ”€β”€ Server/QuickBooksServer.php β€” MCP server, registers all 50 tools
β”œβ”€β”€ Services/QuickBooksService.php β€” QBO API wrapper, name resolvers
β”œβ”€β”€ Concerns/ResolvesEntityNames.php β€” trait for name-to-ID resolution
β”œβ”€β”€ Http/
β”‚ β”œβ”€β”€ Controllers/QuickBooksOAuthController.php
β”‚ └── Middleware/
β”‚ β”œβ”€β”€ ResolveQuickBooksRealm.php β€” scopes QBO service to user's company
β”‚ └── RefreshQuickBooksToken.php β€” proactive token refresh
β”œβ”€β”€ Models/QuickBooksConnection.php β€” tracks user ↔ QBO company links
β”œβ”€β”€ Exceptions/
β”‚ β”œβ”€β”€ QuickBooksAuthException.php
β”‚ └── QuickBooksToolException.php
└── Tools/ β€” 50 tool classes across 11 entities
 β”œβ”€β”€ Account/, Bill/, BillPayment/, Customer/, Employee/
 β”œβ”€β”€ Estimate/, Invoice/, Item/, JournalEntry/
 β”œβ”€β”€ Purchase/, Vendor/

License

MIT β€” see LICENSE for details.

Author

Raju Rayhan β€” github.com/rajurayhan