Skip to main content
Glama

Flatfile MCP Server

by FlatFilers
get-calculations-sheet.ts3.35 kB
/** * This file was generated. Do NOT edit this file. */ import fetch from 'node-fetch' import { type ZodRawShape, z } from 'zod' import { commons_CommitIdSchema, commons_FilterFieldSchema, commons_FilterSchema, commons_SearchFieldSchema, commons_SearchValueSchema, commons_SheetIdSchema, commons_VersionIdSchema, } from '../schemas.js' import type { Tool } from './index.js' const params = { sheetId: commons_SheetIdSchema.describe('ID of sheet'), versionId: z .string() .optional() .describe('Returns records that were changed in that version and only those records.'), sinceVersionId: commons_VersionIdSchema.optional().describe("Deprecated, use 'sinceCommitId' instead."), commitId: commons_CommitIdSchema .optional() .describe( 'Returns records that were changed in that version in addition to any records from versions after that version.', ), sinceCommitId: commons_CommitIdSchema .optional() .describe('Listing a commit ID here will return all records since the specified commit.'), filter: commons_FilterSchema.optional().describe('Options to filter records'), filterField: commons_FilterFieldSchema.optional().describe('The field to filter the data on.'), searchValue: commons_SearchValueSchema.optional().describe('The value to search for data on.'), searchField: commons_SearchFieldSchema.optional().describe('The field to search for data on.'), byField: z.boolean().optional().describe('If true, the counts for each field will also be returned'), q: z.string().optional().describe('An FFQL query used to filter the result set to be counted'), } as ZodRawShape export const getCalculationsSheet: Tool<typeof params> = { name: 'getCalculationsSheet', description: 'List calculations: Returns all calculations for a sheet', params, cb: async ({ sheetId, versionId, sinceVersionId, commitId, sinceCommitId, filter, filterField, searchValue, searchField, byField, q, }) => { try { const searchParams = { versionId, sinceVersionId, commitId, sinceCommitId, filter, filterField, searchValue, searchField, byField, q, } 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}/calculations${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