bazel_set_workspace_path
Set the Bazel workspace path to enable building, testing, and managing projects through subsequent commands.
Instructions
Set the current Bazel workspace path for subsequent commands
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | The absolute path to the Bazel workspace directory |
Implementation Reference
- index.ts:359-376 (handler)Core handler function that validates the new workspace path (existence and Bazel files) and updates the BazelClient's workspacePath property.setWorkspacePath(newPath: string): string { if (!fs.existsSync(newPath)) { throw new Error(`Workspace path does not exist: ${newPath}`); } // Check if it appears to be a Bazel workspace const isWorkspace = fs.existsSync(path.join(newPath, 'WORKSPACE')) || fs.existsSync(path.join(newPath, 'WORKSPACE.bazel')) || fs.existsSync(path.join(newPath, 'MODULE.bazel')); if (!isWorkspace) { throw new Error(`Path does not appear to be a Bazel workspace: ${newPath}`); } const oldPath = this.workspacePath; this.workspacePath = newPath; return `Workspace path updated from ${oldPath} to ${newPath}`; }
- index.ts:188-201 (schema)Defines the tool's metadata, description, and input schema for validation (requires 'path' string).const setWorkspacePathTool: Tool = { name: "bazel_set_workspace_path", description: "Set the current Bazel workspace path for subsequent commands", inputSchema: { type: "object", properties: { path: { type: "string", description: "The absolute path to the Bazel workspace directory", }, }, required: ["path"], }, };
- index.ts:569-577 (registration)Registration and dispatch in the CallToolRequest handler switch statement; casts arguments and calls the core handler.case "bazel_set_workspace_path": { const args = request.params.arguments as unknown as SetWorkspacePathArgs; log(`Processing bazel_set_workspace_path to: ${args.path}`, 'info', false); if (!args.path) { throw new Error("Missing required argument: path"); } response = bazelClient.setWorkspacePath(args.path); break; }
- index.ts:608-615 (registration)Tool is registered/returned in the ListToolsRequest response as part of the available tools list.tools: [ buildTargetTool, queryTargetTool, testTargetTool, listTargetsTool, fetchDependenciesTool, setWorkspacePathTool, ],
- index.ts:65-67 (helper)Type definition for tool arguments used in the handler.interface SetWorkspacePathArgs { path: string; }