Skip to main content

MCP Server: connect MCP Server

Frihet's MCP server implements the Model Context Protocol so AI assistants can interact directly with your ERP. Create invoices, log expenses, look up clients, or manage quotes — all from your IDE or terminal, in natural language.

Published on npm: 1.17.0 | 157 tools (+5 fiscal aliases) | 11 resources | 10 prompts | Structured output | Compatible with 30+ AI agents. The remote endpoint mcp.frihet.io serves progressive disclosure so it does not flood the agent's context.

You: "Create an invoice for TechStart Ltd, 40 hours of consulting at 75 EUR/hour, due March 1st"
Claude: Done. Invoice INV-2026-089 created. Total: 3,000.00 EUR + 21% VAT = 3,630.00 EUR.

What to expect (and what not)​

The MCP server is a stateless bridge between your AI assistant and the Frihet REST API. Each tool call translates into an HTTP request to the API.

What it DOES:

  • Full CRUD on invoices, expenses, clients, products, quotes, and webhooks
  • Invoice search by client name
  • Access to reference data (tax rates, fiscal calendar, categories)
  • Guided workflows (monthly close, tax prep, overdue follow-up)

What it DOES NOT:

  • Document OCR (handled by the AI assistant inside the app)
  • PDF generation (use the REST API directly: GET /v1/invoices/:id/pdf)
  • Payment processing (payments are handled via Stripe Connect in the app)

Requirements​

  • Frihet account with API access (paid plans)
  • API key generated from the dashboard

Getting your API key​

  1. Sign in at app.frihet.io
  2. Go to Integrations → API Keys
  3. Click Create API key
  4. Copy the key (starts with fri_) — it is only shown once

Installation​

Universal (30+ agents)​

The fastest way to install the MCP server and the business skill:

npx skills add Frihet-io/frihet-mcp

Works with Claude Code, Cursor, Copilot, Codex, Windsurf, Gemini CLI, Goose, Roo Code, and 30+ more agents.

MCP Registry​

The server is registered as io.frihet/erp on the official MCP Registry. MCP clients that support the registry can discover and install it automatically by its canonical name.

Direct npx​

npx -y @frihet/mcp-server@latest

No global installation needed. npx downloads and runs the latest version automatically.

Manual configuration​

There are two connection modes: local (the server runs on your machine via npx) and remote (direct connection to mcp.frihet.io, no installation needed).

Local (stdio)​

{
"mcpServers": {
"frihet": {
"command": "npx",
"args": ["-y", "@frihet/mcp-server@latest"],
"env": {
"FRIHET_API_KEY": "fri_your_key_here"
}
}
}
}

Remote (streamable-http)​

{
"mcpServers": {
"frihet": {
"type": "streamable-http",
"url": "https://mcp.frihet.io/mcp",
"headers": {
"Authorization": "Bearer fri_your_key_here"
}
}
}
}

Configuration by client​

The JSON structure is identical across all clients. Only the config file location changes.

ClientConfig file
Claude Code~/.claude/mcp.json
Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
Cursor.cursor/mcp.json or ~/.cursor/mcp.json
Windsurf~/.windsurf/mcp.json
ClineVS Code settings or .cline/mcp.json
Codex CLI~/.codex/config.toml (MCP section)
tip

If you use Claude Code, you can add the server with a single command:

claude mcp add frihet -- npx -y @frihet/mcp-server@latest

Then set the FRIHET_API_KEY variable in the resulting ~/.claude/mcp.json file.

Environment variables​

VariableRequiredDefault
FRIHET_API_KEYYes—
FRIHET_API_URLNohttps://api.frihet.io/v1
FRIHET_MCP_DEBUGNo0
  • FRIHET_API_URL is useful if you point to a staging environment or a custom instance. Must be https:// with a hostname under frihet.io.
  • FRIHET_MCP_DEBUG=1 enables debug-level logs (useful for troubleshooting).

OAuth flow​

The MCP server supports OAuth authentication in addition to manual API key setup. When an MCP client initiates the OAuth flow:

  1. The user authenticates in Frihet (email, Google, GitHub, or Microsoft)
  2. The client sends the session token to POST /api/oauth/api-key
  3. The server provisions a new fri_xxx... key labeled "MCP OAuth" with a 365-day expiration
  4. The key is used automatically for subsequent calls

This lets users connect the MCP server without manually copying keys.


Available tools (157)​

The server exposes 157 tools (+5 fiscal aliases) organized across 11 domains (invoicing, expenses, fiscal, banking, crm, hr, stay, pos, intelligence, catalog, platform — the list_tool_groups() taxonomy). Every tool includes structured output (outputSchema + structuredContent) for reliable parsing, plus security and content annotations. Bilingual (EN/ES).

The tables below document the core resource tools plus Fiscal; the rest of the set (Banking, POS, Stay, Time, Recurring, HR, etc.) is available when installing @frihet/mcp-server.

Invoices (12 tools)​

ToolDescriptionKey parameters
list_invoicesList invoices with paginationlimit, offset, status, clientId, from, to
get_invoiceGet an invoice by IDid
create_invoiceCreate an invoice with line itemsclientName, items[] (description, quantity, unitPrice), status, dueDate, notes, taxRate, irpfRate
update_invoiceUpdate fields on an invoice (partial)id, plus any field to modify
delete_invoicePermanently delete an invoiceid
search_invoicesSearch invoices by client nameclientName, limit, offset
send_invoiceSend an invoice by emailid, recipientEmail, customMessage, locale
mark_invoice_paidMark an invoice as paidid, paidDate (optional)
get_invoice_pdfDownload an invoice PDFid
get_invoice_einvoiceGenerate EN16931 e-invoice (XML)id
create_credit_noteCreate a corrective invoice (credit note)id, reason, reasonDescription, fullCredit
apply_late_feeApply a statutory late-payment feeid, amount (optional, auto-calculated if omitted)

Possible invoice statuses: draft, sent, partial, paid, overdue, cancelled

Expenses (5 tools)​

ToolDescriptionKey parameters
list_expensesList expenses with paginationlimit, offset, category, from, to
get_expenseGet an expense by IDid
create_expenseLog a new expensedescription, amount, category, date, vendor, taxDeductible
update_expenseModify an existing expense (partial)id, plus any field to modify
delete_expensePermanently delete an expenseid

Clients (5 tools)​

ToolDescriptionKey parameters
list_clientsList all clientslimit, offset, stage, from, to
get_clientGet a client by IDid
create_clientRegister a new clientname, email, phone, taxId, address, fiscalZone, clientType, stage
update_clientUpdate client details (partial)id, plus any field to modify
delete_clientPermanently delete a clientid

CRM (8 tools)​

Tools to manage contacts, activities, and notes linked to a client.

ToolDescriptionKey parameters
list_client_contactsList contact persons for a clientclientId, limit
create_client_contactCreate a contact person for a clientclientId, name, email, phone, role, isPrimary
delete_client_contactDelete a client contactclientId, contactId
list_client_activitiesList activities for a clientclientId, limit
log_client_activityLog a manual activityclientId, type (call/email/meeting/note_added/task), title, description
list_client_notesList notes for a clientclientId, limit
create_client_noteCreate a note for a clientclientId, content
delete_client_noteDelete a client noteclientId, noteId

Products (5 tools)​

ToolDescriptionKey parameters
list_productsList products and serviceslimit, offset, isActive
get_productGet a product by IDid
create_productCreate a product or servicename, unitPrice, description, sku, taxRate, irpfRate
update_productModify an existing product (partial)id, plus any field to modify
delete_productPermanently delete a productid

Quotes (6 tools)​

ToolDescriptionKey parameters
list_quotesList quoteslimit, offset, status, clientId, from, to
get_quoteGet a quote by IDid
create_quoteCreate a quote for a clientclientName, items[] (description, quantity, unitPrice), validUntil, notes, status
update_quoteModify a quote (partial)id, plus any field to modify
delete_quotePermanently delete a quoteid
send_quoteSend a quote by emailid, recipientEmail, customMessage, locale

Possible quote statuses: draft, sent, accepted, rejected, expired

Vendors (5 tools)​

ToolDescriptionKey parameters
list_vendorsList vendorslimit, offset
get_vendorGet a vendor by IDid
create_vendorRegister a new vendorname, email, phone, taxId, address
update_vendorModify an existing vendor (partial)id, plus any field to modify
delete_vendorPermanently delete a vendorid

Intelligence (4 tools)​

Analytics and context tools so the assistant understands the current state of the business.

ToolDescriptionKey parameters
get_business_contextComplete business context (profile, metrics, configuration)—
get_monthly_summaryMonthly financial summary (revenue, expenses, taxes)month (YYYY-MM, optional)
get_quarterly_taxesQuarterly tax preparation (Modelo 303/130 preview)quarter (YYYY-Q1, optional)
duplicate_invoiceDuplicate an existing invoice as a draftid

Deposits / Retainers (7 tools)​

ToolDescriptionKey parameters
list_depositsList deposits with paginationlimit, offset, clientId, status, from, to
get_depositGet a deposit by IDid
create_depositCreate a deposit for a clientclientId, amount, description, date, notes
update_depositModify an existing deposit (partial)id, plus any field to modify
delete_depositPermanently delete a depositid
apply_depositApply a deposit to an existing invoicedepositId, invoiceId, amount (optional, applies full amount if omitted)
refund_depositRecord a deposit refundid, refundDate (optional), notes

Fiscal (6 tools)​

Tools for tax filings (mainland AEAT models) and VeriFactu status.

Prefix aliases: the frihet_* aliases include frihet_modelo_303_summary, frihet_modelo_130_summary, frihet_modelo_390_summary and frihet_modelo_347_summary, with the same handler and schema as the corresponding get_modelo_* tool.

ToolDescriptionKey parameters
get_modelo_303_summaryQuarterly IVA (VAT) summary for Modelo 303— (current period)
get_modelo_130_summaryQuarterly IRPF estimated payment summary for Modelo 130— (current period)
get_modelo_390_summaryAnnual IVA recap for Modelo 390— (current period)
get_modelo_347_summaryAnnual summary of operations with third parties >€3,005 for Modelo 347— (current period)
verifactu_statusVeriFactu (AEAT) submission status for an invoiceinvoiceId
verifactu_resubmitTRUST AREA. Re-submit a failed VeriFactu submission to AEATinvoiceId, confirm (must be true)

Webhooks (5 tools)​

ToolDescriptionKey parameters
list_webhooksList configured webhookslimit, offset
get_webhookGet webhook configurationid
create_webhookRegister a webhook endpointurl, events[], active, secret
update_webhookModify an existing webhookid, plus any field to modify
delete_webhookPermanently delete a webhookid

See Webhooks for the full list of 15 available events, payload format, and HMAC verification.


Available resources (11)​

MCP resources provide reference data and real-time context. Static resources are always available; dynamic resources require API key authentication.

Static resources (7)​

ResourceURIDescription
API schemafrihet://api/schemaEndpoint summary, authentication, rate limits, and error codes
Tax ratesfrihet://tax/ratesIVA (21/10/4%), IGIC (7/3/0%), IPSI, intra-community, IRPF (15%/7%)
Tax calendarfrihet://tax/calendarQuarterly filing dates (Modelo 303, 130, 420, 390)
Expense categoriesfrihet://config/expense-categories8 categories with deductibility rules and tax treatment
Invoice statusesfrihet://config/invoice-statusesStatus flow (draft, sent, paid, overdue, cancelled) with triggers
Currenciesfrihet://config/currencies40 supported currencies with symbols, decimals, and formatting
Countriesfrihet://config/countries61 countries with default fiscal zone and tax rate

Dynamic resources (4)​

These resources return real-time data from your account. They are registered only when the connection is authenticated.

ResourceURIDescription
Business profilefrihet://business-profileTax details, fiscal zone, currency, and company configuration
Monthly snapshotfrihet://monthly-snapshotCurrent month financial summary (revenue, expenses, taxes)
Overdue invoicesfrihet://overdue-invoicesList of overdue invoices with amounts and days past due
Plan limitsfrihet://status/plan-limitsCurrent plan, invoice/scan/AI message usage, and limits

Available prompts (10)​

Prompts are guided workflows the assistant executes step by step. Invoke them by name.

PromptDescriptionParameters
monthly-closeMonthly close: review unpaid invoices, categorize expenses, verify tax obligations, generate summarymonth (optional)
onboard-clientClient onboarding: determine tax type by location, create record, generate welcome quoteclientName, country, region
quarterly-tax-prepQuarterly tax prep: gather invoices, calculate VAT/IGIC, generate Modelo 303/130 previewquarter, fiscalZone
overdue-followupOverdue follow-up: identify overdue invoices, group by client, draft collection messages—
expense-batchBatch expense processing: categorize, apply taxes, verify deductibility, create with confirmationfiscalZone
new-client-invoiceOnboard a new client + create their first invoice in a single workflowclientName, country
expense-reportExpense report grouped by category with totals and deductibilitymonth (optional)
year-end-closeYear-end close: full review of the fiscal yearyear
cash-flow-forecast3-month cash-flow forecast based on invoices and recurring expensesmonths (optional)
invoice-aging-reviewAccounts receivable aging analysis (aging buckets)—
tip

You can invoke a prompt directly: "Run the monthly close for February" or "Prep my Q1 taxes".


Usage examples​

These are real natural-language requests that the assistant translates into MCP tool calls.

Create an invoice​

"Create an invoice for Acme Ltd with 10 hours of consulting at 95 EUR/hour, due March 15th"

The assistant calls create_invoice with clientName: "Acme Ltd", one line item (10 x 95), and dueDate: "2026-03-15". The total is calculated automatically.

Log an expense​

"Log an expense of 59.99 EUR for Adobe Creative Cloud, category software, tax deductible"

Calls create_expense with description, amount: 59.99, category: "software", and taxDeductible: true.

Search invoices by client​

"Find all invoices for TechStart Ltd"

Calls search_invoices with clientName: "TechStart Ltd" and returns matches with totals and statuses.

Check overdue invoices​

"Show me all unpaid invoices"

Calls list_invoices and filters by status: "sent" or "overdue", displaying overdue invoices sorted by amount.

Add a new client​

"New client: Estudio Norte S.L., tax ID B12345674, email facturacion@example.com, Madrid 28001"

Calls create_client with name, tax ID, email, and address.

Set up automation​

"Create a webhook to notify https://my-app.com/hook when an invoice is paid"

Calls create_webhook with url and events: ["invoice.paid"].

Update a product​

"Raise the hourly consulting rate to 85 EUR"

Calls update_product with the product id and unitPrice: 85. Only the specified field is modified.


Observability​

The MCP server v1.17.0 includes structured logging and tool metrics.

Structured logging​

All logs are emitted as JSON to stderr (MCP uses stdout for protocol messages). Each entry includes:

  • level: debug, info, warn, error
  • service: always frihet-mcp
  • timestamp: ISO 8601
  • tool: tool name (when applicable)
  • operation: operation type (tool_call, api_call, api_retry, startup, shutdown_metrics)
  • durationMs: execution time in milliseconds
  • error: error details (message, code, statusCode)

Enable debug logs with FRIHET_MCP_DEBUG=1.

Tool metrics​

The server tracks in-memory metrics for each tool call: invocation count, errors, and average duration. On shutdown (SIGINT/SIGTERM), it emits a summary:

{
"level": "info",
"message": "Shutdown after 3600s — 42 calls, 1 errors",
"operation": "shutdown_metrics",
"metadata": {
"tools": {
"list_invoices": { "calls": 15, "errors": 0, "avgMs": 230 },
"create_invoice": { "calls": 8, "errors": 1, "avgMs": 450 }
},
"uptime": 3600
}
}

Automatic rate-limit retry​

When the API responds with 429, the server retries automatically with exponential backoff (up to 3 retries). Retries are logged:

{
"level": "warn",
"message": "Rate limited, retrying GET /invoices (attempt 2, delay 2000ms)",
"operation": "api_retry"
}

You don't need to handle rate limiting manually — the server does it for you.


Transport​

Frihet's MCP server supports two transport modes. Both expose the same 157 tools (+5 fiscal aliases), 11 resources, and 10 prompts.

Local (stdio)​

The server runs as a local process on your machine. Communication between the MCP client and server uses standard input/output (stdin/stdout).

  • Requires: Node.js installed (downloaded automatically via npx)
  • Advantage: Lower latency, works offline (except for API calls)
  • Use case: Daily development, heavy usage, corporate environments with network restrictions

Remote (streamable-http)​

The server runs on Cloudflare Workers. Your MCP client connects directly to https://mcp.frihet.io/mcp over HTTP.

  • Requires: Only an internet connection
  • Advantage: No local installation, no dependencies, works on any device
  • Use case: Quick setup, teams that prefer not to install packages, clients that only support HTTP transport
info

If your MCP client doesn't support streamable-http (some older clients only support stdio), use local mode.


MCP profiles, transport, and runtime callability​

When integrating an AI agent with @frihet/mcp-server 1.17.0, distinguish three independent layers that determine which tools the model sees and which ones it can execute in your account:

1. Transport and authentication (local stdio vs remote streamable-http)​

  • Local (stdio via npx -y @frihet/mcp-server@1.17.0): runs on your machine and authenticates using the FRIHET_API_KEY=fri_... environment variable generated in Integrations → API Keys. Ideal for Claude Code, Cursor, Windsurf, Codex CLI, or corporate firewall environments.
  • Remote (streamable-http at https://mcp.frihet.io/mcp): hosted on Cloudflare Workers (1.17.0). Supports both an Authorization: Bearer fri_... header and OAuth 2.1 with PKCE (/.well-known/oauth-authorization-server), where the user authorizes the session in the browser without copying keys manually.

2. Catalog profile (canonical vs localFull vs remoteGrouped)​

Both transports operate on the same 157 canonical operations, 11 resources (7 static and 4 dynamic), and 10 prompts, exposing them according to the client profile:

MCP profileRegistered totalExact composition in 1.17.0When it is used
Canonical (canonical)157 operationsThe 157 core ERP business tools documented in /mcp.jsonBase reference of business operations
Local full (localFull)162 tools157 canonical operations + 5 fiscal aliases (including frihet_modelo_130_summary, frihet_modelo_303_summary, frihet_modelo_347_summary, and frihet_modelo_390_summary)Local stdio process (@frihet/mcp-server@1.17.0)
Remote grouped (remoteGrouped)165 tools162 tools (localFull) + 3 discovery meta-tools (list_tool_groups, search_tools, describe_tool)Remote endpoint https://mcp.frihet.io/mcp (progressive disclosure to save context window)

3. Registered tool vs. callable in your account​

Seeing a tool registered in tools/list or describe_tool does not mean it can execute without preconditions in every account. The catalog authority (/mcp.json) classifies all 165 entries in 1.17.0 into three runtime callability states:

Catalog stateVerifiable examples & contract labelWhat is required for a 200 runtime response
Callable (156 of 165)list_clients, list_invoices, create_invoice (callability: callable, with 54 runtime_checked and 99 api_dependent across the base catalog, plus the 3 remote discovery meta-tools)Active fri_... key or OAuth session, plus resource conditions: subscription plan (e.g., create_webhook requires the Premium plan), workspace role & permissions in Settings → Team, and a complete tax profile in Settings → Tax Profile for tax operations
Surface-deferred (8 of 165)period_close, period_reopen, create_reservation, sync_channel, gestoria_aging_consolidated, gestoria_message_send, gestoria_messages_list, gestoria_template_bulk_send (callability: deferred)Registered in the MCP schema but gated on enabling the corresponding vertical module or accounting firm workflow in the workspace
Unavailable in production (1 of 165)ksef_submit (callability: unavailable)Polish KSeF connector reserved in the schema but disabled in production execution
First-read verification and draft-first safety before writes

After connecting the MCP server, verify a side-effect-free read first by asking your agent to run list_clients or list_invoices with limit: 5 (equivalent to GET /v1/clients?limit=5 in Developers: getting started). Before running tax or accounting write tools (create_invoice, send_einvoice, create_credit_note), always work on a draft first or require explicit confirmation of amounts, tax IDs, and invoice series.


Error handling​

Rate limiting​

The API allows 100 requests per minute per key. If the limit is exceeded, the server returns a 429 error with the wait time in retryAfter.

The MCP server handles rate limiting automatically with exponential backoff: it retries the request after waiting the indicated time, with no user intervention needed. Maximum 3 retries.

Authentication errors​

CodeCauseSolution
401Invalid, expired, or missing API keyVerify the key in your config starts with fri_ and hasn't expired
403The key doesn't have permissions for this resourceGenerate a new key with the required permissions

Other errors​

CodeDescription
400Invalid parameters or missing required fields
404The requested resource doesn't exist
408Request timeout (30 seconds)
413The request body exceeds 1 MB
422Valid data but not processable (e.g., fiscal profile not configured)
429Rate limit exceeded (retried automatically)
500Internal server error

All errors return a descriptive bilingual message (EN/ES) so the assistant can communicate the problem clearly to the user.

Quick troubleshooting and recovery​

Failure observed in MCP clientVerifiable root causeRecovery action
401 Unauthorized when invoking any toolMissing FRIHET_API_KEY, truncated key (does not start with fri_), revoked key in dashboard, or expired OAuth tokenGenerate a new key in Integrations → API Keys, update your MCP client JSON, and restart the agent process (or re-authorize OAuth at https://mcp.frihet.io/mcp)
403 Forbidden on a specific tool (e.g., create_webhook)Plan gate (webhooks require Premium) or user role lacking permission for that moduleCheck your plan in Settings → Plan & Billing and your user permissions in Settings → Team (or via the permissions_me tool)
Local stdio server fails to start or runs an older versionStale local npx cache or FRIHET_API_URL pointing outside frihet.ioPin @frihet/mcp-server@1.17.0 in args, run with FRIHET_MCP_DEBUG=1 to inspect stderr, and remove any invalid FRIHET_API_URL override
422 Unprocessable Entity or rejection on a deferred / unavailable toolMandatory tax profile fields are missing on the account, or ksef_submit (callability: unavailable) / period_close (callability: deferred) was invoked without preconditionsComplete tax ID and address in Settings → Tax Profile, check onboarding_status, and verify tool callability in /mcp.json

Limits​

ConceptValue
Requests per minute100 per API key
Results per page100 maximum (50 default)
Request body1 MB maximum
Webhook payload100 KB maximum
Webhooks per account20 maximum
Request timeout30 seconds
Rate limit retries3 maximum

MCP Server vs REST API​

MCP ServerREST API
Designed forAI assistants (Claude, Cursor, Windsurf)Applications, scripts, integrations
CommunicationNatural language through the MCP clientDirect HTTP/JSON
AuthenticationEnvironment variable in client config (or OAuth)X-API-Key header or Authorization: Bearer
FormatFormatted text + structured output for the assistantRaw JSON
Rate limitingHandled automatically (exponential backoff, 3 retries)Manual (consumer must implement retries)
ObservabilityStructured logging + per-tool metricsRequest logs via X-Request-Id
Use caseTalk to your ERP from your IDEBuild programmatic integrations

Internally, the MCP server translates each tool call into a REST API request. It doesn't duplicate logic — it's a stateless bridge.


Development​

To contribute or run the server in development mode:

git clone https://github.com/Frihet-io/frihet-mcp.git
cd frihet-mcp
npm install
npm run build

Run locally:

FRIHET_API_KEY=fri_your_key node dist/index.js

Run with debug logs:

FRIHET_MCP_DEBUG=1 FRIHET_API_KEY=fri_your_key node dist/index.js

Test with the MCP Inspector:

npx @modelcontextprotocol/inspector node dist/index.js

Next action​



Previous: Webhooks | Next: Claude Code Skill