invoiceshelf-mcp
by homeserverhq
README.md
# InvoiceShelf MCP Multitenant Proxy Server
This repository contains a Model Context Protocol (MCP) server that acts
as a secure, multi-tenant proxy between an AI Assistant and the
InvoiceShelf backend API. It exposes **109 MCP tools** covering
14 resource domains with full CRUD, search, dashboard,
and relationship management.
## โจ Features
- **๐ Identity Passthrough** โ Extracts the `Authorization: Bearer <token>`
header from incoming HTTP requests and forwards it to the InvoiceShelf
API without server-side authentication.
- **๐ฅ Multi-Tenancy** โ Uses Python `contextvars` to maintain thread-safe
user identity isolation, ensuring all AI-driven actions are scoped to
the authenticated user's permissions.
- **๐ Full InvoiceShelf Coverage** โ 109 tools mapped to InvoiceShelf
API endpoints across 14 resource domains.
- **โก TOON Optimization** โ All list responses are automatically compressed
using TOON (Token-Optimized Object Notation) to reduce token consumption
and maximize context window efficiency.
- **โก Efficient Gets** โ GET responses return only commonly used fields by
default. Full objects are available via an `include_all_fields` flag.
- **๐งช Comprehensive Testing** โ 208 automated tests covering all tool
domains, run via the test runner pipeline.
- ๐ท๏ธ Tool Annotations โ All tools expose standard MCP ToolAnnotations hints (readOnlyHint, destructiveHint, idempotentHint, openWorldHint). The tags field carries grouping metadata (basic/primary/advanced + invoiceshelf).
## ๐ง Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| `INVOICESHELF_BASE_URL` | Yes | Docker-internal URL of the InvoiceShelf API |
| `MCP_SERVER_PORT` | Yes | Port number the MCP server listens on |
| `ALLOW_ALL_AGGREGATE` | No | When `true`, aggregate listing tools honor the `include_all_fields` parameter. When `false` (default), the parameter is silently forced to `False` for aggregate list operations. |
| `IS_STATEFUL` | No | When `true`, uses stateful Streamable HTTP with session tracking. When `false` (default), uses stateless mode. |
| `INVOICESHELF_PUBLIC_URL` | No | Public-facing URL to replace internal Docker URLs in responses. Defaults to `INVOICESHELF_BASE_URL` if not set. |
## ๐ฆ Installation & Local Development
1. Ensure you have Python 3.12+ installed.
2. Install dependencies:
```bash
pip install fastmcp httpx pydantic uvicorn toon-mcp-server
```
3. Run the server:
```bash
export INVOICESHELF_BASE_URL=http://localhost:8080
export INVOICESHELF_PUBLIC_URL=https://invoiceshelf.example.com
export MCP_SERVER_PORT=80
python -m src.main
```
## ๐ณ Docker Deployment
Build and run the server using Docker:
```bash
docker build -t invoiceshelf-mcp:latest .
docker run -d --name invoiceshelf-mcp \
-e INVOICESHELF_BASE_URL="http://invoiceshelf-app:8080" \
-e INVOICESHELF_PUBLIC_URL="https://invoiceshelf.example.com" \
-e MCP_SERVER_PORT=80 \
invoiceshelf-mcp:latest
The MCP server serves at `http://invoiceshelf-mcp:80/mcp`
(Streamable HTTP).
```
## โ ๏ธ Important Notes
- **๐ `include_all_fields`** โ The `include_all_fields` parameter (available
on all `get_*` and `list_*` tools) controls whether all available fields
are included in responses. Defaults to `False` for performance; set to
`True` only when additional fields are needed.
- **โก TOON Compression** โ All list responses are automatically compressed
using TOON (Token-Optimized Object Notation) to reduce token
consumption by 30-60%.
- **๐ Required Fields & Defaults** โ Each `create_*` tool requires specific
key fields (e.g. `name` for resources). All other fields default to
empty strings or reasonable values. The company assignment is
automatically set to the authenticated user's company for most resources.
## ๐ ๏ธ API Tool Mapping
The server implements 109 MCP tools organized into the following
categories:
### ๐งพ Invoices (10 tools)
- `list_all_invoices` โ List all invoice records
- `get_invoice_by_id` โ Get a single invoice by ID
- `create_invoice` โ Create a new invoice
- `update_invoice` โ Update an existing invoice
- `delete_invoices_by_id` โ Delete an invoice by ID
- `send_invoice` โ Send an invoice via email
- `clone_invoice` โ Clone an existing invoice
- `change_invoice_status` โ Change an invoice's status
- `list_invoice_templates` โ List available invoice templates
- `get_invoice_send_preview` โ Get an invoice send preview
### ๐ Estimates (11 tools)
- `list_all_estimates` โ List all estimate records
- `get_estimate_by_id` โ Get a single estimate by ID
- `create_estimate` โ Create a new estimate
- `update_estimate` โ Update an existing estimate
- `delete_estimates_by_id` โ Delete an estimate by ID
- `send_estimate` โ Send an estimate via email
- `clone_estimate` โ Clone an existing estimate
- `change_estimate_status` โ Change an estimate's status
- `convert_estimate_to_invoice` โ Convert an estimate to an invoice
- `list_estimate_templates` โ List available estimate templates
- `get_estimate_send_preview` โ Get an estimate send preview
### ๐ฅ Customers (7 tools)
- `list_all_customers` โ List all customer records
- `get_customer_by_id` โ Get a single customer by ID
- `get_customer_roles_by_id` โ Get the roles assigned to a customer
- `create_customer` โ Create a new customer
- `update_customer` โ Update an existing customer
- `delete_customers_by_id` โ Delete a customer by ID
- `get_customer_stats` โ Get statistics for a single customer
### ๐ฆ Items (5 tools)
- `list_all_items` โ List all item records
- `get_item_by_id` โ Get a single item by ID
- `create_item` โ Create a new item
- `update_item` โ Update an existing item
- `delete_items_by_id` โ Delete an item by ID
### ๐ Units (5 tools)
- `list_all_units` โ List all unit records
- `get_unit_by_id` โ Get a single unit by ID
- `create_unit` โ Create a new unit
- `update_unit` โ Update an existing unit
- `delete_unit_by_id` โ Delete a unit by ID
### ๐ Recurring Invoices (5 tools)
- `list_all_recurring_invoices` โ List all recurring invoice records
- `get_recurring_invoice_by_id` โ Get a single recurring invoice by ID
- `create_recurring_invoice` โ Create a new recurring invoice
- `update_recurring_invoice` โ Update an existing recurring invoice
- `delete_recurring_invoices_by_id` โ Delete a recurring invoice by ID
### ๐ณ Payments (7 tools)
- `list_all_payments` โ List all payment records
- `get_payment_by_id` โ Get a single payment by ID
- `create_payment` โ Create a new payment
- `update_payment` โ Update an existing payment
- `delete_payments_by_id` โ Delete a payment by ID
- `send_payment` โ Send a payment receipt via email
- `get_payment_send_preview` โ Get a payment send preview
### ๐ฆ Payment Methods (5 tools)
- `list_all_payment_methods` โ List all payment method records
- `get_payment_method_by_id` โ Get a single payment method by ID
- `create_payment_method` โ Create a new payment method
- `update_payment_method` โ Update an existing payment method
- `delete_payment_method_by_id` โ Delete a payment method by ID
### ๐ธ Expenses (6 tools)
- `list_all_expenses` โ List all expense records
- `get_expense_by_id` โ Get a single expense by ID
- `create_expense` โ Create a new expense
- `update_expense` โ Update an existing expense
- `delete_expenses_by_id` โ Delete an expense by ID
- `duplicate_expense` โ Duplicate an existing expense
### ๐๏ธ Expense Categories (5 tools)
- `list_all_expense_categories` โ List all expense category records
- `get_expense_category_by_id` โ Get a single expense category by ID
- `create_expense_category` โ Create a new expense category
- `update_expense_category` โ Update an existing expense category
- `delete_expense_category_by_id` โ Delete an expense category by ID
### ๐งฎ Tax Types (5 tools)
- `list_all_tax_types` โ List all tax type records
- `get_tax_type_by_id` โ Get a single tax type by ID
- `create_tax_type` โ Create a new tax type
- `update_tax_type` โ Update an existing tax type
- `delete_tax_type_by_id` โ Delete a tax type by ID
### ๐ Notes (5 tools)
- `list_all_notes` โ List all note records
- `get_note_by_id` โ Get a single note by ID
- `create_note` โ Create a new note
- `update_note` โ Update an existing note
- `delete_note_by_id` โ Delete a note by ID
### ๐ท๏ธ Custom Fields (5 tools)
- `list_all_custom_fields` โ List all custom field records
- `get_custom_field_by_id` โ Get a single custom field by ID
- `create_custom_field` โ Create a new custom field
- `update_custom_field` โ Update an existing custom field
- `delete_custom_field_by_id` โ Delete a custom field by ID
### ๐ก๏ธ Roles (5 tools)
- `list_all_roles` โ List all role records
- `get_role_by_id` โ Get a single role by ID
- `create_role` โ Create a new role
- `update_role` โ Update an existing role
- `delete_role_by_id` โ Delete a role by ID
### ๐ Domain (23 tools)
- `check_server_status` โ Check connectivity to the InvoiceShelf backend
- `get_dashboard` โ Get dashboard data
- `get_bootstrap` โ Get application bootstrap data
- `search_customers_and_users` โ Search across customers and users
- `search_users` โ Search users by email
- `list_all_currencies` โ List all currencies
- `list_used_currencies` โ List currencies in use
- `list_all_countries` โ List all countries
- `list_timezones` โ List available timezones
- `list_date_formats` โ List available date formats
- `list_time_formats` โ List available time formats
- `get_next_number` โ Get the next number for a resource
- `get_number_placeholders` โ Get number placeholders for a format
- `get_current_company` โ Get the current company
- `get_company_roles_by_id` โ Get the roles for a company
- `get_current_user_roles` โ Get the roles assigned to the current user
- `list_all_companies` โ List all companies
- `list_abilities` โ List all available abilities
- `get_recurring_invoice_frequency` โ Get the next occurrence for a recurring frequency
- `get_exchange_rate` โ Get an exchange rate for a currency
- `get_active_exchange_rate_provider` โ Get the active exchange-rate provider
- `list_used_currencies_for_exchange` โ List currencies used for exchange
- `list_supported_currencies` โ List currencies supported by an exchange-rate provider
This server cannot be deployed
Maintenance
ActivitySlowing
ResponsivenessNo issues