Skip to content

API Reference

Public API

Kaimon.start! Function
julia
start!(; port=nothing, verbose=true, security_mode=nothing, julia_session_name="", workspace_dir=pwd())

Start the Kaimon MCP server.

Arguments

  • port::Union{Int,Nothing}=nothing: Server port. Use 0 for dynamic port assignment (finds first available port in 40000-49999). If nothing, uses port from configuration.

  • verbose::Bool=true: Show startup messages

  • security_mode::Union{Symbol,Nothing}=nothing: Override security mode (:strict, :relaxed, or :lax)

  • julia_session_name::String="": Name for this Julia session

  • workspace_dir::String=pwd(): Project root directory

Dynamic Port Assignment

Set port=0 (or use "port": 0 in security.json) to automatically find and use an available port. The server will search ports 40000-49999 for the first free port. This higher range avoids conflicts with common services.

Examples

julia
# Use configured port from security.json
Kaimon.start!()

# Use specific port
Kaimon.start!(port=4000)

# Use dynamic port assignment
Kaimon.start!(port=0)

# Start with a custom name
Kaimon.start!(julia_session_name="data-processor")
Kaimon.tui Function
julia
tui(; port=2828, theme=:kokaku)

Launch the Kaimon TUI. This is a blocking call that takes over the terminal.

Starts the MCP HTTP server in a background task and watches for REPL gate connections in ~/.cache/kaimon/sock/.

Arguments

  • port::Int=2828: Port for the MCP HTTP server

  • theme::Symbol=:kokaku: Tachikoma theme name

Kaimon.call_tool Function
julia
call_tool(tool_id::Symbol, args::Dict)

Call an MCP tool directly from the REPL without hanging.

This helper function handles the two-parameter signature that most tools expect (args and stream_channel), making it easier to call tools programmatically.

Examples

julia
Kaimon.call_tool(:exec_repl, Dict("expression" => "2 + 2"))
Kaimon.call_tool(:investigate_environment, Dict())
Kaimon.call_tool(:search_methods, Dict("query" => "println"))

Available Tools

Call list_tools() to see all available tools and their descriptions.

Kaimon.list_tools Function
julia
list_tools()

List all available MCP tools with their names and descriptions.

Returns a dictionary mapping tool names to their descriptions.

Kaimon.tool_help Function
julia
tool_help(tool_id::Symbol)

Get detailed help/documentation for a specific MCP tool.

Kaimon.security_status Function
julia
security_status()

Display current security configuration.

Kaimon.setup_security Function
julia
setup_security(; force::Bool=false)

Launch the security setup wizard.

Kaimon.generate_key Function
julia
generate_key()

Generate and add a new API key to the current configuration.

Kaimon.revoke_key Function
julia
revoke_key(key::String)

Revoke (remove) an API key from the configuration.

Kaimon.allow_ip Function
julia
allow_ip(ip::String)

Add an IP address to the allowlist.

Kaimon.deny_ip Function
julia
deny_ip(ip::String)

Remove an IP address from the allowlist.

Kaimon.set_security_mode Function
julia
set_security_mode(mode::Symbol)

Change the security mode (:strict, :relaxed, or :lax).

Gate Module

Missing docstring.

Missing docstring for Kaimon.Gate. Check Documenter's build log for details.

Kaimon.Gate.GateTool Type
julia
GateTool(name, handler)

A tool declared by a gate session. The handler is a normal Julia function; the gate infrastructure reflects on its signature to generate MCP schema and reconstructs typed arguments from incoming Dict values.

Example

julia
function send_key(key::String, modifier::Symbol=:none)
    # handle key event
end

Gate.serve(tools=[GateTool("send_key", send_key)])
Kaimon.Gate.serve Function
julia
serve(; session_id=nothing, force=false, tools=GateTool[], namespace="", allow_mirror=true, allow_restart=true)

Start the eval gate. Binds a ZMQ REP socket on an IPC endpoint and listens for eval requests from the Kaimon TUI server.

Non-blocking — returns immediately. The gate runs in a background task. The session name is derived automatically from the active project path.

Skips registration for non-interactive processes (no TTY). Use force=true to override the TTY check.

Arguments

  • session_id::Union{String,Nothing}: Reuse a session ID (e.g. after exec restart)

  • force::Bool: Skip the TTY gate (for non-interactive processes that want a gate)

  • tools::Vector{GateTool}: Session-scoped tools to expose via MCP

  • namespace::String: Stable prefix for tool names. Auto-derived from project basename if empty. Use explicit namespaces for multi-instance workflows:

    julia
    serve(tools=tools, namespace="todo_dev")    # branch A
    serve(tools=tools, namespace="todo_main")   # branch B

Example

julia
using Kaimon
Gate.serve()

# With custom tools
Gate.serve(tools=[GateTool("send_key", my_key_handler)])