Skip to main content
Grain runs a Model Context Protocol server. An AI assistant that connects to it can ask questions of your analytics data, the same questions you ask in the dashboard. No custom integration is required. MCP is an open protocol that lets a language model call external tools.

What an assistant can do

Read Tools for every tool and its inputs.

Endpoint

MCP endpoint

https://grainql.com/api/mcp
This is the only URL you paste into a client. The server speaks MCP over Streamable HTTP. A client discovers the OAuth flow on its first connection.

The OAuth flow

Grain is its own OAuth 2.1 authorization server. When an MCP client calls the endpoint without a token, this happens:
1

The client asks Grain what it needs

Grain responds 401 with a WWW-Authenticate header that points at /.well-known/oauth-protected-resource.
2

The client registers itself

The client calls /oauth/register (RFC 7591 Dynamic Client Registration) and receives a public, PKCE-only client_id. There are no shared secrets.
3

You approve in the browser

Grain opens a consent screen. You pick the workspace and read the scopes that the client asks for. A workspace on the consent screen is a tenant. A 7-day preview shows what the assistant will see.
4

The client receives a token

After you click Authorize, the client receives a short-lived mcpat_… access token and an mcprt_… refresh token. Both are scoped to the tenant you picked.
You can revoke any client at Settings → Connectors → MCP clients. If you do not want to give an assistant access to production data yet, create a test tenant and connect the assistant to that tenant first.

Scopes

Grain has three scopes. A client asks for the scopes it needs at authorize time. The consent screen shows every scope in plain English before you approve. Read Security and scopes for what each scope unlocks and how tokens are stored.

Clients

Claude

Claude.ai on the web, Claude Desktop, and Claude Code.

Cursor

The Cursor editor and its agent.

ChatGPT

Developer Mode on the Pro, Team, Enterprise, and Edu plans.

Tools

The tool reference for any other MCP client.

Limits

If an agent reaches the budget, it receives a structured error. The agent then asks you to narrow the question.

Safety

  • Every token carries exactly one tenantId, chosen at consent. An assistant cannot cross tenants in a session.
  • Version 1 is read-only. No tool writes, deletes, or changes data. You can grant mcp:investigate without a risk that the assistant changes a segment definition.
  • Grain encrypts upstream tokens with AES-GCM before it writes them to the database. Grain stores its own tokens only as SHA-256 hashes.