search-by-title
Find artworks by title in the Art Institute of Chicago collection. Supports pagination to browse multiple results.
Instructions
Search for artworks by title in the Art Institute of Chicago. Pagination is supported with the page parameter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | The title of the artwork 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/SearchByTitleTool.ts:20-53 (handler)Implements the core execution logic for the 'search-by-title' tool: constructs Elasticsearch bool query matching title or alt_titles, performs POST to /artworks/search API with pagination, validates response, attaches pagination to items, and formats the artwork list.public async executeCore(input: z.infer<typeof this.inputSchema>) { const { title, limit, page } = input; const query = { query: { bool: { should: [ { match_phrase: { title: `${title}` } }, { match_phrase: { alt_titles: `${title}` } }, ], minimum_should_match: 1, }, }, }; const url = new URL(`${this.apiBaseUrl}/artworks/search`); url.searchParams.set('page', `${page}`); url.searchParams.set('limit', `${limit}`); const parsedData = await this.safeApiRequest( url, { method: 'POST', body: JSON.stringify(query), }, artworkSearchResponseSchema, ); // Attach pagination info to each artwork for formatting parsedData.data.forEach((artwork) => { (artwork as any)._pagination = parsedData.pagination; }); return this.formatArtworkList(parsedData.data, title); }
- src/tools/SearchByTitleTool.ts:5-9 (schema)Input schema for the 'search-by-title' tool, validating title (required), and optional limit/page for pagination.const titleSearchSchema = z.object({ title: z.string().describe('The title of the artwork 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/index.ts:58-61 (registration)Registers the 'search-by-title' tool instance with the MCP server, providing name, description, input schema shape, and bound execute method.this.searchByTitleTool.name, this.searchByTitleTool.description, this.searchByTitleTool.inputSchema.shape, this.searchByTitleTool.execute.bind(this.searchByTitleTool),
- src/schemas/schemas.ts:36-51 (schema)Output schema used by the 'search-by-title' tool to validate the Art Institute API search response, including pagination, data array with artwork summaries, info, and config.export const artworkSearchResponseSchema = 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(), is_boosted: z.boolean(), title: z.string(), thumbnail: thumbnailSchema.nullable(), timestamp: z.string(), })), info: apiInfoSchema, config: apiConfigSchema, });