Skip to content

[DOCS] Document custom tools in the CLI #850

Closed

Description

@edenreich

Summary

Document custom tools in the CLI, added in inference-gateway/cli#1372 (issue inference-gateway/cli#1366). Users add tools written in any language with one YAML manifest per tool. infer runs the manifest's command with the call's arguments as JSON on stdin and returns its stdout. The CLI repo's docs/custom-tools.md and the runnable examples/tools are the source.

User-facing behaviour to cover:

  • Where tools load from.

    • User tools: ~/.infer/tools/, or tools.custom_dir / INFER_TOOLS_CUSTOM_DIR.
    • Project tools: the working directory's .infer/tools/ and .agents/tools/.
    • They merge. On a name clash the project tool wins, and .infer/tools/ wins over .agents/tools/.
  • Manifest. The same format as the built-in tool manifests:

    • name, which must match the file name.
    • description.
    • parameters: a JSON Schema of type object.
    • modes and require_approval.
    • command: argv, run without a shell. A bare name is looked up on PATH. A path with a slash resolves against the manifest's directory.
    • timeout: seconds, default 30.
    • enabled.

    Unknown fields are rejected. An invalid manifest is skipped with a warning in the logs.

  • How a call runs.

    1. The arguments are validated against parameters.
    2. They go to stdin as one JSON object.
    3. Exit 0 makes stdout the result. A non-zero exit returns stderr, or stdout, as the error.
    4. The process is killed on timeout or cancel (its whole process group on Linux and macOS).
    5. The output is capped by tools.max_result_bytes.
  • Modes and approval.

    • modes decides where the tool is offered. The default is standard, auto and auto-with-judge, so the tool is hidden in plan and readonly.
    • User tools follow their require_approval, which defaults to tools.safety.require_approval.
    • Project tools always need approval, whatever the manifest says and even in readonly mode, except in auto mode.
    • !!Name(...) and infer tools execute count as the user's approval.
  • Names. Custom tools get no prefix. A name that matches any built-in tool (even one config switches off, compared case-insensitively) or starts with MCP_ is rejected.

  • Write protection. Write, Edit, MultiEdit and Delete refuse any path inside a tools directory, also through a symlink or another spelling of the path. This cannot be switched off. Bash in auto mode is not covered.

  • Security.

    • Tools run with the user's permissions. The sandbox only restricts the built-in file tools.
    • A project's .infer/config.yaml is trusted like the user's own. It can set tools.custom_dir.
  • ~/.infer/tools/ is unrelated to ~/.infer/bin/tools/, which infer binaries owns.

Affected pages:

  • New cli-custom-tools.md, next to cli-skills.md. It carries the full guide, with a shell example and a single-binary Rust example, and links to examples/tools in the CLI repo.
  • cli.md:
    • Key Features: add a Custom Tools bullet linking the new page.
    • Tools & Capabilities -> Tool Categories: add a Custom row.
    • Security Features: add that project tools always need approval and that tool directories are write-protected.
    • Tool Configuration: add infer config set tools.custom_dir <dir>.
    • Configuration Files: add tools/ (Project/user).
    • Essential Environment Variables: add INFER_TOOLS_CUSTOM_DIR.
  • mcp.md: a short "Custom tools vs MCP" pointer to the new page.

Acceptance Criteria

  • cli-custom-tools.md covers where tools load from, the manifest, how a call runs, modes and approval (including that project tools always ask), names, write protection and security, with the shell and Rust examples.
  • cli.md mentions custom tools in Key Features, Tool Categories, Security Features, Tool Configuration, Configuration Files and the environment variables.
  • mcp.md links to the new page.
  • The pages match the CLI's docs/custom-tools.md as merged in feat(tools): allow registering custom tools in any language cli#1372.

Activity

  1. added
    documentation
    on Sep 28, 2026
  2. added theissue type on Sep 28, 2026
  3. moved this to Todo in 2026on Sep 28, 2026
  4. edenreich commented on Sep 28, 2026

    @edenreich
    ContributorAuthor

    @claude Can you document this?

  5. inference-gateway-maintainer commented on Sep 28, 2026

    @inference-gateway-maintainer
    Contributor

    Claude finished @edenreich's task in 3m 16s —— View job • docs/issue-850-20260928-2009 • [Create PR ➔](https://github.com/inference-gateway/docs/compare/main...docs/issue-850-20260928-2009?quick_pull=1&title=Issue%20%23850%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%23850%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)


    Documented custom tools in the CLI

    • Gather context (CLI repo docs/custom-tools.md, existing page style)
    • Write cli-custom-tools.md
    • Update cli.md sections
    • Add "Custom tools vs MCP" pointer in mcp.md
    • Register the page in nav + sidebar
    • Validate (lint:md, format:check, build - all pass)
    • Commit + open PR

    PR: #852

    What landed

    • New cli-custom-tools.md - load order and precedence (~/.infer/tools/ or tools.custom_dir, project .infer/tools/ then .agents/tools/), the manifest reference (name, description, parameters, modes, require_approval, command resolution, timeout, enabled, unknown fields rejected), the call contract (validation, JSON on stdin, exit-code semantics, timeout/cancel process-group kill, tools.max_result_bytes), modes and approval including project tools always asking outside auto mode, name rules (no prefix, built-in and MCP_ names rejected), tool-directory write protection, the security model, the shell and Rust examples, INFER_TOOLS_CUSTOM_DIR, and troubleshooting. Links to examples/tools in the CLI repo.
    • cli.md - Key Features bullet, a Custom row in Tool Categories, two Security Features entries, tools.custom_dir in Tool Configuration, a tools/ row in Configuration Files, INFER_TOOLS_CUSTOM_DIR in the env vars.
    • mcp.md - short "Custom tools vs MCP" section plus a Learn More link.

    One wording change from the source doc: the name regex is spelled out in prose instead of inline, because markdownlint reads the bracketed pattern in a table cell as an undefined reference link.
    | Branch

  6. moved this from QA to Done in 2026on Sep 28, 2026
  7. inference-gateway-releaser commented on Sep 30, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.9.19 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationreleased

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions