bazel
MCP server for Bazel
claude mcp add --transport stdio nacgarg-bazel-mcp-server npx -y github:nacgarg/bazel-mcp-server --bazel_path /absolute/path/to/your/bazel/binary --workspace_path /absolute/path/to/your/bazel/workspace \ --env MCP_LOG_PATH="Optional: path to write server logs to" \ --env MCP_BAZEL_PATH="Path to the Bazel binary to use" \ --env MCP_WORKSPACE_PATH="Path to the Bazel workspace to use" \ --env MCP_WORKSPACE_CONFIG="Optional: path to workspace config (e.g., .bazelrc) in the workspace"
How to use
This Bazel MCP Server exposes a set of MCP-enabled tools that bridge Bazel functionality to AI agents. The available tools include: bazel_build_target to build specified Bazel targets, bazel_query_target to query the dependency graph for targets matching a pattern, bazel_test_target to run tests for selected targets, bazel_list_targets to enumerate all targets in the workspace (requires a workspace path), bazel_fetch_dependencies to fetch external dependencies, and bazel_set_workspace_path to switch the Bazel workspace path at runtime. Each command (except bazel_set_workspace_path) accepts optional additionalArgs to pass through to Bazel, enabling flags like --verbose_failures or --test_output=all. Use the provided configuration to point the server at your Bazel binary and workspace, and leverage set_workspace_path to adjust the workspace without restarting the server.
How to install
Prerequisites:
- Node.js (with npm) installed on the host
- Git installed (for cloning the repository if needed)
- Access to the internet to fetch the Bazel MCP Server package via npx
Installation steps:
-
Ensure Node.js and npm are installed. You can verify with: node -v npm -v
-
If you have a Bazel MCP Server repository (as in this guide), you can run the server directly via npx without a local install: npx -y github:nacgarg/bazel-mcp-server
-
If you prefer to run from source, clone the repository, install dependencies, and build: git clone https://github.com/nacgarg/bazel-mcp-server.git cd bazel-mcp-server npm install npm run build dist/index.js
-
Start the server using the preferred method (see mcp_config above for the npx usage). If you need to customize paths, you can pass --bazel_path and --workspace_path as shown in the configuration.
-
Optional: set environment variables to control behavior, as described in the configuration table.
Note: If you are using Cursor or remote environments, ensure the workspace and Bazel binaries are accessible from the MCP server process. The server will pick up npx-installed packages automatically in most environments.
Additional notes
Tips:
- Provide explicit paths for the Bazel binary and workspace if the automatic path detection fails in your environment.
- Use bazel_list_targets with a workspace_path to quickly survey available targets; this is particularly helpful when starting with a new repo.
- If you encounter permission or path issues, double-check the MCP_LOG_PATH setting and review the log at the specified location for diagnostics.
- The MCP environment variables (MCP_BAZEL_PATH, MCP_WORKSPACE_PATH, MCP_WORKSPACE_CONFIG, MCP_LOG_PATH) can help you reproduce and debug in different environments.
- When running in minimal containers, ensure that the Bazel binary has execute permissions and that any required shared libraries are available.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.