# Build with AI

Set up Claude Code, Cursor, VS Code and other AI coding tools to build Bunny integrations: the docs MCP server, markdown and llms.txt context files, and an AGENTS.md snippet with the rules agents need.

AI coding tools write better Bunny integrations when they read the docs instead of guessing. Three things help: connect the docs MCP server, point your tool at the right context files, and add a short set of Bunny rules to your repo.

This page is about writing code against Bunny. To have an assistant work with your live Bunny data, such as answering MRR questions, composing quotes or updating accounts, connect the [Bunny MCP server](https://docs.bunny.com/guide/tour/revops-agent/mcp-server) instead.

## Connect the docs MCP server

The docs MCP server at `https://docs.bunny.com/mcp` gives your tool two tools:

- `search_docs` searches the guide and developer docs.
- `get_api_reference` returns the exact arguments, types and an example request for any GraphQL query, mutation or type.

It uses Streamable HTTP and needs no authentication. It only reads the public documentation, never your Bunny data.

**Claude Code**

```bash
claude mcp add --transport http bunny-docs https://docs.bunny.com/mcp
```

**Cursor**

Add this to `.cursor/mcp.json` in your project, or to `~/.cursor/mcp.json` for every project:

```json
{
  "mcpServers": {
    "bunny-docs": {
      "url": "https://docs.bunny.com/mcp"
    }
  }
}
```

**VS Code**

Add this to `.vscode/mcp.json` in your project:

```json
{
  "servers": {
    "bunny-docs": {
      "type": "http",
      "url": "https://docs.bunny.com/mcp"
    }
  }
}
```

**Other clients**

Any client that supports remote MCP servers over Streamable HTTP works. Add `https://docs.bunny.com/mcp` as the server URL, with no authentication.

## Give your tool the right context

If your tool can’t use MCP, or you want to load the docs up front, use these files. They’re plain text and rebuilt from the docs on every deploy, so they’re always current.

| File | What’s in it | Use it to |
| /llms-developer.txt | Every developer page as text, plus one line for every GraphQL query and mutation with its scope | Start an integration. This is the one to load. |
| /llms.txt | Every page with a one-line description | Find the page for a topic |
| Any page URL + .md | That page as markdown, with its links, for example /developer/api-reference/mutations/subscriptioncreate.md | Read one page or one operation’s full definition |
| api-reference.json | Every operation and type as JSON: arguments, return types and example requests | Generate typed clients or check queries in code |
| /llms-guide.txt and /llms-full.txt | The guide to using Bunny, and every page in one file | Questions about how Bunny works for your team, not code |

## Add Bunny rules to your repo

Agents tend to make the same few mistakes with a billing API. Paste this into your repo’s `AGENTS.md`, `CLAUDE.md` or Cursor rules, so your tool follows them without being told each time.

```markdown
## Bunny billing integration

Docs: https://docs.bunny.com/llms-developer.txt. Look up exact arguments with the
bunny-docs MCP server (get_api_reference) or the operation's page under
https://docs.bunny.com/developer/api-reference/ (add .md for markdown).
Don't guess field or argument names.

- API: GraphQL at https://<subdomain>.bunny.com/graphql, where <subdomain> is the
  one in your Bunny admin URL. One endpoint for queries and mutations.
- Auth: OAuth client credentials. POST grant_type=client_credentials, client_id,
  client_secret and scope to https://<subdomain>.bunny.com/oauth/token, then send
  "Authorization: Bearer <access_token>". Server-side only: never send the client
  secret or an API access token to the browser.
- Tokens expire (expires_in, in seconds). On a 401 "Token is expired", get a new
  token and retry once.
- Scopes: request only scopes assigned to the API client. Each operation's
  reference page lists the scope it needs.
- Errors: every mutation returns an errors field. Always select it, and treat a
  non-empty list as a failure, as well as top-level GraphQL errors.
- Browser and UI: for Bunny Components or the customer portal, create a portal
  session token on the server with portalSessionCreate (scope portal:write) and
  pass only that token to the browser.
- Signups: call subscriptionCreate when a customer signs up and their tenant
  exists in your platform, passing your tenant code.
- Usage-based charges: report usage with featureUsageCreate.
- Changing an existing subscription's price, quantity or discount creates a quote
  in Bunny (subscriptionUpdate does this). There is no mutation that edits a
  subscription's commercial terms in place.
- Provisioning: keep each tenant's features and quantities in sync from the
  tenantProvisioningChange webhook, not by polling.
- Webhooks: verify the x-bunny-signature header, an HMAC-SHA1 of the raw request
  body with your signing key, with BunnyApp::Webhook.verify (Ruby) or
  bunny.webhooks.validate (Node.js).
- Use the Bunny SDKs (Ruby, Node.js) for common calls, and their raw query method
  for everything else.
```

## Related

- [Integration points](https://docs.bunny.com/developer/integration-points): the four calls most integrations need
- [Authorizing API requests](https://docs.bunny.com/developer/using-the-graphql-api/authorizing-api-requests) and [Scopes](https://docs.bunny.com/developer/using-the-graphql-api/scopes)
- [Portal session token](https://docs.bunny.com/developer/portal-session-token)
- [Webhook security](https://docs.bunny.com/developer/webhooks/webhook-security)

---

Source: https://docs.bunny.com/developer/build-with-ai. Index of every page: https://docs.bunny.com/llms.txt
