Labsco
MCP SERVER

Bazel MCP Server

by nacgarg

Run Bazel from an agent — build, test, query the dependency graph, list targets, fetch dependencies, and switch workspace mid-session.

Build Systems & CI/CDVerified
Summary
The runtime workspace switch is why it beats a shell alias.

`bazel_set_workspace_path` means the model can point the server at whichever checkout the question is about, so one configuration entry covers every repository on the machine rather than one per project. `additionalArgs` keeps the escape hatch open — `--test_output=all` on a failing test gets you the output that the default summary hides. Set `--log_path` if your client swallows console logs, which is the usual reason a failure looks like silence.

What it is

A local MCP server that wraps the Bazel command line. It exists for environments where the agent has no usable shell, or where the shell it does have has an environment misconfigured enough that Bazel will not run in it.

What you get
  • Targets built and tests run — `bazel_build_target`, `bazel_test_target`
  • The dependency graph queried for targets matching a pattern — `bazel_query_target`
  • Every target in the workspace listed, taking a path where `//` means all of them — `bazel_list_targets`
  • External dependencies fetched — `bazel_fetch_dependencies`
  • The workspace path changed at runtime, so one running server can move between checkouts — `bazel_set_workspace_path`
  • An optional `additionalArgs` on every tool except the workspace switch, for flags like `--verbose_failures` or `--test_output=all`
Requirements

No account and no key — it drives your local Bazel. The npm package name is `@nacgarg/bazel-mcp-server` (0.1.0) and it runs straight from GitHub with `npx -y github:nacgarg/bazel-mcp-server`. You usually do not need to configure anything: the Bazel binary is picked up automatically and the workspace can be set at runtime by the model. Where that fails, `--bazel_path` and `--workspace_path` take absolute paths, and each has an environment-variable equivalent in `MCP_BAZEL_PATH` and `MCP_WORKSPACE_PATH`, with a config file as the third fallback. Because it runs locally, it will not work through Cursor's Remote SSH sessions.

Setup effort

One command — npx -y github:nacgarg/bazel-mcp-server