Skip to main content
Glama
Bytebase MCP

Bytebase MCP

Official

query_database

Executes SQL queries against a Bytebase database by auto-resolving the database name, with optional instance, project, schema, container, and row limit controls.

Instructions

Execute a SQL query against a Bytebase database. Resolves the database by name automatically.

Parameter

Required

Description

database

Yes

Database name or substring (e.g., "employee_db" or "employee")

statement

Yes

SQL query to execute

instance

No

Workspace instance ID/name, or the full canonical name for a project instance

project

No

Project name or ID to narrow resolution

schema

No

Default schema for unqualified names (Postgres search path). An access grant applies only when this equals the grant's schema

container

No

CosmosDB container (required for CosmosDB). An access grant applies only when this equals the grant's container

limit

No

Max rows (default: 100, max: 1000)

issueTitle

No

For a statement that may write: the issue's title if the user chooses Create an issue. The form shows it in that choice. Say what the change does, without data values. Without it, the form does not offer Create an issue

Examples: query_database(database="employee_db", statement="SELECT * FROM users LIMIT 10") query_database(database="employee", instance="prod-pg", statement="SELECT count() FROM orders") query_database(database="employee", instance="projects/hr/instances/prod-pg", statement="SELECT count() FROM orders") query_database(database="employee_db", statement="UPDATE employee SET active = false WHERE id = 42", issueTitle="Deactivate an employee")

Notes:

  • Show the user the statement each answer came from, so they can check it read what they asked about.

  • When the user asks for an issue or a review of a change, call propose_database_change instead. It takes no schema, so when the request named one, qualify each name with it.

  • Masked data: masking replaces a value fully (by default ""), partly (e.g. "rn"), or with a hash. maskedColumns in the result names each masked column and why (not reported for MongoDB, CosmosDB or Elasticsearch). A masked value is a placeholder, not a value anything holds, so never write it back and never filter on it. Any statement containing "" is refused. When showing a partly masked value, wrap it in backticks: "rn" renders as bold Markdown.

  • Seeing masked values: the user can ask a project owner for a masking exemption, or, if the project allows just-in-time access, request an access grant with Unmask for this exact statement, schema and container. In a Read-write session, file the request with request_access_grant; otherwise the user requests it in the SQL Editor. Once it is approved, find the grant among the user's access grants, then rerun the granted statement unchanged with the grant's schema and container. appliedAccessGrant in the result names the grant that applied.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "database": "<database>",
      "statement": "<statement>"
    },
    "name": "query_database"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
schemaNo
projectNo
databaseYes
instanceNo
containerNo
statementYes
issueTitleNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so well: it discloses the limit default and cap, that statements containing "******" are refused, how masking is rendered and how to display it safely, what appliedAccessGrant and maskedColumns mean in the result, and how issueTitle changes the form offered. It falls short of complete only because the write path is implied ("a statement that may write") rather than stated as a policy — it never says which write/DDL statements are permitted or what happens on approval.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Structure is strong — one-line purpose, parameter table, examples, then notes — and the purpose is front-loaded. The masking paragraph is dense and partly redundant with the later "Seeing masked values" paragraph, which makes it longer than strictly necessary, but nearly every sentence carries operational information an agent needs.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For an eight-parameter tool with no annotations and no output schema, the definition covers the missing pieces: parameter meanings, resolution rules, row limits, result fields (maskedColumns, appliedAccessGrant), and the escalation paths for unmasking. There is no output schema to lean on, yet the description still explains what the agent will see back and how to interpret it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate entirely, and it does with a full parameter table covering all eight parameters, including non-obvious semantics for schema (Postgres search path, grant-match condition), container (required for CosmosDB, grant-match condition), and issueTitle (omitting it removes the Create-an-issue option). Four worked examples further pin down instance formats and substring resolution.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives a specific verb and resource ("Execute a SQL query against a Bytebase database") plus a distinguishing behavior ("Resolves the database by name automatically"). The Notes section explicitly names the sibling it is not (propose_database_change) and the condition that selects that sibling, so an agent can route correctly without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It states when to use an alternative explicitly: "When the user asks for an issue or a review of a change, call propose_database_change instead," including the workaround for that tool's lack of a schema parameter. It also gives conditional guidance for masked values (ask a project owner, file request_access_grant in a Read-write session, otherwise use the SQL Editor) and for the issueTitle field.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.