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
| Name | Required | Description | Default |
|---|---|---|---|
| author | Yes | The author name to search for | |
| exact_match | No | If true, search for the exact author name; otherwise, search for author containing the words | |
| max_results | No | Maximum number of results to return (1-50) | |
| start_record | No | Starting record for pagination |
Implementation Reference
- src/tools/gallicaSearch.ts:68-107 (handler)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 ); }, }; } - src/gallica/search.ts:190-198 (handler)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); - src/tools/gallicaSearch.ts:17-19 (schema)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(), }); - src/gallica/types.ts:45-50 (schema)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>; }