bazel-mcp
A mcp server that exposes Bazel build system capabilities to AI assistants.
Documentation
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.
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-serverThen 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.
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 64000Development
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 pytestFrequently asked questions
What is bazel-mcp?
bazel-mcp is A mcp server that exposes Bazel build system capabilities to AI assistants.
How do I install bazel-mcp?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is bazel-mcp open source?
Yes — it is hosted on GitHub at https://github.com/saeid-rez/bazel-mcp and has 2 stars.
Related MCP tools
Cognee is the open-source AI memory platform for agents. Give your AI agents persistent long-term memory across sessions with a self-hosted knowledge graph engine.
Automate browser based workflows with AI
Hindsight: Agent Memory That Learns
A privacy-first app that strips AI watermarks from content you own.
Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.
The power of Claude Code / GeminiCLI / CodexCLI + [Gemini / OpenAI / OpenRouter / Azure / Grok / Ollama / Custom Model / All Of The Above] working as one.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP