Skip to main content
Glama

get-artwork-by-artist

Retrieve artworks from the Art Institute of Chicago collection by specifying an artist ID. Supports pagination to browse results systematically.

Instructions

Get artworks by artist id in the Art Institute of Chicago collection. Pagination is supported with the page parameter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe id of the artist to search for artworks. Should be the Artist ID of the `search-for-artist` tool.
limitNoThe number of resources to return per page.
pageNoThe page of results to return. Used for pagination.

Implementation Reference

  • The GetArtworkByArtistTool class implements the core execution logic for the 'get-artwork-by-artist' tool, handling input parsing, API request construction to the Art Institute of Chicago search endpoint, response validation, and formatting.
    export class GetArtworkByArtistTool extends BaseTool<typeof artworkByArtistSchema, any> { public readonly name: string = 'get-artwork-by-artist'; public readonly description: string = 'Get artworks by artist id in the Art Institute of Chicago collection. Pagination is supported with the page parameter.'; public readonly inputSchema = artworkByArtistSchema; constructor() { super(); } public async executeCore(input: z.infer<typeof this.inputSchema>) { const { id, limit, page } = input; const query = { query: { term: { artist_id: id, }, }, }; const url = new URL(`${this.apiBaseUrl}/artworks/search`); url.searchParams.set('page', `${page}`); url.searchParams.set('limit', `${limit}`); url.searchParams.set('query', `artist_id:${id}`); 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, `Artworks by artist ID ${id}`); } }
  • Input schema (Zod) defining parameters for the tool: artist ID (required), optional limit and page for pagination.
    const artworkByArtistSchema = z.object({ id: z.number().describe('The id of the artist to search for artworks. Should be the Artist ID of the `search-for-artist` tool.'), 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.'), });
  • Output schema (Zod) for validating the artwork search API response, used in the tool's safeApiRequest method.
    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, });
  • src/index.ts:81-86 (registration)
    Registers the 'get-artwork-by-artist' tool with the MCP server by calling server.tool() with the tool's name, description, input schema, and execute method.
    this.server.tool( this.getArtworkByArtistTool.name, this.getArtworkByArtistTool.description, this.getArtworkByArtistTool.inputSchema.shape, this.getArtworkByArtistTool.execute.bind(this.getArtworkByArtistTool), );
  • formatArtworkList helper method used by the tool to format the list of artworks into a readable text response with pagination info.
    protected formatArtworkList(artworks: any[], query: string) { if (artworks.length === 0) { return { content: [{ type: 'text' as const, text: `No artworks found for "${query}".` }], isError: false, }; } const artText = artworks.map((artwork) => { return `Title: ${artwork.title}\n` + `Artwork ID: ${artwork.id}\n` + `Thumbnail alt text: ${artwork.thumbnail?.alt_text ?? 'No thumbnail available'}\n` + `Score: ${artwork._score}\n`; }).join('\n-----\n'); const paginationText = artworks.length > 0 ? `\nPagination Info\n` + `Total: ${artworks[0]._pagination?.total || 'Unknown'}\n` + `Total Pages: ${artworks[0]._pagination?.total_pages || 'Unknown'}\n` + `Current Page: ${artworks[0]._pagination?.current_page || 'Unknown'}` : ''; return { content: [{ type: 'text' as const, text: artText + paginationText }], }; }

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