Building a Lightweight MCP Server for Local Markdown Libraries
004M · reddit · 2026-07-15
To solve the issue of LLMs needing project context re-explained in every conversation, the author developed an MCP server based on a local Markdown library and shared its core design principles:
- Tool minimalism: The model only sees 10 tools, preventing excessive tool definitions from burning tokens per turn and reducing the chance of misuse.
- Retrieval ladder: Searches return only ranked snippets, not full files; wiki links are used to fetch IDs and titles; outlines or specific sections are pulled as needed before finally requesting the complete note. This saves about 60% tokens compared to direct full-file RAG, keeping costs flat as the library grows.
- Controlled writes: A fixed folder structure is enforced; unknown tags are returned as proposals rather than silently written; all write operations are logged in an append-only audit log.
- Access control: Uses stateless HTTP, OAuth 2.0 + PKCE, and constant-time Bearer validation, failing safely if misconfigured.
- Decoupled access and judgment: An accompanying Skill teaches the model how to properly use these access rights (e.g., search before writing, archive correctly) rather than just providing an interface.
More from coding & agent
- A roundup of AI agents and MCP resources, including how to evaluate agents — _jaydeepkarale · 2026-07-21
- Anthropic shares a masterclass on how it builds AI agents — _jaydeepkarale · 2026-07-21
- A beginner guide to AI agents points readers to a Stanford webinar — _jaydeepkarale · 2026-07-21
- A full course shows how to build and deploy an AI agent with OpenAI and LangChain — _jaydeepkarale · 2026-07-21
- A practical guide on how to evaluate AI agents — _jaydeepkarale · 2026-07-21
- Karpathy’s LLM fundamentals are recommended before building AI agents — _jaydeepkarale · 2026-07-21