Skip to main content
Connect AI tools to Bytebase using the Model Context Protocol. Your AI tool runs on its own model, so MCP works whether or not the workspace AI Assistant setting is enabled. That setting powers the AI features built into Bytebase.
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

  1. 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.
  2. Check that the workspace access policy is not Disabled. A new workspace starts at Read-only.
  3. 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.
  4. Sign in to Bytebase in the browser window your AI tool opens, and click Allow access.
  5. Ask your AI tool something that only reads, such as “List all projects in my Bytebase instance”.
The setup guide has the steps for each tool, the other ways to set each one up, and troubleshooting. Once connected, your AI tool acts as you. It can do what both your Bytebase permissions and the access policy allow. To let it propose or make changes, switch the access policy to Read-write. Read Read-write changes first: an AI tool that cannot ask you for confirmation runs a write statement without asking.

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.
  1. Go to Integration > MCP.
  2. Under Access policy, click Edit policy.
  3. Select a mode and click Save policy.
Access policy section in edit mode When the policy refuses a call, the AI tool reports a message such as “Ask a workspace admin to raise the MCP ceiling in the workspace settings”. That setting is the access policy on the Integration > MCP page.
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 as SET 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) runs INSERT, UPDATE, DELETE, CREATE, ALTER, and DROP without an issue, within your permissions. This works on MySQL, PostgreSQL, Oracle, SQL Server, TiDB, Snowflake, Spanner, BigQuery, MongoDB, and Elasticsearch.
Before the query tool runs a statement Bytebase cannot show is a read, it asks you in your MCP client. This includes statements that return no data, such as 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.
A client that cannot show this form does not ask: under Read-write, the statement runs as soon as the AI tool sends it. To keep an AI tool from writing, leave the access policy at Read-only.
Exports run only statements Bytebase can show are reads. A statement that returns no data is refused, so name the schema in the export request instead of sending 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_grant tool 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, and appliedAccessGrant in 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_issue tool 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_access tool turns a project’s Allow access grants on or off. The grant_masking_exemption and revoke_masking_exemption tools 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.get permission, 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.
Approving, rejecting, changing the access-grant setting, and granting or revoking an exemption each take effect only after you confirm them in your MCP client: the AI tool shows a confirmation form, and nothing changes until you accept it. An answer expires after 10 minutes. A client that cannot show the form gets a 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, the administer_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.
Any job in the repository signs in as a workload identity created this way. It can create plans, releases, and rollouts in its project and run their tasks. Its rollouts carry no issue, so no approval rule holds them, and the MCP access policy does not limit it. It stays active until someone removes it in the console: an MCP session cannot change or remove a workload identity.
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.
An MCP session can read any saved query you can read in the console. Some roles can read every saved query in a project, such as Workspace Admin, Workspace DBA, and Project Owner. For them, this includes saved queries other people have not shared.

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, and BatchSyncDatabases).
  • Schema diffs (DiffSchema and DiffMetadata), 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.
The settings page and the authorization page sum this up in one line, “All operations executed via MCP will be recorded in the audit log.” The exceptions above still apply.
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.
  • mcp == true for the entries MCP produced, mcp == false for 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 /mcp HTTP endpoint. For an AI tool that can only start MCP servers as local commands, the @bytebase/bytebase-mcp npm 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.