YDB MCP
OfficialThis server lets you interact with a YDB database through MCP tools for querying, explaining, inspecting schema/directory, and checking status.
ydb_query: Run a SQL query against YDB.
ydb_query_with_params: Run a parameterized SQL query with JSON parameters.
ydb_explain_query: Retrieve the execution plan for a SQL query.
ydb_explain_query_with_params: Retrieve the execution plan for a parameterized SQL query.
ydb_list_directory: List the contents of a YDB directory.
ydb_describe_path: Get detailed information about a YDB path, such as a table or directory.
ydb_status: Get the current status of the YDB connection.
By default, operations run in read-only mode; writes can be explicitly enabled if configured.
Mentioned as part of the uvx tool, which is described as 'an alias for uv run tool' from astral.sh for running Python applications without explicitly installing them
Used as the primary development tool, providing commands for development tasks
Used as a deployment method for running the MCP server without explicit installation
Hosts the ydb-mcp package that can be installed via pip
Used for running tests in the development workflow
Serves as the runtime environment for the MCP server, with commands referencing Python's interpreter for executing the server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@YDB MCP show me the top 5 customers by total orders"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
YDB MCP
Model Context Protocol server for YDB. It allows to work with YDB databases from any LLM that supports MCP. This integration enables AI-powered database operations and natural language interactions with your YDB instances.
Usage
Via uvx
uvx, which is an allias for uv run tool, allows you to run various python applications without explicitly installing them. Below are examples of how to configure YDB MCP using uvx.
Example: Using Anonymous Authentication
{
"mcpServers": {
"ydb": {
"command": "uvx",
"args": [
"ydb-mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local"
]
}
}
}Via pipx
pipx allows you to run various applications from PyPI without explicitly installing each one. However, it must be installed first. Below are examples of how to configure YDB MCP using pipx.
Example: Using Anonymous Authentication
{
"mcpServers": {
"ydb": {
"command": "pipx",
"args": [
"run", "ydb-mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local"
]
}
}
}Via pip
YDB MCP can be installed using pip, Python's package installer. The package is available on PyPI and includes all necessary dependencies.
pip install ydb-mcpTo get started with YDB MCP, you'll need to configure your MCP client to communicate with the YDB instance. Below are example configuration files that you can customize according to your setup and then put into MCP client's settings. Path to the Python interpreter might also need to be adjusted to the correct virtual environment that has the ydb-mcp package installed.
Example: Using Anonymous Authentication
{
"mcpServers": {
"ydb": {
"command": "python3",
"args": [
"-m", "ydb_mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local"
]
}
}
}Authentication
Regardless of the usage method (uvx, pipx or pip), you can configure authentication for your YDB installation. To do this, pass special command line arguments.
Using Login/Password Authentication
To use login/password authentication, specify the --ydb-auth-mode, --ydb-login, and --ydb-password arguments:
{
"mcpServers": {
"ydb": {
"command": "uvx",
"args": [
"ydb-mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local",
"--ydb-auth-mode", "login-password",
"--ydb-login", "<your-username>",
"--ydb-password", "<your-password>"
]
}
}
}Using Access Token Authentication
To use access token authentication, specify the --ydb-auth-mode and --ydb-access-token arguments:
{
"mcpServers": {
"ydb": {
"command": "uvx",
"args": [
"ydb-mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local",
"--ydb-auth-mode", "access-token",
"--ydb-access-token", "qwerty123"
]
}
}
}Using Service Account Authentication
Service account authentication requires the yandexcloud package, which is not installed by default. Make sure it is available in the environment that runs YDB MCP:
uvx: add it on the fly with
--with yandexcloud(passed beforeydb-mcp).pipx: install YDB MCP with the extra package using
pipx install ydb-mcpfollowed bypipx inject ydb-mcp yandexcloud.pip: install it alongside YDB MCP with
pip install ydb-mcp yandexcloud.
To use service account authentication, specify the --ydb-auth-mode and --ydb-sa-key-file arguments:
{
"mcpServers": {
"ydb": {
"command": "uvx",
"args": [
"--with", "yandexcloud",
"ydb-mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local",
"--ydb-auth-mode", "service-account",
"--ydb-sa-key-file", "~/sa_key.json"
]
}
}
}TLS Connections
Use a grpcs:// endpoint to connect over TLS. If the cluster certificate is issued by a private CA, pass a path to the PEM file with its root certificates via --ydb-root-certificates; otherwise the system trust store is used:
{
"mcpServers": {
"ydb": {
"command": "uvx",
"args": [
"ydb-mcp",
"--ydb-endpoint", "grpcs://localhost:2135",
"--ydb-database", "/local",
"--ydb-root-certificates", "~/ydb_ca.pem"
]
}
}
}Write Queries
The server runs queries in read-only mode by default. Read-only queries use native YDB snapshot read-only transactions,
so data and schema writes are rejected by YDB itself without relying on SQL text matching. The mode applies to both
built-in query tools and custom tools that call YDBMCPServer.execute().
To explicitly allow write queries, set --ydb-allow-write:
{
"mcpServers": {
"ydb": {
"command": "uvx",
"args": [
"ydb-mcp",
"--ydb-endpoint", "grpc://localhost:2136",
"--ydb-database", "/local",
"--ydb-allow-write"
]
}
}
}The same setting can be provided through YDB_ALLOW_WRITE=true. Enable it only when writes are intended, and
prefer read-only YDB credentials as an additional permission boundary whenever the server does not need to modify data.
Related MCP server: GreptimeDB MCP Server
Available Tools
YDB MCP provides the following tools for interacting with YDB databases:
ydb_query: Run a SQL query against a YDB databaseParameters:
sql: SQL query string to execute
ydb_query_with_params: Run a parameterized SQL query with JSON parametersParameters:
sql: SQL query string with parameter placeholdersparams: JSON string containing parameter values
ydb_explain_query: Explain a SQL query (returns the execution plan)Parameters:
sql: SQL query string to explain
ydb_explain_query_with_params: Explain a parameterized SQL queryParameters:
sql: SQL query string with parameter placeholdersparams: JSON string containing parameter values
ydb_list_directory: List directory contents in YDBParameters:
path: YDB directory path to list
ydb_describe_path: Get detailed information about a YDB path (table, directory, etc.)Parameters:
path: YDB path to describe
ydb_status: Get the current status of the YDB connection
Building Custom MCP Servers
YDBMCPServer is designed to be subclassed. You can add your own tools on top of an established YDB connection and, optionally, disable the built-in generic tools to expose only the queries your application needs.
Why build a custom server?
Security — restrict the LLM to a fixed set of read-only queries instead of exposing arbitrary SQL execution.
Domain specificity — give the model tools that match your business logic rather than raw database primitives.
Simplicity — fewer tools means less ambiguity for the model.
Available methods
Override or call these in your subclass:
Method | Description |
| Run a SQL query. Returns |
| Return the query execution plan as a |
| List a YDB directory. Returns |
| Describe a YDB path (table schema, directory, etc.). Returns a |
The params argument is a plain dict. Keys without a $ prefix get it added automatically. To specify an explicit YDB type, use a (value, "TypeName") tuple — e.g. {"id": (42, "Int64")}.
Controlling generic tools
Use the generic_tools class attribute to control which built-in tools are registered:
Value | Effect |
| All built-in tools (default) |
| No built-in tools — only your own |
| Only the listed tools |
YDBGenericTool is a string enum — available values: QUERY, QUERY_WITH_PARAMS, EXPLAIN, EXPLAIN_WITH_PARAMS, STATUS, LIST_DIRECTORY, DESCRIBE_PATH.
Example
# my_server.py
from ydb_mcp import YDBMCPServer, YDBGenericTool, serialize_ydb_response
class OrdersServer(YDBMCPServer):
"""Minimal read-only MCP server for the orders service."""
generic_tools = {YDBGenericTool.STATUS} # keep status check for diagnostics
def __init__(self, **kwargs):
super().__init__(**kwargs)
@self.tool()
async def get_order(order_id: str) -> str:
"""Fetch a single order by ID."""
rows = await self.execute(
"SELECT * FROM orders WHERE id = $id",
{"id": order_id},
)
return serialize_ydb_response(rows)
@self.tool()
async def list_recent_orders(limit: int = 10) -> str:
"""Return the most recent orders."""
rows = await self.execute(
"SELECT * FROM orders ORDER BY created_at DESC LIMIT $limit",
{"limit": limit},
)
return serialize_ydb_response(rows)
if __name__ == "__main__":
OrdersServer(
endpoint="grpc://localhost:2136",
database="/local",
).run()Run it directly:
python my_server.pyOr wire it up as an MCP server in your client config:
{
"mcpServers": {
"orders": {
"command": "python",
"args": ["my_server.py"]
}
}
}Development
The project uses Make as its primary development tool, providing a consistent interface for common development tasks.
Available Make Commands
The project includes a comprehensive Makefile with various commands for development tasks. Each command is designed to streamline the development workflow and ensure code quality:
make all: Run clean, lint, and test in sequence (default target)make clean: Remove all build artifacts and temporary filesmake test: Run all tests using pytestCan be configured with environment variables:
LOG_LEVEL(default: WARNING) - Control test output verbosity (DEBUG, INFO, WARNING, ERROR)
make unit-tests: Run only unit tests with verbose outputCan be configured with environment variables:
LOG_LEVEL(default: WARNING) - Control test output verbosity (DEBUG, INFO, WARNING, ERROR)
make integration-tests: Run only integration tests with verbose outputCan be configured with environment variables:
YDB_ENDPOINT(default: grpc://localhost:2136)YDB_DATABASE(default: /local)MCP_HOST(default: 127.0.0.1)MCP_PORT(default: 8989)LOG_LEVEL(default: WARNING) - Control test output verbosity (DEBUG, INFO, WARNING, ERROR)
make run-server: Start the YDB MCP serverCan be configured with environment variables:
YDB_ENDPOINT(default: grpc://localhost:2136)YDB_DATABASE(default: /local)
Additional arguments can be passed using
ARGS="your args"
make lint: Run all linting checks (flake8, mypy, black, isort)make format: Format code using black and isortmake install: Install the package in development modemake dev: Install the package in development mode with all development dependencies
Test Verbosity Control
By default, tests run with minimal output (WARNING level) to keep the output clean. You can control the verbosity of test output using the LOG_LEVEL environment variable:
# Run all tests with debug output
make test LOG_LEVEL=DEBUG
# Run integration tests with info output
make integration-tests LOG_LEVEL=INFO
# Run unit tests with warning output (default)
make unit-tests LOG_LEVEL=WARNINGAvailable log levels:
DEBUG: Show all debug messages, useful for detailed test flowINFO: Show informational messages and aboveWARNING: Show only warnings and errors (default)ERROR: Show only error messages
Available Tools
7 toolsydb_describe_pathC
Get detailed information about a YDB path
Inputs: path (required). Returns: result
ydb_explain_queryC
Explain a SQL query against YDB
Inputs: sql (required). Returns: result
ydb_explain_query_with_paramsC
Explain a parameterized SQL query against YDB
Inputs: sql (required), params (required). Returns: result
ydb_list_directoryC
List directory contents in YDB
Inputs: path (required). Returns: result
ydb_queryB
Run a read-only SQL query against YDB database
Inputs: sql (required). Returns: result
ydb_query_with_paramsC
Run a read-only parameterized SQL query with JSON parameters
Inputs: sql (required), params (required). Returns: result
ydb_statusA
Get the current YDB connection status
Inputs: no named parameters. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool targets a clearly distinct purpose: executing vs explaining queries, with vs without parameters, and separate tools for status, directory listing, and path details. No two tools are ambiguous or likely to be confused during selection.
All tools share the ydb_ prefix, and most follow a verb_noun pattern (list_directory, describe_path) with a consistent with_params modifier. Minor deviations like the noun-only ydb_status and ydb_query are still predictable and do not hinder readability.
Seven tools is well-scoped for a database server focused on read-only operations, covering queries, explanations, status, and structural navigation without overflow or sparse coverage.
The server's read-only scope is fully covered: plain and parameterized queries, explain plans for both, connection status, and directory/path inspection. No obvious missing operations are needed for the intended use case.
Maintenance
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
MCP server for AI dialogue using various LLM models via AceDataCloud
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables Large Language Models to seamlessly interact with ClickHouse databases, supporting resource listing, schema retrieval, and query execution.2MIT
- AlicenseAqualityBmaintenanceA Model Context Protocol server implementation that enables AI assistants to securely interact with GreptimeDB, allowing them to explore database schema, read data, and execute SQL queries through a controlled interface.1529MIT
- AlicenseAqualityCmaintenanceA Model Context Protocol server that enables large language models to access database metadata and perform cross-engine data querying across diverse database ecosystems.1654Apache 2.0
- AlicenseNot gradedqualityCmaintenanceMCP server for PostgreSQL, MySQL, and SQLite that gives AI assistants secure database access via the Model Context Protocol.47 npm5MIT