Cortex SDK
The official Rust SDK for Cortex's trusted native plugin boundary.
cortex-sdk lets Rust plugin authors implement Tool and MultiToolPlugin while exporting Cortex's stable native ABI. The daemon loads a C-compatible function table through cortex_plugin_init; Rust trait objects stay inside the plugin library.
Process-isolated JSON plugins do not need this crate. They are declared entirely through manifest.toml and a child-process command. Use cortex-sdk when you are building a trusted in-process native plugin.
Supported Plugin Boundaries
Cortex has two public plugin boundaries:
- Process JSON — child-process tools declared in
manifest.toml, using stdin/stdout JSON. This is the default boundary for third-party and cross-language plugins and does not require the SDK. - Stable native ABI — trusted in-process shared libraries that export
cortex_plugin_init.cortex-sdkis the Rust facade for that ABI.
Add The Crate
[]
= "1.2"
= "1"
Process JSON Scaffold
Use the process JSON boundary when you do not need in-process latency or host callbacks:
The generated project contains:
cortex-plugin-hello/
├── manifest.toml
├── bin/
│ └── hello-tool
├── skills/
├── prompts/
└── README.md
Manifest
= "hello"
= "0.1.0"
= "Example process-isolated Cortex plugin"
= "1.2.0"
[]
= ["tools", "skills"]
[]
= "process"
[[]]
= "word_count"
= "Count words in text using a child process."
= "bin/word-count"
= ["PATH"]
= 5
= 1048576
= 67108864
= 2
= { = "object", = { = { = "string" } }, = ["text"] }
Protocol
Cortex sends:
The process returns:
Use is_error = true for command-level failures that should be visible as failed tool calls.
Packaging
Folder installs are supported too:
When you install from a local plugin directory, Cortex copies only plugin assets (manifest.toml, lib/, skills/, prompts/). If lib/ is missing but the manifest declares [native].library, the installer automatically copies the built shared library from target/release/ (or target/debug/) into the installed plugin lib/ directory.
Structured Media
Tool output can include structured media by returning the SDK ToolResult shape from a host language binding or by emitting compatible JSON. Media attachments are delivered by Cortex transports independently from the text returned to the model.
Native ABI Manifest
Trusted native plugins declare the stable native boundary explicitly:
= "dev"
= "1.2.0"
= "Trusted native development tools"
= "1.2.0"
[]
= ["tools", "skills"]
[]
= "lib/libcortex_plugin_dev.so"
= "trusted_in_process"
= 1
The runtime does not load legacy Rust trait-object symbols. Native plugins must export cortex_plugin_init, which cortex_sdk::export_plugin! generates.
Documentation
- API docs: https://docs.rs/cortex-sdk
- Runtime/plugin guide: https://github.com/by-scott/cortex/blob/main/docs/plugins.md