ProjectBuild a Permission-Aware Knowledge Hub as an MCP Server: the explanation · Start here · part 1 of 22
Part 1 · Start here

Build a Permission-Aware Knowledge Hub as an MCP Server: the explanation

3 min read·

A working engineering knowledge hub, Wayfinder, taken apart in illustrated modules. Engineers connect the AI assistant they already use (Claude Code, Cursor or Claude Desktop) through the Model Context Protocol and ask "Why does billing retry three times?", "Who owns routing?" or "What did we decide about Kafka?". Wayfinder searches the team's docs, runbooks, postmortems, architecture decisions, issues and pull requests, and returns cited passages that this engineer is allowed to read: the permission filter runs inside the database query, before anything is ranked. The server has no language model of its own; the assistant's model writes the answer from the passages. One write tool files an issue only after the user confirms it, every call lands in an audit log, and a React console lets people search as themselves, connect their client and see who can read what. The demo company, Tidewater Freight, is fictional: 41 people, 6 teams and 403 sources.

Who it is for: anyone who knows a little Python and wants to understand, rebuild or extend a real MCP server with search, sign-in and permissions, from beginners to working engineers. Each module says what to read first.

How each module is laid out

SectionAnswers
Where this fitsthe same system map in every module, with this module's parts highlighted
What it doesthe idea in one picture, then each production practice at a glance: what, why, how, when, where
Use cases and examplesthe same practice at Tidewater Freight and in other industries
How it worksthe mechanism step by step, one figure per step, with real values
Code tourthe real files, short excerpts, every line explained, concept boxes for new ideas, and a "what happens when" trace
Design decisionswhat was chosen, the alternatives and why, with measured numbers, and when to choose differently
What can go wrongfailures and attacks, how the code handles each, and the test that proves it
Try it yourselfexact commands and what you should see
Check yourself, Key termsa short quiz and a glossary

Figures use one colour language: blue is our system, amber is a model (the AI client's model or the embedding model) or anything uncertain, green is correct, safe or allowed, red is failure, attack or hidden from this user, grey is background.

Modules

#ModuleMain code
0Project overview: a guided tour of Wayfinderscreenshots of the real console, no code
1The problem: knowledge AI assistants cannot seeseed/world.md, prototype/
2The solution: an MCP server with permission-aware retrievalmain.py, mcp/server.py, search.py
3MCP in depth: protocol, transports and the SDKresearch/spike_mcp_server.py, mcp/server.py, mcp/stdio.py
4High-level designmain.py, nginx.conf.template, docker-compose.yml
5Low-level design: data, ids, API and schemasmodels/, alembic/, types.py, api/routes.py, mcp/models.py
6The seed company: Tidewater Freightseed/, seed/tools/validate.py, index/loader.py
7The access model: groups and visibilityaccess.py, seed/access.md, auth/scopes.py
8Indexing and embeddingsindex/chunker.py, index/embedder.py, index/indexer.py
9Hybrid search and rankingsearch.py
10Permission filtering before rankingsearch.py, knowledge.py, test_security_acl.py
11The MCP tools, resources and promptsmcp/server.py, mcp/models.py, mcp/render.py, knowledge.py
12OAuth 2.1 for MCP clients and personal tokensauth/oauth.py, auth/pages.py, auth/pats.py, auth/sessions.py
13Writing safely: create_issue and elicitationmcp/server.py (create_issue), knowledge.py
14The audit log and redactionaudit.py, api/routes.py
15The web consoleconsole/src
16Connecting Claude Code, Cursor and Claude Desktoppages/Connect.tsx, mcp/stdio.py, research/claude-code-livetest.md
17Evaluating retrieval and the 0-leak gateevals/, seed/eval/
18Security: threats and fixescore/middleware.py, core/http.py, core/proxy.py, test_security_review.py
19Containers and the local stackserver/Dockerfile, console/Dockerfile, docker-compose.yml
20Deploying to Google Cloud with CI/CDdeploy/, .github/workflows/