Bazel MCP Server

MCP server for interacting with Bazel

Local serverstdio

What is the Bazel MCP server?

If you already use Bazel, the bazel mcp server is the piece that lets your assistant work with it directly. MCP server for interacting with Bazel.

What the server does

A local MCP server that exposes functionality of the Bazel build system to MCP-enabled AI agents.

Installation

The server ships on npm as github, so your MCP client can launch it on demand — there is no separate build step. Add the server block to your client's configuration, restart it, and the tools register themselves.

Available tools

The toolset is worth reading before you wire it up, because it tells you what the integration is really for:

  • 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
  • Installation — The Installation tool exposed by this server
  • Configuration — This MCP server allows a couple different configuration methods. They will be used in the following order:

Credentials and setup notes

Configuration is passed through the environment: MCP_BAZEL_PATH, MCP_WORKSPACE_PATH, MCP_LOG_PATH. Treat anything key-shaped as a real credential — scope it to the minimum the server needs, and rotate it if it ever lands in a shared config.

Worth knowing first

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • Keep per-call confirmation enabled while you learn its behaviour; it is the cheapest safeguard you have.

Where it fits

This sits in the developer tooling group, where several servers overlap in what they claim to do but differ sharply once you actually set them up. Bazel's toolset — bazel_build_target, bazel_query_target, bazel_test_target and 5 more — is a fair guide to whether it matches your workflow. It is maintained by nacgarg; worth a glance at recent repository activity before you build anything load-bearing on it.

This entry was verified against Bazel's own documentation before publication; SyncDev keeps the directory reviewed rather than auto-generated.

Available tools

ToolWhat it does
bazel_build_targetBuild specified Bazel targets
bazel_query_targetQuery the dependency graph for targets matching a pattern
bazel_test_targetRun tests for specified targets
bazel_list_targetsList all available targets in the workspace (requires path parameter, use "//" for all targets)
bazel_fetch_dependenciesFetch external dependencies
bazel_set_workspace_pathChange the Bazel workspace path at runtime
InstallationThe Installation tool exposed by this server.
ConfigurationThis MCP server allows a couple different configuration methods. They will be used in the following order:

How to install the Bazel MCP server

{
  "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
      ]
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

VariableDescriptionRequired
MCP_BAZEL_PATHFilesystem location the server is allowed to use.Optional
MCP_WORKSPACE_PATHFilesystem location the server is allowed to use.Optional
MCP_LOG_PATHFilesystem location the server is allowed to use.Optional

Example prompts to try

  • Use Bazel to bazel build target.
  • Use Bazel to bazel query target.
  • Use Bazel to bazel test target.

Frequently asked questions

It connects Bazel to MCP-compatible AI assistants such as Claude and Cursor, exposing 8 tools (bazel_build_target, bazel_query_target, bazel_test_target, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Bazel directly.