Skip to main content

MCP Server

OPBX ships an optional MCP (Model Context Protocol) server, opbx-mcp. It gives AI agents (Claude, IDE assistants, your own LLM tools) a safe way to inspect and change your phone system: extensions, phone numbers, ring groups, call queues, IVR menus, business hours, conference rooms, AI assistants, auto-dialer campaigns, call records, live calls and more.

What it is, and what it is not​

  • It is a layer of intent-level tools over the OPBX REST API, for example configure_phone_number_routing, start_campaign or validate_configuration.
  • It is not a generic REST proxy. It never reads the database. Every action goes through the REST API with the caller's own credential and permissions.
  • It never exposes the call-handling side of OPBX (voice webhooks, dialer internals), SIP passwords, web phone or embed credentials, Cloudonix settings or API-key management.

Prerequisites​

  • The mcp-server service is running (it is part of the Docker Compose stack).
  • An OPBX credential for the agent: an API key (recommended) or a user's personal access token.

Where to find the URL​

The MCP Server card at the top of the API Keys page (Owner) shows the URL to give to MCP clients, next to the REST API card. It is the organization's Webhook Base URL from Settings followed by /mcp, or, when that is empty, the address you opened OPBX on followed by /mcp, for example https://pbx.example.com/mcp. nginx forwards /mcp to the MCP container, so no extra port is needed.

For local development only, the container's port can be published on the loopback interface by starting the stack with -f docker-compose.ports.yml (http://127.0.0.1:8080/mcp, port from MCP_PORT).

PathPurpose
/mcpMCP endpoint (Streamable HTTP)
/healthLiveness (container-internal or on the dev port)
/readyReadiness, including a check that OPBX answers

Workflows​

Copy the MCP server URL​

Who can do this: Owner (the API Keys page is Owner-only).

  1. In the sidebar, click API Keys.
  2. On the MCP Server card, click the copy button next to the URL.

A toast confirms "MCP Server URL copied to clipboard".

The REST API and MCP Server endpoint cards on the API Keys page, with the MCP URL ending in /mcp and its copy button

Connect an MCP client​

Who can do this: Owner, to create the API key. Anyone can then use the key in an MCP client.

  1. On the API Keys page, create a key with the resource grants the agent needs, and copy the opbxk_… value (it is shown once).
  2. Copy the MCP server URL.
  3. In your MCP client (for example Claude or MCP Inspector), add a server with that URL and the header Authorization: Bearer <key>. See the example configuration below.
  4. Ask the agent to run validate_configuration to check the connection.

The agent lists the OPBX tools and answers with the configuration report. A wrong or revoked key makes every tool call fail with an authentication error.

Credentials​

The client sends its own OPBX credential as a bearer token. The MCP server stores nothing.

CredentialFormatBest forNotes
API keyopbxk_…Long-running agentsNever expires; can be revoked. Access is exactly the key's resource grants
Personal access tokenid|tokenInteractive useActs with the user's role. Expires after 24 hours (30 days when the login sent "remember": true) and stops working when the user signs in again or changes the password

Example client configuration:

{
"mcpServers": {
"opbx": {
"url": "https://pbx.example.com/mcp",
"headers": { "Authorization": "Bearer opbxk_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
}
}
}

The organization always comes from the credential. Tools do not accept an organization id, and the platform-manager "operate as" header is never sent. A request without an Authorization: Bearer header, or with a personal access token OPBX rejects, is refused with 401 before any tool runs. An opbxk_ API key is not checked up front: OPBX checks it on each tool call, and a wrong or revoked key fails there with an authentication error.

Permissions​

The MCP server checks the caller's role on every tool call, using the same rules as OPBX, and is stricter where OPBX is permissive.

CallerWhat the agent can do
OwnerEverything the tools offer
PBX AdminConfiguration tools. Owner-only actions stay Owner-only (for example deleting or archiving a campaign, disconnecting a call)
PBX UserRead tools only, except the user and supervisor tools
ReporterRead tools only (configuration, call records, analytics), except the user and supervisor tools
SupervisorRead tools, scoped views and start_call_coaching, limited to the people and groups assigned to them
API keyWhatever the key's grants allow, enforced by OPBX

Confirmation for risky actions​

Deletes, campaign start, pause, resume and archive, disconnect_call, start_call_coaching, assigning a distribution list and removing security rules need two calls:

  1. Called without confirm, the tool returns confirmation_required: true and a live preview of the target with warnings (for example "deleting the extension also removes its Cloudonix subscriber").
  2. Called again with confirm: true (the boolean, not a string), the action runs.

A delete that OPBX refuses because the item is still in use comes back as a conflict error with OPBX's message, which names where the item is used. Change those references first, as you would in the app.

Rate limits​

Per caller, per minute (defaults, configurable by the administrator with RATE_LIMIT_READ_PER_MIN, RATE_LIMIT_WRITE_PER_MIN, RATE_LIMIT_SENSITIVE_PER_MIN and RATE_LIMIT_IP_PER_MIN):

ClassLimit
Read tools120
Write tools30
Sensitive tools (campaign control, live calls, bulk operations such as validate_configuration)10
Per IP address600

OPBX's own per-organization API limits also apply.

Tools, resources and prompts​

More than a hundred tools, grouped by area:

AreaExamples
Extensions and userslist_extensions, create_extension, update_user, invite_user
Phone numberslist_phone_numbers, configure_phone_number_routing, list_available_caller_ids
Routingcreate_ring_group, create_ivr_menu, list_ivr_voices, create_business_hours, set_business_hours_status
Call queues (read-only)list_call_queues, get_call_queue, get_call_queue_stats, get_call_queue_live, list_queue_calls
Conference rooms and AIcreate_conference_room, list_ai_assistants, list_ai_load_balancers, list_ai_providers
Auto dialercreate_campaign, start_campaign, list_campaign_destinations, create_distribution_list, get_campaigns_monitor_summary
Callssearch_calls, get_call_details, get_call_statistics, list_active_calls, disconnect_call
Security listslist_inbound_blacklist, block_inbound_number, list_blocked_calls, add_outbound_whitelist_rule
Trunkslist_trunks, create_trunk, update_trunk
Supervisorsget_supervisor_assignments, get_supervisor_dashboard, start_call_coaching
Auditvalidate_configuration

validate_configuration checks the whole configuration for broken references (phone numbers routed to inactive targets, ring groups without members, campaigns without ready lists and so on) and suggests fixes. It is a good first tool to try.

The server also offers read-only resources (opbx://organization, opbx://extensions/{id} and similar) and four prompts: configure_pbx, build_inbound_call_flow, create_outbound_campaign and diagnose_call_problem.

Audit​

Every tool call is logged with a request id, trace id, tool name, permission, organization and user. Destructive tools are logged at an elevated level. OPBX also audit-logs sensitive changes on its side.

Troubleshooting​

SymptomCauseWhat to do
401 on every callMissing header, or a wrong or expired personal access tokenCheck the bearer token
Every tool fails with an authentication errorWrong or revoked API keyCreate a new API key
502 "OPBX API is unreachable; credential could not be validated" (JSON-RPC error from the MCP server)The MCP server cannot reach OPBXCheck that the OPBX stack is up
429Too many requests from one addressWait a minute
A tool answers rate_limited ("Rate limit for … operations exceeded")The caller passed the per-minute limit for that class of toolsWait a minute
A tool answers "forbidden"The role or API key does not allow itUse a credential with the right role or grant
A delete answers with a conflictThe item is still used elsewhereChange the listed references, then delete
/mcp returns 502The mcp-server container is not runningdocker compose up -d mcp-server

More documentation​

The full reference is in the repository under mcp-server/docs/: the tool catalog (mcp-tools.md), resources, prompts, authentication, security model and deployment.

  • API Keys — the recommended credential for agents
  • Users — roles that tokens act with