Skip to main content
Glama
ukicar

Gallica/BnF MCP Server

by ukicar

search_by_subject

Find documents in the Gallica digital library by searching for specific subjects, with options for exact matches and pagination controls.

Instructions

Search for documents in the Gallica digital library by subject.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subjectYesThe subject to search for
exact_matchNoIf true, search for the exact subject; otherwise, search for subject containing the words
max_resultsNoMaximum number of results to return (1-50)
start_recordNoStarting record for pagination

Implementation Reference

  • The main tool handler and registration for search_by_subject. Creates the tool with name, description, input schema, and async handler function that parses arguments and calls the SearchAPI.searchBySubject method.
    export function createSearchBySubjectTool(searchApi: SearchAPI) {
      return {
        name: 'search_by_subject',
        description: 'Search for documents in the Gallica digital library by subject.',
        inputSchema: {
          type: 'object',
          properties: {
            subject: {
              type: 'string',
              description: 'The subject to search for',
            },
            exact_match: {
              type: 'boolean',
              description: 'If true, search for the exact subject; otherwise, search for subject containing the words',
              default: false,
            },
            max_results: {
              type: 'number',
              description: 'Maximum number of results to return (1-50)',
              default: config.defaultMaxRecords,
            },
            start_record: {
              type: 'number',
              description: 'Starting record for pagination',
              default: config.defaultStartRecord,
            },
          },
          required: ['subject'],
        },
        handler: async (args: unknown) => {
          const parsed = exactMatchSchema.extend({ subject: z.string() }).parse(args);
          return await searchApi.searchBySubject(
            parsed.subject,
            parsed.exact_match ?? false,
            parsed.max_results ?? config.defaultMaxRecords,
            parsed.start_record ?? config.defaultStartRecord
          );
        },
      };
  • The actual implementation of searchBySubject method in the SearchAPI class. Constructs the SRU query using 'dc.subject' field with optional exact matching, then delegates to the core search method.
    searchBySubject(
      subject: string,
      exactMatch: boolean = false,
      maxResults: number = config.defaultMaxRecords,
      startRecord: number = config.defaultStartRecord
    ): Promise<SearchResult> {
      const query = exactMatch ? `dc.subject all "${subject}"` : `dc.subject all ${subject}`;
      return this.search(query, startRecord, maxResults);
    }
  • Schema definitions used by search_by_subject. Defines searchParamsSchema (max_results, start_record) and exactMatchSchema which extends it with exact_match boolean field.
    const searchParamsSchema = z.object({
      max_results: z.number().int().positive().max(50).optional(),
      start_record: z.number().int().positive().optional(),
    });
    
    const exactMatchSchema = searchParamsSchema.extend({
      exact_match: z.boolean().optional(),
    });
  • src/mcpServer.ts:20-20 (registration)
    Import statement for createSearchBySubjectTool function from tools/gallicaSearch.js.
    createSearchBySubjectTool,
  • src/mcpServer.ts:78-97 (registration)
    Tool instantiation and registration. Creates the searchBySubject tool instance on line 78 and adds it to the tools array on line 97 for MCP server registration.
    const searchBySubject = createSearchBySubjectTool(searchApi);
    const searchByDate = createSearchByDateTool(searchApi);
    const searchByDocumentType = createSearchByDocumentTypeTool(searchApi);
    const advancedSearch = createAdvancedSearchTool(searchApi);
    const naturalLanguageSearch = createNaturalLanguageSearchTool(searchApi);
    
    // Register extended item tools (4 new tools)
    const getItemDetails = createGetItemDetailsTool(itemsClient);
    const getItemPages = createGetItemPagesTool(itemsClient);
    const getPageImage = createGetPageImageTool(iiifClient);
    const getPageText = createGetPageTextTool(textClient);
    
    // Register sequential reporting tool
    const sequentialReporting = createSequentialReportingTool(reportingServer);
    
    // Register all tools with error handling
    const tools = [
      searchByTitle,
      searchByAuthor,
      searchBySubject,
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions searching but doesn't disclose behavioral traits like rate limits, authentication needs, pagination behavior beyond the parameters, or what the return format looks like (e.g., list of documents with metadata). For a search tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

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 a single, efficient sentence that front-loads the core purpose. There is zero waste or redundancy, making it highly concise and well-structured for quick understanding.

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

Completeness2/5

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

Given the complexity of a search tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., document list, metadata), how results are ordered, or error conditions. For a tool with rich input schema but missing output and behavioral context, more detail is needed.

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 description coverage is 100%, so the schema fully documents all 4 parameters. The description adds no additional meaning beyond what the schema provides (e.g., it doesn't explain subject format, Gallica's subject taxonomy, or how exact_match interacts with subject terms). Baseline 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.

Purpose4/5

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

The description clearly states the verb ('Search for') and resource ('documents in the Gallica digital library'), specifying the search dimension ('by subject'). It distinguishes from siblings like search_by_author or search_by_title by indicating the subject-based filtering, but doesn't explicitly contrast with natural_language_search or advanced_search which might also handle subjects differently.

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 prefer search_by_subject over natural_language_search, advanced_search, or other subject-related tools, 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