{"slug": "give-claude-code-a-knowledge-base-it-can-actually-edit", "title": "Give Claude Code a Knowledge Base It Can Actually Edit", "summary": "Doco, a collaborative document platform, has released a tutorial demonstrating how to give Claude Code an editable knowledge base via a Model Context Protocol (MCP) server. The approach emphasizes starting with read-only access, verifying citations, and implementing versioned writes with If-Match-style preconditions to prevent lost updates. The tutorial highlights the importance of a reliable boundary between AI agents and maintained knowledge, ensuring human oversight and safe editing.", "body_md": "Give Claude Code an editable knowledge base by connecting a narrowly scoped MCP server that exposes structured search, versioned reads, and block-level writes. Start read-only, verify citations, then grant write access only after stale writes fail safely and every change remains visible to humans.\n\nDoco series · Article 11 · Claude Code tutorial\n\nClaude Code can already read files in a repository. That is enough for source code and temporary project notes. It is not enough when the source of truth is a living team handbook, product specification, or research library that people are editing in a browser at the same time.\n\nThe missing piece is not “more context.” It is a reliable boundary between Claude Code and maintained knowledge.\n\nAn agent can technically edit a knowledge base if it can overwrite a file or call a generic update endpoint. A useful editing contract is stricter:\n\nClaude Code uses the [Model Context Protocol](https://code.claude.com/docs/en/mcp) to connect to external tools and data sources. Anthropic recommends HTTP for remote services and stdio for local processes. MCP provides the connection; the quality of the knowledge contract still depends on the server behind it.\n\nDoco is the product I am building, so treat the recommendation here as a first-party tutorial rather than an independent comparison. It is MIT licensed, and its relevant distinction is that browser users and API clients operate on the same collaborative documents.\n\nFor the hosted MCP endpoint, create a Doco token with read scopes only, then add it to Claude Code:\n\n```\nclaude mcp add --transport http doco https://api.doco.page/mcp \\\n  --header \"Authorization: Bearer YOUR_DOCO_TOKEN\"\n```\n\nFor a local stdio connection:\n\n```\nclaude mcp add doco -- npx -y --package doco-agent-cli doco mcp\n```\n\nKeep the token outside committed configuration. Claude Code supports environment-variable expansion in project-scoped `.mcp.json`\n\nfiles, so a shared configuration can reference a local secret without storing it in Git.\n\nRun `claude mcp list`\n\n, then open `/mcp`\n\ninside Claude Code. Confirm that the Doco server is connected and inspect the tools before asking the model to use them. The official Claude Code documentation also warns that servers which fetch external content can expose clients to prompt injection; knowledge-base text is data, not trusted instruction.\n\nUse a question whose answer you already know:\n\n```\nSearch Doco for the release rollback procedure. Return the document title,\nheading path, stable block ID, and the exact evidence you relied on.\nDo not modify anything.\n```\n\nThe goal is not a polished summary. You are checking the retrieval contract:\n\nThis matters because a confident answer without an address is hard to audit. A useful knowledge tool should let the agent browse structure, search to a block, and read enough surrounding context to interpret it.\n\nAfter read-only retrieval is dependable, create a token with the minimum write scope needed for the test. Choose a disposable document or a clearly reversible paragraph.\n\nAsk Claude to follow an explicit read-edit-verify loop:\n\n```\nOpen the document “Release checklist.” Read the block under “Rollback owner.”\nChange only that block to add the on-call alias. Preserve the rest of the\ndocument. If the version changed after your read, stop and show the conflict.\nThen read the block again and report its stable ID and resulting version.\n```\n\nIn Doco, reads expose a version fingerprint and protected writes use an `If-Match`\n\n-style precondition. That follows the lost-update protection described by [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-if-match): a state-changing request proceeds only when the selected representation still matches the condition supplied by the caller.\n\nThe version check is the important part. Without it, an agent can read version A, a teammate can create version B, and the agent can silently write an update based on A over B.\n\nOpen the target document before running the edit. The changed block should update in the collaborative editor because the API and browser share the same Yjs document state. Yjs describes shared editing as peers exchanging document updates that merge without a central ordering assumption; see its [collaborative editor guide](https://docs.yjs.dev/getting-started/a-collaborative-editor).\n\nThis check catches a common integration failure: the agent updates a shadow database or exported file while the human-facing workspace continues to show something else.\n\nA safe demo must include a conflict, not only a successful write.\n\nDo not automatically retry semantic conflicts. A retry is safe only after the caller has incorporated the newer state. “Last writer wins” is convenient until the last writer is an unattended agent.\n\nThe prompt below is deliberately procedural:\n\n```\nSearch the Doco knowledge base for the current API deprecation policy.\nUse source blocks, not generated summaries, as authority.\nIf you find conflicting policies, cite both and stop.\nOtherwise update only the “Timeline” block in the canonical policy document.\nDo not write without a version precondition. If the version is stale, do not\nretry automatically. Report the document URL, changed block ID, and new version.\n```\n\nThe prompt does not create safety by itself. It tells Claude how to use safety properties enforced by the server.\n\n`documents:read`\n\n; do not issue a broad write token for exploration.Yes. It can edit files it is allowed to access. That is appropriate when the file is the source of truth and Git-style review is the intended collaboration model. A shared live knowledge base needs additional identity, concurrency, and permission semantics.\n\nNo. A CLI or direct API can work. MCP is useful when you want discoverable tools, resources, authentication, and a reusable connection inside Claude Code.\n\nNo. Prove search, evidence, and citations with a read-only token first. Add narrow write scope for a reversible test, then verify both a successful update and a stale-write rejection.\n\nIt limits the mutation surface and gives the changed paragraph a durable address. Document-level version protection is still required because other blocks may have changed since the agent read the document.\n\nConnecting Claude Code is the easy part. The real acceptance test is whether it can find evidence, edit one stable block, lose a race safely, and show the same result to a human in the browser. If those properties hold, the knowledge base is not merely readable by an agent—it is maintainable by one.\n\nOriginally published on [Doco](https://doco.page/s/OrWQqXi-hm42qjNA6Hind_fzWBMbhATF).\n\nDoco is an open-source document workspace where humans and AI agents write together. [Explore Doco](https://doco.page/?utm_source=devto&utm_medium=content&utm_campaign=content_series).", "url": "https://wpnews.pro/news/give-claude-code-a-knowledge-base-it-can-actually-edit", "canonical_source": "https://dev.to/songofhawk/give-claude-code-a-knowledge-base-it-can-actually-edit-5ae8", "published_at": "2026-08-30 08:51:52+00:00", "updated_at": "2026-08-30 09:22:23.008213+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-products"], "entities": ["Claude Code", "Doco", "Anthropic", "Model Context Protocol"], "alternates": {"html": "https://wpnews.pro/news/give-claude-code-a-knowledge-base-it-can-actually-edit", "markdown": "https://wpnews.pro/news/give-claude-code-a-knowledge-base-it-can-actually-edit.md", "text": "https://wpnews.pro/news/give-claude-code-a-knowledge-base-it-can-actually-edit.txt", "jsonld": "https://wpnews.pro/news/give-claude-code-a-knowledge-base-it-can-actually-edit.jsonld"}}