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 setupThis 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.
Recommended Workflow
The get_started tool returns the full guided workflow, but here's the overview:
| Step | Tool | What it does |
|---|---|---|
| 1 | create_site | Register the domain, auto-create banner + default categories |
| 2 | scan_site | Detect tracking scripts and cookies on the live site |
| 3 | configure_from_scan | Auto-import detected services into consent categories |
| 4 | update_banner_config | Customize banner template, colors, text, position |
| 5 | get_setup_snippet | Generate 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 sitescreate_site— Create a site with name and domainupdate_site— Rename a sitedelete_site— Delete a site and all its data
Scanner
scan_site— Scan a website for tracking scripts and cookieslist_scans— View scan historyget_scan— Get detailed scan resultsconfigure_from_scan— Auto-import detected services
Cookie Library
search_library— Browse known services (Google Analytics, Meta Pixel, Hotjar, etc.)get_library_service— Get full details about a library serviceimport_service— Import a service into a site
Services
list_site_services— List all services with their cookiesadd_custom_service— Add a custom tracking serviceremove_service— Remove a service
Banner
get_banner_config— Get current banner configurationupdate_banner_config— Update template, position, colors, text
Categories
list_categories— List consent categories (essential, statistics, marketing)create_category— Create a new categorydelete_category— Delete a custom category
Setup
get_started— Get the recommended workflow and see existing sitesget_setup_snippet— Generate the install code for any framework
Important Notes
- The
<script>tag must be placed in<head>withoutdeferorasync— 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.