Bazel MCP Server

by nacgarg

9 stars
200 downloads
Not rated
GitHub

About

Exposes the Bazel build system to AI agents, enabling them to build, query, test, and manage dependencies.

Details

Author
nacgarg
GitHub stars
9
Downloads
200
Categories
Developer Tools, Infrastructure, Other

- Build specified Bazel targets
- Query the dependency graph for matching targets
- Run tests for specified targets
- List all available targets in the workspace
- Fetch external dependencies
- Change the Bazel workspace path at runtime
- Pass additional arguments to underlying Bazel commands

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Bazel MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install by adding a configuration entry to .cursor/mcp.json (for Cursor) or launching standalone with npx -y github:nacgarg/bazel-mcp-server. Configuration can be provided via CLI arguments, environment variables, or a configuration file. The AI agent can change the workspace path at runtime using the bazel_set_workspace_path tool.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "bazel mcp server": {
            "bazel-mcp-server": {
                "command": "npx",
                "args": [
                    "-y",
                    "github:nacgarg/bazel-mcp-server"
                ]
            }
        }
    }
}

McpServers

{
    "bazel-mcp-server": {
        "command": "npx",
        "args": [
            "-y",
            "github:nacgarg/bazel-mcp-server"
        ]
    }
}

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

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.