Bazel

MCP server for Bazel
  • javascript

9

GitHub Stars

javascript

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "nacgarg-bazel-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "github:nacgarg/bazel-mcp-server",
        "--bazel_path",
        "/absolute/path/to/your/bazel/binary",
        "--workspace_path",
        "/absolute/path/to/your/bazel/workspace"
      ],
      "env": {
        "MCP_LOG_PATH": "<log path>",
        "MCP_BAZEL_PATH": "<path to bazel binary>",
        "MCP_WORKSPACE_PATH": "<path to workspace>",
        "MCP_WORKSPACE_CONFIG": "<workspace config>"
      }
    }
  }
}

The Bazel MCP Server exposes Bazel build and workspace actions to MCP-enabled AI agents, enabling you to run builds, query dependencies, fetch sources, and manage workspaces even when the local shell environment isn’t conducive to running Bazel directly.

How to use

You interact with the Bazel MCP Server through an MCP client. Start the server as a local process and pass the appropriate commands to invoke Bazel actions. Use the provided tools to build targets, query graphs, run tests, list targets, fetch dependencies, and switch workspaces. You can also customize the runtime via optional arguments to tailor behavior such as verbose failure output or test result streams.

How to install

Prerequisites you need on your machine:

  • Node.js (version 12+ recommended) and npm.

Follow one of these installation paths.

Install path A: Using npx to run directly

npx -y github:nacgarg/bazel-mcp-server

This runs the MCP server directly from the hosting source without a local install.

## Install path B: Local install and build

If you prefer to install locally and build, use these steps.

git clone https://github.com/nacgarg/bazel-mcp-server.git cd bazel-mcp-server npm install npm run build dist/index.js


This compiles the server and starts from the built distribution.

MCP server configuration and startup

Configure the server by using the provided MCP JSON configuration. You can specify the MCP server as a stdio process started by npm/npx, including optional paths to the Bazel binary and workspace. The server is designed to be used from local environments and supports runtime workspace changes.

{
  "mcpServers": {
    "bazel": {
      "command": "npx",
      "args": [
        "-y",
        "github:nacgarg/bazel-mcp-server",
        "--bazel_path",
        "/absolute/path/to/your/bazel/binary",
        "--workspace_path",
        "/absolute/path/to/your/bazel/workspace"
      ]
    }
  }
}

This configuration uses a local MCP server process with the Bazel MCP Server package and passes the Bazel binary path and workspace path at runtime.

## Additional startup notes

If you encounter environment-related issues, you can set a configuration for the Bazel path and workspace via command-line arguments or environment variables when launching the server. You can enable verbose logging for debugging by setting the DEBUG environment variable to true and direct logs to a file if necessary.

## Additional sections

Configuration options are applied in this order: command-line arguments, environment variables, then a configuration file. You can adjust the Bazel binary path, the workspace path, the workspace configuration file, and the log path. The configuration table below summarizes the options.

## Notes on usage patterns

- Use the stdio mode when you want to run the server locally with a direct command and pass additional arguments to Bazel as needed. - Use the http/remote mode if you have a remote MCP server URL to connect to instead of running locally.

## Available tools

### bazel\_build\_target

Build specified Bazel targets using the MCP interface to trigger builds and report results.

### bazel\_query\_target

Query the Bazel dependency graph for targets matching a pattern to understand relationships and dependencies.

### bazel\_test\_target

Run tests for specified Bazel targets and collect test results.

### bazel\_list\_targets

List all targets in the workspace, requiring a path parameter; use "//" for all targets.

### bazel\_fetch\_dependencies

Fetch external dependencies declared in the workspace to ensure a successful build.

### bazel\_set\_workspace\_path

Change the Bazel workspace path at runtime to switch contexts without restarting the server.
Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational