Skip to main content
Glama

Flatfile MCP Server

by FlatFilers
list-spaces.ts3.21 kB
/** * This file was generated. Do NOT edit this file. */ import fetch from 'node-fetch' import { type ZodRawShape, z } from 'zod' import { commons_AppIdSchema, commons_EnvironmentIdSchema, commons_SortDirectionSchema, spaces_GetSpacesSortFieldSchema, } from '../schemas.js' import type { Tool } from './index.js' const params = { environmentId: commons_EnvironmentIdSchema.optional().describe('The ID of the environment.'), pageSize: z.number().int().optional().describe('Number of spaces to return in a page (default 10)'), pageNumber: z.number().int().optional().describe('Based on pageSize, which page of records to return'), app: commons_AppIdSchema.optional().describe('Filter by appId'), search: z.string().optional().describe('Search query for spaces'), namespace: z.string().optional().describe('Search by namespace'), archived: z.boolean().optional().describe('Flag to include archived spaces'), sortField: spaces_GetSpacesSortFieldSchema .optional() .describe("Field to sort spaces by; requires 'sortDirection' if provided."), sortDirection: commons_SortDirectionSchema .optional() .describe("Direction of sorting; requires 'sortField' if provided."), isCollaborative: z.boolean().optional().describe('Flag for collaborative (project) spaces'), appId: commons_AppIdSchema.optional().describe("(Deprecated!) Use 'app' query parameter"), isAppTemplate: z.boolean().optional().describe('Flag for app templates'), } as ZodRawShape export const listSpaces: Tool<typeof params> = { name: 'listSpaces', description: 'List spaces: Returns all spaces for an account or environment', params, cb: async ({ environmentId, pageSize, pageNumber, app, search, namespace, archived, sortField, sortDirection, isCollaborative, appId, isAppTemplate, }) => { try { const searchParams = { environmentId, pageSize, pageNumber, app, search, namespace, archived, sortField, sortDirection, isCollaborative, appId, isAppTemplate, } 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}/spaces${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