mcp-bazel

MCP.Pizza Chef: aaomidi

mcp-bazel is an MCP server that exposes essential Bazel project actions such as building targets, running tests, and analyzing dependencies. It provides tools to query direct and reverse dependencies, source files, and execute builds and tests, enabling seamless integration of Bazel workflows into AI-enhanced environments. Designed for use with clients like Claude Desktop, it facilitates real-time interaction with Bazel projects through the Model Context Protocol.

Use This MCP server To

Build specified Bazel targets programmatically Run tests on Bazel targets via MCP integration Query direct dependencies of Bazel targets Find reverse dependencies for impact analysis Retrieve source files associated with Bazel targets Integrate Bazel build and test workflows into AI copilots Automate dependency analysis for Bazel projects Enable real-time Bazel project inspection in IDEs

README

Bazel MCP Server

This project provides a Model Context Protocol (MCP) server that exposes tools for interacting with Bazel projects.

Status: 🚧 Under Active Development 🚧

Features and interfaces may change.

Features

This server currently provides the following tools:

  • build: Builds a specified Bazel target.
  • deps: Finds the dependencies of a given Bazel target, with an optional depth parameter.
  • rdeps (Reverse Dependencies): Finds all Bazel targets that depend on a given target or file path, with an optional depth parameter.
  • sources: Finds the direct source files associated with a given Bazel target.
  • test: Runs tests for a specified Bazel target.

Usage with Claude Desktop

This server is designed to be used as a tool provider for applications like the Claude Desktop app.

1. Installation

Install the server using go install:

# Ensure your Go environment is set up (GOPATH, GOBIN, etc.)
go install github.com/aaomidi/mcp-bazel@latest

This command compiles and installs the mcp-bazel binary. By default, it's placed in your $GOPATH/bin directory or $HOME/go/bin if GOPATH is not set. Make sure this location is in your system's PATH or note the full path to the binary for the next step.

2. Configuration

Add the following configuration to your Claude Desktop settings file (claude_desktop_config.json). You can usually find this file via the app's settings menu ("Open Config Folder").

Modify the "command" path to point to the actual location where go install placed the mcp-bazel binary on your system.

{
  "mcpServers": {
    "mcp-bazel": {
      "command": "/path/to/your/go/bin/mcp-bazel"
    }
  }
}

3. Restart Claude Desktop

After saving the configuration file, restart the Claude Desktop app. The Bazel tools should now be available.

mcp-bazel FAQ

How do I install the mcp-bazel server?
Install it using Go with the command `go install github.com/yourrepo/mcp-bazel` after setting up your Go environment.
Can mcp-bazel run tests on Bazel targets?
Yes, it provides a `test` tool to run tests for specified Bazel targets.
How does mcp-bazel handle dependency queries?
It offers `deps` to find dependencies and `rdeps` to find reverse dependencies with optional depth parameters.
Is mcp-bazel compatible with multiple MCP clients?
Yes, it is designed to work with any MCP client, including Claude Desktop and others.
What Bazel actions does mcp-bazel support?
It supports build, test, dependency analysis, reverse dependency lookup, and source file retrieval.
Is mcp-bazel stable for production use?
It is currently under active development, so features and interfaces may change.
Can mcp-bazel be integrated into IDEs?
Yes, it can be integrated to provide real-time Bazel project insights within IDEs.
Does mcp-bazel support custom Bazel targets?
Yes, you can specify any Bazel target for build, test, or dependency queries.