Repository navigation
Description
Summary
Let users add custom tools written in any language by placing a manifest in ~/.infer/tools/. A custom tool should work like a built-in one: the model sees it, it runs through !!Name(arg="v") and infer tools execute, and it follows the same tool policy as a built-in (agent modes, require_approval, tools.safety.approval_behaviour).
Motivating case: the desktop app (Rust) embeds infer and needs a few tools that only make sense there. Today those tools have to be written in Go in this repo or run as an MCP server. With this feature the desktop app ships one binary (e.g. infer-desktop-tools <subcommand>) and one manifest per tool, and infer picks them up.
~/.infer/tools/ would be a new directory that the user owns. It has nothing to do with ~/.infer/bin/tools/, which infer binaries owns and fills with prebuilt ffmpeg / whisper-cli / llama-tts.
Why not just MCP?
MCP already lets you add tools in any language, but it is the heavier option here:
- infer only speaks MCP over stateless Streamable HTTP (2026-07-28), so every tool needs a server listening on a port or an OCI container, started and health-checked per session. The desktop app starts one
infer headlessper message. - MCP tools show up as
MCP_<server>_<tool>, are hidden in plan mode, and cannot setrequire_approvalper tool (they fall back to the global setting).
A stdio MCP transport (supported by Claude Code, Codex, Goose and Gemini CLI) would complement this feature, but it is a separate feature and out of scope here.
Prior art
| Agent | How custom tools are added | Languages |
|---|---|---|
| pi | TypeScript extensions in ~/.pi/agent/extensions/ or .pi/extensions/, loaded into the pi process via jiti; pi.registerTool() with a TypeBox schema. They run with pi's own permissions. |
TypeScript only |
| OpenCode | .opencode/tools/*.ts or ~/.config/opencode/tools/*.ts; the filename becomes the tool name; a custom tool with a built-in name replaces the built-in. |
TS/JS definition that can shell out to any language |
| Gemini CLI | tools.discoveryCommand prints a JSON array of function declarations; tools.callCommand <name> gets the arguments as JSON on stdin and prints the result on stdout. Tools are prefixed discovered_tool_. |
Any |
| Amp | Toolboxes: a directory of executables (AMP_TOOLBOX), each run with TOOLBOX_ACTION=describe to get its definition and TOOLBOX_ACTION=execute with the arguments on stdin. |
Any |
| Claude Code, Codex, Goose | stdio MCP servers | Any, needs an MCP SDK |
Gemini CLI and Amp come closest to what we want: tools talk to the agent through an executable's stdin and stdout, and no SDK is needed. This proposal uses the same idea with one change: a static manifest replaces the discovery command. That way nothing runs at startup, which keeps startup cheap for each headless process, and no tool code runs until a call is approved.
Proposed design
A custom tool manifest is the built-in tool manifest from #1369 (agentdomain.ToolManifest) plus three fields only custom tools have: command, timeout and enabled. One file per tool, ~/.infer/tools/<Name>.yaml; the file name must match name, as for the embedded manifests.
name: TakeScreenshot # ^[A-Za-z][A-Za-z0-9_]{0,63}$, must match the file name, must not be a built-in or start with MCP_
description: Capture a screenshot of a desktop app window and return the PNG path.
command: # argv, no shell. A bare name is looked up on PATH; a path with a slash resolves against the manifest's directory
- infer-desktop-tools
- screenshot
parameters: # JSON Schema of type object, sent to the model unchanged
type: object
properties:
window:
type: string
description: Title of the window to capture
required:
- window
modes: [standard, auto, auto-with-judge] # agent modes that offer the tool; omitted = these three
require_approval: true # omitted = inherit tools.safety.require_approval (default true), as for built-in manifests
timeout: 30 # seconds, default 30
enabled: truemodesreplaces theread_onlyflag this issue first proposed, matching the built-in manifests.[standard, auto, auto-with-judge, plan, readonly]offers the tool in plan and readonly like Read/Grep. Readonly mode runs its tools without approval, so listingreadonlydeclares the tool safe to run unapproved.
How a call runs:
- infer starts
commandwithout a shell, in the session working directory, with infer's environment. It writes the call's arguments to stdin as one JSON object and closes stdin. - Exit 0: stdout is the tool result (text). Non-zero exit: the call fails, and stderr (or stdout if stderr is empty) goes back to the model as the error.
- The process is killed on timeout or when the turn is cancelled. On Unix the whole process group is killed, so children of a script die too; on Windows the direct child.
- Captured output is bounded, and the model sees at most
tools.max_result_bytes, like every other tool. - Custom tool names get no prefix, so they look native. A name that matches a built-in tool of any context (agent, a2a, browser, computer), whether or not config enables it, is rejected, and so is a name starting with the reserved
MCP_prefix. A custom tool never replaces a tool, and no tool replaces a custom one. OpenCode lets custom tools replace built-ins; we deliberately do not. - Custom tools are local tools:
tools.enabled: falseturns them off too. They register before Markdown subagents load, so.infer/agents/*.mdmay list them intools:. - The approval policy gates calls the model makes.
!!Name(...)andinfer tools executeare user-initiated and count as approved, as for built-ins;infer tools execute --format jsonstill reportsapproval_required.
The desktop app can keep its tools out of the terminal CLI by pointing infer headless at its own directory with INFER_TOOLS_CUSTOM_DIR.
Groundwork
- refactor(tools): define built-in tools through embedded manifests #1369 added
agentdomain.ToolManifest, and the registry answers tool policy throughManifestTool/ToolManifestLookup. A custom tool whoseManifest()returns its manifest gets the per-mode tool lists, theExecuteToolmode guard,!!autocomplete and the approval policy with no tool-name lists. - refactor(a2a): extract A2A into its own bounded context #1371 settled the pattern for capability contexts: they build their tools with
NewTools(...)and the container registers them (a2a, browser, computer). Custom tools follow it. tools.max_result_bytesis applied centrally by the tool result formatter.
Out of scope (follow-ups)
- Project-scoped
.infer/tools/: a cloned repo could register executables, so this needs a trust model first. - Distributing tools through
infer plugins, which installs content only by design. - Structured results (images, metadata) and streaming output.
- A stdio MCP transport.
Acceptance Criteria
- infer loads every
*.yamlmanifest in~/.infer/tools/at startup. The directory can be changed withtools.custom_dir/INFER_TOOLS_CUSTOM_DIR. A missing directory is not an error. - A custom manifest goes through the same strict decode and validation as the built-in manifests, plus
command(required, non-empty),timeout(> 0) andenabled. Embedded built-in manifests keep rejecting those three fields. - A manifest that fails to parse or validate, whose file name does not match its
name, whose name matches a built-in tool (enabled or not), or whose name starts withMCP_is skipped with a logged warning. Startup continues and no existing tool is replaced.enabled: falseskips the tool without a warning. - The model sees custom tools with the manifest's description and JSON Schema. They appear in
!!autocomplete and run through!!Name(arg="v")andinfer tools execute Name '{...}'. - Arguments are validated against the manifest's
parametersbefore the process starts. The required-field and property-type checks ininternal/mcp/tool.gomove intoagentdomainso MCP and custom tools share them, which also fixesrequiredbeing skipped for[]stringschemas. - Calls follow the contract above: no shell, JSON arguments on stdin, stdout is the result on exit 0, stderr is the error on non-zero exit, the process (its process group on Unix) is killed on timeout or cancel, and output is capped by
tools.max_result_bytes. - A custom tool answers its policy through
Manifest()like a built-in.modesdecides which agent modes list it, andExecuteToolrejects a call outside them; an omittedmodeshides it in plan and readonly like an MCP tool.require_approval(omitted =tools.safety.require_approval) feedsStandardApprovalPolicy, and approval is delivered according totools.safety.approval_behaviour(prompt / ipc / block / judge) in both chat and headless. -
docs/custom-tools.mddocuments the manifest (includingmodes, what listingreadonlyimplies, and howcommandresolves) and how a call runs, with one shell-script example and one compiled single-binary example (Rust). It explains how~/.infer/tools/differs from~/.infer/bin/tools/and states that the tool runs with the user's permissions: the sandbox directory allow-list only applies to infer's built-in file tools.docs/tools-reference.mdlinks to it,docs/configuration-reference.mdliststools.custom_dir/INFER_TOOLS_CUSTOM_DIR, anddocs/directory-structure.mdlists~/.infer/tools/. - Tests cover manifest loading and validation, name collisions (built-in, disabled built-in,
MCP_), success, non-zero exit, timeout (including a child process a script spawned), and mode and approval gating.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][FEATURE] Allow registering custom tools[/-][+][FEATURE] Allow registering custom tools in any language[/+]refactor(tools): define built-in tools through embedded manifests (#1369
refactor(a2a): extract A2A into its own bounded context (#1371)
inference-gateway-releaser commentedon Sep 28, 2026
🎉 This issue has been resolved in version 0.216.0 🎉
The release is available on:
Your semantic-release bot 📦🚀