8.2 KiB
icon
| icon |
|---|
| lucide/library |
Architecture
Overview
The platform is implemented as a resource-first MCP system with an integrated static documentation surface. The same methodology content powers both MCP resources and the published docs site.
An MCP server is a runtime that exposes machine-readable resources and tools through stable interfaces so AI clients can discover and consume context consistently. Here, the server's role is intentionally narrow: publish canonical methodology documents as resources, keep discovery predictable through a catalog layer, and serve the same source material as pre-built static documentation.
The system is complete in three layers:
- Canonical methodology is maintained in Markdown skill documents.
- Catalog resources provide normalized discovery.
- Zensical builds a static site from those same Markdown sources and the FastAPI app serves it in the FastMCP runtime process.
This architecture is anchored by three contracts:
- Docs-first authored content contract under
docs/with strict per-skill ownership. SKILL.mdfrontmatter contract with Anthropic fields plusx-personal-mcpmetadata.- Canonical resource URI contract with break-and-replace policy for contract changes.
Detailed contract pages:
This architecture keeps authored content human-friendly while preserving machine-stable contracts.
Intent
The architecture is designed to satisfy three long-term requirements:
- Methodology must be editable as markdown by humans.
- Agents must consume stable, discoverable resource contracts, with a minimal read-only catalog tool fallback for constrained clients.
- Public documentation must be pre-built static output served from the application runtime without a separate docs service.
System Model
Pattern Modules
Each skill encapsulates one methodology domain in a docs-owned directory:
docs/skills/<skill-id>/SKILL.mddocs/skills/<skill-id>/references/...
The skill document and references are the authored source of truth; runtime code indexes and serves these files without becoming a second authored source.
Each skill publishes resource families:
- document
The document resource returns canonical Markdown, while clients can perform any downstream section extraction they need.
Catalog Module
The catalog is the canonical discovery layer and publishes normalized records for all modules. It may also expose a minimal set of read-only discovery tools that resolve back to the same canonical markdown content when a client chat surface does not expose MCP resource attachment.
Typical catalog resources:
- resource://catalog/skills_index
- resource://catalog/skills/{skill_id}
Only canonical catalog resources are part of the runtime contract in this phase.
Registry Loader
The runtime composition includes a startup registry loader that reads packaged docs resources using importlib.resources.files(...) and Traversable APIs.
Loader responsibilities:
- Parse SKILL.md frontmatter for each skill.
- Validate schema and cross-field constraints before any resource registration.
- Build an in-memory registry keyed by
skill_id. - Fail fast for duplicate ids, missing markdown files, broken reference mappings, and invalid
depends_onvalues.
Registry load failure is a startup error, not a partial runtime warning.
Content Sources
Content is authored in markdown under docs/ and managed as long-form reference material. Skill documents and companion references now live under docs/skills/, while project-authored pages remain alongside them in the docs tree. Resource handlers expose the same authored documents through stable resource URIs.
Static Docs Surface
Static docs are built directly from two markdown source streams:
- Project-authored docs pages
- Skill and reference markdown pages
The merged docs tree is built by Zensical into static files and served by the FastAPI app.
Data Flow
flowchart TD
A[Authored Markdown] --> C[Resource Handlers]
B[Pattern Metadata] --> D[Catalog Resources]
A --> E[Zensical Static Build]
E --> H[FastAPI Static Mount]
H --> I[Served Docs Site]
D --> I
Contracts
Metadata Contract
Each skill declares frontmatter in docs/skills/<skill-id>/SKILL.md.
For the full field-level contract, validation model, and FastMCP metadata mapping, see Frontmatter Contract.
Anthropic-facing required fields:
- name
- description
Repository indexing metadata is declared in x-personal-mcp:
- id
- version
- tags
- capabilities
- depends_on
- references map (ref id to relative path and optional metadata)
No metadata.yaml sidecar is part of the end-state contract.
URI Contract
Canonical resource URIs are:
For the full URI semantics, parameter validation rules, and compatibility policy, see URI Contract.
- resource://skills/<skill_id>/document
- resource://skills/<skill_id>/references/<ref_id>
- resource://catalog/skills_index
- resource://catalog/skills/{skill_id}
- resource://docs/{path*}
Validation rules:
skill_idis lowercase kebab-case and must satisfy the stable skill id contract.ref_idis lowercase kebab-case and must be declared in the skill references manifest.path*resolves only to normalized markdown paths underdocs/.
Resource Registration Contract
Resources are registered from the validated registry, not by ad hoc per-skill hardcoding.
Registration rules:
- Use RFC6570 URI templates where appropriate.
- Mark documentation resources as read-only and idempotent.
- Set explicit mime types for resource responses.
- Configure duplicate URI handling with
on_duplicate="error"for startup safety.
This keeps runtime behavior deterministic and prevents accidental URI collisions.
Versioning Rule
URIs are unversioned and canonical in this phase.
- Breaking URI changes are handled as direct replacement.
- No compatibility aliases or dual URI families are maintained.
Static Hosting Pattern
The docs site is pre-built and served by the same FastAPI runtime process used by the MCP app.
Runtime behavior:
- App starts.
- FastAPI mounts the static docs output directory.
- Requests to docs paths are served as static assets.
This provides a single deployment artifact with no runtime markdown rendering dependency.
Advantages
Single Source of Truth
Methodology is authored once and reused in both MCP resources and docs pages.
High-Fidelity Agent Context
Resources expose the same canonical Markdown that humans author and review.
Operational Simplicity
A single app process serves MCP and docs surfaces.
Long-Term Maintainability
Markdown remains easy to review, while contracts remain stable for clients.
Client Independence
Clients can use Ask, Edit, or Agent modes without requiring server-owned prompt orchestration. However, MCP affordances are still chat-surface-dependent: some clients or sessions expose resource attachment directly, while others make tool invocation the more reliable retrieval path.
Authoring and Publishing Lifecycle
- Update markdown reference content.
- Update metadata if capability surface changes.
- Build static docs with Zensical.
- Serve built output through FastAPI static mount.
Scope and Non-Goals
In-scope:
- Resource-first methodology delivery
- Catalog-based discovery
- Pre-built static docs hosting in app runtime
Out-of-scope:
- Prompt-first orchestration as the primary interface
- Large tool inventories duplicating static guidance across skill modules
- Separate dynamic docs service at runtime
Allowed exception:
- A small catalog-level tool layer is acceptable when it improves client interoperability without creating a second source of truth for skill content.
Example Content Inputs
Existing markdown reference sets are valid examples of authored source material for this architecture:
- docs/skills/pytest-scaffolding/references/pytest-docs.md
- docs/skills/python-logging-dictconfig/references/python-logging-docs.md
- docs/skills/fastapi-uv-docker/references/fastapi-best-practices.md
These inputs are treated as content sources, while resource URIs and catalog payloads remain the machine-facing contracts.