Skip to main content
Glama

bazel_test_target

Execute Bazel tests for specified targets by providing a list of test paths and optional command-line arguments. Simplifies testing in environments without direct Bazel access.

Instructions

Run Bazel tests for specified targets

Input Schema

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

Implementation Reference

  • Core implementation that executes the 'bazel test' command with validated arguments on the specified targets.
    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}`; }
  • JSON schema defining the input parameters for the bazel_test_target tool: required 'targets' array and optional 'additionalArgs'.
    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"], },
  • index.ts:542-549 (registration)
    Tool dispatch handler in the CallToolRequest switch statement that processes arguments and invokes the 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;
  • index.ts:609-616 (registration)
    Registers bazel_test_target (as testTargetTool) in the tools list returned by ListToolsRequest.
    buildTargetTool, queryTargetTool, testTargetTool, listTargetsTool, fetchDependenciesTool, setWorkspacePathTool, ], };
  • index.ts:117-140 (registration)
    Tool object definition including name, description, and input schema.
    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"], }, };

Other Tools

Related 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