MCI uses modules to execute code and communicate with end services.Documentation Index
Fetch the complete documentation index at: https://modelcontrolinterface.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Module Types
MCI coordinates two module types:-
Environment modules
- Execute process code in an isolated runtime.
- Expose generated bindings for available services and tools.
- Stream stdout, stderr, and structured output updates.
-
Adapter modules
- Receive invocation requests from environments.
- Translate those requests to target protocols and service contracts.
- Return normalized results back to the environment.
Adapter responsibilities (implementation details)
- Parse and register service definitions (see
AdapterModule.register). - Maintain per-service configuration and secret snapshots via
setServiceConfig/setServiceSecret. - Translate environment invoke calls into HTTP requests (or other protocols) and normalize responses (
invoke). - Emit errors with structured payloads that the server inspects and surfaces to callers.
AdapterModule implements JSON manifest parsing, endpoint resolution, and POST-style invocation semantics.
Pooling
Modules are managed by pools to avoid repeated cold starts and reduce execution overhead.- Environment pool: allocates and releases staged environment modules.
- Adapter pool: allocates and releases adapter modules with current service configuration and secrets.
Hydration
Hydration loads runtime data into modules so they can execute correctly.Environment hydration
- Loads staged service and tool definitions.
- Generates service/tool bindings that process code can call.
setServiceManifestBindings and updateServiceManifestBindings. These bindings are visible to transpiled code running in the environment and map tool invocations to runtime-built invoke calls.
Environment modules also provide runtime events and outputs that the host listens to:
stdout: emitted when the environment worker writes to stdoutstderr: emitted when the environment worker writes to stderroutput: emitted when the environment sends structured output patches (key/value)
execute(code, options) method runs transpiled code in the worker, wires up stream handling, enforces timeouts, and returns an execution status (success or failed). The environment provides kill() to forcibly terminate a running worker.
Adapter hydration
- Loads service configuration snapshots.
- Loads service secret snapshots.
- Applies updated configuration and secrets during restage.
AdapterModule instance via setServiceConfigs and setServiceSecrets.
Module Lifecycle
- Instantiate module
- Hydrate module with current definitions and runtime data
- Stage module in pool as ready
- Allocate module for execution
- Release module back to pool
- Recycle/Retire module when unhealthy or outdated
Lifecycle notes (implementation)
- Staging is guarded by a
stagingPromiseto avoid concurrent staging attempts. - When a new staged module replaces the active one, the previous module is retired and either killed immediately if it has no leases or left to be killed after active leases finish.
- If staging fails, the pool records the failure state and keeps the previously staged module (if any) available.
Failure Handling
If a module execution fails, times out, or health checks fail, the module is recycled or retired and replaced by a newly staged module. Module health checks and recycling are implemented in the process execution path. When an execution finishes or errors, the runtime inspects module health (e.g.,isHealthy / isValid hooks) and either returns the module to the pool or recycles/destroys it.
Environment health and recycling
After process execution, the runtime evaluates the environment module’s health. Implementations may provideisHealthy or isValid hooks and a status field. If an environment is unhealthy or reported timeout/failed, the pool will recycle or destroy that module and stage a replacement to keep the pool ready.