Bazel MCP Server logo

Bazel MCP Server

by nacgarg

A local MCP server that exposes the functionality of the Bazel build system to MCP-enabled AI agents. This is helpful when MCP environments don't have an existing command-line tool, or where the invoked shell has a misconfigured environment that prevents Bazel from being used.

View on GitHub

Last updated: N/A

What is Bazel MCP Server?

The Bazel MCP Server is a local server that allows MCP-enabled AI agents to interact with the Bazel build system. It provides a set of tools to build, query, test, and list Bazel targets, as well as fetch dependencies and manage the workspace path.

How to use Bazel MCP Server?

The server can be installed and used with Cursor or Claude Desktop by adding the server configuration to the respective MCP configuration files. It can also be launched standalone using npx or by cloning the repository and running the server from source. Configuration can be provided via command-line arguments, environment variables, or a configuration file.

Key features of Bazel MCP Server

  • Build Bazel targets

  • Query the dependency graph

  • Run tests for specified targets

  • List available targets in the workspace

  • Fetch external dependencies

  • Change the Bazel workspace path at runtime

  • Configurable via CLI arguments, environment variables, or config file

Use cases of Bazel MCP Server

  • Automating Bazel builds in AI-driven workflows

  • Integrating Bazel with MCP-enabled development environments

  • Providing a consistent Bazel interface across different environments

  • Enabling AI agents to understand and manipulate Bazel projects

FAQ from Bazel MCP Server

How do I specify the Bazel binary path?

Use the --bazel_path CLI argument, MCP_BAZEL_PATH environment variable, or bazel_path configuration file key.

How do I specify the Bazel workspace path?

Use the --workspace_path CLI argument, MCP_WORKSPACE_PATH environment variable, or workspace_path configuration file key. You can also use the bazel_set_workspace_path tool to change it at runtime.

How do I pass additional arguments to Bazel commands?

Use the additionalArgs parameter for each command (except bazel_set_workspace_path).

How do I enable verbose logging?

Set the DEBUG=true environment variable.

Where can I find the server logs?

Specify a path using the --log_path CLI argument, MCP_LOG_PATH environment variable, or log_path configuration file key.