Matrix OSMatrix OS

IPC Tools & Hooks

The 26 IPC tools, hook lifecycle, and permission model.

IPC Tool System

The kernel interacts with the system through IPC tools exposed as an in-process MCP server. The createIpcServer() function in packages/kernel/src/ipc-server.ts creates a server named matrix-os-ipc using createSdkMcpServer().

Each tool is defined with:

  • Name -- the tool identifier (e.g., list_tasks)
  • Description -- what the tool does (helps the agent decide when to use it)
  • Zod schema -- input validation
  • Handler -- async function that executes the tool's logic

Available IPC Tools

Task Management

ToolDescription
list_tasksList tasks with optional status/assignee filtering
create_taskCreate a new task for an agent
claim_taskClaim an unassigned pending task
complete_taskMark a task as completed with output
fail_taskMark a task as failed with error details

Messaging

ToolDescription
send_messageSend a message (inter-agent or to user)
read_messagesRead messages from the message queue
read_stateRead the current system state

Skills & Knowledge

ToolDescription
load_skillLoad a skill's full body into context on demand

Identity & Sync

ToolDescription
set_handleSet the user's federated handle
sync_filesGit commit, push, and pull for cross-device sync

Scheduling

ToolDescription
manage_cronCreate, update, delete, and list cron jobs

Onboarding

ToolDescription
get_persona_suggestionsGet persona-based setup suggestions
write_setup_planWrite a personalized setup plan

File Tools (SDK Built-in)

In addition to IPC tools, agents have access to standard file tools via the Agent SDK:

ToolDescription
ReadRead file contents
WriteWrite/create files
EditEdit existing files
GlobSearch for files by pattern
GrepSearch file contents
BashExecute shell commands

These are tracked by the FILE_TOOLS constant and controlled per-agent via allowedTools and disallowedTools.

Hook System

Hooks intercept agent actions at specific lifecycle points. They're configured in kernelOptions() and defined in packages/kernel/src/hooks.ts.

PreToolUse Hooks

Run before a tool executes. Can block or modify the tool call.

HookApplied ToPurpose
safetyGuardHookBash, Write, EditPrevents dangerous commands (rm -rf, etc.)
protectedFilesHookWrite, EditBlocks modifications to critical system files

PostToolUse Hooks

Run after a tool executes. Can observe or react to the result.

HookApplied ToPurpose
gitSnapshotHookWrite, EditCreates a git commit after file changes
updateStateHookWrite, EditUpdates system state after file operations
notifyShellHookWrite, EditSends file:change event to connected shells
logActivityHookBashLogs shell command execution

Lifecycle Hooks

HookEventPurpose
persistSessionHookStopSaves the conversation session on kernel exit
onSubagentCompleteSubagentStopLogs completion of sub-agent tasks
preCompactHookPreCompactRuns before context window compaction

Permission Model

The kernel uses two mechanisms to control tool access:

allowedTools

A baseline allow-list set in kernelOptions() for the main kernel agent. Includes file tools, task management, web tools, and all IPC tools.

allowedTools is auto-approve, not filter

In the Agent SDK, allowedTools controls which tools are auto-approved (skip user confirmation). It does NOT filter which tools are available. Use tools or disallowedTools to restrict access.

Per-Agent Restrictions

Each AgentDefinition can specify:

  • tools -- explicit allow-list (only these tools are available)
  • disallowedTools -- deny-list (these tools are blocked, all others allowed)

For example, the Builder agent has access to FILE_TOOLS plus claim_task, complete_task, fail_task, and send_message from IPC tools -- but not manage_cron or set_handle.

Permission Bypass

The kernel runs with permissionMode: "bypassPermissions" which propagates to all sub-agents. This means tool access control relies entirely on allowedTools/disallowedTools lists and PreToolUse hooks, not on a separate permission prompt.

How is this guide?

On this page