cite
Generate citations for artworks from open-access museum collections. Choose from full (artist, title, date, museum, license, URL), caption, or short style for reuse-safe attribution.
Instructions
Render a citation for an artwork. Styles: "full" (artist, title, date, museum, license, URL), "caption" (image caption form), "short" (inline reference).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Normalized artwork ID. | |
| style | No | full |
Implementation Reference
- src/server.ts:325-330 (handler)The handler function that executes the 'cite' tool logic: parses the input (id + style), fetches the artwork by id, and returns the citation string produced by the cite() utility.
async function handleCite(args: unknown) { const input = CiteInput.parse(args); const out = await fetchAndCache(input.id); if (!out.ok) return errorResult(out.reason); return { content: [{ type: 'text' as const, text: cite(out.artwork, input.style as CiteStyle) }] }; } - src/server.ts:107-110 (schema)Zod schema for the 'cite' tool's input: object with 'id' (string matching museum ID regex) and optional 'style' enum (short/full/caption, defaulting to full).
const CiteInput = z.object({ id: z.string().regex(ID_REGEX), style: z.enum(['short', 'full', 'caption']).default('full'), }); - src/server.ts:202-218 (registration)The tool registration in ListToolsRequestSchema: the 'cite' tool with its name, description, and input JSON schema for id and style.
{ name: 'cite', description: 'Render a citation for an artwork. Styles: "full" (artist, title, date, museum, license, URL), "caption" (image caption form), "short" (inline reference).', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Normalized artwork ID.' }, style: { type: 'string', enum: ['short', 'full', 'caption'], default: 'full', }, }, required: ['id'], }, }, - src/cite.ts:60-68 (handler)The core cite() function that generates citation strings from an Artwork object. Dispatches to per-museum formatters (currently only 'met' overrides) for 'full' and 'caption' styles, or uses 'shortStyle' for the 'short' style.
export function cite(artwork: Artwork, style: CiteStyle = 'full'): string { if (style === 'short') return shortStyle(artwork); if (style === 'caption') { const fn = PER_MUSEUM_CAPTION[artwork.museum.code] ?? metCaption; return fn(artwork); } const fn = PER_MUSEUM_FULL[artwork.museum.code] ?? metFull; return fn(artwork); } - src/cite.ts:5-7 (helper)Helper function joinNonEmpty that filters out empty/null/undefined strings and joins with a separator, used by citation formatters.
function joinNonEmpty(parts: Array<string | undefined | null>, sep: string): string { return parts.filter((p): p is string => Boolean(p && p.trim())).join(sep); }