Skip to content

Architecture: six-pillar fail-closed pipeline

ToolMesh is a Go middleware that orchestrates, authorizes, and secures the execution of tool calls between AI agents and backend infrastructure.

Claude CodetrustedClaude Desktoptrusted3rd Party AgentuntrustedMCP + CallerIDToolMeshSelf-hosted MCP gatewayAuthOAuth 2.1AuthZOpenFGACredentialsSecret InjectGateJS PoliciesExecuteMCP / RESTAuditslog / SQLiteMCP ServersHTTP / STDIOAny existing MCP serverDADL LibraryREST APIs described in YAML, one file per APIdadl.aiStripeGitHubHetznerDeepLCloudflareyour REST API4,591 tools across 36 APIs in the registry at dadl.ai

Every tool call passes through a fail-closed pipeline. If any step rejects (AuthZ, Gate), the entire execution stops. No partial results leak through.

PillarImplementationBacked by
Any BackendMCP servers (HTTP/STDIO) + REST APIs via DADLGo MCP SDK + DADL parser
Code Modediscover_tools + execute_code — LLMs write JS instead of JSONAST-parsed tool calls
AuditEvery tool call logged structurallyslog (write-only) or SQLite (queryable)
AuthorizationOn by default: users, roles and plans get tools through presets or grants; kits add rights for one task, granted and signed by a personOpenFGA, built in
Credential StoreSecrets injected at runtime, never in prompts; each backend reads only its own, and the hosts they go to are limitedEnv vars (CREDENTIAL_*) or a command such as sops, held in memory; extensible
Output GateJS policies validate input/outputgoja (Go JS engine)

Three components are extensible via a registry pattern (inspired by Go’s database/sql drivers):

ComponentRegistry FunctionBuilt-inConfig
Credential Storecredentials.Register()embedded (env vars), command (in memory)CREDENTIAL_STORE=<name>
Tool Backendbackend.Register()mcp, rest (DADL), echoconfig/backends.yaml
Gate Evaluatorgate.RegisterEvaluator()goja (JavaScript)GATE_EVALUATORS=<list>

Extensions register via init() functions. Enterprise extensions live in a separate module and are included via Go build tags:

Terminal window
go build -tags enterprise ./cmd/toolmesh
ComponentExtensionDescription
Credential StoreInfisicalStoreInfisical Secrets Manager integration
Credential StoreVaultStoreHashiCorp Vault / OpenBao integration
Gate EvaluatorCompliance-LLMLLM-based content classification
toolmesh/
├── cmd/
│ └── toolmesh/ # Main entrypoint (MCP server)
├── config/
│ ├── authz.yaml.example # Authorization grants (copy to authz.yaml)
│ └── openfga/ # Example model, tuples and setup script for an external OpenFGA server
├── internal/
│ ├── mcp/ # MCP server (Streamable HTTP + STDIO)
│ ├── backend/ # ToolBackend interface + MCPAdapter + RESTAdapter
│ ├── executor/ # ExecuteTool pipeline (AuthZ → Creds → Gate → Exec → Audit)
│ ├── audit/ # Audit store interface + log/sqlite implementations
│ ├── authz/ # Authorization (embedded or external OpenFGA)
│ ├── credentials/ # Credential store interface, EmbeddedStore, CommandStore
│ ├── gate/ # Output gate (goja policy engine)
│ ├── userctx/ # UserContext propagation
│ └── config/ # Environment-based configuration
├── config/ # Backend config (backends.yaml, users.yaml, apikeys.yaml)
├── tools/ # TypeScript tool definitions (canonical source)
├── policies/ # JavaScript gate policies
└── docs/ # Documentation