Scope
This draft defines the in-process protocol model used by mtp-python.
Positioning note:
- This file describes protocol-layer contracts only.
- SDK/framework layering and MCP interoperability strategy are documented in:
- Project Direction
Core entities
ToolSpec
name: stable tool identifier (toolkit.actionrecommended)description: model-facing descriptioninput_schema: JSON schema-like object for tool argstags: optional model/runtime grouping hintsrisk_level:read_only|write|destructivecost_hint: optional human-facing cost hintside_effects: optional description of expected side effectscache_ttl_seconds: optional cache hint for runtime reuse
ToolCall
id: unique call identifier inside a planname: selected tool namearguments: dict payloaddepends_on: list of call IDs required before this callreasoning: optional public decision summary, not private chain-of-thought
ToolBatch
mode:parallelorsequentialcalls: list ofToolCall
ExecutionPlan
batches: ordered list of batchesmetadata: provider/planner metadata
ToolResult
call_id,tool_name,outputsuccess,errorcachedapproval: policy decision used (allow/ask/deny)skipped: true when blocked by policycreated_at: timestamp for the result objectexpires_at: cache expiry timestamp when TTL caching is activeimages,videos,audios,files: optional multimodal tool outputs
ToolOutput
Tools may return ToolOutput when they need to separate normal content from multimodal outputs:
content: primary tool outputimages,videos,audios,files: optional media/file payloads
Envelope
MessageEnvelope provides a lightweight versioned wrapper:
mtp_versionkindpayloadmetadata
Validation rules
validate_execution_plan(plan) enforces:
- no duplicate
ToolCall.id - every dependency references an existing call ID
- dependency graph is acyclic
$refarguments anddepends_onentries only target calls available earlier in execution order
Execution semantics
- Validate plan.
- Execute batches in order.
- For sequential batches, execute calls in listed order.
- For parallel batches, execute all listed calls concurrently.
- Before execution, resolve argument references:
{ "$ref": "<call_id>" }replaces value with prior result output.
- Enforce risk policy.
- Apply cache lookup/store if TTL configured.
Non-goals in v0.1.0
- transport protocol definition (HTTP/stdio/ws)
- cryptographic signing/auth
- streaming partial tool result chunks
- formal RFC process
Persistence note:
- Session persistence is implemented at runtime level (
session_store) and is intentionally separate from the protocol model.
Related: