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
bazel_cquery Run configured bazel cquery expressions (select() and platforms)
bazel_aquery Run action bazel aquery expressions (compiler flags, commands)
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
get_dependency_path Trace dependency chains (somepath/allpaths) between targets
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
bazel_run Run bazel run with arguments, environment variables, and working directory controls
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

Metadata

Release files for bazel-mcp-server 0.1.6

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.6
File Size Uploaded Provenance Actions
bazel_mcp_server-0.1.6.tar.gz 81.6 kB Without provenance Details for bazel_mcp_server-0.1.6.tar.gz

Built distribution (wheel)

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

Total release size: 100.7 kB

Release files / bazel_mcp_server-0.1.6.tar.gz

Download URL bazel_mcp_server-0.1.6.tar.gz
Size 81.6 kB
Tags Source
SHA-256 checksum
How to use checksums
46ab26ff8f0b4b0d6e2dd8cecbe0e0f8edbc241b341b8080fa5f9d7aaac03fea
BLAKE2b-256 checksum
How to use checksums
3b46b09b615bbe4a3458984665258df37a2a2eb663c5236a1e2a29f0813d2c16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.6-py3-none-any.whl

Download URL bazel_mcp_server-0.1.6-py3-none-any.whl
Size 19.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c14fce1aaf9578a5e116fb9a77a70e177c0307127b32cb400cae74311ae63840
BLAKE2b-256 checksum
How to use checksums
0de659d25966a11c0a74f5e1c2e84558f5e3c6b32cbcb5545b97c4d27c62ab73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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}

Security for bazel-mcp-server 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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