Skip to main content
Glama
mikechao

Met Museum MCP Server

by mikechao

get-museum-object

Read-onlyIdempotent

Retrieve detailed information about a specific museum object from the Metropolitan Museum of Art collection using its object ID, with an optional primary image.

Instructions

Get a museum object by its ID, from the Metropolitan Museum of Art Collection. Use this when the user asks for deeper details on a specific object ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectIdYesThe positive integer ID of the museum object to retrieve
returnImageNoWhether to return the image (if available) of the object

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
objectYesDetailed object data for the requested object ID

Implementation Reference

  • The GetObjectTool class implements the 'get-museum-object' tool. The execute() method (line 25) fetches object data from the Met Museum API via apiClient.getObject(), formats the response as text content, optionally fetches and returns the image as base64, and returns structured content with the full object data.
    export class GetObjectTool {
      public readonly name: string = 'get-museum-object';
      public readonly description: string = 'Get a museum object by its ID, from the Metropolitan Museum of Art Collection. '
        + 'Use this when the user asks for deeper details on a specific object ID.';
    
      public readonly inputSchema = z.object({
        objectId: z.number().int().positive().describe('The positive integer ID of the museum object to retrieve'),
        returnImage: z.boolean().optional().default(true).describe('Whether to return the image (if available) of the object'),
      }).describe('Get a museum object by its ID');
    
      private readonly apiClient: MetMuseumApiClient;
    
      constructor(apiClient: MetMuseumApiClient) {
        this.apiClient = apiClient;
      }
    
      public async execute({ objectId, returnImage }: z.infer<typeof this.inputSchema>): Promise<CallToolResult> {
        try {
          const data = await this.apiClient.getObject(objectId);
          const tagsText = Array.isArray(data.tags)
            ? data.tags
                .map(tag => tag?.term?.trim())
                .filter((term): term is string => Boolean(term))
                .join(', ')
            : '';
    
          let text = `Object ID: ${data.objectID}\n`
            + `Title: ${data.title}\n`
            + `${data.artistDisplayName ? `Artist: ${data.artistDisplayName}\n` : ''}`
            + `${data.artistDisplayBio ? `Artist Bio: ${data.artistDisplayBio}\n` : ''}`
            + `${data.department ? `Department: ${data.department}\n` : ''}`
            + `${data.objectDate ? `Date: ${data.objectDate}\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` : ''}`
            + `${tagsText ? `Tags: ${tagsText}\n` : ''}`;
    
          let imageContent: ImageContent | null = null;
          let imageFetchFailed = false;
          const preferredImageUrl = data.primaryImageSmall || data.primaryImage;
    
          if (returnImage && preferredImageUrl) {
            try {
              const image = await this.apiClient.getImageAsBase64(preferredImageUrl);
              imageContent = {
                type: 'image',
                data: image.data,
                mimeType: image.mimeType,
              };
            }
            catch {
              // Note: Image fetch failed - we'll add a note to the text below.
              // This can happen due to network issues, timeouts, or invalid URLs.
              imageFetchFailed = true;
            }
          }
    
          if (imageFetchFailed) {
            const fallbackImageUrl = data.primaryImage || data.primaryImageSmall;
            text += fallbackImageUrl
              ? `\nNote: Image could not be loaded. You can try accessing it directly here: ${fallbackImageUrl}`
              : '\nNote: Image could not be loaded.';
          }
    
          const content: Array<TextContent | ImageContent> = [];
          content.push({
            type: 'text',
            text,
          });
          if (imageContent) {
            content.push(imageContent);
          }
    
          const structuredContent: GetMuseumObjectStructuredContent = {
            object: data,
          };
    
          return {
            content,
            structuredContent,
          };
        }
        catch (error) {
          if (error instanceof MetMuseumApiError) {
            const message = error.isUserFriendly
              ? error.message
              : `Error getting museum object id ${objectId}: ${error.message}`;
            return {
              content: [{ type: 'text', text: message }],
              isError: true,
            };
          }
          // Note: Error is already returned to user in the tool response.
          // No need to log to stderr as it would leak implementation details in stdio mode.
          return {
            content: [{ type: 'text', text: `Error getting museum object id ${objectId}: ${error}` }],
            isError: true,
          };
        }
      }
    }
  • The GetMuseumObjectStructuredContentSchema defines the output schema for the tool, containing the full object response data validated against ObjectResponseSchema (lines 55-120).
    export const GetMuseumObjectStructuredContentSchema = z.object({
      object: ObjectResponseSchema.describe('Detailed object data for the requested object ID'),
    });
  • The input schema for the tool, accepting objectId (required positive integer) and returnImage (optional boolean, defaults to true).
    public readonly inputSchema = z.object({
      objectId: z.number().int().positive().describe('The positive integer ID of the museum object to retrieve'),
      returnImage: z.boolean().optional().default(true).describe('Whether to return the image (if available) of the object'),
    }).describe('Get a museum object by its ID');
  • The tool is registered with registerAppTool() using the name 'get-museum-object' (via getMuseumObject.name), with annotations including title 'Get Met Museum Object', and is bound to getMuseumObject.execute.
    registerAppTool(
      server,
      getMuseumObject.name,
      {
        description: getMuseumObject.description,
        inputSchema: getMuseumObject.inputSchema.shape,
        outputSchema: GetMuseumObjectStructuredContentSchema.shape,
        annotations: {
          title: 'Get Met Museum Object',
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: true,
        },
        _meta: {
          ui: {
            resourceUri: getMuseumObjectAppResource.uri,
          },
        },
      },
      getMuseumObject.execute.bind(getMuseumObject),
    );
  • The getObject() method on the API client fetches object data from the Met Museum API, normalizes nulls to undefined, and validates the response against ObjectResponseSchema.
    public async getObject(objectId: number): Promise<z.infer<typeof ObjectResponseSchema>> {
      const url = `${this.objectBaseUrl}${objectId}`;
      const rawData = await this.fetchJson(url);
      const normalizedData = normalizeNulls(rawData);
      const parseResult = ObjectResponseSchema.safeParse(normalizedData);
      if (!parseResult.success) {
        logSchemaValidationFailure('object', parseResult.error, { objectId, url });
        throw createUnexpectedResponseError('object');
      }
      return parseResult.data;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv0.9.0
    • removedInput schema / properties / __intent
      Removed value: -{
      -  "description": "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.",
      -  "type": "string"
      -}
    • changedInput schema / properties / objectId / description
      Previous value: -"The ID of the museum object to retrieve"New value: +"The positive integer ID of the museum object to retrieve"
    • addedInput schema / properties / objectId / exclusiveMinimum
      Added value: +0
    • changedInput schema / properties / objectId / type
      Previous value: -"number"New value: +"integer"
    • changedInput schema / properties / returnImage / description
      Previous value: -"Whether to return the image (if available) of the object and add it to the server resources"New value: +"Whether to return the image (if available) of the object"
    • changedInput schema / required
      Previous value: -[
      -  "objectId",
      -  "__intent"
      -]New value: +[
      +  "objectId"
      +]
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": false,
      +  "properties": {
      +    "object": {
      +      "additionalProperties": false,
      +      "description": "Detailed object data for the requested object ID",
      +      "properties": {
      +        "GalleryNumber": {
      +          "description": "Gallery number where artwork is located",
      +          "type": "string"
      +        },
      +        "accessionNumber": {
      +          "description": "Identifying number for each artwork (not always unique)",
      +          "type": "string"
      +        },
      +        "accessionYear": {
      +          "description": "Year the artwork was acquired",
      +          "type": "string"
      +        },
      +        "additionalImages": {
      +          "description": "An array containing URLs to the additional images of an object in JPEG format",
      +          "items": {
      +            "type": "string"
      +          },
      +          "type": "array"
      +        },
      +        "artistAlphaSort": {
      +          "description": "Used to sort artist names alphabetically. Last Name, First Name, Middle Name, Suffix, and Honorific fields",
      +          "type": "string"
      +        },
      +        "artistBeginDate": {
      +          "description": "Year the artist was born",
      +          "type": "string"
      +        },
      +        "artistDisplayBio": {
      +          "description": "Nationality and life dates of an artist, also includes birth and death city when known",
      +          "type": "string"
      +        },
      +        "artistDisplayName": {
      +          "description": "Artist name in the correct order for display",
      +          "type": "string"
      +        },
      +        "artistEndDate": {
      +          "description": "Year the artist died",
      +          "type": "string"
      +        },
      +        "artistGender": {
      +          "description": "Gender of the artist (currently contains female designations only)",
      +          "type": "string"
      +        },
      +        "artistNationality": {
      +          "description": "National, geopolitical, cultural, or ethnic origins or affiliation of the creator",
      +          "type": "string"
      +        },
      +        "artistPrefix": {
      +          "description": "Describes the extent of creation or describes an attribution qualifier to the information given in the artistRole field",
      +          "type": "string"
      +        },
      +        "artistRole": {
      +          "description": "Role of the artist related to the type of artwork or object that was created",
      +          "type": "string"
      +        },
      +        "artistSuffix": {
      +          "description": "Used to record complex information that qualifies the role of a constituent",
      +          "type": "string"
      +        },
      +        "artistULAN_URL": {
      +          "description": "ULAN URL for the artist",
      +          "type": "string"
      +        },
      +        "artistWikidata_URL": {
      +          "description": "Wikidata URL for the artist",
      +          "type": "string"
      +        },
      +        "city": {
      +          "description": "City associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "classification": {
      +          "description": "General term describing the artwork type",
      +          "type": "string"
      +        },
      +        "constituents": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": false,
      +                "properties": {
      +                  "constituentID": {
      +                    "type": "number"
      +                  },
      +                  "constituentULAN_URL": {
      +                    "type": "string"
      +                  },
      +                  "constituentWikidata_URL": {
      +                    "type": "string"
      +                  },
      +                  "gender": {
      +                    "type": "string"
      +                  },
      +                  "name": {
      +                    "type": "string"
      +                  },
      +                  "role": {
      +                    "type": "string"
      +                  }
      +                },
      +                "required": [
      +                  "constituentID",
      +                  "role",
      +                  "name",
      +                  "constituentULAN_URL",
      +                  "constituentWikidata_URL",
      +                  "gender"
      +                ],
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "description": "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)"
      +        },
      +        "country": {
      +          "description": "Country associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "county": {
      +          "description": "County associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "creditLine": {
      +          "description": "Text acknowledging the source or origin of the artwork and the year the object was acquired",
      +          "type": "string"
      +        },
      +        "culture": {
      +          "description": "Information about the culture, or people from which an object was created",
      +          "type": "string"
      +        },
      +        "department": {
      +          "description": "Indicates The Met's curatorial department responsible for the artwork",
      +          "type": "string"
      +        },
      +        "dimensions": {
      +          "description": "Size of the artwork or object",
      +          "type": "string"
      +        },
      +        "dynasty": {
      +          "description": "Dynasty (a succession of rulers of the same line or family) under which an object was created",
      +          "type": "string"
      +        },
      +        "excavation": {
      +          "description": "Excavation associated with the artwork",
      +          "type": "string"
      +        },
      +        "geographyType": {
      +          "description": "Type of location related to the artwork (e.g., \"Made in\", \"From\")",
      +          "type": "string"
      +        },
      +        "isHighlight": {
      +          "description": "When \"true\" indicates a popular and important artwork in the collection",
      +          "type": "boolean"
      +        },
      +        "isPublicDomain": {
      +          "description": "When \"true\" indicates the image is in the public domain",
      +          "type": "boolean"
      +        },
      +        "isTimelineWork": {
      +          "description": "Whether the artwork is featured on the Timeline of Art History website",
      +          "type": "boolean"
      +        },
      +        "linkResource": {
      +          "description": "URL to the object's page on metmuseum.org",
      +          "type": "string"
      +        },
      +        "locale": {
      +          "description": "Locale associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "locus": {
      +          "description": "Locus associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "measurements": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": false,
      +                "properties": {
      +                  "elementDescription": {
      +                    "type": [
      +                      "string",
      +                      "null"
      +                    ]
      +                  },
      +                  "elementMeasurements": {
      +                    "additionalProperties": {
      +                      "type": "number"
      +                    },
      +                    "type": "object"
      +                  },
      +                  "elementName": {
      +                    "type": "string"
      +                  }
      +                },
      +                "required": [
      +                  "elementName",
      +                  "elementMeasurements"
      +                ],
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "description": "Array of elements, each with a name, description, and set of measurements. Spatial measurements are in centimeters; weights are in kg"
      +        },
      +        "medium": {
      +          "description": "Refers to the materials that were used to create the artwork",
      +          "type": "string"
      +        },
      +        "metadataDate": {
      +          "description": "Date metadata was last updated",
      +          "type": "string"
      +        },
      +        "objectBeginDate": {
      +          "description": "Machine readable date indicating the year the artwork was started to be created",
      +          "type": "number"
      +        },
      +        "objectDate": {
      +          "description": "Year, a span of years, or a phrase that describes the specific or approximate date when an artwork was designed or created",
      +          "type": "string"
      +        },
      +        "objectEndDate": {
      +          "description": "Machine readable date indicating the year the artwork was completed",
      +          "type": "number"
      +        },
      +        "objectID": {
      +          "description": "Identifying number for each artwork (unique, can be used as key field)",
      +          "type": "number"
      +        },
      +        "objectName": {
      +          "description": "Describes the physical type of the object",
      +          "type": "string"
      +        },
      +        "objectURL": {
      +          "description": "URL to the object's page on metmuseum.org",
      +          "type": "string"
      +        },
      +        "objectWikidata_URL": {
      +          "description": "Wikidata URL for the object",
      +          "type": "string"
      +        },
      +        "period": {
      +          "description": "Time or time period when an object was created",
      +          "type": "string"
      +        },
      +        "portfolio": {
      +          "description": "A set of works created as a group or published as a series",
      +          "type": "string"
      +        },
      +        "primaryImage": {
      +          "description": "URL to the primary image of an object in JPEG format",
      +          "type": "string"
      +        },
      +        "primaryImageSmall": {
      +          "description": "URL to the lower-res primary image of an object in JPEG format",
      +          "type": "string"
      +        },
      +        "region": {
      +          "description": "Region associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "reign": {
      +          "description": "Reign of a monarch or ruler under which an object was created",
      +          "type": "string"
      +        },
      +        "repository": {
      +          "description": "Indicates the repository containing the artwork",
      +          "type": "string"
      +        },
      +        "rightsAndReproduction": {
      +          "description": "Credit line for artworks still under copyright",
      +          "type": "string"
      +        },
      +        "river": {
      +          "description": "River associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "state": {
      +          "description": "State or province associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "subregion": {
      +          "description": "Subregion associated with the artwork's creation",
      +          "type": "string"
      +        },
      +        "tags": {
      +          "anyOf": [
      +            {
      +              "items": {
      +                "additionalProperties": false,
      +                "properties": {
      +                  "AAT_URL": {
      +                    "type": "string"
      +                  },
      +                  "Wikidata_URL": {
      +                    "type": "string"
      +                  },
      +                  "term": {
      +                    "type": "string"
      +                  }
      +                },
      +                "type": "object"
      +              },
      +              "type": "array"
      +            },
      +            {
      +              "type": "null"
      +            }
      +          ],
      +          "description": "An array of subject keyword tags associated with the object"
      +        },
      +        "title": {
      +          "description": "Title, identifying phrase, or name given to a work of art",
      +          "type": "string"
      +        }
      +      },
      +      "type": "object"
      +    }
      +  },
      +  "required": [
      +    "object"
      +  ],
      +  "type": "object"
      +}
  2. First observed

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, destructiveHint, idempotentHint, openWorldHint. The description adds no additional behavioral context beyond 'Get' and 'deeper details,' which is consistent but not enriching.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences: one for the action and one for usage guidance. Front-loaded and efficient with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple object retrieval tool, the description suffices given the presence of an output schema, annotations, and sibling tools. No missing critical context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for both parameters (objectId and returnImage). The description does not add parameter-specific context, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Get a museum object by its ID' and specifies source (Metropolitan Museum of Art). It distinguishes from siblings that list, search, or open explorer.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this when the user asks for deeper details on a specific object ID,' providing clear when-to-use guidance and implying when not to use (e.g., for listing or searching).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.