Use maxclicks in Lovable
Connect the app you build in Lovable to customer records, events, and prepared emails in maxclicks. Use backend code for API calls, or an MCP connection for an assistant that needs to work with your workspace.
Create a key at https://app.maxclicks.ai/space/-/settings/developers. A key is scoped to one space. Some operations require an admin key.
The npm maxclicks entry is a placeholder. The name currently resolves to a
placeholder that exports no client, so npm install maxclicks will not give
you a working SDK. The code below shows how the client is used. Until the
release lands, call the Public API over HTTP, or use the MCP server
described later on this page.
The existing SDK, CLI, and MCP tools cover an earlier API surface. Use the current REST contract for event readiness/identities, deletion polling, workflow history, and new idempotent operations; see client coverage.
Make a first request over HTTP
This request runs in server-side JavaScript and needs no maxclicks package. Set MAXCLICKS_API_KEY in your server's secret store, then confirm the returned space before making a write.
const apiKey = process.env.MAXCLICKS_API_KEY
if (!apiKey) throw new Error('Set MAXCLICKS_API_KEY first')
const response = await fetch('https://api.maxclicks.ai/v1/me', {
headers: { Authorization: `Bearer ${apiKey}` },
})
const result = await response.json()
if (!response.ok) throw new Error(result.error?.message ?? 'Request failed')
console.log(result.data.space)
For a runtime without process.env, use its server-side secret API. Keep the key out of browser bundles. Follow the API quickstart to sync a contact and send a prepared template.
The SDK examples below assume you have built the Node client from source. Its npm entry is currently a placeholder.
SDK: call maxclicks from the app
Use the SDK for code that runs in the app Lovable builds: upsert contacts, fire events, send templates.
Install the package
In Lovable, open the chat and ask it to install the SDK, or run the command in the Lovable terminal.
# Build and install the source SDK described at /sdks/node.Requires Node.js 18 or newer. Ships ESM and CommonJS builds.
Store the API key
Add
MAXCLICKS_API_KEYin Lovable's environment variables. Never hardcode the key in client code. Call maxclicks from a server route or edge function so the key stays server-side.Call the API
import { Maxclicks } from 'maxclicks' const mc = new Maxclicks() // reads MAXCLICKS_API_KEY // Upsert a contact by identity (id or slug of the contact schema) const contact = await mc.records.upsert('students', { email: '[email protected]', firstName: 'Ada', tags: ['signup'], }) // Fire an event, which can trigger a workflow or a webhook await mc.events.fire('purchase-completed', { eventId: 'ord_123', amount: 42 }) // Send a template, resolving the recipient by email await mc.templates.send(templateId, { data: { contact: { email: '[email protected]' } }, })
On failure a call throws a typed error, one of the MaxclicksError subclasses (MaxclicksNotFoundError, MaxclicksConflictError, MaxclicksRateLimitError, and others). The source SDK retries 429 within its budget; 5xx and transport errors are retried for reads and keyed writes. Preserve the key and payload, and reconcile uncertain outcomes. See the SDK reference for the full method list.
Keep the API key on the server. A key in browser code is exposed to every visitor. Route SDK calls through a Lovable backend route or Supabase edge function.
MCP: give Lovable's agent write access
The MCP server turns maxclicks into tools an MCP client can call. Point Lovable's agent at it and the agent can manage contacts and objects, fire events, send templates, manage webhooks, and trigger workflows while it builds.
Hosted (remote)
Streamable HTTP endpoint:
https://mcp.maxclicks.ai/mcp
Authenticate with your API key as a bearer token:
Authorization: Bearer max_...
Local (stdio)
Run the server over stdio and pass the key in the environment:
maxclicks-mcp is not published to npm, so npx -y maxclicks-mcp does not
resolve and this config does not start a server today. Use the hosted endpoint
above.
{
"mcpServers": {
"maxclicks": {
"command": "npx",
"args": ["-y", "maxclicks-mcp"],
"env": { "MAXCLICKS_API_KEY": "max_..." }
}
}
}
Tools
The agent can read your schemas and attributes but not create them. Call list_schemas and list_attributes to learn how your data is shaped, then write.
| Area | Tools |
|---|---|
| Meta | whoami |
| Schemas and attributes (read) | list_schemas, get_schema, list_attributes |
| Records | list_records, get_record, create_record, upsert_record, update_record, delete_record, get_contact_audit_trail |
| Events | fire_event, fire_events_batch, list_events |
send_template | |
| Suppressions (admin key) | create_suppression, delete_suppression |
| Webhooks | list_webhooks, get_webhook, create_webhook, update_webhook, delete_webhook, rotate_webhook_secret |
| Workflows | trigger_workflow |