Skip to main content
Glama

bazel_test_target

Execute Bazel tests for specified targets to verify code functionality and identify issues in Bazel projects through the MCP server interface.

Instructions

Run Bazel tests for specified targets

Input Schema

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

Implementation Reference

  • Core handler method in BazelClient that executes the 'bazel test' command on the specified targets with validated additional arguments.
    async testTargets(targets: string[], additionalArgs?: string[], onOutput?: (chunk: string) => void): Promise<string> {
      const validatedArgs = this.validateAdditionalArgs(additionalArgs);
      const allArgs = [...targets, ...validatedArgs];
      const { stdout, stderr } = await this.runBazelCommand("test", allArgs, onOutput);
      return `${stdout}\n${stderr}`;
    }
  • Dispatch handler in the MCP CallToolRequest handler that validates arguments and calls the BazelClient.testTargets method.
    case "bazel_test_target": {
      const args = request.params.arguments as unknown as TestTargetArgs;
      log(`Processing bazel_test_target with args: ${JSON.stringify(args)}`, 'info', false);
      if (!args.targets || args.targets.length === 0) {
        throw new Error("Missing required argument: targets");
      }
      response = await bazelClient.testTargets(args.targets, args.additionalArgs);
      break;
    }
  • Tool definition including name, description, and input schema for 'bazel_test_target'.
    const testTargetTool: Tool = {
      name: "bazel_test_target",
      description: "Run Bazel tests for specified targets",
      inputSchema: {
        type: "object",
        properties: {
          targets: {
            type: "array",
            items: {
              type: "string",
            },
            description: "List of Bazel test targets to run (e.g. ['//path/to:test'])",
          },
          additionalArgs: {
            type: "array",
            items: {
              type: "string",
            },
            description: "Additional Bazel command line arguments (e.g. ['--cache_test_results=no', '--test_output=all'])",
          },
        },
        required: ["targets"],
      },
    };
  • TypeScript interface defining the expected arguments for the bazel_test_target tool.
    interface TestTargetArgs {
      targets: string[];
      additionalArgs?: string[];
    }
  • index.ts:607-615 (registration)
    Registration of all tools including testTargetTool in the ListToolsRequest handler response.
    const response = {
      tools: [
        buildTargetTool,
        queryTargetTool,
        testTargetTool,
        listTargetsTool,
        fetchDependenciesTool,
        setWorkspacePathTool,
      ],
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.

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