Bazel MCP Server
by nacgarg
A local MCP server that exposes Bazel build system functionality to MCP-enabled AI agents. It's helpful when MCP environments lack command-line tools or have misconfigured environments preventing Bazel usage.
Last updated: N/A
What is Bazel MCP Server?
The Bazel MCP Server is a local server that allows MCP-enabled AI agents to interact with the Bazel build system. It provides tools to build, query, test, and list Bazel targets, as well as fetch dependencies and manage the workspace path.
How to use Bazel MCP Server?
The server can be installed and run using npx
directly from GitHub, or by cloning the repository and running it from source. Configuration can be done via command-line arguments, environment variables, or a configuration file. The server is compatible with Cursor and Claude Desktop.
Key features of Bazel MCP Server
Build specified Bazel targets
Query the dependency graph for targets
Run tests for specified targets
List all available targets in the workspace
Fetch external dependencies
Change the Bazel workspace path at runtime
Supports additional arguments for Bazel commands
Use cases of Bazel MCP Server
Automating Bazel builds in AI-driven development environments
Integrating Bazel with AI agents for code analysis and modification
Providing a consistent Bazel environment across different MCP setups
Enabling AI agents to explore and understand Bazel projects
FAQ from Bazel MCP Server
How do I specify the Bazel binary path?
How do I specify the Bazel binary path?
Use the --bazel_path
command-line argument, the MCP_BAZEL_PATH
environment variable, or the bazel_path
configuration file key.
How do I specify the Bazel workspace path?
How do I specify the Bazel workspace path?
Use the --workspace_path
command-line argument, the MCP_WORKSPACE_PATH
environment variable, or the workspace_path
configuration file key. Alternatively, the LLM can use set_workspace_path
to change the workspace path at runtime.
How do I pass additional arguments to Bazel commands?
How do I pass additional arguments to Bazel commands?
Use the additionalArgs
parameter with each command (except bazel_set_workspace_path
).
How do I enable verbose logging?
How do I enable verbose logging?
Set the DEBUG=true
environment variable.
How do I specify the workspace configuration?
How do I specify the workspace configuration?
Use the --workspace_config
command-line argument, the MCP_WORKSPACE_CONFIG
environment variable, or the workspace_config
configuration file key. By default, this uses the .bazelrc
file in the workspace root.