get-museum-object
Retrieve detailed information and images from the Metropolitan Museum of Art Collection using specific object IDs to access art data and resources.
Instructions
Get a museum object by its ID, from the Metropolitan Museum of Art Collection
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| objectId | Yes | The ID of the museum object to retrieve | |
| returnImage | No | Whether to return the image (if available) of the object and add it to the server resources | |
| __intent | Yes | In ≤ 30 words, describe why you are calling this tool and how its result advances your overall task. Don't use first-person pronouns like "I" or "my". Make sure to give a gist of the whole task and how this tool fits into it. |
Implementation Reference
- src/tools/GetObjectTool.ts:25-75 (handler)The main handler function that performs the API fetch, response parsing, text formatting, and optional image processing for the get-museum-object tool.public async execute({ objectId, returnImage }: z.infer<typeof this.inputSchema>) { try { const url = `${this.baseURL}${objectId}`; const response = await metMuseumRateLimiter.fetch(url.toString()); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const jsonData = await response.json(); const parseResult = ObjectResponseSchema.safeParse(jsonData); if (!parseResult.success) { throw new Error(`Invalid response shape: ${JSON.stringify(parseResult.error.issues, null, 2)}`); } const data = parseResult.data; const text = `Title: ${data.title}\n` + `${data.artistDisplayName ? `Artist: ${data.artistDisplayName}\n` : ''}` + `${data.artistDisplayBio ? `Artist Bio: ${data.artistDisplayBio}\n` : ''}` + `${data.department ? `Department: ${data.department}\n` : ''}` + `${data.creditLine ? `Credit Line: ${data.creditLine}\n` : ''}` + `${data.medium ? `Medium: ${data.medium}\n` : ''}` + `${data.dimensions ? `Dimensions: ${data.dimensions}\n` : ''}` + `${data.primaryImage ? `Primary Image URL: ${data.primaryImage}\n` : ''}` + `${data.tags ? `Tags: ${data.tags.map(tag => tag.term).join(', ')}\n` : ''}`; const content = []; content.push({ type: 'text' as const, text, }); if (returnImage && data.primaryImageSmall) { const imageBase64 = await imageToBase64(data.primaryImageSmall); content.push({ type: 'image' as const, data: imageBase64, mimeType: 'image/jpeg', }); this.imageByTitle.set(data.title!, imageBase64); this.server.server.notification({ method: 'notifications/resources/list_changed', }); } return { content }; } catch (error) { console.error('Error getting museum object:', error); return { content: [{ type: 'text' as const, text: `Error getting museum object id ${objectId}: ${error}` }], isError: true, }; } }
- src/tools/GetObjectTool.ts:10-13 (schema)Input validation schema using Zod for the tool parameters.public readonly inputSchema = z.object({ objectId: z.number().describe('The ID of the museum object to retrieve'), returnImage: z.boolean().optional().default(true).describe('Whether to return the image (if available) of the object and add it to the server resources'), }).describe('Get a museum object by its ID');
- src/types/types.ts:49-114 (schema)Output/response validation schema for the Met Museum object API response data.export const ObjectResponseSchema = z.object({ objectID: z.number().describe('Identifying number for each artwork (unique, can be used as key field)'), isHighlight: z.boolean().describe('When "true" indicates a popular and important artwork in the collection'), accessionNumber: z.string().describe('Identifying number for each artwork (not always unique)'), accessionYear: z.string().describe('Year the artwork was acquired'), isPublicDomain: z.boolean().describe('When "true" indicates the image is in the public domain'), primaryImage: z.string().describe('URL to the primary image of an object in JPEG format'), primaryImageSmall: z.string().describe('URL to the lower-res primary image of an object in JPEG format'), additionalImages: z.array(z.string()).describe('An array containing URLs to the additional images of an object in JPEG format'), constituents: z.array(constituentSchema).nullable().describe( 'An array containing the constituents associated with an object, with the constituent\'s role, name, ' + 'ULAN URL, Wikidata URL, and gender, when available (currently contains female designations only)', ), department: z.string().describe('Indicates The Met\'s curatorial department responsible for the artwork'), objectName: z.string().describe('Describes the physical type of the object'), title: z.string().describe('Title, identifying phrase, or name given to a work of art'), culture: z.string().describe('Information about the culture, or people from which an object was created'), period: z.string().describe('Time or time period when an object was created'), dynasty: z.string().describe('Dynasty (a succession of rulers of the same line or family) under which an object was created'), reign: z.string().describe('Reign of a monarch or ruler under which an object was created'), portfolio: z.string().describe('A set of works created as a group or published as a series'), artistRole: z.string().describe('Role of the artist related to the type of artwork or object that was created'), artistPrefix: z.string().describe('Describes the extent of creation or describes an attribution qualifier to the information given in the artistRole field'), artistDisplayName: z.string().describe('Artist name in the correct order for display'), artistDisplayBio: z.string().describe('Nationality and life dates of an artist, also includes birth and death city when known'), artistSuffix: z.string().describe('Used to record complex information that qualifies the role of a constituent'), artistAlphaSort: z.string().describe('Used to sort artist names alphabetically. Last Name, First Name, Middle Name, Suffix, and Honorific fields'), artistNationality: z.string().describe('National, geopolitical, cultural, or ethnic origins or affiliation of the creator'), artistBeginDate: z.string().describe('Year the artist was born'), artistEndDate: z.string().describe('Year the artist died'), artistGender: z.string().describe('Gender of the artist (currently contains female designations only)'), artistWikidata_URL: z.string().describe('Wikidata URL for the artist'), artistULAN_URL: z.string().describe('ULAN URL for the artist'), objectDate: z.string().describe('Year, a span of years, or a phrase that describes the specific or approximate date when an artwork was designed or created'), objectBeginDate: z.number().describe('Machine readable date indicating the year the artwork was started to be created'), objectEndDate: z.number().describe('Machine readable date indicating the year the artwork was completed'), medium: z.string().describe('Refers to the materials that were used to create the artwork'), dimensions: z.string().describe('Size of the artwork or object'), measurements: z.array(z.object({ elementName: z.string(), elementDescription: z.string().nullable().optional(), elementMeasurements: z.record(z.string(), z.number()), })).nullable().describe('Array of elements, each with a name, description, and set of measurements. Spatial measurements are in centimeters; weights are in kg'), creditLine: z.string().describe('Text acknowledging the source or origin of the artwork and the year the object was acquired'), geographyType: z.string().describe('Type of location related to the artwork (e.g., "Made in", "From")'), city: z.string().describe('City associated with the artwork\'s creation'), state: z.string().describe('State or province associated with the artwork\'s creation'), county: z.string().describe('County associated with the artwork\'s creation'), country: z.string().describe('Country associated with the artwork\'s creation'), region: z.string().describe('Region associated with the artwork\'s creation'), subregion: z.string().describe('Subregion associated with the artwork\'s creation'), locale: z.string().describe('Locale associated with the artwork\'s creation'), locus: z.string().describe('Locus associated with the artwork\'s creation'), excavation: z.string().describe('Excavation associated with the artwork'), river: z.string().describe('River associated with the artwork\'s creation'), classification: z.string().describe('General term describing the artwork type'), rightsAndReproduction: z.string().describe('Credit line for artworks still under copyright'), linkResource: z.string().describe('URL to the object\'s page on metmuseum.org'), metadataDate: z.string().describe('Date metadata was last updated'), repository: z.string().describe('Indicates the repository containing the artwork'), objectURL: z.string().describe('URL to the object\'s page on metmuseum.org'), tags: z.array(tagSchema).nullable().describe('An array of subject keyword tags associated with the object'), objectWikidata_URL: z.string().describe('Wikidata URL for the object'), isTimelineWork: z.boolean().describe('Whether the artwork is featured on the Timeline of Art History website'), GalleryNumber: z.string().describe('Gallery number where artwork is located'), }).partial(); // All fields are optional as the API may not return all fields for all objects
- src/index.ts:73-78 (registration)Registers the get-museum-object tool with the MCP server.this.server.tool( this.getMuseumObject.name, this.getMuseumObject.description, this.getMuseumObject.inputSchema.shape, this.getMuseumObject.execute.bind(this.getMuseumObject), );