list-projects
Retrieve all Google Cloud Platform projects accessible with your current credentials using this tool. Manage and query GCP services effectively across multiple projects.
Instructions
List all GCP projects accessible with current credentials
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:98-106 (registration)Registration of the 'list-projects' tool in the ListTools response, defining its name, description, and empty input schema.{ name: "list-projects", description: "List all GCP projects accessible with current credentials", inputSchema: { type: "object", properties: {}, required: [], }, },
- index.ts:404-406 (handler)Handler logic in CallToolRequestSchema: invokes listAvailableProjects() helper and formats response as JSON.} else if (name === "list-projects") { const projects = await listAvailableProjects(); return createTextResponse(JSON.stringify({ projects }));
- index.ts:680-690 (helper)Core implementation: Uses Google Cloud's ProjectsClient to search and list accessible projects, serializes each to JSON string, handles errors gracefully.async function listAvailableProjects(): Promise<string[]> { const projectsClient = new ProjectsClient(); try { const [projects] = await projectsClient.searchProjects(); return projects.map((p: any) => JSON.stringify(p)); } catch (error) { console.error('Error listing projects:', error); return []; } }