Extensions & Plugins
Hands-On Walkthrough
Want a step-by-step guide covering the six default built-in extensions, installing a physical Java SPI .jar (kompile extension install <file.jar>), packaging a runnable .jar Process Extension ("kind": "jar"), and building GraalVM Native-Image Plugins (both compile-time SPI and runtime native executables)? Start with Building & Managing Kompile Extensions.
Kompile provides several extension points depending on whether you want to ship new CLI commands + MCP tools, connect third-party MCP servers, wrap quick shell/HTTP helpers, add reusable skills/roles, enforce tool hooks, or package an entire persona.
Choosing the Right Extension Mechanism
| Mechanism | Best for | Language / Format | Scope & Precedence | How it's managed |
|---|---|---|---|---|
| Process Extension Packages | Distributable CLI subcommands + MCP tools (any language, works in native CLI without a plugin JVM) | extension.json + executable or runnable JAR | User (~/.kompile/extensions/packages/) | kompile extension / /extension |
Java Plugin SPI (kompile-cli-plugin-api, kompile-cli-tool-api) | Trusted in-process Java commands & tools — drop-in .jar on JVM (cli-harness-any) or compiled into custom native images | Physical .jar + ServiceLoader | User (~/.kompile/extensions/jars/), Dist (<dist>/lib/extensions/), or build classpath | kompile extension install <file.jar> / remove <jar> (KOMPILE_NO_EXTENSION_JARS=1 to bypass) |
| Custom MCP Servers | Existing third-party or remote MCP servers (stdio, HTTP, SSE) | Any MCP server | User (~/.kompile/config/mcp-servers.json) < Project (.mcp.json) | kompile mcp add|list|disable|remove |
| Declarative Custom Tools | Lightweight bash or HTTP tools without writing an MCP server | JSON files | User (~/.kompile/tools/) < Project (.kompile/tools/) | Drop .json files + activate_tools(["custom"]) |
| Skills & Roles | Reusable workflows, prompt templates, and agent personas | Markdown + YAML frontmatter / JSON | Bundled < Provider dirs < User (~/.kompile/) < Project (.kompile/) | /skills, /roles, skill_manager, role_manager |
| Tool Hooks | Pre/post tool validation, policy checks, and side-effect automation | JSON + shell scripts | User (~/.kompile/hooks.json) + Project (.kompile/hooks.json) | /hooks, hooks tool |
| Spins & Companions | Packaging prompts + tools + models into an installable persona, or overlaying local ML onto cli-harness | Distribution / overlay | Install root | kompile spin, kompile install local-runtime |
1. Trusted Process Extension Packages (kompile extension)
Process extensions let you add both new top-level kompile <subcommand> commands and MCP tools from any language (Rust, Go, Python, Node, shell, or a runnable JAR) — including inside GraalVM native cli-harness binaries without dynamic Java classloading.
Installing and Managing Packages
# Inspect all composed extensions (built-in + installed process packages)
kompile extension
kompile extension builtin.code --json
# Install from a local directory, .zip archive, https:// URL, or configured source
kompile extension install /path/to/my-extension
kompile extension install ./my-extension-1.0.zip --sha256 <64-hex-chars>
kompile extension install https://example.com/releases/my-extension-1.0.zip --sha256 <64-hex-chars>
kompile extension install --from-source team-artifacts my-extension
# Upgrade to a new immutable version
kompile extension install ./my-extension-1.1.zip --replace
# Inspect or deactivate
kompile extension inspect my-extension --json
kompile extension remove my-extensionThe same operations are available inside kompile chat via /extension (aliases: /extensions, /plugin, /plugins).
Package Layout & extension.json
Place extension.json (max 1 MiB) at the root of the directory or .zip archive:
{
"schemaVersion": 1,
"apiVersion": 1,
"id": "demo",
"version": "1.0",
"timeoutSeconds": 60,
"commands": {
"demo-command": {
"kind": "executable",
"path": "bin/demo",
"args": ["--cli"]
}
},
"mcp": {
"kind": "executable",
"path": "bin/demo",
"args": ["--mcp"]
},
"tools": [
{
"name": "echo",
"description": "Echo a message",
"inputSchema": {
"type": "object",
"properties": {
"message": { "type": "string" }
},
"required": ["message"]
}
}
]
}Runtime & Security Contract
- No code runs during install. Payloads are copied into immutable directories under
~/.kompile/extensions/packages/<id>/<version>and activated atomically viainstalled.json. - Archive & path safety:
.zipextraction enforces entry count (≤ 4,096) and uncompressed size (≤ 512 MiB) bounds and rejects symlinks, non-regular files, absolute paths, and..traversal. Launch argv is literal (no shell interpolation). - Executable vs. JAR targets:
kind: "executable"runs directly with zero JVM requirement;kind: "jar"launches via Kompile's Java runtime locator. Child processes receiveKOMPILE_EXTENSION_ID,KOMPILE_EXTENSION_VERSION, andKOMPILE_EXTENSION_ROOT. - MCP export: Declared tools are exposed as
mcp__extension_<id>__<name>with permission keymcp.extension-<id>. Schemas are validated strictly against declaredtools; undeclared tools returned by the subprocess are never exposed. - Recovery: If a broken package prevents normal startup,
kompile extension remove <id>loads compiled commands only so you can always deactivate it cleanly.
2. Java Plugin SPI (kompile-cli-plugin-api & kompile-cli-tool-api)
For trusted in-process Java extensions — either installed as physical .jar files (kompile extension install <file.jar> / remove <jar> into ~/.kompile/extensions/jars/, or bundled in <dist>/lib/extensions/*.jar, auto-loaded by kompile.sh / kompile.cmd, bypassable with KOMPILE_NO_EXTENSION_JARS=1) or compiled into custom builds / GraalVM native images — Kompile provides two lightweight SPI modules with no dependency on kompile-cli-main, graph engines, or JNI:
kompile-cli-plugin-api(JDK + Picocli only):CliExtension—ServiceLoaderentry point supplying aCliExtensionDescriptorand optional Picocli subcommands.CliExtensionDescriptor&CliToolDescriptor— immutable identity, API version, provided/required capabilities, commands, and declared tool ownership.CliExtensionCatalog— validates metadata (rejecting duplicate IDs, unsupported APIs, and missing required capabilities) before any contribution factory runs.CliCommandRegistrar— legacy Picocli subcommand registrar SPI (still supported).
kompile-cli-tool-api(plugin-api + Jackson only):CliToolProvider— contributesProvidedToolinstances given aToolProviderContext(endpoints,ObjectMapper, working directory, andCHAT/MCPsurface).ExtensionTool<C>&ToolInvocationContext— portable tool execution contract exposing only session ID, working directory, cancellation, permission checks, and safe path resolution.
Built-In Composed Extensions
Kompile organizes its own built-in capability families through the same extension catalog (inspectable via kompile extension):
| Extension ID | Owned Tools |
|---|---|
builtin.code | code_search, code_graph, local_code_index |
builtin.knowledge | knowledge_search, knowledge_status, rag_search, graph_search |
builtin.graph | Knowledge graph CRUD, grounding, reasoning (ask_graph_*), analytics (graph_*), process mining |
builtin.crawl | crawl_source, crawl_documents, crawl_discover, crawl_control, crawl_result |
builtin.model | model_runtime, subprocess_watchdog, vlm_model_definition (chat) |
builtin.pipeline | pipeline |
See CLI Extension Composition for the full architectural and native-image verification details.
3. Custom MCP Servers (kompile mcp)
Connect any third-party stdio, HTTP, or SSE MCP server across standard chat, headless chat, and managed passthrough:
kompile mcp add context7 -- npx -y @upstash/context7-mcp
kompile mcp add --scope user --transport http docs https://mcp.example.com/mcp
kompile mcp list
kompile mcp disable context7
kompile mcp remove context7- Project servers live in
.mcp.json; user servers live in~/.kompile/config/mcp-servers.json(project entries override user entries by name). - Tools are namespaced as
mcp__<server>__<tool>and reachable through themcp_tool_search/mcp_tool_callgateway. - See Custom MCP Servers for transport options, auth references, trust rules, and tool filtering.
4. Declarative Custom Tools (~/.kompile/tools/, .kompile/tools/)
When you only need a quick shell command or HTTP endpoint exposed as a tool, drop a .json file into ~/.kompile/tools/ (user) or .kompile/tools/ (project, overrides user by name).
Custom tools are registered as custom_<name> inside the custom dynamic MCP group (activated via activate_tools(["custom"])) and default to a 30-second timeout (timeout_seconds).
Bash-backed tool example
{
"name": "jira_lookup",
"description": "Look up a JIRA ticket by ID",
"parameters": {
"type": "object",
"properties": {
"ticket": { "type": "string", "description": "JIRA ticket ID" }
},
"required": ["ticket"]
},
"execute": {
"type": "bash",
"command": "jira view {{ticket}} --json",
"working_dir": "."
},
"timeout_seconds": 30
}HTTP-backed tool example
{
"name": "deploy_status",
"description": "Check deployment status for an environment",
"parameters": {
"type": "object",
"properties": {
"env": { "type": "string" }
},
"required": ["env"]
},
"execute": {
"type": "http",
"url": "https://deploy.internal/api/status/{{env}}",
"method": "GET",
"headers": {
"Accept": "application/json"
}
}
}5. Skills & Roles
Custom Skills
Skills are Markdown files with YAML frontmatter that teach agents repeatable procedures (and are also exposed through the MCP prompts endpoint).
Search order (later overrides earlier):
<install>/lib/skills/— bundled first-party defaults- User provider skill directories (compatibility imports)
~/.kompile/skills/— user-scoped skills- Project provider skill directories (compatibility imports)
.kompile/skills/— project-scoped skills
---
name: deploy
description: Deploy the current branch to staging
category: devops
tools: bash, read, grep, glob
model: default
---
Deploy the current branch to staging. {{args}}
1. Verify tests pass cleanly.
2. Run the staging deployment pipeline and report the URL.Inspect and manage skills with /skills or the skill_manager MCP tool. See Skills and Prompt Templates.
Custom Roles
Roles define reusable persona prompts and behavior constraints loaded with built-in < ~/.kompile/roles/ < .kompile/roles/ precedence. Per-agent role assignments are stored in ~/.kompile/roles/agent-roles.json and managed via /roles, /role <name>, or role_manager.
6. Tool Hooks (.kompile/hooks.json, ~/.kompile/hooks.json)
Claude-style deterministic tool hooks run before or after tool calls to enforce custom policies, block unsafe operations, or trigger automated checks. Manage hooks interactively with /hooks or programmatically via the hooks MCP tool. See Hooks for event names, matchers, and JSON schemas.
7. Spins & Runtime Overlays
- Spins (
kompile spin) package prompts, skills, MCP tool configurations, declarative custom tools, and optional local models into a self-contained installable persona distribution. Follow the end-to-end Building a Kompile Spin Walkthrough or read the Spins Reference. - Local Runtime Overlay (
kompile install local-runtime) addslib/kompile-local-runtime.jar(local embeddings, dense retrieval, and graph reasoning) onto a slimcli-harnessinstallation while preserving base updates and release channels.