Skip to main content
Glama
andyl25

Google Cloud MCP Server

by andyl25

set-project-id

Set the default Google Cloud project ID for subsequent operations in the MCP server, enabling streamlined access to services like Logging, Spanner, Monitoring, and Cloud Trace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesThe Google Cloud project ID to set as default

Implementation Reference

  • The asynchronous handler function for the 'set-project-id' tool. It calls setProjectId(projectId), handles errors, and returns markdown content indicating success or failure.
    async ({ projectId }, context) => { try { await setProjectId(projectId); return { content: [{ type: 'text', text: `# Project ID Updated\n\nDefault Google Cloud project ID has been set to: \`${projectId}\`\n\nThis project ID will be used for all Google Cloud operations until changed.` }] }; } catch (error: any) { // Error handling for set-project-id tool return { content: [{ type: 'text', text: `# Error Setting Project ID\n\nFailed to set project ID: ${error.message}` }] }; } }
  • Zod input schema for the 'set-project-id' tool defining the required projectId string parameter.
    projectId: z.string().describe('The Google Cloud project ID to set as default') },
  • Registration of the 'set-project-id' tool on the MCP server instance within registerProjectTools, including schema and handler.
    server.tool( 'set-project-id', { projectId: z.string().describe('The Google Cloud project ID to set as default') }, async ({ projectId }, context) => { try { await setProjectId(projectId); return { content: [{ type: 'text', text: `# Project ID Updated\n\nDefault Google Cloud project ID has been set to: \`${projectId}\`\n\nThis project ID will be used for all Google Cloud operations until changed.` }] }; } catch (error: any) { // Error handling for set-project-id tool return { content: [{ type: 'text', text: `# Error Setting Project ID\n\nFailed to set project ID: ${error.message}` }] }; } } );
  • src/index.ts:165-165 (registration)
    Top-level call to registerProjectTools(server) in the main server setup, which includes registration of the set-project-id tool.
    registerProjectTools(server);
  • Helper function setProjectId that persists the project ID using the state manager, called by the tool handler.
    export async function setProjectId(projectId: string): Promise<void> { // Use the state manager to set the project ID await stateManager.setCurrentProjectId(projectId); }

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/andyl25/googlecloud-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server