AI agents and MCP
Connect a coding assistant to Lector's guides, search the docs, or fetch complete Markdown without a browser.
Give your assistant access to the same guides and examples you read here. Every page has a Markdown export, and the MCP server offers search and retrieval over the complete documentation catalog. No API key is required.
These docs describe the source deployed with this site and track main. They are not versioned by npm release. Before applying an example, have your assistant inspect your installed @anaralabs/lector, pdfjs-dist, and React versions. Use the release history when working with an older package.
Connect an MCP client
Add a remote server in your assistant's MCP settings:
| Setting | Value |
|---|---|
| Name | lector |
| Server URL | https://anara.com/lector/mcp |
| Transport | Streamable HTTP |
| Authentication | None; public, read-only documentation |
For clients that use an mcpServers configuration with a url field:
Configuration keys vary by client. If yours asks for a transport type, select HTTP or Streamable HTTP. This endpoint is not a local stdio command or the older HTTP+SSE transport with a separate /sse URL. The server also supports clients using the 2025 MCP initialization handshake.
After connecting, ask the assistant to list the Lector documentation. It should discover these tools:
| Tool | Input | Result |
|---|---|---|
list_docs | {} | All page slugs, descriptions, URLs, resource URIs, and content hashes |
search_docs | query, optional limit | Ranked excerpts and links; defaults to 5 results, maximum 10 |
get_doc | slug | A complete Markdown guide, including its fenced code examples |
Search accepts 1–200 characters. Use focused keywords such as worker, Next.js, useSearch, or dark mode. Results are keyword-ranked, not semantic search. An empty results list means no matching terms; try the API name or use list_docs to browse.
Use the exact slug from a result: installation, code/search, or index for the overview. get_doc does not accept arbitrary URLs or local file paths.
A useful first request
For a specific task, search first and then read the complete result. Excerpts help find a guide; they may omit prerequisites or limitations that matter when writing code.
Clients that support resources can list and read lector://docs for the JSON catalog and lector://docs/<slug> for individual Markdown pages. For example, lector://docs/code/search contains the search guide. Clients with prompts can run build_pdf_viewer with framework: "react" or framework: "nextjs" to start with the installation and first-viewer guides already included.
The server only reads Lector documentation. It does not open your PDFs, access your repository, change files, or provide a PDF-processing service. Your assistant's other tools perform application work.
Fetch docs without MCP
An agent with HTTP access can read any of these directly:
| URL | When to use it |
|---|---|
| /llms.txt | Start here: concise project context and links to every guide |
| /llms.json | Discover page slugs, URLs, resource URIs, and SHA-256 content hashes programmatically |
| /docs/installation.md | Read one complete page; append .md to a guide URL |
| /docs/index.md | Read the /docs overview as Markdown |
| /llms-full.txt | Fetch every guide in one response for tools with enough context |
Each HTML guide advertises its Markdown version through a rel="alternate" link. Markdown responses include a link to the discovery file. See the llms.txt proposal for the discovery convention.
Markdown is generated from the MDX used to build the site. Tables, links, and fenced source examples are retained. Executable MDX imports are removed, and interactive demos become a pointer to the browser page. A guide's sha256 and the catalog's revision identify its exported content, so a client can detect changes without relying on a handwritten update date.
Connection problems
| Symptom | Check |
|---|---|
Opening /mcp in a browser returns 405 | Expected: use an MCP client that sends POST requests. For browser-readable content, use the docs or Markdown URLs. |
The client tries /sse or requires a command | Configure a remote Streamable HTTP server, or use direct Markdown fetching if the client only supports local servers. |
| Tools work but resources or prompts are missing in the UI | Client support varies. All documentation is also available through the three tools. |
| A browser-based client receives 403 | The deployment must explicitly allow that client's origin. Native clients without an Origin header can connect directly. |
| Search finds too much or nothing | Use a distinctive API name, reduce the query to keywords, or browse list_docs. |
| An example uses an export absent from your app | Compare installed versions with the source and releases; the corpus is not pinned to your npm version. |
For a self-hosted site, replace the hostname above with your deployment's URL. The maintainer guide covers origin configuration, validation, and how new pages enter the catalog.