# mastanley13/gohighlevel-mcp architecture

> Architecture diagram of the GitHub repository mastanley13/gohighlevel-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mastanley13/gohighlevel-mcp
- Repository: https://github.com/mastanley13/gohighlevel-mcp

## Overview

1. **What this repo is**
   This is a Node.js/TypeScript MCP server that exposes GoHighLevel sub-account APIs as AI-callable tools. The core architecture is an adapter layer: Claude Desktop or an HTTP MCP client talks to this server, and the server translates tool calls into GoHighLevel REST API requests.

2. **Primary execution modes**
   There are two server entrypoints: `src/server.ts` for the CLI/stdio MCP mode used by Claude Desktop, and `src/http-server.ts` for HTTP-based MCP access. The `api/index.js` file exists as a deployment entrypoint for serverless platforms like Vercel. This means the same tool layer can be served over local stdio or HTTP without changing the domain logic.

3. **Central data flow**
   The main flow is: MCP client → server entrypoint → tool registry/module → shared GoHighLevel API client → GoHighLevel API. Tool results flow back as MCP responses. The server itself is thin; most business behavior lives in domain-specific tool files, not in the transport layer.

4. **GoHighLevel integration boundary**
   `src/clients/ghl-api-client.ts` is the integration boundary to the external system. It encapsulates authenticated HTTP calls to GoHighLevel, using environment-provided credentials and location context. This client is the only place that should know about base URLs, authorization headers, API version quirks, pagination, and error translation.

5. **Tool layer by domain**
   The `src/tools/` directory is the real application surface. Each file groups tools by GoHighLevel domain: contacts, conversations, calendar, opportunities, blog, email, location, media, custom objects, associations, custom fields, workflows, surveys, store, products, payments, and invoices. Architecturally, this is a vertical-slice design: each module owns a bounded capability set and exposes it as MCP tools.

6. **MCP tool contract**
   Each tool module likely defines both the tool metadata/schema and the handler function. The handler validates inputs, calls the GHL client, and returns structured data suitable for MCP. Because the repo is explicitly a tool server, the tool schemas are part of the public API boundary and are as important as the HTTP endpoints.

7. **Shared types**
   `src/types/ghl-types.ts` centralizes TypeScript models for GoHighLevel entities and responses. This reduces drift between tool modules and the API client, and it makes the tool surface more consistent. In architecture terms, the types layer is the contract bridge between raw API payloads and typed tool handlers.

8. **Transport and hosting differences**
   The repo supports multiple deployment targets without changing application logic: local Node execution, containerized runtime via `Dockerfile`, serverless HTTP via `vercel.json` and `api/index.js`, and process-based hosting via `Procfile`/`railway.json`. Those files matter because they define how the server is launched, not what the domain logic does.

9. **Configuration and security boundary**
   Runtime configuration is environment-driven via `.env.example` and README-described variables like `GHL_API_KEY`, `GHL_LOCATION_ID`, and `GHL_BASE_URL`. The system is designed around private integration credentials, so the main security boundary is credential handling and scope control, not user authentication inside the app.

10. **Testing structure**
   `tests/` mirrors the source layout: client tests validate the GoHighLevel integration boundary, tool tests validate domain behavior, and mocks isolate external API calls. This indicates the architecture is designed to be testable at both the client and tool layers, with the transport layer mostly smoke-tested.

11. **Operational concerns**
   Because the server is a thin wrapper over an external SaaS API, rate limiting, request failure handling, and location-scoped access are important operational constraints. The README’s emphasis on retries, monitoring, and permissions reflects that the main failure modes are external API limits and credential/scoping mistakes rather than internal state corruption.

12. **How to diagram it**
   A good architecture diagram should show three layers: the MCP transports on the left, the tool/domain layer in the middle, and the GoHighLevel API client plus external GHL service on the right. Underneath, show shared types/config as cross-cutting concerns, and tests/deployment files as supporting infrastructure rather than runtime subsystems.

Main entry points: [`src/tools`](https://github.com/mastanley13/gohighlevel-mcp/tree/main/src/tools) (Tool surface), [`src/clients/ghl-api-client.ts`](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/clients/ghl-api-client.ts) (GHL client), [`src/server.ts`](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/server.ts) (StdIO server), [`src/http-server.ts`](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/http-server.ts) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime"]
  node_node_server_stdio["StdIO server<br/>mcp entrypoint<br/>[server.ts]"]
  node_node_server_http["HTTP server<br/>mcp entrypoint<br/>[http-server.ts]"]
  node_node_api_entry["Serverless entry<br/>deployment entrypoint<br/>[index.js]"]
end

subgraph group_group_tools["Tools"]
  node_node_tool_surface["Tool surface<br/>domain modules"]
  node_node_contacts["Contacts<br/>tool module<br/>[contact-tools.ts]"]
  node_node_conversations["Conversations<br/>tool module"]
  node_node_calendar["Calendar<br/>tool module<br/>[calendar-tools.ts]"]
  node_node_opportunities["Opportunities<br/>tool module"]
  node_node_workflows["Workflows<br/>tool module<br/>[workflow-tools.ts]"]
  node_node_email["Email<br/>tool module<br/>[email-tools.ts]"]
  node_node_social["Social media<br/>tool module"]
  node_node_store["Store<br/>tool module<br/>[store-tools.ts]"]
  node_node_payments["Payments<br/>tool module<br/>[payments-tools.ts]"]
  node_node_invoices["Invoices<br/>tool module<br/>[invoices-tools.ts]"]
end

subgraph group_group_core["Core"]
  node_node_client[("GHL client<br/>api client<br/>[ghl-api-client.ts]")]
  node_node_types["GHL types<br/>shared types<br/>[ghl-types.ts]"]
end

subgraph group_group_support["Support"]
  node_node_config["Config<br/>[.env.example]"]
  node_node_docker["Docker<br/>container packaging"]
  node_node_vercel["Vercel config<br/>serverless config<br/>[vercel.json]"]
  node_node_tests_client["Client tests<br/>test suite"]
  node_node_tests_tools["Tool tests<br/>test suite"]
end

node_node_server_stdio -->|"loads tools"| node_node_tool_surface
node_node_server_http -->|"loads tools"| node_node_tool_surface
node_node_api_entry -->|"boots"| node_node_server_http
node_node_tool_surface -->|"includes"| node_node_contacts
node_node_tool_surface -->|"includes"| node_node_conversations
node_node_tool_surface -->|"includes"| node_node_calendar
node_node_tool_surface -->|"includes"| node_node_opportunities
node_node_tool_surface -->|"includes"| node_node_workflows
node_node_tool_surface -->|"includes"| node_node_email
node_node_tool_surface -->|"includes"| node_node_social
node_node_tool_surface -->|"includes"| node_node_store
node_node_tool_surface -->|"includes"| node_node_payments
node_node_tool_surface -->|"includes"| node_node_invoices
node_node_contacts -->|"calls"| node_node_client
node_node_conversations -->|"calls"| node_node_client
node_node_calendar -->|"calls"| node_node_client
node_node_opportunities -->|"calls"| node_node_client
node_node_workflows -->|"calls"| node_node_client
node_node_email -->|"calls"| node_node_client
node_node_social -->|"calls"| node_node_client
node_node_store -->|"calls"| node_node_client
node_node_payments -->|"calls"| node_node_client
node_node_invoices -->|"calls"| node_node_client
node_node_client -->|"uses"| node_node_types
node_node_tests_client -.->|"verifies"| node_node_client
node_node_tests_tools -.->|"verifies"| node_node_tool_surface
node_node_docker -.->|"packages"| node_node_server_stdio
node_node_vercel -.->|"deploys"| node_node_api_entry
node_node_config -.->|"configures"| node_node_client

click node_node_server_stdio "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/server.ts"
click node_node_server_http "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/http-server.ts"
click node_node_api_entry "https://github.com/mastanley13/gohighlevel-mcp/blob/main/api/index.js"
click node_node_tool_surface "https://github.com/mastanley13/gohighlevel-mcp/tree/main/src/tools"
click node_node_contacts "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/contact-tools.ts"
click node_node_conversations "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/conversation-tools.ts"
click node_node_calendar "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/calendar-tools.ts"
click node_node_opportunities "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/opportunity-tools.ts"
click node_node_workflows "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/workflow-tools.ts"
click node_node_email "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/email-tools.ts"
click node_node_social "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/social-media-tools.ts"
click node_node_store "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/store-tools.ts"
click node_node_payments "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/payments-tools.ts"
click node_node_invoices "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/invoices-tools.ts"
click node_node_client "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/clients/ghl-api-client.ts"
click node_node_types "https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/types/ghl-types.ts"
click node_node_config "https://github.com/mastanley13/gohighlevel-mcp/blob/main/.env.example"
click node_node_docker "https://github.com/mastanley13/gohighlevel-mcp/tree/main/Dockerfile"
click node_node_vercel "https://github.com/mastanley13/gohighlevel-mcp/blob/main/vercel.json"
click node_node_tests_client "https://github.com/mastanley13/gohighlevel-mcp/blob/main/tests/clients/ghl-api-client.test.ts"
click node_node_tests_tools "https://github.com/mastanley13/gohighlevel-mcp/tree/main/tests/tools"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_server_stdio,node_node_server_http,node_node_api_entry toneBlue
class node_node_tool_surface,node_node_contacts,node_node_conversations,node_node_calendar,node_node_opportunities,node_node_workflows,node_node_email,node_node_social,node_node_store,node_node_payments,node_node_invoices toneAmber
class node_node_client,node_node_types toneMint
class node_node_config,node_node_docker,node_node_vercel,node_node_tests_client,node_node_tests_tools toneRose
```

## Components

### Runtime

MCP entrypoints and deployment adapters

- [StdIO server](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/server.ts): mcp entrypoint · Claude Desktop / stdio MCP host · `src/server.ts`
- [HTTP server](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/http-server.ts): mcp entrypoint · HTTP-based MCP host · `src/http-server.ts`
- [Serverless entry](https://github.com/mastanley13/gohighlevel-mcp/blob/main/api/index.js): deployment entrypoint · Platform entry for serverless hosting · `api/index.js`

### Tools

Domain-specific MCP tool modules

- [Tool surface](https://github.com/mastanley13/gohighlevel-mcp/tree/main/src/tools): domain modules · Directory containing the MCP tool implementations · `src/tools`
- [Contacts](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/contact-tools.ts): tool module · Contact-related MCP tools · `src/tools/contact-tools.ts`
- [Conversations](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/conversation-tools.ts): tool module · Conversation and messaging tools · `src/tools/conversation-tools.ts`
- [Calendar](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/calendar-tools.ts): tool module · Calendar and scheduling tools · `src/tools/calendar-tools.ts`
- [Opportunities](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/opportunity-tools.ts): tool module · Pipeline and deal tools · `src/tools/opportunity-tools.ts`
- [Workflows](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/workflow-tools.ts): tool module · Automation and workflow tools · `src/tools/workflow-tools.ts`
- [Email](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/email-tools.ts): tool module · Email-related MCP tools · `src/tools/email-tools.ts`
- [Social media](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/social-media-tools.ts): tool module · Social media tools · `src/tools/social-media-tools.ts`
- [Store](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/store-tools.ts): tool module · Storefront and commerce tools · `src/tools/store-tools.ts`
- [Payments](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/payments-tools.ts): tool module · Payment tools · `src/tools/payments-tools.ts`
- [Invoices](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/tools/invoices-tools.ts): tool module · Invoice tools · `src/tools/invoices-tools.ts`

### Core

Shared client and types

- [GHL client](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/clients/ghl-api-client.ts): api client · Authenticated GoHighLevel API boundary · `src/clients/ghl-api-client.ts`
- [GHL types](https://github.com/mastanley13/gohighlevel-mcp/blob/main/src/types/ghl-types.ts): shared types · Typed models for GoHighLevel payloads · `src/types/ghl-types.ts`

### Support

Config, deployment, and tests

- [Config](https://github.com/mastanley13/gohighlevel-mcp/blob/main/.env.example): runtime config · Environment and deployment configuration · `.env.example`
- [Docker](https://github.com/mastanley13/gohighlevel-mcp/tree/main/Dockerfile): container packaging · Container runtime definition · `Dockerfile`
- [Vercel config](https://github.com/mastanley13/gohighlevel-mcp/blob/main/vercel.json): serverless config · Serverless deployment settings · `vercel.json`
- [Client tests](https://github.com/mastanley13/gohighlevel-mcp/blob/main/tests/clients/ghl-api-client.test.ts): test suite · Integration-boundary tests for the GHL client · `tests/clients/ghl-api-client.test.ts`
- [Tool tests](https://github.com/mastanley13/gohighlevel-mcp/tree/main/tests/tools): test suite · Domain tool behavior tests · `tests/tools`

## Connections

- StdIO server → Tool surface: loads tools · StdIO host wires MCP tools into the runtime
- HTTP server → Tool surface: loads tools · HTTP host exposes the same tool surface
- Serverless entry → HTTP server: boots · Serverless entry delegates to the HTTP server
- Tool surface → Contacts: includes · Tool directory organizes contact tools
- Tool surface → Conversations: includes · Tool directory organizes conversation tools
- Tool surface → Calendar: includes · Tool directory organizes calendar tools
- Tool surface → Opportunities: includes · Tool directory organizes opportunity tools
- Tool surface → Workflows: includes · Tool directory organizes workflow tools
- Tool surface → Email: includes · Tool directory organizes email tools
- Tool surface → Social media: includes · Tool directory organizes social media tools
- Tool surface → Store: includes · Tool directory organizes store tools
- Tool surface → Payments: includes · Tool directory organizes payment tools
- Tool surface → Invoices: includes · Tool directory organizes invoice tools
- Contacts → GHL client: calls · Tool handlers translate requests into GHL API calls
- Conversations → GHL client: calls · Tool handlers translate requests into GHL API calls
- Calendar → GHL client: calls · Tool handlers translate requests into GHL API calls
- Opportunities → GHL client: calls · Tool handlers translate requests into GHL API calls
- Workflows → GHL client: calls · Tool handlers translate requests into GHL API calls
- Email → GHL client: calls · Tool handlers translate requests into GHL API calls
- Social media → GHL client: calls · Tool handlers translate requests into GHL API calls
- Store → GHL client: calls · Tool handlers translate requests into GHL API calls
- Payments → GHL client: calls · Tool handlers translate requests into GHL API calls
- Invoices → GHL client: calls · Tool handlers translate requests into GHL API calls
- GHL client → GHL types: uses · Shared models shape requests and responses
- Client tests → GHL client: verifies · Tests validate API client behavior
- Tool tests → Tool surface: verifies · Tests validate tool-layer behavior
- Docker → StdIO server: packages · Container runtime can host the Node process
- Vercel config → Serverless entry: deploys · Serverless config targets the API entrypoint
- Config → GHL client: configures · Environment variables feed auth and base URL settings
