Announcing CIMD support for MCP Client registration
Learn more

PlanetScale MCP vs PlanetScale API for AI Agents (2026)

TL;DR

  • PlanetScale MCP and the PlanetScale API cover different ground, and the split is not where you would guess. The hosted MCP server runs SQL and reads Insights; provisioning work like branches, deploy requests, backups, and passwords lives only in the API. Choose per task, not per preference.
  • The MCP server is not OAuth-only. It accepts OAuth 2.1 for interactive clients and a service token for CI and headless agents, so background jobs do not need a browser flow.
  • The management API never touches your data. api.planetscale.com/v1 provisions and manages; to run SQL directly you connect to the database with a branch password and a driver such as @planetscale/database. That is a separate credential to hold.
  • The MCP server ships safeguards you do not get for free on the raw data plane: ephemeral per-query credentials, automatic replica routing, blocked unqualified DELETE and TRUNCATE, and DDL that requires human confirmation.
  • Whichever path you pick, per-user isolation, rotation, revocation, and audit attribution are yours to build. The Scalekit PlanetScale connector vaults each user's grant, scopes the tool surface, and logs every call, so the MCP vs API choice does not change your auth infrastructure.

Your agent needs to work with PlanetScale. It needs to inspect a branch schema, run a query against a pull request branch, read Insights to explain a slow query, maybe open a deploy request when a migration is ready. PlanetScale ships a hosted MCP server, general availability since January 2026, and a full REST API that has been production-ready for years. They are not interchangeable, and the dividing line is unusual: the MCP server is built to query and observe a database; the API is built to provision and manage one. Here is how to pick.

What PlanetScale MCP and PlanetScale API actually are

You are comparing three surfaces, not two. The MCP server is one object. The API is really a control plane plus a data plane, and the difference matters for agents.

PlanetScale MCP, the hosted server

The PlanetScale MCP server is a hosted, remote server at https://mcp.pscale.dev/mcp/planetscale, maintained by PlanetScale and reachable from any client that supports HTTP-hosted MCP over Streamable HTTP. It works for both Vitess (MySQL) and Postgres databases. Queries execute over HTTP through the server, which makes it usable from browser-based tools and sandboxed agents that cannot open a database socket.

It exposes roughly two dozen tools today, weighted toward querying and observability: read and write SQL execution, branch and schema inspection, Query Insights, schema recommendations, query error patterns, query tags, Postgres logs, and billing. The full, current tool list lives in the official PlanetScale MCP server documentation.

PlanetScale API, the control plane

The PlanetScale API is a REST management API at api.planetscale.com/v1. Its own documentation is explicit that it does not include direct access to the data in your database; it manages the platform around the data. That surface is broad: databases, branches, deploy requests, backups, passwords and roles, regions, organizations and members, webhooks, audit logs, IP restrictions, and Query Insights reports. You can read the full contract in the PlanetScale API reference.

The data plane the API leaves to you

Because the management API does not run SQL, the direct path to your data is a database connection. For Vitess and MySQL, the Fetch-compatible @planetscale/database serverless driver connects over HTTP using a branch password; for Postgres, PlanetScale supports the Neon serverless driver. Standard wire-protocol clients work too. The credential here is a PlanetScale password scoped to a branch, which is a different secret from the service token or OAuth grant the control plane uses.

Comparing them where it matters for agents

The two paths overlap on inspection and Insights, diverge sharply on provisioning, and split cleanly on how you run SQL at volume. The four dimensions below are what actually decide the build.

What your agent can actually do

The table maps agent-relevant capabilities. For SQL execution, the "PlanetScale API" column refers to the database connection described above, not the management API, since the management API does not run queries.

Capability
PlanetScale MCP
PlanetScale API
Run read queries (SELECT, SHOW, EXPLAIN)
Yes, with replica routing and ephemeral credentials
Data plane only, via a driver or SQL client
Run write queries and DDL
Yes, with safeguards
Data plane only, via a driver or SQL client
Inspect branch schema, tables, columns
Yes
Yes
Read Query Insights and slow queries
Yes
Yes, via Query Insights reports
Get schema recommendations
Yes
Yes
List and get organizations, databases, branches
Yes
Yes
Create, delete, or promote branches
No
Yes
Create databases
No
Yes
Open and manage deploy requests
No
Yes
Manage backups, passwords, and roles
No
Yes
Webhooks, audit logs, IP restrictions
No
Yes
Invoices and payment method
Yes
Yes

Where the MCP surface stops

The pattern in the table is the whole story. The MCP server is a read-and-query instrument: it inspects, it profiles, it executes SQL. The moment your agent needs to change the shape of the platform, create a branch, open a deploy request, take a backup, mint a database password, the tools are not there. Those operations live in the API today. PlanetScale is adding MCP tools over time, so treat the boundary as current rather than permanent, but do not design a provisioning agent around tools the server does not yet expose.

The auth path each one puts you on

This is where PlanetScale departs from most MCP servers, so read carefully rather than assuming the usual OAuth-only story.

The MCP server accepts two credential types. Interactive clients use OAuth 2.1: each client registers dynamically as an OAuth application, the user signs in through the browser, and scopes control access at the organization, database, and branch level. Headless clients export a PlanetScale service token as PLANETSCALE_API_TOKEN and skip the browser entirely, which is what makes CI and background agents viable on the MCP path.

The direct path uses service tokens for the management API, authenticated with an Authorization: <SERVICE_TOKEN_ID>:<SERVICE_TOKEN> header and granular per-organization and per-database accesses, plus a branch password for the data plane. OAuth applications are also available when you need users to grant your platform access to their own PlanetScale accounts.

The implication for a multi-tenant agent is concrete. If your product lets each customer connect their own PlanetScale account, every customer is a separate OAuth grant or service token to store, refresh, and revoke. If your agent operates on your own database, the risk shifts from credential sprawl to tool-surface scope, production write access, and per-user audit attribution. Both problems live at the infrastructure layer, not in the choice of path.

What you own in production

The MCP server hands you meaningful safety for free. Each query runs with short-lived, ephemeral credentials that are created on demand and deleted immediately after execution. Read queries route to a replica when one exists, and every statement carries a source=planetscale-mcp comment so you can trace it in Insights. Write safety is built in: unqualified UPDATE and DELETE are blocked, TRUNCATE is blocked, and DDL prompts for human confirmation before it runs. On Postgres, reads run under a role that respects row-level security and warn you when a policy may be filtering results.

The direct path gives you none of that automatically. You own SQL construction, replica routing, retries, the 600 requests per minute management-API rate limit, cursor pagination, and API versioning. That control is exactly what a deterministic pipeline wants: you pin behavior and change it on your schedule rather than absorbing a managed server update mid-run.

When to use MCP, when to use the API

Use PlanetScale MCP when:

  • Your agent inspects, debugs, or explains a database: schema review, slow-query triage, index suggestions, drift analysis across branches, the work behind a DevOps assistant agent or an incident response agent.
  • You want the built-in query safeguards and ephemeral credentials rather than handing an LLM a long-lived database password.
  • You are running interactive, user-present sessions where OAuth consent is natural, or headless jobs where a service token is acceptable.
  • You want to reach the database from a sandboxed or edge runtime that cannot open a raw socket.

Use the PlanetScale API directly when:

  • Your agent provisions or manages the platform: creating branches, opening deploy requests, taking backups, rotating passwords, configuring webhooks, the work behind an auto release notes agent or an engineering standup agent.
  • You are moving data at volume, where the serverless driver or a wire-protocol client and your own pagination beat per-query HTTP execution.
  • You need deterministic, versioned behavior for a scheduled pipeline that cannot tolerate an unplanned schema change from a managed server.
  • You need a capability that is not in the MCP tool set yet.

The credential problem that exists on both paths

PlanetScale gives you a strong security posture on the query path. It does not give you the credential lifecycle for your tenant base. That gap is identical whichever path you choose; only the token type changes.

What PlanetScale gives you

On the MCP path, ephemeral per-query credentials mean the agent never holds a durable database password: the server mints and discards credentials around each execution, and OAuth scopes bound what the connection can see. This is the right default, and it removes a whole class of leaked-credential incidents from the query path.

What neither path manages for you

Neither path is a token vault, a rotation loop, or a revocation flow. A product where customers connect their own PlanetScale accounts accumulates one grant per customer, each needing storage, refresh, and clean revocation when a customer churns. An agent on your own database avoids the sprawl but still needs its tool surface scoped, its production write access controlled, and every action attributed to the user who triggered it. A service token generated months ago and left in an environment variable stays valid until someone remembers to delete it. This is exactly why a token vault is critical for AI agent workflows.

Where Scalekit fits

The Scalekit PlanetScale connector wraps the hosted MCP server and vaults each user's grant as a connected account, so credentials never sit in your agent runtime and the same auth infrastructure holds whether your agent leans on the MCP path or calls the API and database directly. The path decision stops being an auth decision.

Connect PlanetScale to your agent with Scalekit

Scalekit's PlanetScale connector, slug planetscalemcp, is a vendor-MCP connector: it fronts PlanetScale's hosted server with OAuth 2.1 and dynamic client registration, vaults the token, and returns tools your framework can call directly. The examples below use Python and LangChain. The same methods exist in the Node SDK.

Install and initialize

Install the SDK and your framework packages, then construct the client from environment credentials found in your Scalekit dashboard.

pip install scalekit-sdk-python langchain-openai
import os import scalekit.client scalekit_client = scalekit.client.ScalekitClient( client_id=os.getenv("SCALEKIT_CLIENT_ID"), client_secret=os.getenv("SCALEKIT_CLIENT_SECRET"), env_url=os.getenv("SCALEKIT_ENV_URL"), ) actions = scalekit_client.actions

Authorize the user's PlanetScale account

Resolve the user's connected account and, if it is not active, send them through PlanetScale's OAuth flow once. The authorize a user guide covers production handling of the redirect.

connection_name = "planetscalemcp" identifier = "user_123" account = actions.get_or_create_connected_account( connection_name=connection_name, identifier=identifier, ) if account.connected_account.status != "ACTIVE": link = actions.get_authorization_link( connection_name=connection_name, identifier=identifier, ) print("Authorize PlanetScale:", link.link) input("Press Enter after authorizing...")

Discover the tools this user can call

Before the agent runs, load the tools the current connected account is authorized to call. This is the distinction between a per-user agent and a shared-credential one: the surface is derived from what this user granted, not a flat catalog.

from google.protobuf.json_format import MessageToDict scoped_response, _ = actions.tools.list_scoped_tools( identifier=identifier, filter={"connection_names": [connection_name]}, page_size=100, ) for t in scoped_response.tools: definition = MessageToDict(t.tool).get("definition", {}) print(definition.get("name"), "-", definition.get("description", ""))

Execute a single tool

The execute_tool call runs one PlanetScale tool under the user's connected account. A read query returns rows without the agent ever holding a database password.

result = actions.execute_tool( tool_name="planetscalemcp_planetscale_execute_read_query", identifier=identifier, tool_input={ "organization": "my-org", "database": "my-db", "branch": "main", "query": "SELECT id, email FROM users ORDER BY created_at DESC LIMIT 10", }, ) print(result.data)

Run the agent loop with LangChain

actions.langchain.get_tools() returns native LangChain tools, so the loop is standard: bind the tools, call the model, run each tool call, feed results back until the model stops. The LangChain integration guide has the full walkthrough. For a deeper look at how LangChain tool calling works and where it stops, see our guide on LangChain tool calling.

from langchain_openai import ChatOpenAI from langchain_core.messages import HumanMessage, ToolMessage tools = actions.langchain.get_tools( identifier=identifier, connection_names=[connection_name], page_size=100, ) tool_map = {t.name: t for t in tools} llm = ChatOpenAI(model="gpt-4o").bind_tools(tools) messages = [HumanMessage("Find the 5 slowest queries on my production branch and suggest indexes")] while True: response = llm.invoke(messages) messages.append(response) if not response.tool_calls: print(response.content) break for tc in response.tool_calls: result = tool_map[tc["name"]].invoke(tc["args"]) messages.append(ToolMessage(content=str(result), tool_call_id=tc["id"]))

Or expose a scoped virtual MCP endpoint

If you would rather hand your agent an MCP URL than wire tools in code, define a Virtual MCP server that exposes only the PlanetScale tools this agent role needs, then mint a short-lived session token per user and connect over Streamable HTTP.

pip install langchain-mcp-adapters
import asyncio from langchain_mcp_adapters.client import MultiServerMCPClient from langchain_openai import ChatOpenAI from langchain_core.messages import HumanMessage, ToolMessage async def run(mcp_url: str): async with MultiServerMCPClient( {"scalekit": {"transport": "streamable_http", "url": mcp_url}} ) as client: tools = client.get_tools() tool_map = {t.name: t for t in tools} llm = ChatOpenAI(model="gpt-4o").bind_tools(tools) messages = [HumanMessage("List branches on my-db and summarize schema drift from main")] while True: response = await llm.ainvoke(messages) messages.append(response) if not response.tool_calls: print(response.content) break for tc in response.tool_calls: result = await tool_map[tc["name"]].ainvoke(tc["args"]) messages.append(ToolMessage(content=str(result), tool_call_id=tc["id"])) asyncio.run(run(mcp_url))

Why build PlanetScale agents on Scalekit

PlanetScale already secures the query path well. Scalekit addresses the parts that only appear once an agent serves more than one user and touches more than one tool. Recommended reading: MCP authorization for agentic workflows.

Downstream tool-calling auth logs for observability

Every execute_tool call runs under a specific connected account, and Scalekit records which user, which tool, and which account was involved. That gives you an audit trail tied to the human who authorized the action rather than a shared token, which is exactly what a reviewer wants to see when an agent runs a write query.

One scoped endpoint for multi-tool, multi-tenant agents

Most real agents talk to more than PlanetScale. A Virtual MCP server gives every agent role one static endpoint that declares exactly which connections and tools it can see, while a short-lived session token minted before each run binds the endpoint to a single user's connected accounts. One server definition serves all users; no per-user server configuration, and no credential sharing between tenants.

Least privilege over a two-dozen-tool server

The hosted PlanetScale server exposes around twenty-five tools. A summarizer that only reads Insights needs a handful of them. Handing an agent the full surface inflates the context window on every run and widens the blast radius if the model misfires. Scoping the surface to the tools a role actually needs cuts token overhead and enforces least privilege, so what the user cannot do, the agent cannot do either. This is a core principle behind production tool-calling auth patterns.

Which one to build against

Most production PlanetScale agents will use both surfaces, and the boundary is clean once you see it.

The decision in one line

If your agent inspects, queries, or explains a database, build on the MCP path and take the ephemeral credentials and query safeguards that come with it. If your agent provisions the platform or moves data at volume, build on the API and the database connection, where you control versioning, throughput, and lifecycle. The credential management problem is the same either way, and that is the part that needs production-grade infrastructure.

Understanding the difference between MCP and APIs at the architecture level helps clarify why both paths exist and when each one fits.

Start building

Read the Scalekit PlanetScale connector docs, see the capabilities on the PlanetScale connector page, or browse the wider developer-tools connectors and full connector catalog. When you are ready to plan a deployment, check pricing.

Building a PlanetScale agent and want a second pair of eyes on the auth model? Join the Scalekit community on Slack, or talk to an engineer for help right away.

No items found.
Agent
Auth Quickstart
On this page
Share this article
Agent
Auth Quickstart

Acquire enterprise customers with
zero upfront cost.

Every feature unlocked. No hidden fees.