bazel-mcp
Based on the provided schema, the server exposes MCP tools to inspect, query, build, and test Bazel targets.
Run
bazel_buildwith targets, optional Bazel flags, and timeout.Run
bazel_testwith structured test results, exit code, summary, stdout/stderr, and per-target status/logs/duration.Run arbitrary
bazel_queryexpressions with selectable output format.List targets matching package patterns (default
//...).Get dependencies up to a specified depth, excluding the target.
Get reverse dependencies within a scope, excluding the target.
Show a target's BUILD rule definition via
query --output=build.Read BUILD file contents for analysis.
Provides tools for interacting with the Bazel build system, enabling AI assistants to run queries, list targets, get dependencies, perform builds and tests, and analyze BUILD files.
Bazel MCP
A Model Context Protocol server that exposes Bazel build system capabilities to AI assistants.
Repo: github.com/saeid-rez/bazel-mcp
Tools
Tool | Description |
| Run arbitrary |
| Run configured |
| Run action |
| List targets in a package or subtree |
| Direct or transitive dependencies of a target |
| Reverse dependencies within a scope |
| Trace dependency chains ( |
| Rule definition via |
| Find targets affected by changed files |
| Run |
| Run |
| Run |
| Read BUILD file contents for analysis |
Related MCP server: mcp-cli-catalog
Usage
Requires uv. Configure the server with a Bazel workspace path if your MCP client does not start it from that workspace.
Antigravity (agy)
Add the following to ~/.gemini/config/mcp_config.json:
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/saeid-rez/bazel-mcp",
"bazel-mcp-server"
]
}
}
}Bazel commands run in your active workspace by default. If Antigravity does not start the server from your Bazel workspace, pass --workspace-root explicitly:
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/saeid-rez/bazel-mcp",
"bazel-mcp-server",
"--workspace-root",
"/path/to/your/bazel/workspace"
]
}
}
}OpenCode
Add the following to opencode.json or opencode.jsonc. Replace /path/to/your/bazel/workspace with the absolute path to your Bazel workspace.
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"bazel": {
"type": "local",
"command": [
"uvx",
"--from",
"git+https://github.com/saeid-rez/bazel-mcp",
"bazel-mcp-server",
"--workspace-root",
"/path/to/your/bazel/workspace"
],
"enabled": true
}
}
}GitHub Copilot CLI
Add the following to ~/.copilot/mcp-servers.json. Replace /path/to/your/bazel/workspace with the absolute path to your Bazel workspace.
{
"mcp": {
"servers": {
"bazel": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/saeid-rez/bazel-mcp",
"bazel-mcp-server",
"--workspace-root",
"/path/to/your/bazel/workspace"
],
"protocol": "stdio"
}
}
}
}Alternatively, run /mcp add bazel inside Copilot CLI and provide the same command and arguments.
Install With uv
To install the server persistently instead of running it from GitHub, run:
uv tool install bazel-mcp-serverThen use the following installed-server configuration in place of the GitHub-based command above. Include --workspace-root and its path when the client does not start the server from the Bazel workspace.
Antigravity (agy):
{
"mcpServers": {
"bazel": {
"command": "bazel-mcp-server",
"args": ["--workspace-root", "/path/to/your/bazel/workspace"]
}
}
}OpenCode:
{
"mcp": {
"bazel": {
"type": "local",
"command": ["bazel-mcp-server", "--workspace-root", "/path/to/your/bazel/workspace"],
"enabled": true
}
}
}GitHub Copilot CLI:
{
"mcp": {
"servers": {
"bazel": {
"command": "bazel-mcp-server",
"args": ["--workspace-root", "/path/to/your/bazel/workspace"],
"protocol": "stdio"
}
}
}
}Cursor
Add this to .cursor/mcp.json in the Bazel workspace.
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": ["--from", "git+https://github.com/saeid-rez/bazel-mcp", "bazel-mcp-server"]
}
}
}Bazel commands run in your open workspace by default.
If Cursor does not start the server from the Bazel workspace, pass the workspace explicitly:
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": [
"bazel-mcp-server",
"--workspace-root",
"/path/to/your/bazel/workspace"
]
}
}
}Other optional flags:
bazel-mcp-server --bazel-path bazelisk --timeout 600 --max-output-chars 64000Development
Clone the repo and run tests locally:
git clone https://github.com/saeid-rez/bazel-mcp
cd bazel-mcp
uv sync --group dev
uv run pytestAvailable Tools
8 toolsbazel_buildB
Run a Bazel build and return stdout, stderr, and exit code.
options are passed as extra bazel flags (e.g. --config=ci, -c opt).
Inputs: targets (required), options, timeout. Returns: result
bazel_queryARead-onlyIdempotent
Run an arbitrary Bazel query expression.
Query is read-only but can be expensive on broad patterns like //... output_format: label, build, xml, package, location, graph, etc.
Inputs: query (required), output_format. Returns: result
bazel_testB
Run Bazel tests and return structured pass/fail results with failure log excerpts.
Inputs: targets (required), options, timeout. Returns: exit_code, summary, targets, stdout, +1 more
explain_build_fileBRead-onlyIdempotent
Return BUILD file contents for analysis by the host LLM.
path is relative to the workspace root (e.g. foo/bar/BUILD or foo/bar).
Inputs: path (required). Returns: result
get_depsARead-onlyIdempotent
Get dependencies of a target up to the given depth, excluding the target itself.
Inputs: target (required), depth. Returns: result
get_rdepsARead-onlyIdempotent
Find reverse dependencies of a target within scope, excluding the target itself.
Inputs: target (required), scope. Returns: result
list_targetsARead-onlyIdempotent
List all targets matching a package pattern.
Default //... lists targets across the entire workspace (can be slow). For a single package use //pkg or pkg (normalized to //pkg:all). For a subtree use //pkg/...
Inputs: package. Returns: result
show_target_infoARead-onlyIdempotent
Show the BUILD rule definition for a target (bazel query --output=build).
Macro-generated targets may differ from on-disk BUILD files.
Inputs: target (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: build, test, query, file explanation, dependency queries, target listing, and target info. No overlap or ambiguity.
Three tools use the 'bazel_' prefix (bazel_build, bazel_test, bazel_query) while the rest use plain verb_noun (explain_build_file, get_deps, etc.). The inconsistency is noticeable but still readable.
8 tools is well-scoped for a Bazel MCP server, covering the essential operations without unnecessary bloat.
Core workflows (build, test, query, dependency analysis, file inspection) are covered. Minor gaps like 'bazel run' or 'clean' are missing but not critical.
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server exposing the Backtest360 engine API as tools for AI agents.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseAqualityDmaintenanceA local MCP server that exposes Bazel build system functionality to AI agents, allowing them to build, test, query, and manage Bazel projects through natural language even in environments where Bazel can't be directly accessed.69MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that publishes CLI tools on your machine for discoverability by LLMs7 npm1MIT
- AlicenseNot gradedqualityDmaintenanceThin MCP server wrapping the Gemini CLI for AI assistants, supporting workspace-aware multi-repository analysis and forward-compatible flags.105 PyPIMIT
- AlicenseNot gradedqualityCmaintenanceLocal-first MCP server that provides project context, verification gates, and structured tools for coding agents to discover knowledge, run diagnostics, and execute allowlisted commands within a repository.40 npmMIT