MCP.so
Sign In

Bazel MCP Server

@nacgarg

Basic information

Category

Other

License

MIT

Transports

stdio

Author

nacgarg

About Bazel MCP Server

MCP server for Bazel

Bazel MCP Server config

Add this server to your MCP-compatible client using the configuration below.

{
  "mcpServers": {
    "bazel-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "github:nacgarg/bazel-mcp-server"
      ]
    }
  }
}

Bazel MCP Server tools

6

Build specified Bazel targets

Query the dependency graph for targets matching a pattern

Run tests for specified targets

List all available targets in the workspace (requires path parameter, use "//" for all targets)

Fetch external dependencies

Change the Bazel workspace path at runtime

Overview

What is Bazel MCP Server?

Bazel MCP Server is a local MCP server that exposes functionality of the Bazel build system to MCP-enabled AI agents. It is useful when MCP environments lack a command-line tool or have a misconfigured shell that prevents Bazel from being used.

How to use Bazel MCP Server?

Install by adding a configuration entry to .cursor/mcp.json (for Cursor) or launching standalone with npx -y github:nacgarg/bazel-mcp-server. Configuration can be provided via CLI arguments, environment variables, or a configuration file. The AI agent can change the workspace path at runtime using the bazel_set_workspace_path tool.

Key features of Bazel MCP Server

  • Build specified Bazel targets
  • Query the dependency graph for matching targets
  • Run tests for specified targets
  • List all available targets in the workspace
  • Fetch external dependencies
  • Change the Bazel workspace path at runtime
  • Pass additional arguments to underlying Bazel commands

Use cases of Bazel MCP Server

  • Build specific targets from an AI agent without a working shell
  • Query the Bazel dependency graph to understand target relationships
  • Run tests and view results through the agent
  • List all targets in a workspace to explore available build rules
  • Fetch external dependencies before building or testing

Frequently asked questions

1

What does Bazel MCP Server do that the regular Bazel CLI cannot?

It provides an MCP-compatible interface so that AI agents can interact with Bazel even when the invoked shell is misconfigured or lacks the Bazel command-line tool.

2

What are the runtime dependencies?

The server requires Node.js (to run via `npx`) and the Bazel binary. The path to the Bazel binary can be specified via `--bazel_path` or the `MCP_BAZEL_PATH` environment variable.

3

How do I set the Bazel workspace path?

The workspace path can be set at startup via the `--workspace_path` CLI argument, the `MCP_WORKSPACE_PATH` environment variable, or a configuration file. At runtime, the AI agent can use the `bazel_set_workspace_path` tool to change it.

4

Does the server work with Cursor Remote SSH sessions?

No, the server runs locally and will not work when using Cursor with Remote SSH sessions.

5

Can I pass extra flags to Bazel commands?

Yes, each tool (except `bazel_set_workspace_path`) accepts an optional `additionalArgs` parameter to supply extra flags like `--verbose_failures` or `--test_output=all`.

Comments

More Other MCP servers