mcpField
B
Bazel MCP Server

Bazel MCP Server

Local
github.com/nacgargDeveloper Tools9Updated 86w ago

About Bazel MCP Server

A local MCP server that exposes Bazel build-system operations to MCP agents, including cases where command-line tools are unavailable or the shell environment is misconfigured. It can build targets, inspect dependencies, and run tests.

Key features

  1. 01Build specified Bazel targets
  2. 02Query target dependency graphs
  3. 03Run target tests
  4. 04List workspace targets
  5. 05Fetch dependencies and change workspace path

Use cases

  1. 01Trigger Bazel builds through an agent
  2. 02Inspect target dependencies
  3. 03Run Bazel tests
  4. 04Switch workspaces at runtime

MCP support

The local MCP server exposes tools for Bazel builds, queries, tests, target listing, dependency fetching, and workspace path configuration to MCP agents.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"bazel": {
"command": "npx",
"args": [
"-y",
"github:nacgarg/bazel-mcp-server"
]
}
}
}
Run commandnpx -y github:nacgarg/bazel-mcp-server

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmgithub:nacgarg/bazel-mcp-server

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

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.

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.js
Configuration

This MCP server allows a couple different configuration methods. They will be used in the following order:

  1. Command line arguments
  2. Environment variables
  3. Configuration file
Configuration Table
CLI ArgumentEnvironment VariableConfiguration File KeyDescription
--bazel_pathMCP_BAZEL_PATHbazel_pathThe path to the Bazel binary to use.
--workspace_pathMCP_WORKSPACE_PATHworkspace_pathThe path to the Bazel workspace to use.
--workspace_configMCP_WORKSPACE_CONFIGworkspace_configThe configuration of the workspace to use. By default, this uses the .bazelrc file in the workspace root.
--log_pathMCP_LOG_PATHlog_pathThe 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.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.