Gallica/BnF MCP Server
Enables access to the Gallica digital library of the Bibliothèque nationale de France (BnF) with search capabilities across titles, authors, subjects, and dates, plus retrieval of document metadata, IIIF images, and OCR text content.
README
Node.js MCP Server for Gallica/BnF
A high-quality TypeScript/Node.js MCP (Model Context Protocol) server for accessing the Gallica digital library of the Bibliothèque nationale de France (BnF). This server faithfully reproduces all functionality from the Python MCP server and extends it with additional features for IIIF images, OCR text, and item metadata.
Features
Core Search Tools (8 tools - matching Python)
- search_by_title - Search documents by title with exact match option
- search_by_author - Search documents by author with exact match option
- search_by_subject - Search documents by subject with exact match option
- search_by_date - Search documents by date (YYYY, YYYY-MM, or YYYY-MM-DD)
- search_by_document_type - Search by document type (monographie, periodique, image, etc.)
- advanced_search - Custom CQL query syntax for complex searches
- natural_language_search - Natural language search across all fields
- sequential_reporting - Multi-step sequential report generation with source management
Extended Tools (4 new tools)
- get_item_details - Get full metadata for an item by ARK identifier
- get_item_pages - Enumerate pages of a document with IIIF URLs
- get_page_image - Generate IIIF image URLs for specific pages
- get_page_text - Retrieve OCR/text content (ALTO, plain text)
Installation
Prerequisites
- Node.js 18.0 or higher
- npm or yarn
Steps
-
Clone or download this repository
-
Install dependencies:
cd node-mcp-bnf npm install -
Build the project:
npm run build
Usage
Local Development
Option 1: HTTP Server (Recommended for Development)
Run the server on a local HTTP port for testing:
npm run dev:http
This starts the server on http://localhost:3000 (or the port specified in PORT environment variable).
The server will:
- Listen on the specified port
- Accept MCP requests via HTTP/SSE
- Log all activity to the console
You can test it by connecting an MCP client to http://localhost:3000/message.
Option 2: STDIO Mode (For MCP Clients)
The server can be used locally with Claude Desktop or Cursor MCP via STDIO.
Run in STDIO mode:
npm run dev
Claude Desktop Configuration
Add to your Claude Desktop configuration file (usually ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"gallica-bnf": {
"command": "node",
"args": ["/path/to/node-mcp-bnf/dist/index.js"],
"cwd": "/path/to/node-mcp-bnf"
}
}
}
Cursor MCP Configuration
Add to your Cursor MCP settings:
{
"mcpServers": {
"gallica-bnf": {
"command": "node",
"args": ["/path/to/node-mcp-bnf/dist/index.js"]
}
}
}
Development Scripts
npm run dev- Run in STDIO mode (for MCP clients like Cursor/Claude Desktop)npm run dev:http- Run HTTP server on local port (default: 3000)npm start- Run compiled STDIO versionnpm run start:http- Run compiled HTTP server version
Environment Variables for HTTP Server:
PORT- Port to listen on (default: 3000)LOG_LEVEL- Logging level (error, warn, info, debug)
Deployment on Vercel
Prerequisites
- Vercel account
- Vercel CLI installed (
npm i -g vercel)
Steps
-
Create
vercel.jsonin project root:{ "functions": { "src/httpServer.ts": { "runtime": "nodejs18.x" } }, "routes": [ { "src": "/(.*)", "dest": "src/httpServer.ts" } ] } -
Set environment variables in Vercel dashboard:
GALLICA_BASE_URL(optional, default:https://gallica.bnf.fr)GALLICA_SRU_URL(optional, default:https://gallica.bnf.fr/SRU)LOG_LEVEL(optional, default:info)MCP_ICON_URL(optional, absolute URL to icon - defaults to/icon.svgrelative to server URL)
-
Deploy:
vercel deploy -
Configure Cursor/Claude Desktop to use HTTP endpoint:
{ "mcpServers": { "gallica-bnf": { "url": "https://your-vercel-app.vercel.app" } } }
API Documentation
Search Tools
search_by_title
Search for documents by title.
Parameters:
title(string, required): The title to search forexact_match(boolean, optional): If true, search for exact titlemax_results(number, optional, default: 10): Maximum results (1-50)start_record(number, optional, default: 1): Starting record for pagination
Example:
{
"title": "Les Misérables",
"exact_match": false,
"max_results": 10
}
search_by_author
Search for documents by author.
Parameters:
author(string, required): The author nameexact_match(boolean, optional): If true, search for exact author namemax_results(number, optional, default: 10)start_record(number, optional, default: 1)
search_by_subject
Search for documents by subject/keywords.
Parameters:
subject(string, required): The subject to search forexact_match(boolean, optional)max_results(number, optional, default: 10)start_record(number, optional, default: 1)
search_by_date
Search for documents by publication date.
Parameters:
date(string, required): Date in format YYYY, YYYY-MM, or YYYY-MM-DDmax_results(number, optional, default: 10)start_record(number, optional, default: 1)
Example:
{
"date": "1862",
"max_results": 20
}
search_by_document_type
Search for documents by type.
Parameters:
doc_type(string, required): Document type (monographie, periodique, image, manuscrit, carte, musique, etc.)max_results(number, optional, default: 10)start_record(number, optional, default: 1)
advanced_search
Perform advanced search with custom CQL query.
Parameters:
query(string, required): CQL query stringmax_results(number, optional, default: 10)start_record(number, optional, default: 1)
Example:
{
"query": "dc.creator all \"Victor Hugo\" and dc.type all \"monographie\""
}
natural_language_search
Natural language search across all fields.
Parameters:
query(string, required): Natural language search querymax_results(number, optional, default: 10)start_record(number, optional, default: 1)
Extended Tools
get_item_details
Get full metadata for an item.
Parameters:
ark(string, required): ARK identifier (e.g., "ark:/12148/bpt6k123456" or "bpt6k123456")
Returns:
- Bibliographic data (title, creator, date, etc.)
- Available formats (iiif, image, text, alto)
- IIIF manifest URL
- Gallica URL
get_item_pages
Enumerate pages of a document.
Parameters:
ark(string, required): ARK identifierpage(number, optional): Get specific page numberpage_size(number, optional): Get first N pagespage_range(array, optional): Get pages in range [start, end]
Returns:
- Array of page info with:
- Page number
- Label
- IIIF image URL
- Text availability flag
- Thumbnail URL
get_page_image
Get IIIF image URL for a specific page.
Parameters:
ark(string, required): ARK identifierpage(number, required): Page numbersize(string, optional): Image size (e.g., "full", "200,", "500,500")region(string, optional): Image region (e.g., "full", "x,y,w,h")
Returns:
- IIIF image URL
- Thumbnail URL
get_page_text
Retrieve OCR/text content for a page.
Parameters:
ark(string, required): ARK identifierpage(number, required): Page numberformat(string, optional): Text format ("plain", "alto", "tei")
Returns:
- Text content (or null if not available)
- Availability flag
Sequential Reporting Tool
sequential_reporting
Generate research reports in a sequential, step-by-step manner.
Workflow:
-
Initialize:
{ "topic": "Impressionnisme en France", "page_count": 4, "source_count": 10, "include_graphics": true } -
Search sources:
{ "search_sources": true } -
Create bibliography:
{ "section_number": 1, "total_sections": 8, "title": "Bibliography", "content": "...", "is_bibliography": true, "sources_used": [1, 2, 3], "next_section_needed": true } -
Write sections sequentially:
{ "section_number": 2, "total_sections": 8, "title": "Introduction", "content": "...", "sources_used": [1, 2], "next_section_needed": true } -
Complete report:
{ "section_number": 8, "total_sections": 8, "title": "Conclusion", "content": "...", "sources_used": [5, 6], "next_section_needed": false }
Configuration
Environment Variables
GALLICA_BASE_URL- Base URL for Gallica API (default:https://gallica.bnf.fr)GALLICA_SRU_URL- SRU search endpoint (default:https://gallica.bnf.fr/SRU)LOG_LEVEL- Logging level:error,warn,info,debug(default:info)HTTP_TIMEOUT- HTTP request timeout in milliseconds (default: 30000)HTTP_RETRIES- Maximum number of retry attempts (default: 3)DEFAULT_MAX_RECORDS- Default maximum search results (default: 10)DEFAULT_START_RECORD- Default starting record for pagination (default: 1)
Development
Project Structure
node-mcp-bnf/
├── src/
│ ├── index.ts # STDIO entry point
│ ├── httpServer.ts # HTTP entry point
│ ├── mcpServer.ts # MCP server setup
│ ├── config.ts # Configuration
│ ├── logging.ts # Logging utility
│ ├── tools/ # MCP tools
│ └── gallica/ # Gallica API clients
├── docs/ # Documentation
├── tests/ # Unit tests
└── package.json
Building
npm run build
Testing
npm test
Development Mode
npm run dev
Documentation
- Python Architecture Analysis - Analysis of the original Python server
- Gallica API Notes - Detailed API documentation
- Node.js Architecture - Architecture and design of this server
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
- Based on the Python MCP server by Kryzo
- Uses the Model Context Protocol SDK
- Built for the Gallica digital library of the Bibliothèque nationale de France
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。