select-project
Select a Google Cloud Platform project to manage resources like Compute Engine, Cloud Storage, and BigQuery for subsequent operations.
Instructions
Selects GCP project to use for subsequent interactions
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ID of the GCP project to select | |
| region | No | Region to use (if not provided, us-central1 is used) |
Implementation Reference
- index.ts:407-412 (handler)The main handler logic for executing the 'select-project' tool. It validates input using Zod schema, initializes credentials, sets the selected project ID and region, and returns a success message.} else if (name === "select-project") { const { projectId, region } = SelectProjectSchema.parse(args); selectedProjectCredentials = await auth.getClient(); selectedProject = projectId; selectedRegion = region || "us-central1"; return createTextResponse("Project selected successfully!");
- index.ts:107-124 (registration)Registration of the 'select-project' tool in the ListTools response, defining its name, description, and JSON input schema.{ name: "select-project", description: "Selects GCP project to use for subsequent interactions", inputSchema: { type: "object", properties: { projectId: { type: "string", description: "ID of the GCP project to select", }, region: { type: "string", description: "Region to use (if not provided, us-central1 is used)", }, }, required: ["projectId"], }, },
- index.ts:223-226 (schema)Zod runtime validation schema for the 'select-project' tool inputs, used in the handler for parsing arguments.const SelectProjectSchema = z.object({ projectId: z.string(), region: z.string().optional(), });
- index.ts:293-305 (helper)Helper function for selecting a project with authentication initialization and error handling, similar to handler logic but not directly invoked by the tool.const selectProject = async (projectId: string, region?: string) => { try { selectedProject = projectId; selectedRegion = region || "us-central1"; selectedProjectCredentials = await initializeAuth(); return true; } catch (error) { console.error('Failed to select project:', error); selectedProject = null; selectedProjectCredentials = null; throw error; } };