New to the Bytebase MCP server? Follow the Connect an AI Tool to Bytebase with MCP tutorial for a hands-on walkthrough.
Connect an AI tool
- Configure the external URL. Bytebase uses it to tell your AI tool where to sign in, and binds each MCP token to it. Without it, sign-in fails.
- Check that the workspace access policy is not Disabled. A new workspace starts at Read-only.
- Add Bytebase to your AI tool. The Integration > MCP page in Bytebase shows the setup for Claude Code, Claude Desktop, Codex, Copilot CLI, Gemini CLI, VS Code, and other tools, with your URL filled in.
- Sign in to Bytebase in the browser window your AI tool opens, and click Allow access.
- Ask your AI tool something that only reads, such as “List all projects in my Bytebase instance”.
Access policy
The access policy is the most any MCP session may do in the workspace. Each session is also limited by the signed-in user’s own Bytebase permissions. The policy only narrows those permissions; it never grants any. What a session can do on a database also depends on what Bytebase supports for its engine, as Read-only queries and Read-write changes describe. The policy has one of three modes: Disabled, Read-only, and Read-write. Under Disabled, nothing is allowed and no MCP session can connect. The modes are nested: Read-write allows everything Read-only does, and more. Bytebase saves Read-only for every new workspace. A workspace created by an older version may have no saved policy. It runs at Read-write until someone saves one, so check the mode after you upgrade. A policy change applies to the next request of every session, including sessions that are already connected, and to the authorization page from then on.What each mode allows
The Integration > MCP page and the authorization page show each mode as a list of capabilities: what the mode allows, then what it does not allow. This table lists every capability in the same order, with what it covers. The list runs reads first, then writes. Within each, capabilities are ordered by category, which the product does not show:- Databases: what touches a database itself, such as schemas, queries, statements, exports, and saved queries.
- Changes and access: one change or one person’s access, such as plans, rollouts, issues, approvals, access grants, and masking exemptions.
- Workspace: what the workspace manages, such as projects, instances, databases, and workload identities.
- Policies: the rules every later change or query runs under, such as roles, approval rules, masking rules, and access-grant settings.
Set the access policy
Requires the
bb.settings.set permission. The Workspace Admin and Workspace DBA roles have it.- Go to Integration > MCP.
- Under Access policy, click Edit policy.
- Select a mode and click Save policy.

Set or read the access policy through the API
Set or read the access policy through the API
Set the mode:
<access_token> is an API token for a user or service account with the bb.settings.set permission, not the MCP token. The values are DISABLED, READ_ONLY, and READ_WRITE.To read the mode in force, call GET /v1/actuator/info with an API token and read mcpSetting. Use this endpoint, not GET /v1/settings/MCP, which answers 404 on a workspace with no saved policy.Read-only queries
Under Read-only, Bytebase checks every statement in a query before it runs. It refuses the whole request unless every statement is a read that returns data. Statements that return no data, such asSET and USE, are refused, because they change the session the rest of the request runs on.
How deeply Bytebase can check a statement varies by engine. On some engines, Bytebase also opens the database session read-only. On others, the check classifies each statement, and a statement that classifies as a read can still call a function that writes.
On MongoDB, Elasticsearch, and Databricks, Bytebase cannot show that a statement is a read, so no query runs under Read-only.
Read-write changes
Under Read-write, the AI tool can change data and schemas two ways:- Propose a change. The change tool (
propose_database_change) creates a sheet, a plan with plan checks, and an issue. The issue follows the project’s review and rollout flow. - Run a statement directly. The query tool (
query_database) runsINSERT,UPDATE,DELETE,CREATE,ALTER, andDROPwithout an issue, within your permissions. This works on MySQL, PostgreSQL, Oracle, SQL Server, TiDB, Snowflake, Spanner, BigQuery, MongoDB, and Elasticsearch.
SET search_path. Choose one:
- Run now runs the statement at once, with no issue or approval.
- Create an issue titled ”…” files a plan and an issue for the statement instead of running it. The form offers this only when the AI tool proposed an issue title and the request names no schema.
- Change it in chat runs nothing and returns you to the conversation.
SET search_path. Exports from Databricks are refused.
The project’s approval policy decides whether a person must approve a proposed change. Where no approval is required, as on the Community plan, Bytebase creates the rollout as soon as it skips approval. A Read-write session can then run it, if your role can run tasks. An AI tool can approve a change it proposed only if the project allows issue creators to approve their own issues and allows approval by the person who last changed the plan, the same rules as in the console.
Access requests and approvals
Under Read-write, an AI tool can also take an access request from start to finish, within your permissions and the project’s approval rules. The mode grants nothing on its own: an AI tool can request, approve, or change only what you could in the console.- Request an access grant. The
request_access_granttool files a just-in-time access grant for one read-only statement on one database, with optional unmasked or exportable results, a reason, and a duration in hours counted from approval. The project must have Allow access grants on. A person approves the request in Bytebase; once approved, the AI tool reruns the statement, andappliedAccessGrantin the query result names the grant. If no one other than you can approve the request, the tool says so and names the role the approval step needs. When no approval rule requires a person to approve the request, Bytebase refuses it over MCP, because the access would be granted at once; request it in the console instead. - Approve or reject. The
decide_issuetool approves or rejects a database change issue or an access request at its current step. Role requests cannot be decided over MCP. - Change project access settings. The
set_just_in_time_accesstool turns a project’s Allow access grants on or off. Thegrant_masking_exemptionandrevoke_masking_exemptiontools manage masking exemptions; one exemption can cover several columns of one table. An AI tool can also revoke an active access grant. - See who can approve. In every mode, the AI tool can read a project’s and the workspace’s IAM policy, groups, and roles, so it can tell who holds a reviewer role. With the
bb.settings.getpermission, it can also read the approval rules, so it can tell which role an approval step waits on, and the environments, semantic types, and data classification.
CONFIRMATION_UNAVAILABLE error with a link to decide in the console, and nothing changes. Requesting an access grant needs no confirmation form, because a person approves it in Bytebase.
To stop AI tools from approving, switch the access policy to Read-only.
Workspace administration
Under Read-write, theadminister_workspace tool makes four kinds of workspace administration change, within your own permissions:
Each change applies only after you confirm it in your MCP client. The form shows the change and asks Apply this change? Choose Apply, or Change it in chat to return to the conversation with nothing changed. An answer expires after 10 minutes, and is refused if what it changes was changed in the meantime. A client that cannot show the form gets a
CONFIRMATION_UNAVAILABLE error with a link to the console, and nothing changes. The same changes sent through the generic API tool (call_api) are refused.
The confirmation checks your intent; it is not a security boundary, because a hook in your own client can answer the form. To keep AI tools from making these changes, switch the access policy to Read-only.
To set up GitOps from a repository, an AI tool can also call the get_gitops_workflow tool. It returns complete GitHub Actions or GitLab CI workflow files for the project and databases you name, and changes nothing in Bytebase. See GitOps.
What no mode allows
In every mode, an MCP session cannot:- Change the MCP access policy itself, or any workspace setting other than the approval rules for database changes.
- Create a service account key, change a user’s password, email, or MFA, or show a stored secret, such as a data source password.
- Read or change users, identity providers, service accounts, or billing, or read or export the audit log. No MCP call can edit or delete an audit log entry.
- Read workspace settings other than the approval rules, environments, semantic types, and data classification.
- Change groups, roles, or the workspace IAM policy. Reading them is allowed, so the AI tool can tell who holds a reviewer role.
- Change a project’s IAM policy, except to give a new workload identity the GitOps Service Agent role in that project.
- Change any other policy or rule, such as the rollout, data query, tag, and review policies, or SQL review configs. Reading them is allowed.
- Create or delete projects, change a project’s settings other than Allow access grants, or manage project webhooks.
- Change or delete instances, or create one other than a PostgreSQL instance added to a project. Reading project and instance details is allowed.
- Change or remove a workload identity.
- Open an Admin mode session in SQL Editor.
- Read other users’ query history.
- Send data to a third party through a stored workspace credential, such as Bytebase’s built-in AI chat, which uses the workspace AI API key, or a webhook test. A proposed change still notifies the project’s webhooks, like any issue, with its title and description.
- Request a role through an issue, or decide a role request. Only database change issues can be created over MCP; access is requested as an access grant, not through an issue.
Masking
Query results honor your data masking policies on the engines Bytebase masks: MySQL, PostgreSQL, Oracle, SQL Server, MariaDB, OceanBase, TiDB, BigQuery, Spanner, Redshift, Cassandra, Trino, MongoDB, Cosmos DB, and Elasticsearch. On other engines, the AI tool sees real values. Masking needs the Enterprise plan. A query result names each masked column with its semantic type, algorithm, and the reason it was masked, so the AI tool can request unmasked access for the columns it needs instead of guessing. Masked columns are not named on MongoDB, Cosmos DB, and Elasticsearch.****** is the value Bytebase shows for a fully masked cell. In every mode, Bytebase refuses any MCP query or change whose SQL contains it, so the AI tool does not copy masked values back over real data. The check reads the SQL text only.
Your masking exemptions and unmask grants apply to your MCP sessions as they do in the console: an AI tool sees what you see.
Audit
The audit log stores an entry for each MCP call to an audited method that reaches its handler, under the signed-in user. That covers queries, exports, proposed changes, rollouts, access requests, approvals, and workspace administration changes, among others. Each MCP entry records the OAuth client, the scope approved at sign-in, the MCP endpoint URL, and a correlation ID. Every call in one MCP session shares the same correlation ID. Searching the audit log needs the Pro or Enterprise plan. Some MCP calls are not stored:- Schema and metadata reads. A query (
SQLService/Query) is the only read that is stored. - Syncing instances and databases (
SyncInstance,BatchSyncInstances,SyncDatabase, andBatchSyncDatabases). - Schema diffs (
DiffSchemaandDiffMetadata), release checks (CheckRelease), and starring a saved query (UpdateSavedQueryStar). - A call refused before it reaches its handler: by the access policy, by the list of things no mode allows, by a permission check, or by the
******check. Refusals made while a call runs are stored, such as a query that Read-only refuses. A connection or sign-in refused while MCP is Disabled is stored too.
Record refused calls
Record refused calls
A call refused by the access policy or by a permission check is streamed when audit logging to stdout is on, whether or not it is stored. To stream, turn on Enable audit logging to stdout (see Streaming). This needs self-hosted Bytebase with an Enterprise license, or an existing self-hosted Pro license. Bytebase Cloud cannot stream audit logs.
Filter MCP entries in the audit log API
Filter MCP entries in the audit log API
mcp == truefor the entries MCP produced,mcp == falsefor the rest.mcp_correlation_id == "<id>"for one MCP session. A refused connection or sign-in has no correlation ID.
How changes work
A few behaviors are worth knowing before you work through an AI tool:- One database per change. A proposed change targets a single database. For changes across multiple databases, the AI tool uses the batch workflow and the underlying APIs.
- Each change creates a new issue. A proposed change always creates a fresh sheet, plan, and issue — it does not edit an existing one. Iterating on SQL across several turns produces multiple issues, so settle on the statement before proposing, and close any superseded issues.
Limitations
- No dry-run tool. The change tool always creates a change. Plan checks (SQL review, DDL simulation) run when it creates the plan.
- Query results are capped. Queries return 100 rows by default and 1,000 at most, with a 30-second timeout. Larger result sets are truncated.
- Schema output is capped. Schema inspection returns up to 200 tables per schema when it includes columns or details; the default summary lists every table. Narrow it with a schema or table name.
-
HTTP transport only. The server is reached over the
/mcpHTTP endpoint. For an AI tool that can only start MCP servers as local commands, the@bytebase/bytebase-mcpnpm package connects to that endpoint for it. See the setup guide. - Request size is capped. Bytebase refuses requests over 4 MiB with HTTP 413. Send very large migration statements through the console instead.

