Skip to content

MCP Server

The graph8 MCP server connects AI coding agents (Claude Code, Cursor, Windsurf, Claude Desktop) to your graph8 workspace. It exposes tools for contact search, campaign management, tracking snippet installation, and progressive form generation — all from within your IDE.

Setup

There are two ways to connect: Remote (recommended) and Local. Remote uses OAuth — no API key or installation required. Local runs the server on your machine via stdio.

Paste this config into your AI client. Your client will prompt you to sign in via OAuth when you first connect — no API key needed.

Add to ~/.claude/mcp.json:

{
"mcpServers": {
"graph8": {
"url": "https://be.graph8.com/mcp/"
}
}
}

Local (stdio)

If you prefer running the server locally (or your client doesn’t support remote MCP), use the stdio transport. This requires Python 3.10+ and an org API key.

Replace <your-api-key> with a key from Settings -> API (Authentication).

For developers in Cursor, Windsurf, or Claude Code:

{
"mcpServers": {
"graph8": {
"command": "uvx",
"args": ["g8-mcp-server"],
"env": {
"G8_API_KEY": "<your-api-key>",
"G8_MCP_MODE": "dev"
}
}
}
}

uvx runs the server directly from PyPI without installing it. If you’d rather install permanently, use pip install g8-mcp-server — but that’s primarily for the CLI.

Environment Variables (local only)

VariableRequiredDefaultDescription
G8_API_KEYYesYour org API key (create one)
G8_MCP_MODENoallTool set to load: dev, gtm, or all
G8_API_URLNohttps://be.graph8.comAPI base URL (for self-hosted or staging)

Modes

The G8_MCP_MODE variable controls which tools are loaded. This applies to local (stdio) connections only — remote connections load all tools.

Developer Mode (dev)

For developers building products in Cursor, Windsurf, or Claude Code. Provides repo-scoped tools for scanning codebases, installing tracking, generating forms, and managing campaigns.

Set: G8_MCP_MODE=dev

GTM Mode (gtm)

For campaign managers and marketing ops in Claude Desktop. Provides org-scoped tools for creating campaigns, browsing knowledge base content, and launching outreach — no repo context needed.

Set: G8_MCP_MODE=gtm

All Mode (default)

Loads all legacy tools for backward compatibility. If you don’t set G8_MCP_MODE, this is the default.

Set: G8_MCP_MODE=all (or omit the variable)

Available Tools

Platform Tools (all modes)

Available in every mode — core contact and company operations.

ToolDescription
g8_search_contactsSearch contacts by email or list membership
g8_search_companiesSearch companies by name, domain, or industry
g8_lookup_personEnrich a person by email — returns full profile
g8_lookup_companyEnrich a company by domain — returns firmographics
g8_add_to_sequenceAdd a contact to an outreach sequence

Developer Tools (dev mode)

Repo-scoped tools for building graph8 into your codebase.

ToolDescription
g8_connect_repoConnect a GitHub/GitLab repo to graph8
g8_scan_repoTrigger a codebase scan for GTM integration points
g8_get_scan_resultsGet scan results (frameworks, pages, components)
g8_statusCheck repo integration status
g8_doctorDiagnose integration health issues
g8_install_spineGenerate tracking installation plan
g8_apply_installApply the tracking installation
g8_list_campaignsList campaigns for a repo
g8_get_campaignGet campaign details
g8_search_kbSearch knowledge base articles
g8_list_kb_documentsList all KB documents

Tracking & Forms (dev mode)

Install graph8’s JavaScript tracking and generate progressive forms.

ToolDescription
g8_get_tracking_snippetGet framework-specific tracking snippet (p.js). Supports: HTML, React, Next.js, Vue, WordPress, Webflow, Shopify
g8_get_form_templateGet progressive form template (embedded or popup). Supports the same frameworks as the tracking snippet

Tracking Snippet — Server-Side vs Client-Side

The graph8 tracking snippet (p.js) works differently depending on whether your framework renders on the server or the client. Understanding this is critical for correct installation.

Server-Side Rendered (SSR)

Frameworks: Next.js, WordPress, Shopify, Webflow, HTML

The snippet is included in the server-rendered HTML layout (e.g., app/layout.tsx, theme.liquid, functions.php). It loads on every page from the first paint — no hydration delay.

// SSR — snippet is always available, call directly
g8.identify("user-123", { email: "user@example.com" });
g8.track("page_view", { page: "/pricing" });

Client-Side Rendered (CSR)

Frameworks: React, Vue

The snippet is injected via useEffect (React) or onMounted (Vue) after hydration. The script may not be ready immediately — use optional chaining to safely call tracking methods.

// CSR — use optional chaining since g8 loads after hydration
window.g8?.identify("user-123", { email: "user@example.com" });
window.g8?.track("button_click", { button: "signup" });

Privacy Options

Add these data-attributes to the script tag to control privacy behavior:

AttributeValuesDescription
data-privacy-dont-send"true"Disables cookies and event sending
data-privacy-user-ids"true"Disables storing user identifiers
data-privacy-ip-policy"keep", "stripLastOctet", "remove"Controls IP address handling
data-init-only"true"Initializes the script without sending a page event

Verification

After installing the snippet, verify it’s working:

  1. Open browser DevTools -> Network tab
  2. Look for requests to your tracking host (/p.js)
  3. In Console: window.g8 should be defined
  4. Call g8.track('test_event') — you should see a network request

Campaign Management (gtm mode)

Org-scoped tools for campaign managers — no repo context required.

ToolDescription
g8_list_campaignsList all campaigns in the org
g8_get_campaignGet campaign details and status
g8_get_campaign_documentGet a campaign document (emails, landing pages)
g8_create_campaignCreate a new campaign with audience, channels, and content
g8_update_campaignUpdate campaign settings
g8_launch_campaignLaunch a campaign (or dry run)
g8_search_kbSearch knowledge base
g8_list_kb_documentsList KB documents

Resources

MCP resources provide read-only context that agents can include in prompts.

Resource URIDescription
g8://reposList of connected repositories
g8://repos/{repo_id}/scanScan results for a repo
g8://repos/{repo_id}/kbKnowledge base documents for a repo
g8://repos/{repo_id}/kb/{doc_id}Single KB document content
g8://repos/{repo_id}/campaignsCampaigns for a repo
g8://repos/{repo_id}/campaigns/{campaign_id}/briefCampaign brief
g8://contactsContact list summary
g8://companiesCompany list summary

Prompt Templates

Pre-built prompts for common GTM workflows.

PromptArgumentsDescription
gtm_setuprepo_urlFull setup workflow: connect, scan, install, launch
campaign_reviewcampaign_idReview and optimize a campaign
icp_refinementfeedbackRefine ideal customer profile based on feedback

Getting Started

A typical developer workflow with the MCP server:

  1. Configure — Add the remote config to your AI client (no install needed)
  2. Connect — Ask your agent to connect your repo: “Connect my repo github.com/org/app”
  3. Scan — The agent scans your codebase for frameworks and integration points
  4. Install snippet“Install the graph8 tracking snippet for Next.js”
  5. Configure tracking — Add g8.identify() on login and g8.track() on key actions
  6. Add forms“Generate an embedded progressive form for React”
  7. Launch campaigns“Create a campaign targeting trial users”