Busflow Docs

Internal documentation portal

Skip to content

MCP Agent Bridge Protocol โ€‹

Purpose: Define how Paperclip agents access Busflow systems via MCP (Model Context Protocol) servers. Related: ADR-020, agentic-led-company-spec.md


Overview โ€‹

Paperclip runs as a standalone governance platform with its own Postgres. It does not share a database with Busflow. All data access flows through MCP servers โ€” lightweight protocol adapters that expose Busflow resources as agent-consumable tools.

โ”Œโ”€โ”€โ”€ Paperclip โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€ Busflow โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                                     โ”‚       โ”‚                         โ”‚
โ”‚  Commerce Team (PM ยท Eng ยท QA)      โ”‚       โ”‚  Hasura (GraphQL)       โ”‚
โ”‚    โ†’ mcp-server-hasura (commerce) โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Commerce data        โ”‚
โ”‚    โ†’ mcp-server-busflow-api โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Commerce actions     โ”‚
โ”‚    โ†’ mcp-server-github โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Code repos           โ”‚
โ”‚                                     โ”‚       โ”‚                         โ”‚
โ”‚  Backoffice Team (PM ยท Eng ยท QA)    โ”‚       โ”‚  n8n (Automations)      โ”‚
โ”‚    โ†’ mcp-server-hasura (backoffice) โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Backoffice data      โ”‚
โ”‚    โ†’ mcp-server-busflow-api โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Backoffice actions   โ”‚
โ”‚    โ†’ mcp-server-github โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Code repos           โ”‚
โ”‚                                     โ”‚       โ”‚                         โ”‚
โ”‚  Operations Team (PM ยท Eng ยท QA)    โ”‚       โ”‚                         โ”‚
โ”‚    โ†’ mcp-server-hasura (operations) โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Operations data      โ”‚
โ”‚    โ†’ mcp-server-busflow-api โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Operations actions   โ”‚
โ”‚    โ†’ mcp-server-github โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Code repos           โ”‚
โ”‚                                     โ”‚       โ”‚                         โ”‚
โ”‚  Comms Team (PM ยท Eng ยท QA)         โ”‚       โ”‚                         โ”‚
โ”‚    โ†’ mcp-server-hasura (comms) โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Messaging data       โ”‚
โ”‚    โ†’ mcp-server-busflow-api โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Comms actions        โ”‚
โ”‚    โ†’ mcp-server-github โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Code repos           โ”‚
โ”‚                                     โ”‚       โ”‚                         โ”‚
โ”‚  Cross-Cutting: PM ยท Co-Founder     โ”‚       โ”‚                         โ”‚
โ”‚    โ†’ mcp-server-analytics โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Usage metrics        โ”‚
โ”‚    โ†’ mcp-server-hasura (read-only) โ”€โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚โ”€โ”€โ–บ Aggregated views     โ”‚
โ”‚                                     โ”‚       โ”‚                         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

MCP Server Inventory โ€‹

MCP ServerPurposeData SourceEstimated Effort
mcp-server-hasuraRead product data: tours, bookings, customers, vehicles, crewBusflow Hasura (GraphQL)~1 day (community server exists)
mcp-server-busflow-apiExecute NestJS Hasura Actions: manage bookings, trigger workflows, update operator configBusflow NestJS API (REST)~2 days
mcp-server-n8nTrigger n8n automations from agent workflowsn8n webhook API~1 day
mcp-server-githubRead/write code, PRs, issues, CI statusGitHub API~0 (community server exists)
mcp-server-analyticsRead anonymized usage metrics, churn signals, feature adoptionAnalytics store (TBD)~1 day

TIP

Community MCP servers exist for GitHub and generic GraphQL endpoints. Prefer community servers where available; only build custom servers for Busflow-specific APIs.


Bounded Context Enforcement via MCP โ€‹

The spec (ยง3.2) defines a strict access control matrix. MCP tool assignment enforces this โ€” agents see only the MCP servers assigned in their Paperclip config.

Domain Teams โ€‹

Each domain team receives MCP servers scoped to its bounded context. The mcp-server-hasura instance exposes only the Hasura views and permissions relevant to that domain.

Domain TeamMCP Servers AssignedMonorepo ScopeCannot Access
Commercehasura (commerce views), busflow-api (commerce actions), githubapps/booking-widget, apps/passenger, packages/commerce/*Other domains' data, analytics, marketing
Backofficehasura (backoffice views), busflow-api (backoffice actions), githubapps/workspace, packages/backoffice/*Other domains' data, analytics, marketing
Operationshasura (operations views), busflow-api (operations actions), githubapps/driver, packages/operations/*Other domains' data, analytics, marketing
Communicationshasura (comms views), busflow-api (comms actions), githubpackages/comms/*, Real-time Inbox modulesOther domains' data, analytics, marketing

Cross-Cutting Roles โ€‹

RoleMCP Servers AssignedCannot Access
Product Managerhasura (read-only aggregated views), analyticsSource code, marketing internals
Domain ExpertNone (uses own knowledge base)All Busflow systems
Co-Founder (Strategy)analyticsRaw code, raw customer data

IMPORTANT

MCP servers should expose scoped views, not raw database access. The mcp-server-hasura instance for each domain team should expose only the tables/views belonging to that domain's schema. The Product Manager's instance should expose pre-authorized GraphQL queries (anonymized booking counts, feature usage metrics) instead of full table access.


Authentication & Security โ€‹

ConcernApproach
MCP โ†” Busflow authMCP servers authenticate to Busflow APIs using service account tokens (stored as Docker secrets)
Agent โ†” MCP authPaperclip manages agent-to-MCP authentication via its adapter config
Data isolationEach MCP server exposes only the endpoints/queries its target agent needs. No blanket database access
PII protectionmcp-server-hasura must NOT expose passenger PII to non-Engineering agents. Use Hasura view-based permissions to expose anonymized aggregates
Audit trailPaperclip's audit trail logs MCP tool calls. Additionally, Busflow NestJS logs inbound API calls from MCP servers

Deployment โ€‹

Paperclip and its MCP servers run as standalone services in the Docker Swarm stack:

yaml
# docker-compose.paperclip.yml (simplified)
services:
  paperclip:
    image: busflow/paperclip-fork:latest  # or official image
    ports:
      - "3100:3100"
    environment:
      - DATABASE_URL=postgresql://paperclip:***@paperclip-db:5432/paperclip
    volumes:
      - paperclip-data:/data

  paperclip-db:
    image: postgres:16
    volumes:
      - paperclip-pgdata:/var/lib/postgresql/data

  mcp-server-hasura:
    image: busflow/mcp-server-hasura:latest
    environment:
      - HASURA_GRAPHQL_ENDPOINT=http://hasura:8080/v1/graphql
      - HASURA_ADMIN_SECRET=***

NOTE

The exact deployment configuration will evolve. This serves as the initial architectural direction. Traefik routing, secrets management, and monitoring integration follow the patterns established in infrastructure.md.


Evolution Triggers โ€‹

If any of the following occur, re-evaluate the MCP bridge approach per ADR-020:

  • Latency: MCP round-trip adds unacceptable delay to agent workflows โ†’ consider shared DB access
  • Data scope: Agents need real-time subscriptions to Busflow data โ†’ consider Hasura subscriptions (requires shared DB or webhook forwarding)
  • Complexity: >5 custom MCP servers โ†’ consider consolidating into a single Busflow gateway MCP server

Internal documentation โ€” Busflow