Authentication

MCP Server

Connect AI tools to Billabex using the Model Context Protocol (MCP) with OAuth 2.1.

MCP Server

Billabex exposes a Model Context Protocol (MCP) server so AI tools can access Billabex data using OAuth 2.1. This guide explains discovery, authorization, available tools and resources, and how to connect.

MCP Endpoint

The MCP server uses Streamable HTTP (stateless):

POST [baseURL]/mcp

OAuth Discovery Flow

MCP clients follow RFC 9728 (Protected Resource Metadata) and RFC 8414 (OAuth Authorization Server Metadata):

  1. Call POST /mcp without a token.
  2. The server responds with WWW-Authenticate including resource_metadata and scope.
  3. Fetch the resource metadata URL to discover authorization_servers and scopes_supported for /mcp.
  4. Fetch the authorization server metadata to locate the authorization and registration endpoints.

Example 401 Response

The MCP server returns:

WWW-Authenticate: Bearer resource_metadata="[baseURL]/.well-known/oauth-protected-resource", scope="mcp:read mcp:write"

Protected Resource Metadata (Path-Aware)

For /mcp, request:

[baseURL]/.well-known/oauth-protected-resource/mcp

The response includes:

{
  "resource": "[baseURL]",
  "authorization_servers": ["[baseURL]"],
  "scopes_supported": ["mcp:read", "mcp:write"],
  "bearer_methods_supported": ["header"]
}

Authorization Server Metadata

GET [baseURL]/.well-known/oauth-authorization-server

This returns the authorization_endpoint, token_endpoint, and registration_endpoint needed for OAuth 2.1 + PKCE.

Scopes

MCP uses two scopes:

ScopeAccessDescription
mcp:readReadList and get invoices, accounts, communications.
mcp:writeWriteCreate, update, delete operations.

If an authorization request omits the scope parameter, Billabex defaults to mcp:read mcp:write for MCP clients.

Protocol Details

  • Transport: Streamable HTTP (stateless mode).
  • Authentication: Authorization: Bearer <token> header (required).
  • Rate limiting: 300 requests/minute per token (sliding window).
  • CORS header: Clients may send Mcp-Protocol-Version header.

Resources

MCP resources provide metadata that AI tools can read to understand Billabex capabilities.

URIDescription
billabex://aboutPlatform overview, value proposition, key features
billabex://conceptsKey entities, statuses, relationships, and business rules
billabex://workflowStep-by-step dunning workflow, task handling, and processes

These resources help AI agents understand:

  • About: What Billabex is, how it helps businesses manage invoice collection
  • Concepts: Domain model including invoices, accounts, customer balances, communications, and tasks
  • Workflow: Standard dunning workflow from invoice overdue to payment recovery

Prompts

MCP prompts provide business-oriented templates for AI agents to perform common tasks. Unlike tools, prompts use human-readable parameters (account names, organization names) instead of technical IDs.

PromptParametersUse Case
financial-snapshotorganizationName?, period? (7/30/all days)Overview of outstanding balances, top accounts, cash flow
account-360accountName, organizationName?Complete account summary with invoices, communications, tasks
daily-planorganizationName?Daily action plan: tasks, reminders, follow-ups
daily-digestorganizationName?Summary of today’s activities and updates
communication-intelligenceaccountName?, organizationName?Recent replies, payment promises, accounts that replied but didn’t pay
risk-reportorganizationName?Accounts at risk, silent accounts, accounts without contacts

How Prompts Work

  1. User provides names: You call a prompt with an account name like “Acme Corp” instead of a UUID
  2. Agent resolves IDs: The prompt instructs the AI agent to use tools like list-accounts and list-organizations to find the matching IDs
  3. Agent gathers data: The agent calls multiple tools to gather relevant data
  4. Agent presents results: Results are formatted naturally without exposing technical IDs

Example: Financial Snapshot

{
  "name": "financial-snapshot",
  "arguments": {
    "organizationName": "My Company",
    "period": "30days"
  }
}

The agent will:

  1. Use list-organizations to find “My Company”
  2. Use list-customer-balances to get outstanding balances
  3. Use list-invoices to find upcoming due invoices
  4. Present a formatted overview of your financial position

Tools Reference

Tools are grouped by domain. Read tools require mcp:read; Write tools require mcp:write.

Tool outputs include human-friendly fields such as displayName and summary where available. Prefer those fields for user-facing responses and keep IDs for follow-up tool calls.

All tools include annotations (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) to help AI agents understand their behavior.

Invoicing

ToolAccessDescription
list-invoicesReadList invoices for an organization (paginated).
get-invoiceReadGet invoice by ID or by number.
create-invoiceWriteCreate invoice with base64 file upload.
update-invoice-paid-amountWriteUpdate paid amount on an invoice.
delete-invoiceWriteDelete an invoice.
list-accountsReadList customer accounts (paginated).
get-accountReadGet account details with contacts.
create-accountWriteCreate a customer account.
update-accountWriteUpdate account name, currency, or address.
delete-accountWriteDelete a customer account.
list-contactsReadList contacts on an account.
get-contactReadGet a specific contact.
create-contactWriteAdd a contact to an account.
update-contactWriteUpdate a contact.
delete-contactWriteRemove a contact.
upsert-contactWriteCreate or update contact by email/name match.
list-internal-representativesReadList internal reps on an account.
get-internal-representativeReadGet a specific internal rep.
create-internal-representativeWriteAdd an internal rep.
update-internal-representativeWriteUpdate an internal rep.
delete-internal-representativeWriteRemove an internal rep.
upsert-internal-representativeWriteCreate or update internal rep by match.
list-credit-notesReadList credit notes (paginated).
get-credit-noteReadGet credit note details.
create-credit-noteWriteCreate a credit note.
delete-credit-noteWriteDelete a credit note.
apply-credit-allocationWriteApply credit from a credit note to an invoice.
remove-credit-allocationWriteRemove a credit allocation.
link-account-sourceWriteLink an external source to an account.
update-account-sourceWriteUpdate account source last-sync timestamp.
unlink-account-sourceWriteUnlink an external source.
upsert-partyWriteCreate/update contact or rep by email domain.

Dunning

ToolAccessDescription
list-customer-balancesReadList customer outstanding balances (paginated).
get-customer-balanceReadGet balance details with invoices/credit notes.
list-outgoing-communicationsReadList outgoing dunning emails (paginated).
get-outgoing-communicationReadGet outgoing communication details.
list-outgoing-communications-by-accountReadList outgoing communications for an account.
update-outgoing-communicationWriteUpdate a scheduled outgoing email.
list-incoming-communicationsReadList incoming (reply) communications.
get-incoming-communicationReadGet incoming communication details.
list-incoming-communications-by-accountReadList incoming communications for an account.

Email

ToolAccessDescription
list-emailsReadList all emails (incoming + outgoing).
list-incoming-emailsReadList incoming emails (paginated).
get-incoming-emailReadGet incoming email with simplified body.
list-outgoing-emailsReadList outgoing emails (paginated).
get-outgoing-emailReadGet outgoing email with simplified body.

Platform

ToolAccessDescription
list-organizationsReadList organizations for the user.
get-organizationReadGet organization details.
update-organizationWriteUpdate organization name or email domain.
update-organization-settingsWriteUpdate reminder delay settings.
list-organization-membersReadList members of an organization.
remove-organization-memberWriteRemove a member from an organization.
create-organization-invitationWriteInvite a user to an organization.
cancel-organization-invitationWriteCancel a pending invitation.

Tasking

ToolAccessDescription
list-account-tasksReadList active tasks requiring user input.
get-account-taskReadGet task details and required input format.
cancel-account-taskWriteCancel an account task.
add-account-task-text-interactionWriteAdd a text response to a task.
add-account-task-structured-interactionWriteAdd a structured response to a task.

Pagination

Tools returning lists use cursor-based pagination:

  • Parameters: first (items per page, max 100), after (cursor).
  • Response: nodes array + pageInfo.endCursor.

Notes

  • OAuth is required for all MCP access.
  • Tokens must be sent in the Authorization: Bearer <token> header.
  • Rate limiting applies to MCP requests (300/min per token).
  • update-outgoing-communication accepts message in markdown. Do not include a signature; the platform renders HTML/text and appends the agent signature automatically.

Next Steps