Skip to main content
Glama
search-records.ts1.31 kB
import type {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js'; import {z} from 'zod'; import type {ToolContext} from './types.js'; import {tableId} from './schemas.js'; import {jsonResult} from '../utils/response.js'; const outputSchema = z.object({ records: z.array(z.object({ id: z.string(), fields: z.record(z.string(), z.unknown()), })), }); export function registerSearchRecords(server: McpServer, ctx: ToolContext): void { server.registerTool( 'search_records', { title: 'Search Records', description: 'Search for records containing specific text', inputSchema: { ...tableId, searchTerm: z.string().describe('The text to search for'), fieldIds: z.array(z.string()).optional().describe('Optional array of field IDs to search in'), maxRecords: z.number().optional().describe('The maximum total number of records that will be returned'), view: z.string().optional().describe('The name or ID of a view in the table'), }, outputSchema, annotations: { readOnlyHint: true, }, }, async (args) => { const records = await ctx.airtableService.searchRecords( args.baseId, args.tableId, args.searchTerm, args.fieldIds, args.maxRecords, args.view, ); return jsonResult(outputSchema.parse({records})); }, ); }

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/domdomegg/airtable-mcp-server'

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