Bazel MCP Server
Exposes Bazel build system functionality, allowing for building targets, querying dependency graphs, running tests, listing available targets, fetching external dependencies, and setting the workspace path at runtime.
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., "@Bazel MCP Server build the //src/main:app target with verbose failures"
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.
Bazel MCP Server
A local MCP server that exposes functionality of the Bazel build system to MCP-enabled AI agents.
This is helpful when MCP environments either don't have an existing command-line tool, or where the invoked shell has a misconfigured environment that prevents Bazel from being used.
Tools
The Bazel MCP Server provides the following tools:
bazel_build_target: Build specified Bazel targets
bazel_query_target: Query the dependency graph for targets matching a pattern
bazel_test_target: Run tests for specified targets
bazel_list_targets: List all available targets in the workspace (requires path parameter, use "//" for all targets)
bazel_fetch_dependencies: Fetch external dependencies
bazel_set_workspace_path: Change the Bazel workspace path at runtime
Each command (except bazel_set_workspace_path) supports an optional additionalArgs parameter that allows passing additional arguments to the underlying Bazel command. This is useful for specifying flags like --verbose_failures or --test_output=all.
Related MCP server: bazel-mcp
Usage
Installation
Using with Cursor
Add the following to .cursor/mcp.json.
You don't need to provide the workspace path, as the LLM can use set_workspace_path to change the workspace path at runtime.
The bazel binary usually gets picked up automatically, but if you run into issues, you can provide the path to the bazel binary using the --bazel_path flag.
:warning: Note that this will not work when using Cursor with Remote SSH sessions, since it runs the MCP server locally.
{
"mcpServers": {
"bazel": {
"command": "npx",
"args": [
"-y",
"github:nacgarg/bazel-mcp-server",
// If you need to specify the bazel binary path
"--bazel_path",
"/absolute/path/to/your/bazel/binary",
// If you need to specify the workspace path
"--workspace_path",
"/absolute/path/to/your/bazel/workspace"
// See Configuration Table below for more options
]
}
}
}Using with Claude Desktop
You can use the same configuration as above with Claude Desktop.
Launching standalone
# Run directly from GitHub (no installation needed)
npx -y github:nacgarg/bazel-mcp-server
# From source
git clone https://github.com/nacgarg/bazel-mcp-server.git
cd bazel-mcp-server
npm install
npm run build
dist/index.jsConfiguration
This MCP server allows a couple different configuration methods. They will be used in the following order:
Command line arguments
Environment variables
Configuration file
Configuration Table
CLI Argument | Environment Variable | Configuration File Key | Description |
|
|
| The path to the Bazel binary to use. |
|
|
| The path to the Bazel workspace to use. |
|
|
| The configuration of the workspace to use. By default, this uses the |
|
|
| The path to write server logs to. |
Debugging
Set the DEBUG=true environment variable to enable verbose logging to the console.
Setting the log path is also helpful for debugging with clients that don't print logs to the console (looking at you, Cursor).
License
This project is licensed under the MIT License. See the LICENSE file for details.
Available Tools
6 toolsbazel_build_targetC
Build specified Bazel targets
Inputs: targets (required), additionalArgs.
bazel_fetch_dependenciesB
Fetch Bazel external dependencies
Inputs: targets, additionalArgs.
bazel_list_targetsB
List all available Bazel targets under a given path
Inputs: path (required), additionalArgs.
bazel_query_targetA
Query the Bazel dependency graph for targets matching a pattern
Inputs: pattern (required), additionalArgs.
bazel_set_workspace_pathB
Set the current Bazel workspace path for subsequent commands
Inputs: path (required).
bazel_test_targetC
Run Bazel tests for specified targets
Inputs: targets (required), additionalArgs.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose with no ambiguity: building, fetching dependencies, listing targets, querying the dependency graph, setting workspace path, and testing. The descriptions clearly differentiate their functions, making misselection unlikely.
All tools follow a consistent 'bazel_verb_noun' pattern (e.g., bazel_build_target, bazel_fetch_dependencies), using snake_case throughout. This predictable naming makes the tool set easy to navigate and understand.
With 6 tools, this server is well-scoped for Bazel operations, covering core workflows like building, testing, querying, and workspace management. Each tool earns its place without feeling excessive or insufficient for the domain.
The tool set provides strong coverage for essential Bazel tasks, including build, test, query, and dependency management. A minor gap exists in operations like cleaning or caching, but agents can work around this with the available tools for most common workflows.
Maintenance
Related MCP Connectors
MCP server for building and testing AI agents with multi-model experimentation and insights.
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
MCP server that lets your AI assistant build and deploy apps, hosting each one at a live URL.
The Buildkite MCP server exposes Buildkite product data (pipelines, builds, jobs, and test data) to AI tools, editors, and agents through the Model Context Protocol. It provides capabilities including pipeline creation and management, build monitoring with specialized tools like 'wait_for_build', efficient log querying using Apache Parquet conversion and caching, and OAuth-based authentication for both read-write and read-only access to Buildkite's REST API.
Related MCP Servers
- AlicenseBqualityDmaintenanceA local-first MCP server that provides AI agents with safe codebase access through file discovery, hybrid lexical-semantic search, and project introspection. It features durable local memory and semantic indexing while keeping all data and processing entirely on your local machine.7427 npm6MIT
- AlicenseAqualityBmaintenanceA local MCP server that exposes Bazel build system capabilities to AI assistants.82MIT
- AlicenseNot gradedqualityDmaintenanceA lightweight build daemon that exposes project build flows as MCP tools, enabling AI assistants to drive builds, check status, and react to results.MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that allows AI agents to manage BuildBase resources (users, workspaces, subscriptions, projects) via 48 tools, with built-in agent authentication and discovery.MIT