tools/call request passes through a deterministic pipeline. The stages are identical for DB-backed and script-backed tools — only the execution step differs. If any stage fails, execution halts immediately and an error response is returned.
Tool resolution
The runtime matches the tool name from thetools/call request to a compiled tool definition loaded at startup.
If no tool matches, a JSON-RPC error is returned with code -32601.
Authentication
If the tool defines anauth block, the configured plugin is invoked with the request context and policy parameters.
- Plugin returns
nil: authentication passes, pipeline continues. - Plugin returns an error: pipeline halts, error returned to caller.
- No
authblock: stage is skipped entirely.
Input transform
Ifmappers.input is configured or discovered by convention, the mapper script’s export default function executes in the embedded runtime.
Payload:
Execution
The execution stage branches based on the tool’s configuration. Only one path runs per invocation.Script-backed tools
Whenhandler is configured, the handler script’s export default function executes in the embedded runtime. The return value becomes the execution result.
DB-backed tools
Whenuse and statement are configured, the executor runs six substeps:
- Input validation. Validate all declared inputs against type definitions. Missing required inputs and type mismatches produce errors.
- Environment substitution. Resolve
{{ env.VAR }}placeholders. Missing variables produce errors. - Input substitution. Replace
{{ inputs.field }}placeholders with post-transform values. Substitution is textual. - Cache check. If caching is enabled, compute the cache key from tool name + statement hash. On hit, return cached result and skip connector execution.
- Connector execution. Execute the statement against the configured connector and return row/object results.
- Cache store. On miss, store the result with the configured TTL.
Output transform
Ifmappers.output is configured or discovered by convention, the mapper script’s export default function executes in the embedded runtime.
Payload:
Response serialization
The final result is JSON-encoded and wrapped in an MCP content block:Error propagation
| Stage | Error condition | JSON-RPC code |
|---|---|---|
| Tool resolution | Tool name not found | -32601 |
| Authentication | Plugin returns error | -32000 |
| Input transform | Script throws | -32000 |
| Input validation | Missing input or type mismatch | -32000 |
| Env substitution | Missing variable | -32000 |
| Connector execution | Query error | -32000 |
| Handler execution | Script throws | -32000 |
| Output transform | Script throws | -32000 |