Harvard Library MCP Server
A Model Context Protocol (MCP) server for the Harvard University Library catalog API, providing comprehensive bibliographic search and metadata retrieval capabilities for AI assistants.
✨ Features
- 🔍 Comprehensive Search: Free-text search, advanced fielded search, collection-specific queries
- 📚 Rich Metadata: Native MODS XML format with structured JSON conversion
- 🔌 Universal Integration: stdio MCP transport for Claude Desktop, Cherry Studio, and other AI assistants
- ⚡ High Performance: Async HTTP client with built-in rate limiting and error handling
- 🌐 Access to 20M+ Records: Search Harvard's entire academic library collection
- 📖 Complete Metadata: Access to bibliographic records, subject headings, and collection information
🚀 Quick Start
Installation from PyPI
pip install harvard-library-mcp
Usage with AI Assistants
Cherry Studio Integration
Cherry Studio provides native MCP server support for seamless integration with the Harvard Library catalog.
Prerequisites:
- Cherry Studio installed on your system
harvard-library-mcppackage installed viapip install harvard-library-mcp
Step 1: Install MCP Environment
- Open Cherry Studio → Settings → MCP Server
- Click "Install" to automatically install required dependencies
- If installation fails, manually install to the Cherry Studio directory:
- Windows:
C:\Users\{username}\.cherrystudio\bin - macOS/Linux:
~/.cherrystudio/bin
- Windows:
Step 2: Configure Harvard Library MCP Server Cherry Studio may use the standard MCP configuration format. Add the following to your Cherry Studio MCP settings:
{
"mcp": {
"servers": {
"harvard-library": {
"command": "uvx",
"args": ["harvard-library-mcp"],
"env": {}
}
}
}
}
Step 3: Start Using
- Restart Cherry Studio
- The Harvard Library tools will be available in your chat interface
- Try queries like:
- "Search for books about machine learning"
- "Find works by Shakespeare in Harvard's collection"
- "Show me records from the Harvard Fine Arts Library"
Claude Desktop Integration
Add to your claude_desktop_config.json:
{
"mcp": {
"servers": {
"harvard-library": {
"command": "uvx",
"args": ["harvard-library-mcp"]
}
}
}
}
Configuration File Location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Standard MCP Configuration
For any MCP-compatible client, use this JSON configuration format:
{
"mcp": {
"servers": {
"harvard-library": {
"command": "uvx",
"args": ["harvard-library-mcp"],
"env": {}
}
}
}
}
Configuration Options:
command: The command to run (uvxfor running from PyPI packages)args: Package name and additional arguments (["harvard-library-mcp"])env: Environment variables for the server process (optional)
Example with custom settings:
{
"mcp": {
"servers": {
"harvard-library": {
"command": "uvx",
"args": ["harvard-library-mcp"],
"env": {
"LOG_LEVEL": "DEBUG",
"RATE_LIMIT_REQUESTS_PER_SECOND": "5"
}
}
}
}
}
Note: Using uvx harvard-library-mcp is the recommended approach as it automatically handles virtual environments and dependencies from PyPI.
Local Development
# Clone and install in development mode
git clone https://github.com/kltng/harvard-library-mcp.git
cd harvard-library-mcp
pip install -e .
# Run as MCP server (stdio)
python -m harvard_library_mcp.server
🛠️ Available MCP Tools
🔍 Search Tools
search_catalog(query)- Free-text search across entire Harvard Library catalogsearch_by_title(title)- Search specifically by title fieldsearch_by_author(author)- Search by author/creator namessearch_by_subject(subject)- Search by subject headings and keywordsadvanced_search(filters)- Multi-field search with specific filters (title, author, subject, date, etc.)search_by_collection(collection_id)- Search within specific Harvard Library collectionssearch_by_date_range(start_date, end_date)- Search by publication date rangesearch_by_geographic_origin(location)- Search by publication location
📊 Utility Tools
get_record_details(record_id)- Fetch complete bibliographic record by Harvard IDget_collections_list()- List all available collections with metadataparse_mods_metadata(mods_xml)- Convert MODS XML to structured JSON
📝 Usage Examples
Basic Search
Search for books about artificial intelligence published after 2020
Academic Research
Find works by Noam Chomsky in the linguistics collection
Show me details for Harvard record ID: 12345678
Collection Discovery
List all Harvard Library collections
Search within the Fine Arts Library collection for Renaissance art
⚙️ Configuration
Environment Variables
HARVARD_API_BASE_URL: Base URL for Harvard Library API (default:https://api.lib.harvard.edu/v2)RATE_LIMIT_REQUESTS_PER_SECOND: API rate limit (default:10)LOG_LEVEL: Logging level (default:INFO)
Advanced Configuration
For custom deployments, you can configure additional settings:
# Custom rate limiting
export RATE_LIMIT_REQUESTS_PER_SECOND=5
# Debug logging
export LOG_LEVEL=DEBUG
# Custom API endpoint (for development/testing)
export HARVARD_API_BASE_URL=https://api.lib.harvard.edu/v2
🏗️ Architecture
Core Components
- Server (
server.py): MCP stdio interface implementation - API Client (
api/client.py): Async HTTP client for Harvard Library API - Tools (
tools/search_tools.py): MCP tool implementations - Models (
models/harvard_models.py): Pydantic models for data validation - Configuration (
config.py): Environment-based configuration management
Data Flow
AI Assistant → MCP Server → Harvard Library API → Bibliographic Records
The server handles:
- ✅ Rate limiting (10 req/sec default)
- ✅ Error handling and retries
- ✅ MODS XML parsing and JSON conversion
- ✅ Response validation and typing
👨💻 Development
Prerequisites
- Python 3.11 or higher
- Git
Setup Development Environment
# Clone the repository
git clone https://github.com/kltng/harvard-library-mcp.git
cd harvard-library-mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode with dependencies
pip install -e ".[dev]"
# Set up pre-commit hooks (optional)
pre-commit install
Running Tests
# Run all tests
make test
pytest tests/ -v
# Run tests with coverage
make test-coverage
pytest tests/ --cov=src --cov-report=html
# Run specific test categories
pytest tests/ -m unit # Unit tests only
pytest tests/ -m integration # Integration tests only
Code Quality
# Run all linting checks
make lint
mypy src/
ruff check src/
black --check src/
isort --check-only src/
# Format code automatically
make format
black src/
isort src/
ruff check --fix src/
🐳 Docker Support
Build and Run
# Build Docker image
docker build -t harvard-library-mcp:latest .
# Run container
docker run -d --name harvard-library-mcp harvard-library-mcp:latest
# Using Docker Compose
docker-compose up -d
docker-compose logs -f
📦 Installation Options
From PyPI (Recommended)
pip install harvard-library-mcp
From Source
git clone https://github.com/kltng/harvard-library-mcp.git
cd harvard-library-mcp
pip install -e .
Development Version
pip install git+https://github.com/kltng/harvard-library-mcp.git
🔄 Release Process
This project uses automated releases with GitHub Actions and PyPI Trusted Publishing.
For Users
Install the latest version:
pip install harvard-library-mcp
Install a specific version:
pip install harvard-library-mcp==0.1.0
📄 License
MIT License - see LICENSE file for details.
🔗 Links & Resources
- PyPI Package: https://pypi.org/project/harvard-library-mcp/
- GitHub Repository: https://github.com/kltng/harvard-library-mcp
- Bug Reports: https://github.com/kltng/harvard-library-mcp/issues
- Harvard Library API Documentation:
- MODS XML Schema: http://www.loc.gov/standards/mods/
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Quick Contribution Guide
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📊 Project Statistics
- Total Records: 20M+ bibliographic records
- Collections: 100+ specialized library collections
- API Rate Limit: 10 requests/second (configurable)
- Response Formats: JSON, MODS XML
- Python Versions: 3.11, 3.12, 3.13
- License: MIT
⭐ Star this repository on GitHub if you find it useful!
Made with ❤️ for the academic research community
Metadata
Release files for harvard-library-mcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| harvard_library_mcp-0.1.1.tar.gz | 45.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| harvard_library_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 74.8 kB
Release files / harvard_library_mcp-0.1.1.tar.gz
| Download URL | harvard_library_mcp-0.1.1.tar.gz |
|---|---|
| Size | 45.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac204c2c0e44abd8d5c87547e24bd95d91d836f45e49f6d2e46a8a454430b24d
|
|
BLAKE2b-256 checksum How to use checksums |
3cb587e98ccd82dcee41dcef478929b63390f95c89ab0cb5df055a4fe8a2022d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / harvard_library_mcp-0.1.1-py3-none-any.whl
| Download URL | harvard_library_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 29.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4444ee37930b150bc7754887180a6fd6a3846cd5344b00a4851c7360f154d358
|
|
BLAKE2b-256 checksum How to use checksums |
ed86c0ce3ef5238927eef6319219572a487119d2b2211ab40b429c65706711ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Security for harvard-library-mcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.