mcpField
B
Bazel Mcp

Bazel Mcp

Local
github.com/saeid-rezDeveloper Tools2Updated 6d ago

About Bazel Mcp

Bazel Mcp is a local MCP server that gives AI assistants access to Bazel workspace queries, build, test, and run operations. It is for developers working in Bazel repositories, with structured diagnostics for build and test failures.

Key features

  1. 01Run query, cquery, and aquery
  2. 02List targets and inspect dependencies
  3. 03Trace dependency paths and reverse dependencies
  4. 04Find targets affected by changed files
  5. 05Build, test, and run targets
  6. 06Read BUILD files

Use cases

  1. 01Explore targets in a Bazel workspace
  2. 02Trace a target's dependency chain
  3. 03Identify targets affected by code changes
  4. 04Run builds and tests with failure details

MCP support

Exposes Bazel workspace inspection and execution tools to MCP clients, including queries, target listing, dependency analysis, builds, tests, and runs. Commands operate in the active workspace by default, or can use an explicitly configured workspace root.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": [
"git+https://github.com/saeid-rez/bazel-mcp"
]
}
}
}
Run commanduvx 'git+https://github.com/saeid-rez/bazel-mcp'

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypigit+https://github.com/saeid-rez/bazel-mcp

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Bazel MCP

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

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

Tools

ToolDescription
bazel_queryRun arbitrary bazel query expressions
bazel_cqueryRun configured bazel cquery expressions (select() and platforms)
bazel_aqueryRun action bazel aquery expressions (compiler flags, commands)
list_targetsList targets in a package or subtree
get_depsDirect or transitive dependencies of a target
get_rdepsReverse dependencies within a scope
get_dependency_pathTrace dependency chains (somepath/allpaths) between targets
show_target_infoRule definition via query --output=build
find_affected_targetsFind targets affected by changed files
bazel_buildRun bazel build with structured failure diagnostics
bazel_testRun bazel test with structured target and failed-case results
bazel_runRun bazel run with arguments, environment variables, and working directory controls
explain_build_fileRead 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

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.