Skip to main content
Glama
FullTextSearchTool.ts1.58 kB
import { z } from 'zod'; import { artworkSearchResponseSchema } from '../schemas/schemas'; import { BaseTool } from './BaseTool'; const fullTextSearchSchema = z.object({ query: z.string().describe('The term to search the metadata for.'), limit: z.number().optional().default(10).describe('The number of resources to return per page.'), page: z.number().optional().default(1).describe('The page of results to return. Used for pagination.'), }); export class FullTextSearchTool extends BaseTool<typeof fullTextSearchSchema, any> { public readonly name: string = 'full-text-search'; public readonly description: string = 'Search for artworks in the Art Institute of Chicago collection' + ' whose metadata contains mention of the query term.' + 'Pagination is supported with the page parameter'; public readonly inputSchema = fullTextSearchSchema; constructor() { super(); } public async executeCore(input: z.infer<typeof this.inputSchema>) { const { query, limit, page } = input; const url = new URL(`${this.apiBaseUrl}/artworks/search`); url.searchParams.set('page', `${page}`); url.searchParams.set('limit', `${limit}`); url.searchParams.set('q', query); const parsedData = await this.safeApiRequest( url, { method: 'GET' }, artworkSearchResponseSchema, ); // Attach pagination info to each artwork for formatting parsedData.data.forEach((artwork) => { (artwork as any)._pagination = parsedData.pagination; }); return this.formatArtworkList(parsedData.data, query); } }

Implementation Reference

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/mikechao/artic-mcp'

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