Clamp docs

Analytics your coding agent can read, query, and act on. Install the SDK to collect data, connect the MCP server to ask questions.

Quickstart

1. Install the SDK

terminal
npm install @clamp-sh/analytics

Add it to your root layout:

app/layout.tsx
import { Analytics } from "@clamp-sh/analytics/react"

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        {children}
        <Analytics projectId="proj_xxx" />
      </body>
    </html>
  )
}

Pageviews are tracked automatically, including SPA navigations. No cookies, no consent banner.

2. Connect the MCP server

Add Clamp to your AI assistant so it can query your analytics. Pick your client:

VS Code — .vscode/mcp.json
{
  "servers": {
    "clamp": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@clamp-sh/mcp"],
      "env": {
        "CLAMP_API_KEY": "sk_proj..."
      }
    }
  }
}
Claude Code
claude mcp add clamp -- npx -y @clamp-sh/mcp
export CLAMP_API_KEY="sk_proj..."

See MCP docs for Claude Desktop, Cursor, and other clients.

3. Ask

Once connected, your AI assistant can query your analytics directly.

"How's my traffic this week?"
"What's the bounce rate on /pricing?"
"Break down signups by plan"
"Why did traffic drop last week?"

What to read next