This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Create and activate virtual environment
uv venv
source .venv/bin/activate
# Install with test dependencies
uv pip install -e ".[test]"# Run all tests with coverage
python -m pytest
# Run specific test file
python -m pytest tests/tools/test_search.py
# Run tests with verbose output
python -m pytest -v# Run as module
python -m arxiv_mcp_server
# Or via entry point
arxiv-mcp-serverThis is an MCP (Message Control Protocol) server that provides AI models access to arXiv research papers. The codebase follows a modular architecture with four main layers:
- Server Layer (
server.py): Main MCP server implementation that handles tool registration and request routing - Tools Layer (
tools/): Individual MCP tools for paper operations:search.py: Advanced arXiv paper search with filteringdownload.py: Paper download and storage managementlist_papers.py: List locally stored papersread_paper.py: Read paper content from storage
- Resource Management (
resources/papers.py):PaperManagerclass handles paper storage, PDF-to-markdown conversion using pymupdf4llm, and local caching - Configuration (
config.py): Pydantic-based settings with environment variable support
- MCP Protocol Compliance: All tools follow MCP specification with proper type definitions
- Async-First: Built on asyncio with aiofiles for non-blocking I/O operations
- Storage Strategy: Papers downloaded as PDFs, converted to markdown, stored locally with PDF cleanup
- Error Handling: Comprehensive error handling with user-friendly messages throughout tool chain
Environment variables (all optional with sensible defaults):
ARXIV_STORAGE_PATH: Paper storage location (default:~/.arxiv-mcp-server/papers)ARXIV_MAX_RESULTS: Search results limit (default: 50)ARXIV_REQUEST_TIMEOUT: API timeout in seconds (default: 60)
Tests use pytest with async support and comprehensive mocking:
conftest.pyprovides shared fixtures for mock arXiv papers and HTTP responses- Tests cover both unit-level tool functionality and integration scenarios
- Mock-based approach avoids external API calls during testing