Skip to main content
Glama

bazel_set_workspace_path

Define the Bazel workspace path for executing commands in environments without direct Bazel access. Enables AI agents to manage Bazel projects via the MCP server.

Instructions

Set the current Bazel workspace path for subsequent commands

Input Schema

NameRequiredDescriptionDefault
pathYesThe absolute path to the Bazel workspace directory

Input Schema (JSON Schema)

{ "properties": { "path": { "description": "The absolute path to the Bazel workspace directory", "type": "string" } }, "required": [ "path" ], "type": "object" }

Implementation Reference

  • Core implementation of the tool logic: validates the new workspace path exists and contains Bazel workspace files (WORKSPACE, WORKSPACE.bazel, or MODULE.bazel), then updates the internal workspacePath state and returns confirmation.
    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}`; }
  • Tool dispatch handler in the CallToolRequest switch statement: extracts arguments, performs basic validation, and delegates to BazelClient.setWorkspacePath.
    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; }
  • Tool definition including name, description, and input schema specifying the required 'path' string parameter.
    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:608-616 (registration)
    Registers the setWorkspacePathTool in the list of available tools returned by ListToolsRequest.
    tools: [ buildTargetTool, queryTargetTool, testTargetTool, listTargetsTool, fetchDependenciesTool, setWorkspacePathTool, ], };

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