Skip to main content
Glama
ukicar

Gallica/BnF MCP Server

by ukicar

get_item_pages

Retrieve document page details including logical numbers, IIIF image URLs, and text availability from Gallica digital library using ARK identifiers.

Instructions

Enumerate pages of a document. Returns logical page numbers, IIIF image URLs, and text availability flags.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
arkYesARK identifier
pageNoGet specific page number
page_sizeNoGet first N pages
page_rangeNoGet pages in range [start, end]

Implementation Reference

  • Main tool handler function 'createGetItemPagesTool' that defines the MCP tool with name, description, input schema, and handler logic. The handler parses Zod-validated arguments and calls the ItemsClient.getItemPages method with appropriate options (page, pageSize, or range).
    export function createGetItemPagesTool(itemsClient: ItemsClient) {
      return {
        name: 'get_item_pages',
        description: 'Enumerate pages of a document. Returns logical page numbers, IIIF image URLs, and text availability flags.',
        inputSchema: {
          type: 'object',
          properties: {
            ark: {
              type: 'string',
              description: 'ARK identifier',
            },
            page: {
              type: 'number',
              description: 'Get specific page number',
            },
            page_size: {
              type: 'number',
              description: 'Get first N pages',
            },
            page_range: {
              type: 'array',
              items: { type: 'number' },
              minItems: 2,
              maxItems: 2,
              description: 'Get pages in range [start, end]',
            },
          },
          required: ['ark'],
        },
        handler: async (args: unknown) => {
          const parsed = z.object({
            ark: z.string(),
            page: z.number().int().positive().optional(),
            page_size: z.number().int().positive().optional(),
            page_range: z.tuple([z.number().int().positive(), z.number().int().positive()]).optional(),
          }).parse(args);
    
          const options: {
            page?: number;
            pageSize?: number;
            range?: [number, number];
          } = {};
    
          if (parsed.page !== undefined) {
            options.page = parsed.page;
          } else if (parsed.page_size !== undefined) {
            options.pageSize = parsed.page_size;
          } else if (parsed.page_range !== undefined) {
            options.range = parsed.page_range;
          }
    
          return await itemsClient.getItemPages(parsed.ark, options);
        },
      };
  • Backend implementation 'getItemPages' method in ItemsClient class. Parses IIIF manifest, filters pages based on options (single page, page range, or first N pages), and returns array of PageInfo objects with page numbers, IIIF URLs, and text availability flags.
    async getItemPages(
      ark: string,
      options?: {
        page?: number;
        pageSize?: number;
        range?: [number, number];
      }
    ): Promise<PageInfo[]> {
      if (!ark) {
        return [];
      }
      try {
        const manifest = await this.iiifClient.parseManifest(ark);
        let pages = manifest.pages;
    
        // Apply filters
        if (options?.range) {
          const [start, end] = options.range;
          pages = pages.filter((p) => p.page >= start && p.page <= end);
        } else if (options?.page !== undefined) {
          // Get single page
          const page = pages.find((p) => p.page === options.page);
          return page ? [page] : [];
        } else if (options?.pageSize !== undefined) {
          // Get first N pages
          pages = pages.slice(0, options.pageSize);
        }
    
        return pages;
      } catch (error) {
        logger.error(`Error getting pages for ${ark}: ${error instanceof Error ? error.message : String(error)}`);
        return [];
      }
    }
  • Type definition for PageInfo interface that defines the structure of page objects returned by get_item_pages tool, including page number, label, IIIF image URL, text availability flag, and optional thumbnail URL.
    export interface PageInfo {
      page: number;
      label?: string;
      iiif_image_url: string;
      has_text: boolean;
      thumbnail_url?: string;
    }
  • src/mcpServer.ts:86-86 (registration)
    Tool instantiation: creates the get_item_pages tool by calling createGetItemPagesTool with the itemsClient instance.
    const getItemPages = createGetItemPagesTool(itemsClient);
  • Tool registration: adds getItemPages to the tools array that is registered with the MCP server for listing and calling.
    getItemPages,
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it states what the tool returns, it doesn't cover important aspects like whether this is a read-only operation (implied but not stated), potential rate limits, authentication requirements, error conditions, or pagination behavior for large documents. The description adds minimal behavioral context beyond the basic return statement.

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?

The description is extremely concise with just two sentences that efficiently convey the core functionality and return values. Every word earns its place - the first sentence states the action and resource, the second specifies the return data structure. There's no wasted verbiage or redundancy.

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

Completeness3/5

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

For a tool with 4 parameters, no annotations, and no output schema, the description provides adequate but incomplete context. It explains what the tool does and what it returns, but lacks behavioral details (permissions, limits, errors) and parameter usage guidance. Given the complexity of having multiple pagination options (page, page_size, page_range) and no output schema, the description should do more to help an agent understand how to use it effectively.

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?

The input schema has 100% description coverage, so all parameters are documented in the schema. The description doesn't add any parameter-specific information beyond what's in the schema - it doesn't explain parameter interactions (e.g., that page, page_size, and page_range are mutually exclusive options) or provide usage examples. The baseline of 3 is appropriate when the schema does the heavy lifting.

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?

The description clearly states the specific action ('Enumerate pages'), the resource ('of a document'), and the return data ('logical page numbers, IIIF image URLs, and text availability flags'). It distinguishes from siblings like get_page_image (which fetches a single image) and get_page_text (which retrieves text content) by focusing on page-level metadata enumeration.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose get_item_pages over get_item_details (which might include page info) or get_page_image/get_page_text (for specific page content), nor does it specify prerequisites or exclusions for usage.

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

Install Server

Other Tools

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