Commit ca60962
Add architecture documentation (#2165)
* Add comprehensive architecture documentation
This commit introduces a new architectural documentation suite in docs/arch/
that provides in-depth coverage of ToolHive's design, components, and concepts.
The documentation is organized into the following sections:
- 00-overview.md: High-level architecture overview and introduction
- 01-deployment-modes.md: Local CLI, UI, and Kubernetes deployment patterns
- 02-core-concepts.md: Core terminology, abstractions, and design patterns
- 03-transport-architecture.md: MCP transport protocols and proxy architecture
- 04-secrets-management.md: Secret handling and backend integrations
- 05-runconfig-and-permissions.md: Configuration schema and security profiles
- 06-registry-system.md: Registry architecture and distribution
- 07-groups.md: Group management and virtual MCP servers
- 08-workloads-lifecycle.md: Workload state management and operations
- 09-operator-architecture.md: Kubernetes operator design and patterns
- README.md: Navigation guide and documentation index
This documentation serves as the canonical reference for understanding
ToolHive's architecture, making it easier for contributors to navigate
the codebase and for users to understand deployment options.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Juan Antonio Osorio <[email protected]>
* Address review feedback on architecture docs
Made the following changes based on review comments:
- Fix API version references: point to actual examples instead of inline YAML
- Fix CRD names: ToolConfig → MCPToolConfig, add MCPExternalAuthConfig
- Remove all line number references from code file paths
- Fix CLI commands: registry show → info, group delete → rm
- Remove non-existent CLI commands from documentation
- Fix 1Password implementation details (uses SDK not CLI)
- Point to cmd/thv-operator/ README instead of duplicating info
- Add note that thv-registry-api is moving out of tree
These changes make the documentation more maintainable by reducing
references to implementation details that change frequently and
ensuring all commands and APIs referenced actually exist.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address additional review feedback on architecture docs
Reduces duplication and improves maintainability of architecture documentation:
- Remove duplicated Core Concepts section from overview, replace with brief summary
- Update stdio flow diagram to show independent stdin/stdout streams more clearly
- Add context for when to use exported configs (sharing, migration, version control)
- Remove Project Structure section to reduce maintenance burden
- Simplify Registry API Server section with note about out-of-tree migration
- Fix persistent volume statement in Kubernetes scaling section
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Clarify concepts and add explanations per review feedback
- Change "metrics" to "telemetry" for proxy endpoints clarity
- Clarify stdio session limitations (single connection to container)
- Explain why tool filter vs tool call filter (context optimization)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix code formatting for WriteCloser and ReadCloser
Use backticks for proper code formatting in attach process documentation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix incorrect group commands in documentation
Remove non-existent commands and fix interactive command documentation:
- Remove 'thv group move' (doesn't exist)
- Fix 'thv client setup' description (is interactive, doesn't take client name)
- Update group operations list to match actual CLI
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Clarify scaling considerations and transport limitations
- Soften HA scaling claim (not currently tested)
- Add stdio transport limitation for proxy scaling
- Clarify MCP server scaling applies to SSE/Streamable HTTP transports
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Mark SSE transport as deprecated in MCP spec
Add note that SSE transport is deprecated in the MCP specification,
though ToolHive continues to support it with potential future transition.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Replace embedded RunConfig struct with link to source
Replace full struct definition with link to pkg/runner/config.go
and categorized field summary to reduce maintenance burden.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix commands and paths based on actual code verification
Verified against source code and corrected:
- Export command syntax (requires 2 args: workload and path, no stdout)
- Cedar policy format (Client:: not User::, Action::call_tool not "tools/call")
- Group operations (thv list --group, not thv group list <name>)
- File locations (data files in ~/.local/share, state in ~/.local/state)
- Complete socket paths including macOS locations (Podman Machine, Docker Desktop, Rancher)
All changes verified against pkg/authz/cedar.go, cmd/thv/app/export.go,
pkg/container/docker/sdk/client_unix.go, and pkg state/workloads code.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix Scalar UI path and audit event types
Verified against actual code:
- Scalar UI path is /api/doc not /scalar (pkg/api/docs.go:13, server.go:234)
- Fixed audit event types based on pkg/audit/mcp_events.go (15 total types)
- Corrected mcp_list_operation to actual types: mcp_tools_list, mcp_resources_list, mcp_prompts_list
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Remove outdated project structure reference from README
Project structure section was removed from overview, update index to match.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address review comments on core concepts documentation
- Clarify tool-filter and tool-call-filter middleware descriptions
- Separate tool filtering from tool overriding in documentation
- Rename "Filter" section to "Filter and Override" to reflect both operations
- Change "metrics" to "telemetry" for consistency with middleware naming
- Explain that both middlewares work together with shared configuration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address review comments on core concepts documentation
- Replace CRD examples with references to examples/operator/mcp-servers/ directory
- Fix export command syntax (thv export requires output path)
- Fix group commands documentation (thv list --group instead of thv group list)
- Refocus groups documentation on architecture rather than CLI usage
- Remove excessive CLI usage examples to reduce maintenance burden
All changes verified against actual codebase implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Clarify security and Kubernetes secrets handling
- Clarify token storage security in remote authentication (AES-256-GCM encryption)
- Add Kubernetes Mode section to secrets documentation explaining native K8s Secret usage
- Note that Kubernetes uses SecretKeyRef, not the provider system used in CLI mode
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Add architecture documentation maintenance guidance
Add a new section to CLAUDE.md instructing agents to update
architecture documentation when making code changes. Includes
a mapping table of code areas to documentation files and
guidelines for keeping docs in sync with implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address PR feedback on core concepts documentation
Fix all 12 unresolved review comments by improving architectural focus:
- Remove CLI command examples, focus on architectural concepts
- Update file path references to actual implementation files
- Fix middleware type name from 'authz' to 'authorization'
- Organize RunConfig fields by architectural categories
- Simplify audit events to categories instead of exhaustive list
- Simplify request flow diagram and reference middleware.md
- Correct file paths for registry, session, client, MCP, audit, monitor, healthcheck
These changes align the documentation with architectural best practices:
focusing on concepts, patterns, and system design rather than CLI
usage or exhaustive implementation details.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix transport architecture documentation inaccuracies
Address PR feedback by removing CLI examples and correcting technical details:
- Remove all CLI command examples (architecture docs should focus on design, not usage)
- Fix container monitor path: pkg/container/docker/monitor.go (not pkg/container/monitor.go)
- Correct OAuth token storage: tokens managed in-memory by TokenSource, not persisted
- Clarify MCP_HOST: defaults to 127.0.0.1 locally, 0.0.0.0 in Kubernetes
- Replace CLI examples with architectural descriptions of concepts
- Update port management to describe architecture, not command flags
- Document TokenSource pattern and client credential storage distinction
These changes align documentation with actual implementation and follow
architecture documentation best practices.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix runconfig and secrets documentation inaccuracies
Address final round of PR feedback by removing CLI examples and correcting technical details:
- Remove all CLI command examples from architecture docs
- Fix 1Password implementation: SDK not CLI (diagram and text)
- Add missing secret providers: environment and none
- Document Environment provider security: ListSecrets disabled for security
- Correct environment variable merge order with architectural reasoning
- Fix Windows path handling: allowed as host paths only, not container paths
- Replace export/import CLI examples with architectural descriptions
- Update permission auditing, network isolation, secrets management sections
- Remove CLI flags from custom profiles section
All changes verified by toolhive-expert agent. Documentation now focuses on
architectural concepts and design patterns rather than CLI usage.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address all unresolved PR review comments
Fix architecture documentation inaccuracies identified in code review:
Registry System (06):
- Update file references to actual provider implementation files
- Remove reference to non-existent README
- Fix annotation keys to use correct toolhive.stacklok.dev domain
- Correct MCPRegistry phases (remove Degraded, add Terminating)
- Fix YAML examples (apiVersion, Git repository field, sync policy)
- Remove incomplete OAuth example
- Update CLI flags to match actual implementation
- Remove reference to non-existent converter command
- Simplify architecture diagram to reflect actual implementation
Groups (07):
- Clarify group move functionality is internal only
- Add note about empty default registry groups
- Remove stale PR reference, use generic description
Workloads Lifecycle (08):
- Remove all line number references per documentation guidelines
- Fix storage paths to match XDG directory structure
- Correct label format to simple prefix style
Operator Architecture (09):
- Fix MCPExternalAuthConfig filename reference
- Add missing controller reference
- Remove incorrect StatusCollector example code
- Fix sync trigger annotation key
All changes verified against actual code implementation.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* remove backup file
Signed-off-by: Juan Antonio Osorio <[email protected]>
* Fix workloads lifecycle architecture documentation
Remove CLI-focused content and maintain architecture focus:
- Fix state transition: container exit goes to stopped (was already correct in diagram)
- Remove non-existent update command section
- Remove CLI examples from List section, describe architecture instead
- Rename 'Async Operations' to 'Batch Operations' for clarity
- Remove CLI flags from filtering, describe capability architecturally
- Expand label descriptions with purpose/meaning
Architecture docs should describe system design, not CLI usage.
Verified against pkg/workloads/manager.go and pkg/container/runtime/types.go
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address PR review feedback on deployment modes documentation
- Clarify that Rancher Desktop is Docker-compatible and detected as Docker runtime type
- Convert CRD API documentation reference to clickable link
- Convert operator DESIGN.md reference to clickable link
Rancher Desktop is included in the Docker section because it's detected as
runtime.TypeDocker in the code (pkg/container/docker/sdk/client_unix.go:188),
not as a separate runtime type like Colima or Podman.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Address PR review feedback on architecture documentation
Fix all unresolved PR review comments from PR #2165:
- Fix file paths and references to match actual codebase structure
- Correct API endpoint paths to use /api/v1beta/ prefix
- Update container runtime paths and support descriptions
- Fix environment variable merge order and documentation
- Correct secrets storage paths using XDG specification
- Update MCP_HOST behavior documentation (always 127.0.0.1)
- Fix permission profile selection priority and defaults
- Update Sigstore verification status to implemented
- Fix operator CRD status structures and phase names
- Add MCPRemoteProxy CRD documentation
- Complete operator-created resources list with RBAC details
- Fix ConfigMap storage format and sync policy documentation
- Clarify OIDC and authorization ConfigMap patterns
- Update egress proxy implementation details
- Fix state storage directory name to 'runconfigs'
All changes verified against actual codebase implementation
to ensure documentation accuracy.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Update docs/arch/05-runconfig-and-permissions.md
Co-authored-by: Jakub Hrozek <[email protected]>
---------
Signed-off-by: Juan Antonio Osorio <[email protected]>
Co-authored-by: Claude <[email protected]>
Co-authored-by: Jakub Hrozek <[email protected]>1 parent 89796e7 commit ca60962
12 files changed
+4685
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
204 | 237 | | |
205 | 238 | | |
206 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
0 commit comments