Skip to main content

Bazel MCP

A Model Context Protocol server that exposes Bazel build system capabilities to AI assistants.

Repo: github.com/saeid-rez/bazel-mcp

Tools

Tool Description
bazel_query Run arbitrary bazel query expressions
list_targets List targets in a package or subtree
get_deps Direct or transitive dependencies of a target
get_rdeps Reverse dependencies within a scope
show_target_info Rule definition via query --output=build
find_affected_targets Find targets affected by changed files
bazel_build Run bazel build with structured failure diagnostics
bazel_test Run bazel test with structured target and failed-case results
explain_build_file Read BUILD file contents for analysis

Usage

Requires uv. Configure the server with a Bazel workspace path if your MCP client does not start it from that workspace.

Antigravity (agy)

Add the following to ~/.gemini/config/mcp_config.json:

{
  "mcpServers": {
    "bazel": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/saeid-rez/bazel-mcp",
        "bazel-mcp-server"
      ]
    }
  }
}

Bazel commands run in your active workspace by default. If Antigravity does not start the server from your Bazel workspace, pass --workspace-root explicitly:

{
  "mcpServers": {
    "bazel": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/saeid-rez/bazel-mcp",
        "bazel-mcp-server",
        "--workspace-root",
        "/path/to/your/bazel/workspace"
      ]
    }
  }
}

OpenCode

Add the following to opencode.json or opencode.jsonc. Replace /path/to/your/bazel/workspace with the absolute path to your Bazel workspace.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "bazel": {
      "type": "local",
      "command": [
        "uvx",
        "--from",
        "git+https://github.com/saeid-rez/bazel-mcp",
        "bazel-mcp-server",
        "--workspace-root",
        "/path/to/your/bazel/workspace"
      ],
      "enabled": true
    }
  }
}

GitHub Copilot CLI

Add the following to ~/.copilot/mcp-servers.json. Replace /path/to/your/bazel/workspace with the absolute path to your Bazel workspace.

{
  "mcp": {
    "servers": {
      "bazel": {
        "command": "uvx",
        "args": [
          "--from",
          "git+https://github.com/saeid-rez/bazel-mcp",
          "bazel-mcp-server",
          "--workspace-root",
          "/path/to/your/bazel/workspace"
        ],
        "protocol": "stdio"
      }
    }
  }
}

Alternatively, run /mcp add bazel inside Copilot CLI and provide the same command and arguments.

Install With uv

To install the server persistently instead of running it from GitHub, run:

uv tool install bazel-mcp-server

Then use the following installed-server configuration in place of the GitHub-based command above. Include --workspace-root and its path when the client does not start the server from the Bazel workspace.

Antigravity (agy):

{
  "mcpServers": {
    "bazel": {
      "command": "bazel-mcp-server",
      "args": ["--workspace-root", "/path/to/your/bazel/workspace"]
    }
  }
}

OpenCode:

{
  "mcp": {
    "bazel": {
      "type": "local",
      "command": ["bazel-mcp-server", "--workspace-root", "/path/to/your/bazel/workspace"],
      "enabled": true
    }
  }
}

GitHub Copilot CLI:

{
  "mcp": {
    "servers": {
      "bazel": {
        "command": "bazel-mcp-server",
        "args": ["--workspace-root", "/path/to/your/bazel/workspace"],
        "protocol": "stdio"
      }
    }
  }
}

Cursor

Add this to .cursor/mcp.json in the Bazel workspace.

{
  "mcpServers": {
    "bazel": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/saeid-rez/bazel-mcp", "bazel-mcp-server"]
    }
  }
}

Bazel commands run in your open workspace by default.

If Cursor does not start the server from the Bazel workspace, pass the workspace explicitly:

{
  "mcpServers": {
    "bazel": {
      "command": "uvx",
      "args": [
        "bazel-mcp-server",
        "--workspace-root",
        "/path/to/your/bazel/workspace"
      ]
    }
  }
}

Other optional flags:

bazel-mcp-server --bazel-path bazelisk --timeout 600 --max-output-chars 64000

Development

Clone the repo and run tests locally:

git clone https://github.com/saeid-rez/bazel-mcp
cd bazel-mcp
uv sync --group dev
uv run pytest

Release files for bazel-mcp-server 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bazel-mcp-server 0.1.3
File Size Uploaded
bazel_mcp_server-0.1.3.tar.gz 76.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bazel-mcp-server 0.1.3
File Interpreter ABI Platform
bazel_mcp_server-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 92.9 kB

Release files / bazel_mcp_server-0.1.3.tar.gz

Download URL bazel_mcp_server-0.1.3.tar.gz
Size 76.7 kB
Tags Source
SHA-256 checksum
How to use checksums
90811e45904d9ca9cb01de19e5ddbb59d6315b30e203b321875ca227cd88d9fb
BLAKE2b-256 checksum
How to use checksums
829cdcf2e86afaf5db76cfefb65d8478c468bc254e82204d1865a4bbe3c95220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / bazel_mcp_server-0.1.3-py3-none-any.whl

Download URL bazel_mcp_server-0.1.3-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
927833f5dba138fdb8df7bbfea6d6b94e35290acf0be2cd1bdd6b8d6c28ed942
BLAKE2b-256 checksum
How to use checksums
4892c5fe82958db6fc0c3dbccb94f41a6f99e9a19ea9deb1e3a20a9ccc9e317a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page