pydantic-docs
Provides local-first access to Pydantic documentation with BM25 full-text search, enabling retrieval of documentation pages, sections, and API references via MCP tools.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pydantic-docs search for BaseModel usage with examples"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Pydantic Documentation MCP Server
A Model Context Protocol (MCP) server providing local-first access to Pydantic and Pydantic AI documentation with BM25-powered full-text search.
Features
Local-first architecture - Offline-only mode by default
BM25 full-text search - Fast semantic search across all docs
Git-based extraction - Direct from source repositories (no HTML scraping)
Pre-processed data - JSONL files included for instant setup
Auto-initialization - Builds indices automatically on first run
Complete coverage - Pydantic v2 and Pydantic AI documentation
Related MCP server: MPC Docs Server
Requirements
Python 3.12+
uv package manager
~15MB disk space (with indices)
Quick Start
# Clone and install
git clone <repository-url>
cd mcp_pydantic_docs
uv sync
# Server auto-builds indices on first run
uv run mcp-pydantic-docsMCP Client Configuration
Add to your MCP settings (e.g., cline_mcp_settings.json):
{
"mcpServers": {
"pydantic-docs": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mcp_pydantic_docs",
"run",
"mcp-pydantic-docs"
]
}
}
}Architecture
How It Works
Source Extraction (
source_extractor.py) - Clones Pydantic repos, extracts documentation from markdown/docstrings → JSONLIndex Building (
indexer.py) - Processes JSONL files → BM25 search indicesMCP Server (
mcp.py) - Serves documentation via MCP toolsShared Utilities (
utils.py) - HTML/text processing, normalization
Directory Structure
mcp_pydantic_docs/
├── mcp_pydantic_docs/ # Source code
│ ├── mcp.py # MCP server
│ ├── source_extractor.py # Git-based doc extraction
│ ├── indexer.py # BM25 index builder
│ ├── utils.py # Shared utilities
│ └── setup.py # Setup CLI
├── data/ # Search data
│ ├── pydantic.jsonl # Pydantic docs (2.9MB, in git)
│ ├── pydantic_ai.jsonl # Pydantic AI docs (3.3MB, in git)
│ ├── *_bm25.pkl # BM25 index (generated)
│ └── *_records.pkl # Document records (generated)
└── docs_raw/ # Source repos (not in git)
├── pydantic/ # Cloned from GitHub
└── pydantic_ai/ # Cloned from GitHubData Flow
GitHub Repos → source_extractor.py → JSONL files → indexer.py → BM25 indices → mcp.py → MCP ClientAvailable Tools
Search & Retrieval
pydantic_search(query, k=10)- Full-text search with BM25 rankingpydantic_get(path_or_url, max_chars=None)- Fetch full documentation pagepydantic_section(path_or_url, anchor)- Extract specific sectionpydantic_api(symbol, anchor=None)- Jump to API documentation
Health & Admin
health_ping()- Server health checkhealth_validate()- Validate search indicespydantic_mode()- Server configurationadmin_cache_status()- Detailed cache statusadmin_rebuild_indices()- Rebuild search indices
Updating Documentation
Rebuild from Existing JSONL
uv run python -m mcp_pydantic_docs.indexerExtract Fresh Documentation
# Check status
uv run python -m mcp_pydantic_docs.setup --status
# Download and extract from GitHub
uv run python -m mcp_pydantic_docs.setup --download --build-index
# Clean cache
uv run python -m mcp_pydantic_docs.setup --cleanConfiguration
Environment Variables
PDA_DOC_ROOT- Pydantic v2 source pathPDA_DOC_ROOT_AI- Pydantic AI source pathPDA_DATA_DIR- Data directory path
Offline Mode
Default: Enabled (OFFLINE_ONLY = True in mcp.py)
Blocks remote requests
Validates file paths
All content from local cache
Development
Run Tests
uv run pytestCode Quality
uv run black mcp_pydantic_docs/ # Format
uv run ruff check . # Lint
uv run mypy mcp_pydantic_docs/ # Type checkTroubleshooting
Search indices not found:
uv run python -m mcp_pydantic_docs.indexerWrong Python version:
uv python install 3.12Server won't start:
# Test standalone
uv run mcp-pydantic-docs
# Check indices
uv run python -m mcp_pydantic_docs.setup --statusLicense
MIT License - see LICENSE file.
Contributing
See CONTRIBUTING.md for:
Development setup
Code style
Testing requirements
Pull request process
Available Tools
9 toolsadmin_cache_statusA
Get detailed status of documentation cache including file counts and sizes.
Inputs: no named parameters. Returns: result
admin_rebuild_indicesA
Rebuild BM25 search indices from JSONL files. Use when indices are missing or corrupted.
Inputs: no named parameters. Returns: result
health_pingA
Returns simple pong
Inputs: no named parameters. Returns: result
health_validateB
Validate search indices and data integrity
Inputs: no named parameters.
pydantic_apiB
Jump to an API page by symbol name. Optional anchor.
Inputs: symbol (required), anchor. Returns: result
pydantic_getA
Fetch a local doc page and return plain text + html. Supports chunking for large documents via max_chars parameter.
Inputs: path_or_url (required), max_chars. Returns: url, html, path, text, +4 more
pydantic_modeB
Report data roots and offline mode.
Inputs: no named parameters.
pydantic_searchB
Search local Pydantic + Pydantic-AI docs with filters.
Inputs: query (required), k, site, heading, +1 more. Returns: results
pydantic_sectionC
Extract a section by anchor from a local page.
Inputs: anchor (required), path_or_url (required). Returns: url, path, anchor, section, +1 more
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Tools are mostly distinct: admin and health tools handle backend tasks, while pydantic tools handle content retrieval. pydantic_get and pydantic_section could be confused (both fetch page content), but descriptions clarify that get returns full text and section extracts a specific anchor.
Naming follows a clear 'category_verb' pattern: admin_*, health_*, pydantic_*. Within pydantic, verb_s are used (api, get, mode, search, section). This consistency helps agents predict tool behavior.
9 tools is an appropriate size for a documentation server. It covers admin operations, health checks, and core doc retrieval/search without being too sparse or overwhelming.
The tool set covers essential doc operations: search, fetch page, extract section, jump to API. However, missing a tool to list available pages or get a table of contents, which would be useful for discovery.
Maintenance
Related MCP Connectors
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Read-only MCP server for the OrchestKit docs: full-text search + Markdown fetch. No auth.
MCP server for querying Forkast documentation
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that enables semantic search and retrieval of documentation using a vector database (Qdrant). This server allows you to add documentation from URLs or local files and then search through them using natural language queries.135Apache 2.0
- FlicenseNot gradedqualityDmaintenanceA simple Model Context Protocol server that enables searching and retrieving relevant documentation snippets from Langchain, Llama Index, and OpenAI official documentation.-
- AlicenseAqualityAmaintenanceA Model Context Protocol (MCP) server that scrapes, indexes, and searches documentation for third-party software libraries and packages, supporting versioning and hybrid search.122,728 npm1,912MIT
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server for ingesting, chunking and semantically searching documentation files, with support for markdown, Python, OpenAPI, HTML files and URLs.-