Toolpal

Documentation

Toolpal is a package manager and sandboxed runtime for AI agent workflows in Node.js (22.15 or newer; Node 25+ recommended for native network isolation). Each workflow is one function with JSON Schemas for its input and output, running on your machine in its own permission-restricted process.

On this page

Use a workflow

Install @toolpal/sdk in your application to execute pinned workflows from code, and use the toolpal CLI (npx toolpal ...) to add workflows, publish, or serve them over MCP.

npm i @toolpal/sdk
npx toolpal add @toolpal/github-repo
import { toolpal, ToolpalError } from "@toolpal/sdk";

try {
  const out = await toolpal.execute({
    tool: "@toolpal/github-repo",
    input: { repo: "facebook/react" },
    env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN }, // optional; only declared vars are passed
    outputDir: "./out", // optional: where output files are placed
    timeoutMs: 15_000,  // optional: per-call timeout override
  });
} catch (err) {
  if (err instanceof ToolpalError) console.error(err.code, err.message);
}

toolpal add downloads the workflow, verifies Toolpal's Ed25519 signature and the tarball hash, pins it in toolpal.json and toolpal.lock, and prints what it may do. Commit both files. After that, the workflow runs from the local store without contacting the registry.

execute only runs workflows added to the project: any other name fails with NOT_ADDED instead of downloading code. To pin a specific version, add it directly: npx toolpal add @toolpal/[email protected]. You can also run any added workflow (or a local build path like ./) from the terminal:

npx toolpal run @toolpal/github-repo -i '{"repo":"facebook/react"}'
npx toolpal run @toolpal/qr-code -i '{"text":"https://toolpal.dev"}' -o ./out

execute() options

OptionTypeDescription
toolstring (required)Pinned @scope/name[@range], or a local path to a built workflow directory (e.g. ./my-workflow).
inputobject (required)Validated against the workflow's inputSchema before the child process runs.
envRecord<string, string>Environment variables to pass. Only keys declared in permissions.env are forwarded.
outputDirstringDirectory where files returned by the workflow are copied. Defaults to a fresh OS temp folder; existing files are never overwritten.
fileRootsstring[]Restrict FilePath() inputs to files inside these folders (recommended when an AI model picks file paths).
timeoutMsnumberOverride the call timeout in milliseconds (cannot exceed policy.maxTimeoutMs).
signalAbortSignalAbort an in-flight execution.
onLog(entry) => voidReceives structured logs from ctx.log(), console.* output, and Toolpal runtime notices.

Project configuration (toolpal.json)

Created automatically by toolpal add. You can also configure host-side env mappings and sandbox policies here:

{
  "tools": {
    "@toolpal/github-repo": "2.0"
  },
  "env": {
    "@toolpal/github-repo": {
      "GITHUB_TOKEN": { "fromEnv": "MY_GITHUB_TOKEN" }
    }
  },
  "policy": {
    "maxTimeoutMs": 30000,
    "maxMemoryMb": 256,
    "isolation": "per-call"
  }
}

policy.isolation accepts "warm" (default, reuses a child process across calls) or "per-call" (fresh process and fresh temp dir for every call).

Custom instances & hooks (createToolpal)

Use createToolpal({ ... }) when you need custom defaults (projectDir, offline, isolation, fileRoots, outputDir, lock: false) or hooks.beforeCall / hooks.afterCall to inspect, filter, or reject inputs and outputs (recommended for defending against prompt injection in workflow outputs). Call toolpal.describe("@scope/name") to inspect a workflow's schemas and permissionSummary in code.

Write a workflow

In code, each workflow is a single TypeScript or JavaScript module whose default export is defineTool({ ... }) from @toolpal/tool (and exposed to MCP clients as an MCP tool). Schemas are written with TypeBox (Type, re-exported by @toolpal/tool), which compiles to plain JSON Schema with no runtime code generation.

// src/index.ts
import { defineTool, Type } from "@toolpal/tool";

export default defineTool({
  description: "Counts the words and characters in a piece of text.",
  input: Type.Object({
    text: Type.String({ maxLength: 100_000, description: "Input text to analyze" }),
    unique: Type.Optional(Type.Boolean({ description: "Also count unique words" })),
  }),
  output: Type.Object({
    words: Type.Integer(),
    characters: Type.Integer(),
    uniqueWords: Type.Optional(Type.Integer()),
  }),
  examples: [
    {
      title: "Count words in a sentence",
      prompt: "Count the words in 'Toolpal runs workflows locally'",
      input: { text: "Toolpal runs workflows locally", unique: true },
    },
  ],
  handler: async ({ text, unique }, ctx) => {
    ctx.log("info", "Counting words", { length: text.length });
    const tokens = text.trim() ? text.trim().split(/\s+/) : [];
    return {
      words: tokens.length,
      characters: text.length,
      ...(unique ? { uniqueWords: new Set(tokens.map((w) => w.toLowerCase())).size } : {}),
    };
  },
});

defineTool() parameters

ParameterRequiredDetails
descriptionYesNon-empty string (max 1,024 chars). Shown to AI models and on the workflow page; linted for invisible or bidirectional-override characters.
inputYesTop-level Type.Object(...) schema (max 64 KB serialized). Validated by the host before handler() runs; schema regexes are checked for catastrophic backtracking (ReDoS).
outputYesTop-level Type.Object(...) schema (max 64 KB serialized). Validated by the host before returning to the caller.
examplesNoUp to 5 input-only example objects: { title?, prompt?, input }. Never pass output here — toolpal build runs each input in the sandbox to capture real output.
handlerYes(input, ctx) => output | Promise<output>. Receives typed, validated input and ToolContext. Return a JSON-serializable object matching output.

ToolContext (ctx) reference

MemberSignatureDetails
ctx.log(level, message, data?) => voidEmits a structured log line ("debug" | "info" | "warn" | "error") to the host onLog handler. Never mixed into stdout or the JSON output.
ctx.outputDirreadonly stringPath to a private per-call directory where you write files returned in FilePath() output fields. Only available when the workflow declares a FilePath() field; reading it otherwise throws.

Authoring rules

  • Keep top-level code side-effect free. During toolpal build, your bundle is loaded in a zero-permission sandbox to read its schemas. Do not call fetch, read process.env, or touch the filesystem at module top level — do that inside handler.
  • Dependencies: Any pure JavaScript/TypeScript npm package works and is bundled into dist/tool.mjs by esbuild. Native C++ addons, child_process, worker_threads, cluster, wasi, ffi, and inspector are blocked by the sandbox.
  • Networking & env vars: Use standard fetch and process.env.MY_KEY. Toolpal derives net and env permissions automatically at build time.

Files (FilePath)

Workflows can accept input files and return generated files using FilePath() from @toolpal/tool. Declaring any FilePath() field automatically grants permissions.tmp: true.

import { readFile, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { defineTool, FilePath, Type } from "@toolpal/tool";

export default defineTool({
  description: "Numbers every line of a UTF-8 text file.",
  input: Type.Object({
    file: FilePath({ description: "Input UTF-8 text file" }),
  }),
  output: Type.Object({
    numbered: FilePath({ description: "Output file with line numbers" }),
    lines: Type.Integer(),
  }),
  handler: async ({ file }, ctx) => {
    const lines = (await readFile(file, "utf8")).split("\n");
    const numbered = join(ctx.outputDir, "numbered.txt");
    await writeFile(numbered, lines.map((line, i) => `${i + 1} ${line}`).join("\n"));
    return { numbered, lines: lines.length };
  },
});
  • Placement rule: FilePath() must be a top-level property of input or output, or the item schema of a top-level Type.Array(FilePath()). Nested file fields are rejected by toolpal build.
  • Input files: The caller passes a path on their machine; Toolpal copies it into a private call folder under its original filename and hands your handler the copy's path. The workflow never sees or modifies the caller's original file.
  • Output files: Write regular files inside ctx.outputDir and return their path (absolute or relative to ctx.outputDir). Symlinks or paths outside ctx.outputDir fail with OUTPUT_INVALID.
  • Limits: Up to 64 files per call in each direction, and up to 1 GiB per file.

Examples

Declare up to 5 input-only examples in defineTool() so your workflow's overview page displays real, verified sample inputs and outputs — plus a real Usage snippet instead of empty placeholders.

examples: [
  {
    title: "Profile a sales CSV",             // optional, max 120 chars
    prompt: "Summarize columns in sales.csv", // optional, max 300 chars
    input: { file: "examples/sample.csv" },   // required: concrete input object
  },
]
  • Input only — never hand-written output. Passing an output property inside an example entry throws a TypeError. Instead, toolpal build executes each declared input inside the Toolpal sandbox and records the real output (and generated outputFiles metadata) in dist/manifest.json.
  • File inputs in examples: For FilePath() fields, point at sample fixture files inside your project directory (e.g. "examples/sample.csv"). Paths outside the project directory are refused, and manifest inputs/outputs are rewritten to clean basenames with no temp paths leaked.
  • Env vars & skipping: If an example needs a declared env var, pass it during build with npx toolpal build -e MY_API_KEY=... (or -e MY_API_KEY to read from your shell). Use npx toolpal build --no-examples to skip execution (inputs are kept without captured outputs).
  • Limits: Up to 5 examples, and each serialized example (input + captured output + file metadata) must be at most 32 KB. Avoid adding examples to side-effecting workflows like email senders.

package.json reference

Permissions are derived automatically by static analysis, so most workflows only need name, license, keywords, and toolpal.entry in package.json. Use toolpal.permissions only for capabilities static analysis cannot detect (such as env vars read via computed keys), and toolpal.limits to raise or lower execution limits.

{
  "name": "@your-login/word-count",
  "type": "module",
  "license": "MIT",
  "repository": "https://github.com/your-login/word-count",
  "keywords": ["text", "nlp", "offline"],
  "scripts": {
    "build": "toolpal build",
    "publish": "toolpal publish"
  },
  "toolpal": {
    "entry": "src/index.ts",
    "permissions": {
      "env": ["OPTIONAL_DYNAMIC_KEY"]
    },
    "limits": {
      "timeoutMs": 15000,
      "memoryMb": 256
    }
  },
  "dependencies": {
    "@toolpal/tool": "^0.1.0"
  },
  "devDependencies": {
    "toolpal": "^0.1.0",
    "typescript": "^5.9.0"
  }
}
FieldDefault / ConstraintsDescription
nameRequired · @scope/nameLowercase letters, digits and hyphens. The @scope must be a scope your account owns (your username by default).
versionIgnoredToolpal ignores package.json version. The registry assigns sequential versions automatically: 1.0, 2.0, 3.0, …
licenseOptional · max 128 charsSPDX license identifier shown in the workflow header (e.g. "MIT", "Apache-2.0").
repositoryOptional · max 512 charsString URL or { "url": "https://..." }. Shown as a link under Details when it starts with https://.
keywordsOptional · up to 20 itemsUp to 20 tags (max 64 chars each) indexed for search and browsing.
toolpal.entry"src/index.ts"Entry file bundled by esbuild into dist/tool.mjs.
toolpal.permissions.netfalse (auto-detected)Boolean. Set true only if network access is reached dynamically and missed by static analysis.
toolpal.permissions.env[] (auto-detected · max 64)Extra env var names matching ^[A-Za-z_][A-Za-z0-9_]{0,127}$. Reserved prefixes (NODE_*, NPM_*, LD_*, DYLD_*, ELECTRON_*, PATH, PATHEXT, SYSTEMROOT, COMSPEC) are forbidden.
toolpal.permissions.tmpfalse (auto-detected)Boolean. Automatically enabled if your code imports node:fs or declares any FilePath() field.
toolpal.limits.timeoutMs10000 (100 – 300000)Max execution time per call in milliseconds (100 ms to 5 minutes).
toolpal.limits.memoryMb128 (16 – 4096)V8 heap memory limit per child process in MB (16 MB to 4 GB).

Build & publish

End-to-end steps to scaffold, build, test locally, validate, and publish a workflow:

npx toolpal login                                    # sign in via browser & pin registry key
npx toolpal init word-count                          # creates @your-login/word-count
cd word-count && npm install

# 1. Build (bundles dist/tool.mjs, derives permissions, captures examples)
npx toolpal build

# 2. Inspect generated manifest, schemas, permissions & captured examples
npx toolpal info ./
npx toolpal analyze

# 3. Run locally in the real sandbox before publishing
npx toolpal run ./ -i '{"text":"hello toolpal"}'

# 4. Validate against the registry without publishing, then publish
npx toolpal publish --dry-run
npx toolpal publish

Your scope is your username: everything you publish goes under @your-login/…, and only you can publish there. If you aren't signed in yet when running init, pass the full scoped name: npx toolpal init word-count --name @your-login/word-count.

Build & publish flags

Command / FlagEffect
toolpal build -v, --verbosePrint every individual static-analysis finding (file, line, snippet).
toolpal build -e, --env KEY=VALUEPass env vars while running declared examples (or -e KEY to forward from your shell). Only vars declared in permissions.env are passed.
toolpal build --no-examplesSkip executing declared examples during build (manifest keeps inputs only).
toolpal publish --dry-runBuild, pack, and run every registry validation check (manifest, static analysis, permissions, scope) without creating a version.
toolpal publish --no-buildPack and upload the existing dist/ directory as-is (useful after building with custom -e example env vars).
toolpal publish --privateCreate a new workflow as private (refused if the workflow already exists as public).
toolpal publish --publicExplicitly publish as public (the default for new workflows; refused if the workflow is private).
-C, --cwd <dir> · --registry <url>Global flags supported by all commands. You can also set TOOLPAL_TOKEN and TOOLPAL_REGISTRY in the environment.

What gets packed & versioned

  • Included in the tarball: manifest.json, dist/tool.mjs (unminified esbuild ESM bundle for inspectability and reproducible builds), package.json, everything under src/, root docs (README*, LICENSE*, CHANGELOG*), and your dependency lockfile (package-lock.json, pnpm-lock.yaml, yarn.lock, or bun.lock).
  • Excluded from the tarball: node_modules/, dotfiles, symlinks, and fixture folders outside src/ (such as examples/).
  • Automatic versioning: Every publish is assigned the next whole number by the registry (1.0, 2.0, 3.0, …). Versions are immutable and never reused, even after yanking.
  • README tip: Put a README.md at your project root to add narrative notes, caveats, or usage tips below your verified Examples card. A leading # @scope/name heading is stripped automatically so it isn't repeated.

Private workflows

A workflow is public unless you say otherwise. To keep one to yourself:

npx toolpal publish --private                            # a new workflow, created private
npx toolpal visibility @your-login/word-count private    # an existing workflow; "public" undoes it
  • Only you can see, add or install a private workflow. Signed in (toolpal login, or TOOLPAL_TOKEN set to one of your API tokens), it installs and runs like any other workflow, and toolpal mcp serves it.
  • Everyone else gets “not found” for it, exactly as for a name that doesn't exist. It is in no search or listing, and its pages, files and downloads are withheld.
  • It stays private. Visibility belongs to the workflow, so later versions need no flag. --private on a public workflow (or --public on a private one) refuses to publish rather than changing it.
  • Going private doesn't recall copies. People who already installed a public workflow keep running it from their machine, but their fresh installs fail.

On this site every workflow page says whether the workflow is public or private, next to its name. Your dashboard lists the visibility of each of your workflows, and your private ones also show on your profile and your scope page, where only you see them. To switch a workflow between private and public, open it and use the ⋯ menu. Toolpal's moderators can read a private workflow.

Publish from CI

Create a token in Settings → API tokens (or with toolpal token create --name ci). It acts for your account, except for sessions and admin pages, so keep it in your CI's secret store:

TOOLPAL_TOKEN=${{ secrets.TOOLPAL_TOKEN }} npx toolpal publish

# If examples need secrets or should be skipped in CI:
npx toolpal build --no-examples
TOOLPAL_TOKEN=${{ secrets.TOOLPAL_TOKEN }} npx toolpal publish --no-build

Permissions & limits

Each workflow page lists what the workflow may do. Toolpal derives these permissions from the bundle with static analysis and the registry re-runs the same analyzer on every upload — refusing any publish (HTTP 422) that uses a capability it didn't declare. Open a workflow's Permissions tab to inspect every finding linked to the exact line in dist/tool.mjs.

PermissionDetected fromHow it is enforced
net: truefetch, WebSocket, EventSource, XMLHttpRequest, http/https/http2/net/tls/dgram/dns/undici imports (literal hosts recorded for display)Native --allow-net on Node ≥25; best-effort JS guard on Node 22/24 when net is false.
env: ["KEY"]process.env.KEY reads and destructuring (computed reads trigger dynamic-code)Child process receives only declared env vars passed by the caller.
tmp: truenode:fs / node:fs/promises / node:sqlite imports, or any FilePath() schema fieldWrites allowed only inside a private per-process temp directory (--allow-fs-write).

Analysis badges

Badges appear on the workflow page and in toolpal add / toolpal info. They inform reviewers without blocking a publish:

  • dynamic-code: uses eval, new Function, computed import()/require(), or computed property access on process/globalThis.
  • blocked-apis: contains code paths referencing sandbox-denied modules (child_process, worker_threads, cluster, wasi, ffi, inspector, process.binding).
  • unused-permission: declares a permission in package.json that the analyzer did not see used.

Before updating a dependency, check the Versions tab: any version that adds a new permission is highlighted, and toolpal update prints added permissions in the terminal.

Package & runtime limits

LimitValue
Node.js version>= 22.15.0 (Node 25+ / 26 LTS recommended)
Bundle size (dist/tool.mjs)5 MB max
Packed tarball size / files10 MB max · 2,000 files max
Description length1,024 characters max
Input / output schema size64 KB max each
Declared examples5 max · 32 KB max per serialized example
Execution timeout (timeoutMs)100 ms – 300,000 ms (default 10,000 ms)
Memory limit (memoryMb)16 MB – 4,096 MB (default 128 MB)
Files per call (FilePath)64 files in / 64 files out · 1 GiB per file

MCP

npx toolpal login
claude mcp add --scope user toolpal -- npx -y toolpal mcp

# Or test a local build directly over MCP without publishing:
npx -y toolpal mcp ./my-workflow

For Claude Desktop, Cursor, Windsurf, Antigravity, or any MCP client configured with JSON, add toolpal to mcpServers (the -y flag prevents npx from stalling on an interactive install prompt):

{
  "mcpServers": {
    "toolpal": {
      "command": "npx",
      "args": ["-y", "toolpal", "mcp"]
    }
  }
}

toolpal mcp serves the workflows on your account: the ones you published (including private ones) and the ones you added with the Add button on a workflow page (or toolpal add --account @scope/name). Each becomes an MCP tool (@toolpal/github-repo is exposed as toolpal__github-repo), using the manifest's JSON Schemas. Workflows pinned in a project's toolpal.json are not served. To pass env vars to an account workflow, add an env mapping in ~/.toolpal/account/<registry>/toolpal.json.

Your own workflows follow their newest version on each server start. Workflows owned by others stay pinned at the version you added until you run toolpal update --account (or approve update_tool).

Built-in MCP management tools

MCP toolWhat it does
search_toolsSearches the public registry and returns each workflow's permissions and installed version.
install_toolPrompts for approval, adds a workflow to your account, and registers it on the running server immediately.
update_toolPrompts for approval (highlighting any newly added permissions) and updates an added workflow to its newest version.
publish_toolBuilds a single-file workflow written by the agent (importing only @toolpal/tool and Node built-ins), prompts for approval, publishes it under your scope (private by default), and registers it immediately.

Approval note: Clients that support MCP elicitation show a dedicated confirmation prompt listing the workflow and its permissions before installing, updating, or publishing. Clients that do not support elicitation rely on the client's own tool-call approval prompt (if auto-approve is enabled, nothing prompts).

Your account

Sign in with GitHub or Google, whichever Toolpal offers. It asks for your public profile and email address: the user:email scope from GitHub (no repository access), and openid profile email from Google. Only an address the provider has verified is used.

Or create an account with a username, an email address and a password. Toolpal emails a link to verify the address; after that you can sign in with the username or the email, and reset a forgotten password by email.

One email address belongs to one account. If you sign in with a provider whose email another account already has, sign in to that account instead and connect the provider in Settings → Sign-in methods. Change your address in Settings → Email; the old one keeps working until the new one is verified.

The first time you sign in, you choose a username. It is also your scope, the @name your workflows are published under, and it can't be changed later.

The CLI signs in through this site. toolpal login prints a link and a short code; open the link (or go to /cli and type the code), check that the code matches your terminal, and approve. The CLI then receives its own API token, which you can revoke in Settings → API tokens.

Maintain a workflow

Published versions are immutable and their version numbers are never reused. As a maintainer, you have two registry actions:

  • Yank a bad version: toolpal yank @scope/[email protected] --reason "broken output" (or from the Versions tab). New installs skip it and latest falls back to the previous live version; projects that already pinned it keep working. You can undo a yank from the Versions tab.
  • Deprecate a workflow: toolpal deprecate @scope/workflow "Use @scope/v2 instead" (pass --undo to clear it, or use the ⋯ menu). Installs keep working and print your message as a warning.

Auditing & reproducible builds

Run toolpal audit to check pinned workflows for yanked, quarantined, removed, or deprecated versions, and toolpal verify-build @scope/workflow to rebuild from src/ and confirm the bundle is byte-identical.

Moderation (quarantine & purge)

Moderators can apply two admin-only actions when responding to toolpal report abuse reports or legal takedowns:

  • Quarantined: withholds a malicious or abusive version (HTTP 410 on tarball downloads; clients and toolpal mcp refuse to install or run it even when pinned; toolpal audit exits non-zero). Source files stay visible on the Files tab for review, and admins can lift quarantine if resolved.
  • Purged (removed): permanent takedown that deletes the tarball and README bytes from storage while keeping a tombstone so that version number can never be reused. Files return HTTP 410 and toolpal audit reports removed.

CLI reference

CommandDescription
toolpal init [dir] [--name ...]Scaffold a new workflow project (package.json, src/index.ts, tsconfig.json, README.md).
toolpal build [dir] [-v] [-e K[=V]] [--no-examples]Bundle dist/tool.mjs, derive permissions, capture example outputs, and write dist/manifest.json.
toolpal analyze [path]Run static analysis on a project directory or .mjs bundle and list every finding.
toolpal publish [dir] [--dry-run] [--no-build] [--private|--public]Build, pack, and upload the next sequential version (1.0, 2.0, …) to the registry.
toolpal add <workflows...> [--account]Pin workflows in toolpal.json / toolpal.lock (or add to your account for MCP).
toolpal install [--frozen-lockfile]Install all workflows listed in toolpal.json; --frozen-lockfile fails on any lockfile drift.
toolpal update [workflow] [--account]Move pinned (or account) workflows to their newest version and print any added permissions.
toolpal remove <workflow> [--account]Remove a workflow from toolpal.json / toolpal.lock (or from your account).
toolpal run <workflow> [-i json] [-e K[=V]] [-t ms] [-o dir]Execute a pinned workflow or local build path and print its JSON output.
toolpal info <workflow> [--json]Inspect description, permissions, file fields, schemas, and examples.
toolpal list · toolpal search <q>List pinned workflows in toolpal.lock, or search the public registry.
toolpal mcp [workflows...]Start the stdio MCP server for your account's workflows (or only the workflows/paths given).
toolpal visibility · yank · deprecate · reportManage workflow visibility, yank versions, set deprecation notices, or report abuse.
toolpal login [--token ...] · logout · whoami · tokenAuthenticate with the registry and create, list, or revoke API tokens.
toolpal trust · verify · verify-build · audit · doctorPin signing keys, verify stored hashes and reproducible builds, audit lockfiles, and check Node CVE advisories.

Security model

Toolpal runs each workflow with Node's permission model and re-hashes dist/tool.mjs before loading it (serving those exact bytes through a module-loader hook so nothing else can be imported). That stops buggy and casually malicious code, but it is not a hard security boundary: a workflow that exploits a permission-model bypass or a V8 bug runs as your OS user. Read the source before you run a workflow (every file is on its Files tab), keep Node.js patched (toolpal doctor), prefer Node ≥25 for native network denial, and run agents as a low-privilege user.

A workflow with network access can reach any host, including localhost, internal addresses, and cloud metadata endpoints. The hosts shown on a workflow page are the ones seen statically in its code, not an allow-list.

The HTTP API is documented at https://api.toolpal.dev/docs.