Skip to main content
Glama
ukicar

Gallica/BnF MCP Server

by ukicar

search_by_author

Find documents in the Gallica digital library by searching for specific authors. Use exact or partial name matching to locate relevant materials from the Bibliothèque nationale de France collection.

Instructions

Search for documents in the Gallica digital library by author.

Input Schema

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

Implementation Reference

  • Main tool definition for search_by_author. Contains the input schema (lines 72-96) and handler function (lines 97-105) that parses arguments and calls the SearchAPI.searchByAuthor method.
    export function createSearchByAuthorTool(searchApi: SearchAPI) {
      return {
        name: 'search_by_author',
        description: 'Search for documents in the Gallica digital library by author.',
        inputSchema: {
          type: 'object',
          properties: {
            author: {
              type: 'string',
              description: 'The author name to search for',
            },
            exact_match: {
              type: 'boolean',
              description: 'If true, search for the exact author name; otherwise, search for author 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: ['author'],
        },
        handler: async (args: unknown) => {
          const parsed = exactMatchSchema.extend({ author: z.string() }).parse(args);
          return await searchApi.searchByAuthor(
            parsed.author,
            parsed.exact_match ?? false,
            parsed.max_results ?? config.defaultMaxRecords,
            parsed.start_record ?? config.defaultStartRecord
          );
        },
      };
    }
  • API implementation of searchByAuthor method. Constructs CQL query using dc.creator field and calls the core search method. Handles both exact match and partial match modes.
    searchByAuthor(
      author: string,
      exactMatch: boolean = false,
      maxResults: number = config.defaultMaxRecords,
      startRecord: number = config.defaultStartRecord
    ): Promise<SearchResult> {
      const query = exactMatch ? `dc.creator all "${author}"` : `dc.creator all ${author}`;
      return this.search(query, startRecord, maxResults);
    }
  • src/mcpServer.ts:75-82 (registration)
    Tool registration in MCP server. Creates the searchByAuthor tool instance using createSearchByAuthorTool factory function and adds it to the tools array for registration.
    // Register search tools (7 tools matching Python)
    const searchByTitle = createSearchByTitleTool(searchApi);
    const searchByAuthor = createSearchByAuthorTool(searchApi);
    const searchBySubject = createSearchBySubjectTool(searchApi);
    const searchByDate = createSearchByDateTool(searchApi);
    const searchByDocumentType = createSearchByDocumentTypeTool(searchApi);
    const advancedSearch = createAdvancedSearchTool(searchApi);
    const naturalLanguageSearch = createNaturalLanguageSearchTool(searchApi);
  • Zod validation schema for exact match search parameters. Used to validate and parse input arguments for search_by_author tool handler.
    const exactMatchSchema = searchParamsSchema.extend({
      exact_match: z.boolean().optional(),
    });
  • Type definition for SearchResult returned by searchByAuthor. Contains metadata (query, total_records, records_returned, date_retrieved) and array of SearchRecord objects.
    export interface SearchResult {
      metadata: SearchMetadata;
      records: SearchRecord[];
      error?: string;
      parameters?: Record<string, unknown>;
    }

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