Skip to main content
Glama

Bazel MCP Server

A local MCP server that exposes functionality of the Bazel build system to MCP-enabled AI agents.

This is helpful when MCP environments either don't have an existing command-line tool, or where the invoked shell has a misconfigured environment that prevents Bazel from being used.

Tools

The Bazel MCP Server provides the following tools:

  • bazel_build_target: Build specified Bazel targets

  • bazel_query_target: Query the dependency graph for targets matching a pattern

  • bazel_test_target: Run tests for specified targets

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

  • bazel_fetch_dependencies: Fetch external dependencies

  • bazel_set_workspace_path: Change the Bazel workspace path at runtime

Each command (except bazel_set_workspace_path) supports an optional additionalArgs parameter that allows passing additional arguments to the underlying Bazel command. This is useful for specifying flags like --verbose_failures or --test_output=all.

Related MCP server: projscan

Usage

Installation

Using with Cursor

Add the following to .cursor/mcp.json.

You don't need to provide the workspace path, as the LLM can use set_workspace_path to change the workspace path at runtime.

The bazel binary usually gets picked up automatically, but if you run into issues, you can provide the path to the bazel binary using the --bazel_path flag.

:warning: Note that this will not work when using Cursor with Remote SSH sessions, since it runs the MCP server locally.

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

        // If you need to specify the bazel binary path
        "--bazel_path", 
        "/absolute/path/to/your/bazel/binary",

        // If you need to specify the workspace path
        "--workspace_path",
        "/absolute/path/to/your/bazel/workspace"

        // See Configuration Table below for more options
      ]
    }
  }
}

Using with Claude Desktop

You can use the same configuration as above with Claude Desktop.

Launching standalone

# Run directly from GitHub (no installation needed)
npx -y github:nacgarg/bazel-mcp-server

# From source
git clone https://github.com/nacgarg/bazel-mcp-server.git
cd bazel-mcp-server
npm install
npm run build
dist/index.js

Configuration

This MCP server allows a couple different configuration methods. They will be used in the following order:

  1. Command line arguments

  2. Environment variables

  3. Configuration file

Configuration Table

CLI Argument

Environment Variable

Configuration File Key

Description

--bazel_path

MCP_BAZEL_PATH

bazel_path

The path to the Bazel binary to use.

--workspace_path

MCP_WORKSPACE_PATH

workspace_path

The path to the Bazel workspace to use.

--workspace_config

MCP_WORKSPACE_CONFIG

workspace_config

The configuration of the workspace to use. By default, this uses the .bazelrc file in the workspace root.

--log_path

MCP_LOG_PATH

log_path

The path to write server logs to.

Debugging

Set the DEBUG=true environment variable to enable verbose logging to the console.

Setting the log path is also helpful for debugging with clients that don't print logs to the console (looking at you, Cursor).

License

This project is licensed under the MIT License. See the LICENSE file for details.

Available Tools

6 tools
bazel_build_targetC

Build specified Bazel targets

ParametersJSON Schema
NameRequiredDescriptionDefault
targetsYesList of Bazel targets to build (e.g. ['//path/to:target'])
additionalArgsNoAdditional Bazel command line arguments (e.g. ['--verbose_failures', '--sandbox_debug'])

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Build') but doesn't cover critical traits like whether this is a long-running process, if it requires specific permissions, what happens on failure, or output format. This leaves significant gaps for a build operation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a build operation, no annotations, and no output schema, the description is incomplete. It doesn't explain what the build process entails, potential side effects, or what to expect as a result, leaving the agent with insufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any meaning beyond what's in the schema, such as explaining parameter interactions or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Build') and resource ('specified Bazel targets'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'bazel_test_target' or 'bazel_query_target' beyond the basic action, missing specific scope details that would earn a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'bazel_test_target' for testing or 'bazel_list_targets' for listing. The description lacks context about prerequisites, such as needing a workspace path set via 'bazel_set_workspace_path', or exclusions like not using it for dependency fetching.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

bazel_fetch_dependenciesB

Fetch Bazel external dependencies

ParametersJSON Schema
NameRequiredDescriptionDefault
targetsNoList of specific targets to fetch dependencies for
additionalArgsNoAdditional Bazel command line arguments (e.g. ['--experimental_repository_cache_hardlinks', '--repository_cache=path/to/cache'])

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. 'Fetch' implies a read operation that retrieves dependencies, but the description doesn't specify whether this modifies workspace state, requires network access, has side effects, or what happens when dependencies already exist. For a tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a simple tool and gets straight to the point without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (fetching dependencies often involves network operations and workspace state), no annotations, and no output schema, the description is minimally adequate. It states what the tool does but leaves many contextual questions unanswered about behavior, side effects, and results. For a dependency-fetching operation, more context would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already fully documents both parameters. The description adds no additional parameter information beyond what's in the schema. This meets the baseline expectation when the schema does the heavy lifting, but provides no extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('fetch') and resource ('Bazel external dependencies'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its siblings like 'bazel_build_target' or 'bazel_query_target' - all involve Bazel operations but with different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when this operation is needed, or how it differs from other Bazel operations like building or testing targets. The agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

bazel_list_targetsB

List all available Bazel targets under a given path

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesPath within the workspace to list targets for (e.g. '//path/to' or '//' for all targets)
additionalArgsNoAdditional Bazel command line arguments (e.g. ['--output=build', '--keep_going'])

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool lists targets but doesn't disclose behavioral traits like whether it's read-only (implied by 'List' but not explicit), output format, error handling, or rate limits. The description is minimal and misses key operational details.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It wastes no words and is appropriately sized for a simple listing tool, earning its place with clear intent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a mutation-free tool, the description is incomplete. It doesn't explain what the output looks like (e.g., list format, error cases) or behavioral constraints. For a tool with 2 parameters and siblings, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description adds no additional meaning beyond what's in the schema (e.g., no extra context on path usage or additionalArgs). Baseline 3 is appropriate as the schema handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'List' and resource 'Bazel targets', specifying scope 'under a given path'. It distinguishes from siblings like bazel_build_target or bazel_test_target by focusing on listing rather than building/testing. However, it doesn't explicitly differentiate from bazel_query_target which might also list targets, leaving some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when needing to list targets in a specific path, but provides no explicit guidance on when to use this versus alternatives like bazel_query_target or bazel_build_target. It mentions the path parameter context but lacks when-not scenarios or clear prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

bazel_query_targetA

Query the Bazel dependency graph for targets matching a pattern

ParametersJSON Schema
NameRequiredDescriptionDefault
patternYesBazel query pattern (e.g. 'deps(//path/to:target)')
additionalArgsNoAdditional Bazel command line arguments (e.g. ['--output=label_kind', '--noimplicit_deps'])

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions querying but does not disclose behavioral traits such as whether it's read-only, if it requires specific permissions, rate limits, or what the output format looks like. This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without any wasted words. It is appropriately sized and structured for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is minimal but covers the basic purpose. However, it lacks details on behavioral aspects and output, making it incomplete for a tool with two parameters and no structured safety or output information.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as explaining parameter interactions or usage nuances, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('query'), the resource ('Bazel dependency graph'), and the target ('targets matching a pattern'), distinguishing it from siblings like 'bazel_build_target' or 'bazel_test_target' which perform different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for querying dependencies but does not explicitly state when to use this tool versus alternatives like 'bazel_list_targets' or 'bazel_fetch_dependencies'. It provides context but lacks explicit guidance on exclusions or comparisons.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

bazel_set_workspace_pathB

Set the current Bazel workspace path for subsequent commands

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesThe absolute path to the Bazel workspace directory

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this sets workspace path 'for subsequent commands', implying persistence/statefulness, but doesn't clarify whether this affects the entire session, has side effects, requires specific permissions, or what happens on invalid paths. For a state-changing tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that communicates the core purpose and usage context without any wasted words. It's appropriately sized for a single-parameter tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (state-changing configuration), lack of annotations, and no output schema, the description provides minimal but adequate coverage. It explains what the tool does but lacks details about behavioral implications, error conditions, or return values. For a configuration tool with state persistence, more context would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the single parameter ('path') as an absolute workspace directory path. The description doesn't add any parameter-specific semantics beyond what the schema provides. Baseline 3 is appropriate when schema does the documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Set') and the resource ('current Bazel workspace path'), making the purpose understandable. It distinguishes from siblings by focusing on workspace configuration rather than build/test/query operations. However, it doesn't explicitly contrast with specific sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('for subsequent commands'), suggesting this should be called before other Bazel operations. However, it doesn't provide explicit guidance on when to use this vs. alternatives, nor does it mention prerequisites or exclusions. The relationship to sibling tools is only implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

bazel_test_targetC

Run Bazel tests for specified targets

ParametersJSON Schema
NameRequiredDescriptionDefault
targetsYesList of Bazel test targets to run (e.g. ['//path/to:test'])
additionalArgsNoAdditional Bazel command line arguments (e.g. ['--cache_test_results=no', '--test_output=all'])

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Run Bazel tests') but doesn't describe what this entails—such as whether it's a blocking operation, how long it might take, what happens on failure, or if it requires specific permissions. This is a significant gap for a tool that likely involves execution and potential side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—a single sentence that directly states the tool's function without any fluff. It's front-loaded with the core action and resource, making it efficient and easy to parse, which is ideal for quick understanding by an AI agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of running tests (which involves execution, potential side effects, and no output schema), the description is incomplete. It lacks details on behavioral traits (e.g., runtime, error handling), usage context, and what to expect as output (e.g., test results, logs). With no annotations to fill these gaps, the description doesn't provide enough information for effective tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description doesn't add any parameter-specific information beyond what's already in the input schema, which has 100% coverage with clear descriptions for both 'targets' and 'additionalArgs'. This meets the baseline of 3, as the schema adequately documents the parameters, but the description doesn't provide extra context like examples of common test arguments or target patterns.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Run Bazel tests') and the resource ('for specified targets'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'bazel_build_target' or 'bazel_query_target' beyond the 'test' verb, which leaves some ambiguity about when to choose this specific tool.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'bazel_build_target' (for building) or 'bazel_query_target' (for querying), nor does it specify prerequisites (e.g., needing a configured workspace) or appropriate contexts (e.g., during testing phases). This leaves the agent without clear usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 6 tool updates
    • First observedbazel_build_target
    • First observedbazel_fetch_dependencies
    • First observedbazel_list_targets
    • First observedbazel_query_target
    • First observedbazel_set_workspace_path
    • First observedbazel_test_target

TDQS

A3.6/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose with no ambiguity: building, fetching dependencies, listing targets, querying the dependency graph, setting workspace path, and testing. The descriptions clearly differentiate their functions, making misselection unlikely.

Naming Consistency5/5

All tools follow a consistent 'bazel_verb_noun' pattern (e.g., bazel_build_target, bazel_fetch_dependencies), using snake_case throughout. This predictable naming makes the tool set easy to navigate and understand.

Tool Count5/5

With 6 tools, this server is well-scoped for Bazel operations, covering core workflows like building, testing, querying, and workspace management. Each tool earns its place without feeling excessive or insufficient for the domain.

Completeness4/5

The tool set provides strong coverage for essential Bazel tasks, including build, test, query, and dependency management. A minor gap exists in operations like cleaning or caching, but agents can work around this with the available tools for most common workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    C
    maintenance
    A local-first MCP server that provides AI agents with safe codebase access through file discovery, hybrid lexical-semantic search, and project introspection. It features durable local memory and semantic indexing while keeping all data and processing entirely on your local machine.
    74
    29
    6
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    An MCP server that provides AI coding agents with AST-accurate, context-budget-aware codebase querying, safety gates, and team policy integration via structured tools and a local plugin layer.
    562
    4
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    A lightweight build daemon that exposes project build flows as MCP tools, enabling AI assistants to drive builds, check status, and react to results.
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nacgarg/bazel-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server