Skip to main content
Glama

ops-mcp

A multi-tenant MCP gateway for the ops-platform CRM. A small, safe, fast tool surface for AI agents and staff. One Hono app, stateless, on Cloudflare Workers or Node.

License Node Hono Cloudflare Workers

Contents: Overview · How it works · Tool sets and profiles · What you can ask it to do · Safety model · White-label · Quick start · Configuration · Performance · Multi-tenancy · Project layout · Testing · Documentation · Contributing · Licence


Overview

ops-mcp lets an AI assistant or an AI agent work in an ops-platform CRM through the Model Context Protocol (MCP). It is a gateway: it holds no data and no credentials of its own. Every call is made to the CRM with the caller's own token, so the CRM's roles and record scope apply to everything.

It is for two groups:

  • Staff who talk to Claude, Codex or another MCP client and want "what is due", "how is this client doing" or "draft the invoice" answered in one step.

  • Agent operators who run AI workers that claim tasks from the CRM's queue, follow written procedures, and report back.

The problem it solves is surface area. A CRM's full API has well over a hundred operations. Handing all of them to a model costs context, invites wrong calls and makes every answer slow. ops-mcp ships a small default set of 14 tools, each doing a whole job in one call (the daily profile), and keeps the rest of the API available behind an explicit profile choice.

  • Small by default. daily is a stable contract of 14 tools. Changing it is a breaking change.

  • Composite tools. One call replaces a chain of CRM calls and returns a lean answer with names, not ids.

  • No state. Each request builds a fresh MCP server and transport, so any Worker isolate or Node process can answer any request.

  • Same code on two runtimes. One Hono app serves from a Cloudflare Worker and from Node.

  • White-label. Each tenant has its own URL, name, instructions, logo and connect page.

  • Traceable. Every tool result reports how many CRM calls it made and how long it took.

Related MCP server: Exir MCP Server

How it works

flowchart LR
  Client["MCP client<br/>(Claude, Codex, an agent)"]
  subgraph gw["ops-mcp gateway (Hono)"]
    Route["/t/slug/mcp"]
    Core["token check, profile,<br/>MCP server per request"]
    Route --> Core
  end
  subgraph crm["Tenant CRM (ops-platform)"]
    API["/api/v1 REST + OpenAPI"]
    OAuth["OAuth authorization server"]
  end
  Client -->|"POST JSON-RPC + Bearer token"| Route
  Core -->|"openapi.json, /me, tool calls<br/>(caller's token)"| API
  Client -.->|"sign in (OAuth, PKCE)"| OAuth
  Client -.->|"401 + resource_metadata"| Route

A request to POST /t/<slug>/mcp goes through these steps:

  1. The gateway looks up <slug> in the tenant registry. An unknown slug answers 404.

  2. It reads Authorization: Bearer <token>. A missing token, or one that does not start with ops_, answers 401 with a WWW-Authenticate header that carries resource_metadata. The client follows it to the CRM's OAuth server and signs the person in.

  3. It checks the token against the CRM (GET /api/v1/me), cached per token (30 s fresh, then stale-while-revalidate). A 401 from the CRM answers 401 with error="invalid_token".

  4. It builds a new MCP server for the connection's profile (?profile=, default daily) and answers the JSON-RPC request.

  5. tools/list returns the profile's tools. tools/call runs only a tool that is in that profile, calls the CRM with the caller's token, and returns the result with _meta.crmCalls and _meta.ms.

The full walk-through, with caching and module map, is in docs/ARCHITECTURE.md.

Tool sets and profiles

A profile is chosen per connection with a query string, for example https://mcp.example.com/t/acme/mcp?profile=agent. Without one, the connection gets daily. An unknown profile answers 400 and lists the valid names.

Profile

Contents

Composite tools

Use it for

daily (default)

Exactly the 14 composite tools listed below; a stable contract

14

Everyday staff use and agent work loops

staff

Nine composite tools plus a filtered set of generated list, get and update tools

9

People who need record lookups too

agent

The work-queue tools, record_context, what_can_i_do, review_handoff, my_day, call_list, request_call, plus filtered generated tools (guides, comments, email log, search, record reads)

13

AI workers that claim and finish tasks

admin

Team, agency, calling and billing composites, plus filtered generated tools (members, attendance, invitations, projects, tasks, leads and deals lists)

25

Owners and managers

full

Every composite tool plus every generated tool

34

Power use and automation. all is an alias

The composite counts come from running the code (npm run docs:tools lists each tool with its profiles). The number of generated tools in staff, agent, admin and full depends on the CRM's OpenAPI document at runtime, so it is not fixed here.

The 14 daily tools: my_day, client_status, agent_queue_peek, agent_claim_task, agent_heartbeat, agent_progress, agent_complete_task, agent_release_task, review_handoff, whats_due, create_task, record_context, setup_overview, what_can_i_do.

Every composite tool, with inputs and profile membership, is in docs/TOOLS.md.

What you can ask it to do

The composite tools, grouped by area. Each example is something a person or an agent might say.

Area

Tools

Example request

Daily work

what_can_i_do, my_day, create_task, record_context, setup_overview

"What is on my plate today?" or "What can I do here?"

Agent work queue

agent_whoami, agent_queue_peek, agent_claim_task, agent_heartbeat, agent_progress, agent_complete_task, agent_release_task, review_handoff

"Take the next urgent task, follow its guide, and mark it done with a summary."

Team and clients

team_status, whats_due, whats_pending, assign_task, team_report, triage_inbox, client_status

"Which tasks are overdue, and who is free to take the unassigned ones?"

Money

invoice_create, invoice_send, invoice_mark_paid, quote_to_invoice, unpaid_invoices, billing_summary

"Draft an invoice for this client with two line items, then show me the email before it goes out."

Calling prep

call_list, call_history, request_call

"Who should I phone today?"

Routines

routine_create, list_recurring

"Every week, ask for newsletter content on Monday and send it on Wednesday."

Bulk

tasks_bulk_complete, tasks_bulk_assign, tasks_bulk_create

"Create these 40 tasks and give them to Sam."

A tool cannot place a phone call. The CRM connects each call to a person's browser session, so the calling tools prepare calls (who to phone, what happened) and request_call creates a callback task for a person.

Safety model

  • A profile is not a permission boundary. It chooses what a connection sees in tools/list and may call. The gateway rejects a call to a tool outside the profile. The CRM, not the gateway, decides what the signed-in person may do, whatever profile they pick.

  • Confirmed actions. Every generated tool that maps to a DELETE, plus email_send and sms_send, takes a required confirmed input and refuses to run unless it is true. The schema tells the model to set it only after the user approved that exact action.

  • Blocked tools. The gateway never generates tools for file upload and download, demo status and purge, voice number purchase, update and release, voice settings, voice sessions or voice calls. The list is BLOCKED in src/tools.mjs.

  • Invoice sending previews first. invoice_send without confirmed: true returns the recipient, subject, body and total and sends nothing. With it, the email goes out first and the status changes second. If the status step fails, the result says so and tells the caller not to email again.

  • Retries. Reads retry once, after 150 ms, on a network error or a 5xx, for composite and generated tools alike. Writes are never retried, because a failed write may have been applied.

  • Bulk create is repeat-safe when the CRM allows it. tasks_bulk_create returns a batchKey and sends <batchKey>:<index> as each task's requestKey, but only when the CRM's tasks_create accepts a request key. The result says retrySafe: true or false. When it is false, re-send only the failed items. tasks_bulk_complete is safe to retry: a task already completed reports alreadyDone.

  • Credentials. Nothing is written to disk. Tokens are forwarded to the CRM and held in memory only as cache keys.

The details and the exact failure messages are in SECURITY.md and docs/ARCHITECTURE.md.

White-label

Each tenant in the registry can carry:

Field

Effect

origin (required)

The tenant's CRM origin; the gateway's upstream and the OAuth authorization server

name

Shown to the model as the server title, on the connect page, and as resource_name in the OAuth resource metadata. Defaults to the slug

instructions

Replaces the default instructions the model receives on connect

logoUrl

Shown on the connect page; ignored unless it starts with https://

accent

Link colour on the connect page; ignored unless it is a #rrggbb value

docsUrl

Published as resource_documentation and linked from the connect page (the page links it only when it starts with https://)

GET /t/<slug> serves a connect page for that tenant: the connector address, the Claude Code command (claude mcp add --transport http crm <url>) and notes for other clients.

Quick start

Prerequisites: Node.js 22. The Worker path also needs a Cloudflare account and npx wrangler login.

npm install

Node. Point the gateway at a CRM and start it:

TENANTS='{"acme":"https://crm.example.com"}' PUBLIC_URL=http://localhost:8080 npm start
# connector address: http://localhost:8080/t/acme/mcp

Cloudflare Workers. Copy the example config, edit the tenant, and deploy:

cp wrangler.example.jsonc wrangler.jsonc   # git-ignored
npx wrangler dev                           # local Workers runtime
npm run deploy                             # wrangler deploy

Connect a client.

claude mcp add --transport http crm https://mcp.example.com/t/acme/mcp

Then run /mcp in Claude Code and choose Authenticate. Other clients: add a custom connector (Streamable HTTP) with the same address and no headers. As an alternative to OAuth, send Authorization: Bearer <API token> with a CRM-issued token that starts with ops_. The full procedure and a verification checklist are in docs/DEPLOYMENT.md.

Configuration

Variable

Where

Meaning

Default

TENANTS

Worker var, Node env

JSON object: slug to a CRM origin string, or to an object with origin, name, instructions, logoUrl, accent, docsUrl. Invalid JSON stops startup

none

OPS_API_URL

both

Adds one tenant with slug default, served at /mcp. A default key in TENANTS overrides it

none

PUBLIC_URL

both

Public origin of the gateway, used in metadata and the 401 challenge. Without it the origin of the incoming request is used

request origin

TRACE_CALLS

both

Set to 0 to silence the one-line JSON log per tool call

logging on

PORT

Node

Listening port

8080

CRM_<SLUG>

Worker service binding

Reaches that tenant's CRM Worker without the public edge. Slug upper-cased, dashes to underscores

public fetch

At least one tenant must be configured through TENANTS or OPS_API_URL, or the gateway refuses to start.

Performance

In one reference deployment and region, a Worker with a service binding answered /health at p50 88 ms against 249 ms from a container host, and a read-only sweep of 39 tools had a median of medians of 135 ms, with 31 of 39 under 200 ms. Numbers vary by deployment and region. The gains came from the platform and from fewer CRM calls per tool (whats_due went from 5 CRM calls to 1), not from the web framework. Methodology, tables and how to re-run are in docs/BENCHMARKS.md.

Multi-tenancy

The registry maps a slug to a CRM origin and its branding. The slug appears in the URL (/t/<slug>/mcp) and must match [a-z0-9-]+. On a Worker, a tenant's CRM can be reached through a service binding named CRM_<SLUG> (slug upper-cased, dashes to underscores), which skips DNS, TLS and the public edge. Without a binding the gateway uses a public fetch. The tool-list cache is keyed by tenant origin; the token check and member list caches are keyed by origin and token.

To add a tenant, add it to TENANTS and, on Workers, add a CRM_<SLUG> binding to wrangler.jsonc. See docs/DEPLOYMENT.md.

Project layout

src/
  worker.mjs        Cloudflare Worker entry: service bindings, app cache
  server.mjs        Node entry (@hono/node-server)
  app.mjs           Hono routes: health, OAuth metadata, connect page, MCP endpoint
  core.mjs          profiles, MCP server per request, token and tool caches, tracing
  tools.mjs         OpenAPI document to MCP tools, confirmation gating, blocked list
  tenants.mjs       tenant registry parser, default instructions
  connect-page.mjs  per-tenant connect page
  crm.mjs           shared CRM client: retry, member list cache, paging, lookups
  agent.mjs  admin.mjs  agency.mjs  dialer.mjs  billing.mjs  staff.mjs
                    composite tools by area
scripts/            gen-tools-doc.mjs (writes docs/TOOLS.md), local-setup.mjs
test/               unit tests and the benchmark and flow harnesses
docs/               architecture, tools, deployment, benchmarks

Testing

npm test

runs node --test test/unit. The other files in test/ are harnesses that run against a live gateway and CRM; their headers explain usage:

File

What it does

test/sweep.mjs

calls every read-only tool and reports latency and CRM calls per tool

test/compare.mjs

before and after comparison of two checkouts, counting CRM requests per tool call

test/pages.sh

times the CRM's web pages

test/gateway-ab.mjs

compares two gateway deployments (p50, p95) without a real token

test/bench.mjs, test/bench-writes.mjs

latency of chosen tools and of the agent write loop

test/poc-agents.mjs

races two agents over the queue and checks each task is claimed once

test/oauth-flow.mjs

the full OAuth connect, refresh and revoke flow through the gateway

Documentation

Read

For

docs/ARCHITECTURE.md

request lifecycle, modules, caching, statelessness, trade-offs

docs/TOOLS.md

every composite tool: inputs, read-only flag, profiles (generated)

docs/DEPLOYMENT.md

Workers and Node deployment, adding a tenant, connecting clients, verification, rollback

docs/BENCHMARKS.md

measured latency, CRM call counts, how to re-run

CONTRIBUTING.md

setup, conventions, adding a composite tool

SECURITY.md

reporting a vulnerability and the security model

Contributing

Contributions are welcome. CONTRIBUTING.md covers setup, npm test, conventions and how to add a composite tool. Report security issues privately as described in SECURITY.md.

Licence

MIT, copyright 2026 Abdullah Saeed.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      A secure MCP gateway for enterprise AI tool execution, enabling governed invocation of business tools with authentication, RBAC, audit logging, PII redaction, and async processing.
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      A multi-tenant MCP gateway that connects AI agents to the Exir CRM API, enabling secure, permissioned access to customers, leads, tasks, invoices, and more through natural language.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a unified MCP gateway enabling AI agents to securely access multiple tool servers (knowledge base, database, repo, etc.) with dynamic tool selection and OAuth2/RBAC security.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP-compatible AI clients to search and view CRM customers, deals, contracts, tasks, calendars, and outbound jobs, and to propose opt-in write actions that require human approval in the CRM.
      Apache 2.0