ConsentLayer
Guides

AI Agent Integration

ConsentLayer provides an MCP (Model Context Protocol) server that lets AI coding agents set up cookie consent end-to-end — create sites, scan for trackers, configure consent, and generate install code — without touching the dashboard.

Setup

Claude Code

Run this in your terminal:

npx @consentlayer/mcp setup

This auto-configures Claude Code to connect to the ConsentLayer MCP server.

Alternatively, run manually:

claude mcp add consentlayer --transport http "https://api.consentlayer.com/mcp"

Cursor / Windsurf / Other MCP Clients

Add to your MCP configuration file:

{
  "mcpServers": {
    "consentlayer": {
      "url": "https://api.consentlayer.com/mcp"
    }
  }
}

Authentication

ConsentLayer uses browser-based OAuth — no API keys needed. On the first tool call, your browser opens for login (or signup). Tokens are cached locally for future sessions.

Usage

Once connected, tell your agent what you need:

"Set up cookie consent on my website example.com"

The agent will use the MCP tools to handle everything automatically.

The get_started tool returns the full guided workflow, but here's the overview:

StepToolWhat it does
1create_siteRegister the domain, auto-create banner + default categories
2scan_siteDetect tracking scripts and cookies on the live site
3configure_from_scanAuto-import detected services into consent categories
4update_banner_configCustomize banner template, colors, text, position
5get_setup_snippetGenerate the real <script> tag to add to the site

Example Prompts

Full setup:

"Add GDPR cookie consent to my site example.com. Scan it for trackers and give me the install code."

Customize banner:

"Change my consent banner to a floating style in the bottom-right corner with blue buttons."

Add a service:

"Add Google Analytics to my site's statistics category."

Check status:

"Show me what tracking services are configured on my site."

Available Tools

Site Management

  • list_sites — List all your sites
  • create_site — Create a site with name and domain
  • update_site — Rename a site
  • delete_site — Delete a site and all its data

Scanner

  • scan_site — Scan a website for tracking scripts and cookies
  • list_scans — View scan history
  • get_scan — Get detailed scan results
  • configure_from_scan — Auto-import detected services
  • search_library — Browse known services (Google Analytics, Meta Pixel, Hotjar, etc.)
  • get_library_service — Get full details about a library service
  • import_service — Import a service into a site

Services

  • list_site_services — List all services with their cookies
  • add_custom_service — Add a custom tracking service
  • remove_service — Remove a service
  • get_banner_config — Get current banner configuration
  • update_banner_config — Update template, position, colors, text

Categories

  • list_categories — List consent categories (essential, statistics, marketing)
  • create_category — Create a new category
  • delete_category — Delete a custom category

Setup

  • get_started — Get the recommended workflow and see existing sites
  • get_setup_snippet — Generate the install code for any framework

Important Notes

  • The <script> tag must be placed in <head> without defer or async — it needs to run synchronously to block tracking scripts before they execute.
  • The banner is served as a static JS file per site, regenerated on every config change. No server-side rendering per page view.
  • Default consent categories (essential, statistics, marketing) are created automatically and cannot be deleted.
  • Script blocking uses DOM mutation observers to intercept dynamically-created scripts.