Skip to main content
Glama

bazel_list_targets

List all available Bazel build targets within a specified workspace path to identify and manage project components for building and testing.

Instructions

List all available Bazel targets under a given path

Input Schema

TableJSON 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'])

Implementation Reference

  • Core implementation of bazel_list_targets: runs `bazel query <path>/...` with optional additional args to list targets under the given path.
    async listTargets(path: string, additionalArgs?: string[], onOutput?: (chunk: string) => void): Promise<string> {
      const queryPattern = `${path}/...`;
      const validatedArgs = this.validateAdditionalArgs(additionalArgs);
      const allArgs = [queryPattern, ...validatedArgs];
      const { stdout } = await this.runBazelCommand("query", allArgs, onOutput);
      return stdout;
    }
  • Entry point handler in MCP CallToolRequest: validates 'path' argument and calls BazelClient.listTargets.
    case "bazel_list_targets": {
      const args = request.params.arguments as unknown as ListTargetsArgs;
      log(`Processing bazel_list_targets for path: ${args.path}`, 'info', false);
      if (!args.path) {
        throw new Error("Missing required argument: path");
      }
      response = await bazelClient.listTargets(args.path, args.additionalArgs);
      break;
    }
  • Tool schema: defines name, description, inputSchema with required 'path' (string) and optional 'additionalArgs' (string array).
    const listTargetsTool: Tool = {
      name: "bazel_list_targets",
      description: "List all available Bazel targets under a given path",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "Path within the workspace to list targets for (e.g. '//path/to' or '//' for all targets)",
          },
          additionalArgs: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Additional Bazel command line arguments (e.g. ['--output=build', '--keep_going'])",
          },
        },
        required: ["path"],
      },
    };
  • index.ts:608-615 (registration)
    Registers bazel_list_targets (as listTargetsTool) among other tools in ListToolsResponse.
    tools: [
      buildTargetTool,
      queryTargetTool,
      testTargetTool,
      listTargetsTool,
      fetchDependenciesTool,
      setWorkspacePathTool,
    ],
  • TypeScript interface defining expected arguments for bazel_list_targets.
    interface ListTargetsArgs {
      path: string;
      additionalArgs?: string[];
    }
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.

Install Server

Other Tools

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