search-for-artist
Find artists in the Art Institute of Chicago collection by searching their names, with pagination support for browsing results.
Instructions
Search for artists in the Art Institute of Chicago collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The name of the artist to search for. | |
| limit | No | The number of resources to return per page. | |
| page | No | The page of results to return. Used for pagination. |
Implementation Reference
- src/tools/ArtistSearchTool.ts:20-67 (handler)Implements the core tool logic: builds query for artist search via API, handles response, formats output with artist details and pagination.public async executeCore(input: z.infer<typeof this.inputSchema>) { const { name, limit, page } = input; const query = { query: { bool: { should: [ { match_phrase: { title: `"${name}"` } }, ], minimum_should_match: 1, }, }, }; const url = new URL(`${this.apiBaseUrl}/agents/search`); url.searchParams.set('page', `${page}`); url.searchParams.set('limit', `${limit}`); const parsedData = await this.safeApiRequest( url, { method: 'POST', body: JSON.stringify(query), }, artistSearchResponseSchema, ); if (parsedData.data.length === 0) { return { content: [{ type: 'text' as const, text: `No results found for "${name}".`, }], }; } const text = parsedData.data.map((artist) => { return `Title: ${artist.title}\n` + `Artist ID: ${artist.id}\n` + `Score: ${artist._score}\n`; }).join('\n-----\n'); const paginationText = `\nPagination Info\n` + `Total: ${parsedData.pagination.total}\n` + `Total Pages: ${parsedData.pagination.total_pages}\n` + `Current Page: ${parsedData.pagination.current_page}\n`; return { content: [{ type: 'text' as const, text: text + paginationText }], }; }
- src/index.ts:75-80 (registration)Registers the 'search-for-artist' tool with the MCP server, providing name, description, input schema, and bound execute method.this.server.tool( this.artistSearchTool.name, this.artistSearchTool.description, this.artistSearchTool.inputSchema.shape, this.artistSearchTool.execute.bind(this.artistSearchTool), );
- src/tools/ArtistSearchTool.ts:5-9 (schema)Zod input schema defining parameters: name (required string), optional limit and page.const artistSearchSchema = z.object({ name: z.string().describe('The name of the artist to search 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.'), });
- src/schemas/schemas.ts:96-109 (schema)Zod schema for validating the API response from artist search endpoint (/agents/search).export const artistSearchResponseSchema = z.object({ preference: z.string().nullable(), pagination: paginationSchema, data: z.array(z.object({ _score: z.number(), id: z.number(), api_model: z.string(), api_link: z.string(), title: z.string(), timestamp: z.string(), })), info: apiInfoSchema, config: apiConfigSchema, });
- src/tools/ArtistSearchTool.ts:11-18 (helper)Class definition extending BaseTool, setting tool name, description, and input schema.export class ArtistSearchTool extends BaseTool<typeof artistSearchSchema, any> { public readonly name: string = 'search-for-artist'; public readonly description: string = 'Search for artists in the Art Institute of Chicago collection'; public readonly inputSchema = artistSearchSchema; constructor() { super(); }