MCP server for Bazel: query targets, analyze deps, build, test, and read BUILD files
Project description
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. Run against a Bazel workspace. Open that repo in Cursor, then add to .cursor/mcp.json.
Option 1: Run via PyPI (Recommended)
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": ["bazel-mcp-server"]
}
}
}
Option 2: Run directly from GitHub
{
"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 your MCP client does not start the server from the Bazel workspace, pass the workspace explicitly:
{
"mcpServers": {
"bazel": {
"command": "uvx",
"args": [
"bazel-mcp",
"--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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bazel_mcp_server-0.1.1.tar.gz.
File metadata
- Download URL: bazel_mcp_server-0.1.1.tar.gz
- Upload date:
- Size: 66.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e184e2eba4bda9ae20da780fc60cb94e2fb16101efc9f1a6bd10e6b1abeccd86
|
|
| MD5 |
307c9d262c07af0f7fbb7ccf139637e4
|
|
| BLAKE2b-256 |
61a4c2dba5c314bb45e2fd622978ea55d515db19aaad3dca895eb5ba4c386285
|
File details
Details for the file bazel_mcp_server-0.1.1-py3-none-any.whl.
File metadata
- Download URL: bazel_mcp_server-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76e7ee97e83c4b94d4be10e506218f795d150acf747dd1b02b4be85c0098432e
|
|
| MD5 |
b99eda5ab5c147b848aa7b7bf855f161
|
|
| BLAKE2b-256 |
7cbb3fdd2f7ca28663709a1ac0dcc8218a1d4921aa573d1f65b8129974e723b3
|