You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6527e6f
Browse filesBrowse the repository at this point in the historyBrowse files
The agent prompt keeps the key out of committed files and replies, asks for an existing key instead of a new one, names the self-hosted ingestion URL, covers AWS Lambda with flushMcp and uses the Inspector CLI. Non-admins see who can create a key instead of a button that always fails, self-hosted snippets pass apiUrl, the privacy line names successful results, progress and the last step follow the copy, and collapsed setup rows are inert. The agent buttons and highlighted snippet block are shared with onboarding's ConnectApp.
return`Add Databuddy MCP analytics to the MCP server in this repository, so every tool call shows up on the Databuddy MCP Analytics page: which tools AI clients call, how fast they answer, and why they fail. Tool arguments and successful results never leave the server; only the length of the returned text and the error message of failed calls are sent.
289
-
288
+
${isSelfHosted ? `\nThis is a self-hosted Databuddy instance: pass \`apiUrl: ${apiUrl}\` in the options of every \`trackMcp\` call.\n` : ""}
- \`@modelcontextprotocol/server\` 2.x builds a server per request, so call \`trackMcp\` inside the \`createMcpHandler\` or \`serveStdio\` factory.
308
307
- Vercel \`mcp-handler\`: call \`trackMcp(server)\` inside the callback it passes the server to, and set \`serverInfo: { name, version }\`.
309
-
4. Read the API key from \`DATABUDDY_API_KEY\`. Never hardcode or commit it. ${apiKey ? `The key is \`${apiKey}\`: put it in the server's local env file (make sure that file is gitignored) and tell me to add it to the hosting provider's secrets.` : `Ask me to create a keywith the Event Tracking scope at ${dashboardUrl}/organizations/settings#api-keys.`} Add \`DATABUDDY_API_KEY=\` without a value to \`.env.example\` if the repository has one.
310
-
5. Serverless (Vercel, Cloudflare Workers, Netlify, AWS Lambda): a function can stop before the batch is sent, so pass the platform's \`waitUntil\`: \`trackMcp(server, { waitUntil })\`. On Vercel import it from \`@vercel/functions\`; on Cloudflare Workers import \`env\` and \`waitUntil\` from \`cloudflare:workers\` and pass \`apiKey: env.DATABUDDY_API_KEY\`.
308
+
4. Read the API key from \`DATABUDDY_API_KEY\`. ${apiKey ? `The key is \`${apiKey}\`: put it in the server's local env file (make sure that file is gitignored) and tell me to add it to the hosting provider's secrets.` : `Ask me for my key; if I don't have one, I can create one with the Event Tracking scope at ${dashboardUrl}/organizations/settings#api-keys.`} Never commit the key: use the placeholder \`dbdy_your_key\` in every committed file, including MCP client configs, README and docs, and never repeat the key in replies, commit messages or PR text. Add \`DATABUDDY_API_KEY=\` without a value to \`.env.example\` if the repository has one.
309
+
5. Serverless: a function can stop before the batch is sent, so pass the platform's \`waitUntil\`: \`trackMcp(server, { waitUntil })\`. On Vercel import it from \`@vercel/functions\`; on Cloudflare Workers import \`env\` and \`waitUntil\` from \`cloudflare:workers\` and pass \`apiKey: env.DATABUDDY_API_KEY\`; on Netlify use \`context.waitUntil\`. AWS Lambda has no \`waitUntil\`, so \`await flushMcp()\` (from \`@databuddy/sdk/mcp\`) before the handler returns.
311
310
6. stdio servers started by a desktop client (Claude Desktop, Cursor, VS Code) only receive the variables in the client config, so \`DATABUDDY_API_KEY\` belongs in the server's \`env\` block there. Update any client config examples in the README accordingly.
312
311
7. If the server ends itself with \`process.exit\`, for example in a SIGINT or SIGTERM handler, call \`await flushMcp()\` (from \`@databuddy/sdk/mcp\`) first.
313
312
8. Only if the server has no error convention yet: return failed tool calls as \`isError\` results whose text is JSON with a stable, low-cardinality snake_case code, for example \`{"error":{"code":"not_found","message":"Website not found"}}\`. The MCP Analytics page groups failures by that code. Do not rewrite existing error handling.
314
313
315
314
## Verification
316
315
317
-
1. Run the server with \`DATABUDDY_API_KEY\` set and call any tool once, for example with \`npx @modelcontextprotocol/inspector\`.
316
+
1. Run the server with \`DATABUDDY_API_KEY\` set and call any tool once with the MCP Inspector CLI: \`npx @modelcontextprotocol/inspector --cli <command that starts the server> --method tools/call --tool-name <tool>\`, or \`npx @modelcontextprotocol/inspector --cli <server URL> --transport http --method tools/call --tool-name <tool>\` for an HTTP server.
318
317
2. Temporarily pass \`debug: true\` to \`trackMcp\` to log a missing key or a rejected batch to stderr, then remove it.
319
318
3. The Databuddy MCP Analytics page checks for the first call every few seconds and switches to the analytics view on its own.
0 commit comments