HighLevel MCP OpenAI
No description available
Ask AI about HighLevel MCP OpenAI
Powered by Claude ยท Grounded in docs
I know everything about HighLevel MCP OpenAI. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
GoHighLevel MCP Integration with OpenAI Agents
This example demonstrates how to integrate a GoHighLevel MCP server with the OpenAI Agents framework for intelligent business automation.
๐ Setup Required: You'll need to configure the examples with your GoHighLevel MCP server path and credentials (see setup instructions below).
๐ฏ Prerequisites
- GoHighLevel MCP Server: A compatible GHL MCP server with stdio support (example implementation)
- GHL API Credentials: Valid GoHighLevel API key and location ID from your GHL account
- Node.js Environment: Node.js 18+ with TypeScript support
๐ Project Structure
examples/ghl-integration/
โโโ server.ts # Main chat server with frontend UI
โโโ server/
โ โโโ basic-example.ts # Simple GHL agent example
โ โโโ specialized-agents-example.ts # Multi-agent business workflow
โ โโโ chat-example.ts # Chat interface example
โโโ client/ # Frontend React application
โโโ package.json # Dependencies and scripts
โโโ SETUP.md # Detailed setup instructions
โโโ README.md # This file
๐ Quick Start
1. Environment Setup
Create a .env file in this directory with your GHL credentials:
# Create .env file with your actual credentials
GHL_API_KEY=your_actual_ghl_api_key_here
GHL_LOCATION_ID=your_actual_ghl_location_id_here
GHL_BASE_URL=https://services.leadconnectorhq.com
2. Install Dependencies
# From the repository root
pnpm install
# Or just for this example
pnpm install --filter ghl-integration
3. Configure MCP Server Path
Update the server path in the example files to point to your GHL MCP server:
// Update this path to your actual GHL MCP server location
fullCommand: 'node /path/to/your/ghl-mcp-server/dist/server.js'
4. Run Examples
# Start the main chat server with UI
npm run dev
# Or run individual examples:
# Basic example - Simple GHL operations
npx tsx server/basic-example.ts
# Specialized agents - Multi-agent workflows
npx tsx server/specialized-agents-example.ts
# Chat interface example
npx tsx server/chat-example.ts
๐ Examples Overview
Basic Example (server/basic-example.ts)
Demonstrates fundamental MCP integration patterns:
- โ Connecting to a GHL MCP server
- โ Listing available tools from the server
- โ Creating simple agents with GHL access
- โ Performing basic CRM operations
- โ Error handling and cleanup
Perfect for: Understanding the core integration mechanics
Specialized Agents Example (server/specialized-agents-example.ts)
Demonstrates advanced multi-agent patterns:
- ๐ข CRM Agent: Contact and relationship management
- ๐ฐ Sales Agent: Opportunities and pipeline operations
- ๐ง Marketing Agent: Campaigns and automation workflows
- ๐ง Customer Service Agent: Support and retention activities
- ๐ญ Workflow Orchestrator: Coordinates complex multi-department workflows
Perfect for: Building sophisticated business automation systems
Chat Server Example (server.ts)
Complete chat interface with real-time frontend:
- ๐ฎ Interactive UI: React-based chat interface
- ๐ Real-time Communication: WebSocket integration
- ๐ค AI Assistant: Full-featured GoHighLevel assistant
- ๐ Tool Execution: Visual feedback for GHL operations
- ๐ฏ Production Ready: Complete server implementation
Perfect for: Building user-facing GHL automation tools
๐ง Key Integration Points
1. MCP Server Configuration
const ghlMcpServer = new MCPServerStdio({
name: 'GoHighLevel MCP Server',
fullCommand: 'node /path/to/your/ghl-mcp-server/dist/server.js',
env: {
GHL_API_KEY: process.env.GHL_API_KEY!,
GHL_BASE_URL: process.env.GHL_BASE_URL || 'https://services.leadconnectorhq.com',
GHL_LOCATION_ID: process.env.GHL_LOCATION_ID!,
},
cacheToolsList: true,
clientSessionTimeoutSeconds: 10,
});
2. Agent Creation with MCP Access
const agent = new Agent({
name: 'GHL Assistant',
instructions: 'Your specialized instructions...',
mcpServers: [ghlMcpServer], // This provides tool access
});
3. Multi-Agent Handoffs
const orchestrator = new Agent({
name: 'Workflow Orchestrator',
instructions: 'Coordinate complex operations...',
handoffs: [crmAgent, salesAgent, marketingAgent], // Agent delegation
});
๐๏ธ Configuration Options
MCPServerStdio Options
| Option | Type | Description |
|---|---|---|
name | string | Descriptive name for your MCP server |
fullCommand | string | Complete command to start your server |
command + args | string + array | Alternative: separate command and arguments |
env | object | Environment variables for your server |
cacheToolsList | boolean | Cache tools for better performance (default: true) |
clientSessionTimeoutSeconds | number | Connection timeout (default: 5) |
cwd | string | Working directory for server execution |
Environment Variables
# Required GHL Credentials
GHL_API_KEY=your_ghl_api_key_here
GHL_LOCATION_ID=your_ghl_location_id_here
# Optional Configuration
GHL_BASE_URL=https://services.leadconnectorhq.com
NODE_ENV=development
๐ Connection Lifecycle
// 1. Create MCP server instance
const mcpServer = new MCPServerStdio({ /* config */ });
// 2. Connect to server (starts child process)
await mcpServer.connect();
// 3. Use in agents
const agent = new Agent({ mcpServers: [mcpServer] });
// 4. Always cleanup when done
await mcpServer.close();
๐ ๏ธ Troubleshooting
Connection Issues
Error: Command failed: node /path/to/server.js
Solutions:
- โ Verify the path to your GHL MCP server is correct
- โ
Ensure your server script is executable:
chmod +x server.js(Unix/Linux) - โ
Test your server independently:
node /path/to/your/server.js - โ Check that your GHL MCP server supports stdio communication
Authentication Issues
Error: GHL_API_KEY is required
Solutions:
- โ
Check your
.envfile exists and contains valid credentials - โ Verify API key has proper permissions in GoHighLevel
- โ Confirm location ID is correct for your GHL account
Tool Discovery Issues
Found 0 tools from GHL MCP server
Solutions:
- โ
Verify your MCP server implements the
tools/listmethod - โ Check server logs for any startup errors
- โ Ensure your server properly exports tools in MCP format
- โ Test the MCP server directly before integration
Runtime Issues
Error: Server not initialized. Make sure you call connect() first.
Solutions:
- โ
Always call
await mcpServer.connect()before using - โ Handle connection errors with try/catch blocks
- โ
Implement proper cleanup with
await mcpServer.close()
๐๏ธ Architecture Notes
Why This Approach Works
- ๐ Loose Coupling: Your MCP server remains independent and focused
- ๐ Scalability: Each component can scale independently
- ๐ Flexibility: Easy to update either side without affecting the other
- ๐ฏ Specialization: Agents focus on business logic, MCP server handles API integration
Process Communication
โโโโโโโโโโโโโโโโโโโ stdio โโโโโโโโโโโโโโโโโโโโ HTTP/API โโโโโโโโโโโโโโโ
โ OpenAI Agent โโโโโโโโโโโโโโโบโ GHL MCP Server โโโโโโโโโโโโโโโโโบโ GHL APIs โ
โ (Business โ JSON-RPC โ (Integration โ REST/GraphQL โ (CRM Data) โ
โ Logic) โ โ Layer) โ โ โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
The OpenAI Agents framework spawns the GHL MCP server as a child process and communicates via JSON-RPC over stdio. The MCP server handles all the GoHighLevel API complexity, while the agents focus on intelligent business workflows.
๐ Next Steps
- Setup: Configure your GHL MCP server path and credentials
- Start Simple: Run the basic example to verify integration
- Try the UI: Launch the chat server for interactive testing
- Customize Agents: Modify instructions for your specific business needs
- Add Tools: Extend your MCP server with additional GHL capabilities
- Scale Up: Use the specialized agents pattern for complex workflows
- Deploy: Consider containerization for production deployments
๐ Additional Resources
๐ You now have a complete framework for building intelligent GoHighLevel automation with OpenAI models!
