Overview
What is Bazel Mcp?
Bazel Mcp is a Model Context Protocol server that exposes Bazel build system capabilities to AI assistants. It is designed for developers who want to interact with a Bazel workspace through an MCP-enabled client such as Cursor.
How to use Bazel Mcp?
Install the server with uvx and add a configuration entry to your MCP client’s JSON file (e.g., .cursor/mcp.json). Bazel commands run in your open workspace by default; if your client does not start from that directory, pass the workspace root explicitly with the --workspace-root flag.
Features of Bazel Mcp
- Run arbitrary
bazel queryexpressions - List targets in a package or subtree
- Get direct or transitive dependencies of a target
- Get reverse dependencies within a scope
- Show rule definition via
query --output=build - Run
bazel buildandbazel test - Read BUILD file contents for analysis
Use cases of Bazel Mcp
- Ask an AI assistant for the dependencies of a specific Bazel target
- Let an AI assistant build or test a target and return structured results
- Have an AI assistant explain the contents of a BUILD file
- Query the build graph for reverse dependencies during refactoring
FAQ from Bazel Mcp
What does Bazel Mcp do?
It provides tools (bazel_query, list_targets, get_deps, get_rdeps, show_target_info, bazel_build, bazel_test, explain_build_file) that an AI assistant can invoke to inspect and control a Bazel workspace.
What runtime does it require?
The server requires uv to run.
Where are Bazel commands executed?
Commands run in the Bazel workspace that is open in your MCP client by default. If the client does not start the server from the workspace, you must supply the workspace root path via the --workspace-root flag.
Are there any optional configuration flags?
Yes. You can set --bazel-path to specify the Bazel binary (e.g., bazelisk), --timeout to change the command timeout in seconds, and --max-output-chars to limit the number of characters in command output.

