Skip to content

Connect an AI assistant with MCP ​

Connect your MCP client to https://mcp.terrascale.tech/ over HTTP. Clients that support MCP sign-in (Claude Code, claude.ai connectors, Cursor) need only the URL: they open a browser where you sign in to TerraScale. Other clients send a personal access token. Either way, the assistant acts as your dashboard user, and each call checks your access to the selected organization, project and resource.

1. Add TerraScale and sign in ​

In Claude Code:

bash
claude mcp add --transport http terrascale https://mcp.terrascale.tech/
claude

Run /mcp, select terrascale and choose Authenticate. Your browser opens a TerraScale page that names the client and where the sign-in returns. Choose Sign in and allow, then sign in to TerraScale, or sign up. The browser hands control back to Claude Code, which lists the TerraScale tools.

In Codex, add the server and sign in:

bash
codex mcp add terrascale --url https://mcp.terrascale.tech/
codex mcp login terrascale

See Codex MCP setup.

Other clients that support MCP authorization, such as claude.ai custom connectors and Cursor, start the same sign-in when you add the URL https://mcp.terrascale.tech/.

Sign-in creates a personal access token named MCP: <client name>. It lasts up to 90 days, counts toward the 25-token limit, and appears on Profile → Access tokens, where you can revoke it. The client's registration can expire sooner after inactivity, as described below. When access expires, the client asks you to sign in again.

Check the connection:

text
Use TerraScale get_context to show my accessible organizations and projects.
Do not change anything.

Registration expiry and reconnecting ​

A new OAuth client registration expires after 24 hours if sign-in never completes. After sign-in completes, the registration expires after 30 days without a successful sign-in, token issuance or authenticated request using one of its tokens. Opening the consent page, denying access or sending an invalid token does not extend that period.

An expired registration stops its associated tokens from authenticating, even if their 90-day token deadline has not arrived. Remove and add TerraScale again in your client, then authenticate to create a new registration. Personal access tokens created separately in the dashboard keep their selected expiry.

For custom MCP client integrations, use authorization-server discovery rather than constructing client IDs. Dynamic registration returns a canonical uppercase, 26-character ULID as client_id; keep it unchanged. Registration JSON is limited to 16 KiB, including whitespace and UTF-8 encoding. Oversized bodies return HTTP 413; malformed or unsupported registration metadata returns an OAuth JSON error with HTTP 400. Registration management endpoints are not advertised; knowing a public client ID does not authorize changing or deleting it.

Each client address has a budget for MCP requests, dynamic registrations and rejected tokens. A rejected token is refused without another check for about a minute. Exceeding a budget returns HTTP 429 with Retry-After.

2. Or use a personal access token ​

Use this for clients without MCP sign-in, or for automation.

  1. Sign in to the dashboard.
  2. Open Profile → Access tokens, or open the tab directly.
  3. Create a named token, choose its expiry and complete the sign-in redirect.
  4. Save the token securely when it is shown. Its secret is displayed only once.

Tokens expire after 7, 30, 90 or 365 days. An account can hold up to 25 live tokens. Project API keys support the agent database tools; personal access tokens are required for the wider dashboard tools. Assistants cannot create personal access tokens or change your password, email, authenticator-app MFA or passkeys; those actions require the browser, where passkey sign-in is available on the hosted sign-in page.

In Bash, enter the token without recording its value in shell history:

bash
read -rs TERRASCALE_MCP_TOKEN && export TERRASCALE_MCP_TOKEN
claude mcp add --transport http --scope project terrascale https://mcp.terrascale.tech/ \
  --header 'Authorization: Bearer ${TERRASCALE_MCP_TOKEN}'
claude

Keep the header's single quotes: they save the variable reference rather than the token value. Claude Code expands it from the environment when connecting. Launch Claude from this shell; after opening a new shell, supply the token again. The Claude Code MCP documentation describes HTTP servers and environment variable expansion.

Other MCP clients need the same HTTP URL and an Authorization: Bearer <personal access token> header. Use that client's protected credential storage; do not commit a literal token in client configuration. Clients must support Streamable HTTP and accept both JSON and event-stream responses.

3. Choose the organization and project ​

Call get_context first to discover accessible IDs. Scoped tools accept optional organizationId and projectId arguments:

  1. Omit both to use your saved dashboard selection.
  2. Supply organizationId to use that organization's default project, or the saved project when it is your saved organization.
  3. Supply both to choose an organization and one of its projects explicitly.

Supplying only projectId requires that project to belong to your saved organization. select_organization and select_project change the saved dashboard selection, so pass explicit scope when you want each call to name its target. These arguments select a target without restricting the token's authority: an OAuth-issued or personal access token retains your dashboard user's permissions across accessible organizations and projects. For unattended diagnostics, use a dedicated test user with the minimum required role.

4. Discover tools and check permissions ​

Use your client's tool discovery (tools/list) for the current names, parameters and descriptions; the server returns every tool in one page. A listed tool is not a grant of permission: calls still enforce membership, roles, resource access and availability. Current tools include:

execute_sql runs reads, writes and schema changes; run_sql accepts reads only. get_database_schema lists the database's tables and their declared columns. create_database and fork_database accept ttlHours. With pointInTime, fork_database returns a running restore operation instead of waiting for the copy; poll get_restore_status for the new database. Backup and restore tools preserve the source database. See the complete agent database workflow, including scoped-key minting over an API key connection.

create_organization starts billing checkout with name, plan (default starter) and interval (default monthly). It returns status: "checkout_required" and checkoutUrl. Open that URL and pay. No organization or membership exists before Stripe confirms payment. The next full dashboard page navigation, organization-list MCP call or create_organization call completes creation automatically; get_context then lists the organization. Canceling checkout creates no organization.

Creating or rotating an API key needs the dashboard: an unattended assistant call returns step_up_required, and you finish the action from the dashboard's API keys page, where rotating also asks for a fresh confirmation. Listing, restricting and revoking keys work from the assistant.

Functions ​

Call get_functions_reference before writing a function: it returns the handler and event contracts, SQL and transaction signatures, limits, cron rules and three complete examples. deploy_function creates or replaces source and an optional five-field UTC cron, returning the HTTPS invoke URL or the runner's structured validation error. invoke_function runs a JSON body once and returns its HTTP status, content type and parsed body. It needs only SQL read access, even if the function writes SQL. With SQL write access it also returns the newest invocation log; concurrent calls or cron may produce a newer record. Without write access, log is null and log_note explains how to read logs. If a log read fails after execution, the call retains its HTTP response, with a null log and a failure note; inspect existing logs instead of invoking again. Both MCP and the dashboard test run send an empty event.query; direct HTTPS calls populate it from URL query parameters.

get_function_stats is read-only and returns aggregate metrics independently of retained logs. Pass databaseId, name and an optional window: 1h, 24h (default) or 7d. Invalid windows return a structured validation error. The result contains window, invocations, errors, p50Ms, p95Ms, p99Ms, maxMs, sqlCalls, rowsRead, rowsWritten and oldest-first, zero-filled buckets. Each bucket contains at, invocations, errors, p50Ms and p95Ms.

Project API keys can use the same function tools. Deploy, list, get, logs and stats require SQL read and write scopes; invoke requires SQL read. The reference tool requires no data scope. Database restrictions and project ownership remain enforced. list_functions, get_function, list_function_logs and get_function_stats support inspection; delete_function retains its dashboard confirmation handoff. set_function_secret, delete_function_secret and list_function_secrets manage a function's write-only secrets with the same SQL read and write scopes; they return names and updated_at, never values.

Delete resources ​

The delete_database, delete_project, delete_saved_query, delete_function, delete_file_bucket and delete_file tools never delete through an unattended MCP connection, whether it uses a project API key, OAuth or a personal access token. They return code: "step_up_required", tool, resource and confirmationUrl. Open the URL, sign in to the indicated organization and project, and confirm the action in the dashboard. The resource remains until the dashboard completes deletion.

The URL opens the database's danger zone, organization projects, function details, bucket or file page. For a saved query, pass databaseId to open that database's SQL editor; without it, select the database from the database list and open its Tables tab. The dashboard retains its authorization and confirmation requirements.

execute_sql still accepts writes and schema changes allowed by the key's scopes; it does not use this resource-deletion handoff.