Skip to main content
Glama
ukicar

Gallica/BnF MCP Server

by ukicar

get_page_image

Retrieve IIIF image URLs and metadata for specific pages in Gallica/BnF digital documents using ARK identifiers and page numbers.

Instructions

Get IIIF image URL for a specific page. Returns URL and metadata, not binary data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
arkYesARK identifier
pageYesPage number
sizeNoImage size (e.g., "full", "200,", "500,500", "pct:50")
regionNoImage region (e.g., "full", "x,y,w,h")

Implementation Reference

  • Main tool implementation: createGetPageImageTool function that defines the get_page_image tool with its name, description, input schema, and async handler that validates inputs and calls iiifClient.getImageUrl to return IIIF image URLs
    export function createGetPageImageTool(iiifClient: IIIFClient) {
      return {
        name: 'get_page_image',
        description: 'Get IIIF image URL for a specific page. Returns URL and metadata, not binary data.',
        inputSchema: {
          type: 'object',
          properties: {
            ark: {
              type: 'string',
              description: 'ARK identifier',
            },
            page: {
              type: 'number',
              description: 'Page number',
            },
            size: {
              type: 'string',
              description: 'Image size (e.g., "full", "200,", "500,500", "pct:50")',
            },
            region: {
              type: 'string',
              description: 'Image region (e.g., "full", "x,y,w,h")',
            },
          },
          required: ['ark', 'page'],
        },
        handler: async (args: unknown) => {
          const parsed = z.object({
            ark: z.string(),
            page: z.number().int().positive(),
            size: z.string().optional(),
            region: z.string().optional(),
          }).parse(args);
    
          const options: { size?: string; region?: string } = {};
          if (parsed.size) options.size = parsed.size;
          if (parsed.region) options.region = parsed.region;
          
          const url = iiifClient.getImageUrl(parsed.ark, parsed.page, options);
    
          return {
            ark: parsed.ark,
            page: parsed.page,
            iiif_url: url,
            thumbnail_url: iiifClient.getImageUrl(parsed.ark, parsed.page, { size: '200,' }),
          };
        },
      };
    }
  • Input schema definition: Validates 'ark' (required string), 'page' (required number), 'size' (optional string for image size), and 'region' (optional string for image region)
    inputSchema: {
      type: 'object',
      properties: {
        ark: {
          type: 'string',
          description: 'ARK identifier',
        },
        page: {
          type: 'number',
          description: 'Page number',
        },
        size: {
          type: 'string',
          description: 'Image size (e.g., "full", "200,", "500,500", "pct:50")',
        },
        region: {
          type: 'string',
          description: 'Image region (e.g., "full", "x,y,w,h")',
        },
      },
      required: ['ark', 'page'],
    },
  • src/mcpServer.ts:87-87 (registration)
    Tool instantiation: Creates getPageImage tool instance using createGetPageImageTool with iiifClient dependency
    const getPageImage = createGetPageImageTool(iiifClient);
  • Tool registration: Adds getPageImage to the tools array for MCP server registration
    getPageImage,
  • Helper method: IIIFClient.getImageUrl that constructs IIIF image URLs using ark, page, and options (region, size, rotation, quality, format)
    getImageUrl(ark: string, page: number, options: IIIFImageOptions = {}): string {
      // Extract ARK identifier
      const arkId = ark.replace(/^ark:\/12148\//, '').replace(/^\/ark:\/12148\//, '');
      
      const region = options.region || 'full';
      const size = options.size || 'full';
      const rotation = options.rotation !== undefined ? options.rotation : 0;
      const quality = options.quality || 'native';
      const format = options.format || 'jpg';
    
      return `${this.baseUrl}/iiif/ark:/12148/${arkId}/f${page}/${region}/${size}/${rotation}/${quality}.${format}`;
    }

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/ukicar/sweet-bnf'

If you have feedback or need assistance with the MCP directory API, please join our Discord server