Skip to main content
Glama

Flatfile MCP Server

by FlatFilers
get-cell-values-sheet.ts3.17 kB
/** * This file was generated. Do NOT edit this file. */ import fetch from 'node-fetch' import { type ZodRawShape, z } from 'zod' import { commons_FilterFieldSchema, commons_FilterSchema, commons_PageNumberSchema, commons_PageSizeSchema, commons_SearchValueSchema, commons_SheetIdSchema, commons_SortDirectionSchema, commons_SortFieldSchema, sheets_DistinctSchema, sheets_FieldKeySchema, sheets_IncludeCountsSchema, } from '../schemas.js' import type { Tool } from './index.js' const params = { sheetId: commons_SheetIdSchema.describe('ID of sheet'), fieldKey: sheets_FieldKeySchema.optional(), sortField: commons_SortFieldSchema.optional(), sortDirection: commons_SortDirectionSchema.optional(), filter: commons_FilterSchema.optional(), filterField: commons_FilterFieldSchema.optional().describe('Name of field by which to filter records'), pageSize: commons_PageSizeSchema .optional() .describe('Number of records to return in a page (default 1000 if pageNumber included)'), pageNumber: commons_PageNumberSchema.optional().describe('Based on pageSize, which page of records to return'), distinct: sheets_DistinctSchema.describe('Must be set to true'), includeCounts: sheets_IncludeCountsSchema.optional(), searchValue: commons_SearchValueSchema .optional() .describe('A value to find for a given field in a sheet. Wrap the value in "" for exact match'), } as ZodRawShape export const getCellValuesSheet: Tool<typeof params> = { name: 'getCellValuesSheet', description: 'Get record cells by field: Returns record cell values grouped by all fields in the sheet', params, cb: async ({ sheetId, fieldKey, sortField, sortDirection, filter, filterField, pageSize, pageNumber, distinct, includeCounts, searchValue, }) => { try { const searchParams = { fieldKey, sortField, sortDirection, filter, filterField, pageSize, pageNumber, distinct, includeCounts, searchValue, } const searchParamsString = new URLSearchParams(JSON.parse(JSON.stringify(searchParams))).toString() const baseUrl = process.env.FLATFILE_API_URL || 'https://platform.flatfile.com/api/v1' const url = `${baseUrl}/sheets/${sheetId}/cells${searchParamsString ? `?${searchParamsString}` : ''}` const response = await fetch(url, { method: 'GET', headers: { 'X-Disable-Hooks': 'true', Authorization: `Bearer ${process.env.FLATFILE_BEARER_TOKEN}`, 'Content-Type': 'application/json', }, }) if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status} - ${response.statusText}`) } const data = (await response.json()) as { data: unknown } return { content: [ { type: 'text', text: JSON.stringify(data.data, null, 2), }, ], status: 'success', } } catch (error) { return { content: [{ type: 'text', text: `Error: ${error}` }], status: 'failed', } } }, }

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/FlatFilers/mcp-server-flatfile'

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