Skip to main content
Glama

sheets_get_metadata

Retrieve metadata from Google Sheets, including sheet names, IDs, and properties, by providing the spreadsheet ID for efficient data management.

Instructions

Get metadata about a Google Sheets spreadsheet including sheet names, IDs, and properties

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spreadsheetIdYesThe ID of the spreadsheet (found in the URL after /d/)

Implementation Reference

  • The handler function that implements the core logic: validates input, fetches spreadsheet metadata via Google Sheets API, formats the response, and handles errors.
    export async function handleGetMetadata(input: any) { try { if (!input.spreadsheetId || typeof input.spreadsheetId !== 'string') { throw new Error('spreadsheetId is required and must be a string'); } if (!validateSpreadsheetId(input.spreadsheetId)) { throw new Error('Invalid spreadsheet ID format'); } const sheets = await getAuthenticatedClient(); const response = await sheets.spreadsheets.get({ spreadsheetId: input.spreadsheetId, includeGridData: false, }); return formatSpreadsheetMetadata(response.data); } catch (error) { return handleError(error); } }
  • Defines the tool's name, description, and input schema for validation.
    export const getMetadataTool: Tool = { name: 'sheets_get_metadata', description: 'Get metadata about a Google Sheets spreadsheet including sheet names, IDs, and properties', inputSchema: { type: 'object', properties: { spreadsheetId: { type: 'string', description: 'The ID of the spreadsheet (found in the URL after /d/)', }, }, required: ['spreadsheetId'], }, };
  • src/index.ts:36-36 (registration)
    Registers the handler function for 'sheets_get_metadata' in the toolHandlers Map used for tool execution.
    ['sheets_get_metadata', tools.handleGetMetadata],
  • src/index.ts:71-71 (registration)
    Registers the tool definition (schema) in the allTools array served via ListToolsRequest.
    tools.getMetadataTool,

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/freema/mcp-gsheets'

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