Skip to main content
Glama

list-sql-instances

Retrieve all Cloud SQL instances in your current GCP project to manage database resources and monitor configurations.

Instructions

List all Cloud SQL instances in the current project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the 'list-sql-instances' tool. It checks if a project is selected, creates a SqlInstancesServiceClient, lists the instances for the project, maps them to a simplified format, and returns the JSON response. Handles errors gracefully.
    } else if (name === "list-sql-instances") { if (!selectedProject) { return createTextResponse("No project selected. Please select a project first."); } try { const sqlClient = new SqlInstancesServiceClient({ fallback: 'rest' // Use HTTP/1.1 fallback mode instead of gRPC }); const request = { project: selectedProject }; const [response] = await sqlClient.list(request); return createTextResponse(JSON.stringify({ instances: (response?.items || []).map(instance => ({ name: instance.name || null, databaseVersion: instance.databaseVersion || null, state: instance.state || null, region: instance.region || null })) }, null, 2)); } catch (error: any) { console.error('Error listing SQL instances:', error); return createTextResponse(`Error listing SQL instances: ${error.message}`); } } else if (name === "get-logs") {
  • index.ts:186-193 (registration)
    Registration of the 'list-sql-instances' tool in the server's listTools response, including name, description, and input schema (empty object since no parameters required).
    name: "list-sql-instances", description: "List all Cloud SQL instances in the current project", inputSchema: { type: "object", properties: {}, required: [], }, },
  • TypeScript interface defining the structure of SQL instances returned by the handler, used for type safety in the response mapping.
    interface SQLInstance { name: string | null; databaseVersion: string | null; state: string | null; region: string | null; }
  • Import of the SqlInstancesServiceClient used by the handler.
    import { SqlInstancesServiceClient } from '@google-cloud/sql';

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/RadiumGu/gcp-ops-mcp'

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