# Build a dashboard with Claude Code and the developer API

> Explore your data in Claude Code through your MCP server, then have it build a small dashboard that reads live numbers from the developer API.

This guide goes from an idea ("a page with this month's sessions, ad spend and open tickets") to a working dashboard. You use Claude Code twice: first through your Plugsight MCP server, to explore what data you have; then as a coding assistant, to write a small server that calls Plugsight's developer API and shows the numbers.

You need to be comfortable running commands in a terminal. If you only want answers in a chat, you don't need any of this.

## What you need

- A **Pro** or **Agency** plan. The developer API isn't on Free.
- The accounts the dashboard should show, connected on **Connections**.
- [Claude Code](https://docs.plugsight.app/ai-apps/claude-code.md) installed (the `claude` command).
- Somewhere to run server-side code, such as your own server or a serverless platform. The API key must never reach a web browser.

## Step 1: create an MCP server for the dashboard

Give the dashboard its own server, so its key reaches only what it needs.

1. Open **MCP servers** and click **Create MCP server**.
2. **Name**: where it will be used, for example "Company dashboard".
3. **Account access**: **Selected accounts**, ticking only the accounts the dashboard shows.
4. Untick **Allow changes**. A dashboard only reads, and this way its key can't send or change anything, even by mistake.
5. Click **Create server**.

## Step 2: explore the data in Claude Code

Connect Claude Code to the new server with a browser sign-in, which needs no key:

1. Run, with your server's name and **Server URL**:

   ```
   claude mcp add --transport http company-dashboard https://app.plugsight.app/mcp/YOUR_SERVER_ID
   ```

2. Start `claude`, type `/mcp`, choose the server, then **Authenticate**, and click **Allow access** in the browser.

Now ask Claude Code what's there, the same way you'd ask in a chat:

- "List my marketing accounts and their ids."
- "Which fields can I get from GA4? I want sessions, users and key events by day."
- "Show me last month's Google Ads cost and conversions by campaign."
- "Give me today's Zendesk ticket counts."

Note the tool names, arguments and account ids Claude Code uses. Those are the same calls your dashboard will make.

## Step 3: create the API key

1. Open the server's page in Plugsight.
2. Under **API key**, click **Create API key**.
3. Copy the key straight away. It's shown only once.
4. Store it as an environment variable where the dashboard will run, never in your code:

   ```bash
   export PLUGSIGHT_API_KEY="mcpk_…"
   ```

Check it works:

```bash
curl https://app.plugsight.app/v1/tools \
  -H "Authorization: Bearer $PLUGSIGHT_API_KEY"
```

## Step 4: have Claude Code build the dashboard

In your project folder, ask Claude Code to write it, describing the calls you found in Step 2. For example:

> Build a small Node.js server for a dashboard. It reads the key from the PLUGSIGHT_API_KEY environment variable and calls the Plugsight developer API (POST https://app.plugsight.app/v1/tools/{tool}, JSON body, Bearer key, result under "data"). Make a route /api/stats that calls get_marketing_data for GA4 sessions and users by day for the last 30 days, get_marketing_data for Google Ads cost and conversions by campaign for this month, and zendesk_ticket_stats for this month. Cache the combined result for 10 minutes. Serve one HTML page that fetches /api/stats and shows three tables. Never send the key to the page.

Point Claude Code at [Calling tools](https://docs.plugsight.app/developers/calling-tools.md), which has request and answer examples, and the tool reference for the tools you use, such as [Marketing and analytics tools](https://docs.plugsight.app/developers/marketing-tools.md) and [Zendesk tools](https://docs.plugsight.app/developers/zendesk-tools.md).

Check what it writes against these rules:

- **The key stays on the server.** The web page calls your own route; your server calls Plugsight. The API sends no CORS headers, so a browser can't call it directly anyway.
- **Results are cached.** Each API call reads live from the provider. Up to 120 requests a minute per MCP server are allowed, and providers have their own limits. A few minutes of caching keeps you well clear.
- **Errors are handled.** A failed call returns `{ "error", "message", "docs" }`. Show "data unavailable" for that panel rather than breaking the page. See [Errors](https://docs.plugsight.app/developers/errors.md).

## Step 5: run it and check

1. Run the server and open the page.
2. Compare one or two numbers with the same question asked in a chat, or in Google Ads or GA4 for the same dates.
3. In Plugsight, open **Activity**: each call shows with "Developer API" under **Who**.

## Keep it running

- **Dates**: presets such as `last_30d` and `this_month` are worked out in UTC. See [Get accurate numbers from marketing data](https://docs.plugsight.app/guides/accurate-marketing-numbers.md).
- **If the key leaks**: on the server's page, click **Regenerate key**, then **Replace key**, and update the environment variable. The old key stops working at once.
- **If your plan changes to Free**, every request is refused with `403 plan_required`.
- **New accounts**: with **Selected accounts**, tick new connections on the server before the dashboard can use them.

## Related articles

- [Developer API](https://docs.plugsight.app/developers.md)
- [Authentication](https://docs.plugsight.app/developers/authentication.md)
- [Keep app passwords and API keys safe](https://docs.plugsight.app/guides/keep-credentials-safe.md)

---

Web version: https://docs.plugsight.app/guides/developer-dashboard
