Skip to main content
Glama
andyl25

Google Cloud MCP Server

by andyl25

set-project-id

Set the default Google Cloud project ID for querying and interacting with services like Logging, Spanner, Monitoring, and Cloud Trace via the MCP server.

Input Schema

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

Implementation Reference

  • The handler function for the 'set-project-id' MCP tool. It calls the setProjectId helper, handles errors, and returns a markdown-formatted response.
    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 defining the required 'projectId' string parameter for the tool.
    { projectId: z.string().describe('The Google Cloud project ID to set as default') },
  • The server.tool call that registers the 'set-project-id' tool with the MCP server, 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 function, which includes registration of the set-project-id tool.
    registerProjectTools(server);
  • Helper function called by the tool handler to persist the project ID in the state manager.
    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