Skip to main content
Glama
ukicar

Gallica/BnF MCP Server

by ukicar

get_item_details

Retrieve comprehensive metadata for Gallica digital library items using ARK identifiers. Provides bibliographic details, available formats, and access URLs for French cultural heritage documents.

Instructions

Get full metadata for a Gallica item by its ARK identifier. Returns bibliographic data, available formats, and helpful URLs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
arkYesARK identifier (e.g., "ark:/12148/bpt6k123456" or "bpt6k123456")

Implementation Reference

  • Main tool definition with handler function that creates the get_item_details tool. Includes name, description, input schema validation, and handler that parses the ARK parameter and calls itemsClient.getItemMetadata().
    export function createGetItemDetailsTool(itemsClient: ItemsClient) {
      return {
        name: 'get_item_details',
        description: 'Get full metadata for a Gallica item by its ARK identifier. Returns bibliographic data, available formats, and helpful URLs.',
        inputSchema: {
          type: 'object',
          properties: {
            ark: {
              type: 'string',
              description: 'ARK identifier (e.g., "ark:/12148/bpt6k123456" or "bpt6k123456")',
            },
          },
          required: ['ark'],
        },
        handler: async (args: unknown) => {
          const parsed = z.object({ ark: z.string() }).parse(args);
          return await itemsClient.getItemMetadata(parsed.ark);
        },
      };
    }
  • ItemsClient.getItemMetadata method that implements the core logic for fetching item metadata. It extracts the ARK identifier, fetches the IIIF manifest, extracts metadata fields (title, creator, date, publisher, etc.), and determines available formats.
    async getItemMetadata(ark: string): Promise<ItemMetadata> {
      // Extract ARK identifier
      const arkId = ark.replace(/^ark:\/12148\//, '').replace(/^\/ark:\/12148\//, '');
      const fullArk = `ark:/12148/${arkId}`;
      const gallicaUrl = `${this.baseUrl}/ark:/12148/${arkId}`;
    
      try {
        // Try to get metadata from IIIF manifest first
        if (!ark) {
          throw new Error('ARK is required');
        }
        const manifest = await this.iiifClient.parseManifest(ark);
        
        // Extract metadata from manifest if available
        const metadata = manifest.metadata as Record<string, unknown> || {};
        
        // Build metadata object
        const itemMetadata: ItemMetadata = {
          ark: fullArk,
          gallica_url: gallicaUrl,
          manifest_url: this.iiifClient.getManifestUrl(ark),
          available_formats: ['iiif', 'image'],
          ...this.extractMetadataFromManifest(metadata),
        };
    
        // Check if text is available
        if (manifest.pages.length > 0 && manifest.pages[0]?.has_text) {
          itemMetadata.available_formats.push('text', 'alto');
        }
    
        return itemMetadata;
      } catch (error) {
        logger.warn(`Could not fetch full metadata for ${ark}, returning basic info: ${error instanceof Error ? error.message : String(error)}`);
        
        // Return basic metadata
        return {
          ark: fullArk,
          gallica_url: gallicaUrl,
          manifest_url: this.iiifClient.getManifestUrl(ark),
          available_formats: ['iiif', 'image'],
        };
      }
    }
  • src/mcpServer.ts:28-29 (registration)
    Import statement for createGetItemDetailsTool function from the items tools module.
    import {
      createGetItemDetailsTool,
  • src/mcpServer.ts:85-85 (registration)
    Tool instantiation where getItemDetails is created by calling createGetItemDetailsTool(itemsClient).
    const getItemDetails = createGetItemDetailsTool(itemsClient);
  • Tools array registration where getItemDetails is added to the list of available tools that will be exposed via MCP protocol.
    const tools = [
      searchByTitle,
      searchByAuthor,
      searchBySubject,
      searchByDate,
      searchByDocumentType,
      advancedSearch,
      naturalLanguageSearch,
      getItemDetails,
      getItemPages,
      getPageImage,
      getPageText,
      sequentialReporting,
    ];
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the tool's behavior by specifying it returns 'bibliographic data, available formats, and helpful URLs', which gives useful context about output content. However, it doesn't mention potential limitations like rate limits, error conditions, or authentication needs, leaving gaps for a read operation.

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 front-loaded with the core purpose in the first sentence and adds specific return details in the second. Every sentence earns its place by providing essential information without waste, making it highly efficient and well-structured.

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

Completeness4/5

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

Given the tool's low complexity (single parameter, no output schema, no annotations), the description is mostly complete. It covers purpose, parameter context, and return types adequately. However, without annotations or output schema, it could benefit from more behavioral details like error handling or response structure to achieve full completeness.

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

Parameters4/5

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

The description adds meaning by clarifying the ARK identifier's role and providing example formats ('ark:/12148/bpt6k123456' or 'bpt6k123456'), which enhances the schema's 100% coverage. Since there's only one parameter, the baseline is 4, and the description effectively complements the schema without redundancy.

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 ('Get full metadata'), resource ('a Gallica item'), and key identifier ('by its ARK identifier'). It distinguishes from siblings like get_item_pages or get_page_image by focusing on metadata rather than content or search operations.

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

Usage Guidelines3/5

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

The description implies usage when you have an ARK identifier and need metadata, but doesn't explicitly state when to use this tool versus alternatives like search tools (e.g., search_by_title) or when not to use it (e.g., for content retrieval). It provides basic context but lacks explicit guidance on alternatives or exclusions.

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