What is MCP?
The Model Context Protocol provides a standardized way for AI applications to access external data sources and tools. Grounded Docs exposes its documentation search and indexing capabilities through MCP, allowing AI assistants to:- Search indexed documentation in real-time
- Index new library versions
- Manage scraping jobs
- Fetch and convert web pages to Markdown
Architecture
MCP Server Instance
The MCP server is created insrc/mcp/mcpServer.ts:18 and exposes:
- Tools: Callable functions that perform operations
- Resources: URI-based data endpoints for querying state
Tool Registration
Tools are registered with schemas defined using Zod validation:Read-Only Mode
When configured withreadOnly: true, Grounded Docs restricts access to mutating operations:
Available in Read-Only Mode:
search_docslist_librariesfind_versionfetch_url
scrape_docsrefresh_versionremove_docslist_jobsget_job_infocancel_job
src/mcp/mcpServer.ts:22 for the read-only configuration logic.
Response Format
All MCP tools return structured responses:Success Response
Error Response
Available Tools
Grounded Docs provides the following MCP tools:Read Operations
- search_docs - Search indexed documentation
- list_libraries - List all indexed libraries
- find_version - Find the best matching version
- fetch_url - Fetch and convert a URL to Markdown
Write Operations
- scrape_docs - Index new library documentation
- refresh_version - Re-scrape an existing version
- remove_docs - Remove indexed documentation
Job Management
- list_jobs - List all indexing jobs
- get_job_info - Get details for a specific job
- cancel_job - Cancel a running job
Resources
MCP resources provide URI-based access to server state:docs://libraries
Returns a list of all indexed libraries.
docs://libraries/{library}/versions
Returns all indexed versions for a specific library.
docs://jobs?status={status} (Write mode only)
Returns all pipeline jobs, optionally filtered by status.
docs://jobs/{jobId} (Write mode only)
Returns details for a specific job by ID.
Error Handling
Tools implement consistent error handling:- Validation Errors: Thrown when input parameters are invalid
- Tool Errors: Thrown when operations fail (library not found, job not found, etc.)
- System Errors: Caught and wrapped with user-friendly messages
src/tools/errors.ts for error type definitions.
Telemetry
All MCP tool calls are tracked for analytics (when telemetry is enabled):src/mcp/mcpServer.ts:197 for telemetry implementation.
