@agentskit/tools

中文文档
0.13.16发布于 2026/10/24MITTypeScriptESM + CJS构建来源已验证近 30 天下载 5790

Reusable executable tools for AgentsKit agents.

原始使用文档
文档目录20 节
  1. Verified proof
  2. How this fits the ecosystem
  3. Why tools
  4. Install
  5. Quick example
  6. With useChat (browser)
  7. Authoring tools with defineZodTool
  8. Features
  9. Built-ins (6)
  10. Safe outbound requests
  11. Integrations (20+)
  12. Authoring + composition
  13. MCP bridge
  14. Subpaths
  15. Ecosystem
  16. Contributors
  17. License
  18. Docs
  19. Maturity and compatibility
  20. Contributing

@agentskit/tools

Profile: major-package

AgentsKit

Give your agents real-world capabilities without writing a single integration.

npm version npm downloads bundle size license stability GitHub stars

Tags: ai · agents · llm · agentskit · ai-agents · function-calling · tool-use · mcp · web-search · filesystem

Verified proof

How this fits the ecosystem

@agentskit/tools gives agents useful hands: web fetch, search, filesystem, shell, SQLite, integrations, and MCP-friendly tool definitions.

  • AgentsKit: compose it with the other packages in this repo to build agents from small, swappable parts.
  • Registry: look for ready agents and templates that already use this layer at registry.agentskit.io.
  • Playbook: learn the production patterns behind this layer at playbook.agentskit.io.

Docs: package guide · agent handoff

Why tools

  • Save days of integration work — web search, filesystem read/write, shell execution, and directory listing are ready to drop in; no wiring required
  • Safe by default — filesystem tools are sandboxed to a basePath, shell commands require an explicit allowlist, so agents can't escape their boundaries
  • Composable with any runtime — tools are just objects with a schema; they work with @agentskit/runtime, useChat, or any custom ReAct loop
  • Extend without friction — author custom tools with @agentskit/templates and register them the same way as built-ins

Install

npm install @agentskit/tools

Quick example

import { createRuntime } from '@agentskit/runtime'
import { openai } from '@agentskit/adapters'
import { webSearch, filesystem, shell } from '@agentskit/tools'

const runtime = createRuntime({
  adapter: openai({ apiKey: process.env.OPENAI_API_KEY, model: 'gpt-4o' }),
  tools: [
    webSearch(),
    ...filesystem({ basePath: './workspace' }),
    shell({ timeout: 10_000, allowed: ['ls', 'cat', 'grep'] }),
  ],
})

const result = await runtime.run('Find the README and summarize it')
console.log(result.content)

With useChat (browser)

Tools are plain ToolDefinition values — register them in useChat the same way as in createRuntime.

Authoring tools with defineZodTool

If you use Zod, @agentskit/tools ships defineZodTool — a factory that:

  • Types execute args from a Zod schema (full TypeScript inference)
  • Validates args at runtime via schema.parse before calling your function
  • Converts the Zod schema to JSON Schema for the adapter via a user-supplied toJsonSchema callback

Zod and zod-to-json-schema are consumer-owned optional dependencies. They are not package peers because defineZodTool accepts a structural schema and a consumer-supplied JSON-Schema converter.

npm install zod zod-to-json-schema
import { z } from 'zod'
import { zodToJsonSchema } from 'zod-to-json-schema'
import { defineZodTool } from '@agentskit/tools'
import type { JSONSchema7 } from 'json-schema'

const lookupUser = defineZodTool({
  name: 'lookup_user',
  description: 'Look up a user by ID.',
  schema: z.object({
    userId: z.string().uuid(),
    includeProfile: z.boolean().optional(),
  }),
  toJsonSchema: (s) => zodToJsonSchema(s) as JSONSchema7,
  async execute(args) {
    // args.userId         → string  (UUID-validated by Zod at runtime)
    // args.includeProfile → boolean | undefined
    return await db.users.findById(args.userId, { profile: args.includeProfile })
  },
})

For tools without Zod, use defineTool from @agentskit/core with a JSON Schema as const.

Features

Built-ins (6)

  • webSearch() — live web search with Serper, Tavily, DuckDuckGo, or a custom provider.
  • fetchUrl() — safe HTTP GET with JSON / text handling, size cap, boilerplate stripping.
  • filesystem({ basePath }) — sandboxed read, write, and list operations.
  • shell({ allowed }) — shell execution with command allow-list + timeout.
  • sqliteQueryTool({ path }) — read-only SQL against a local SQLite file. Optional peer dep on better-sqlite3. Note: never feed unvalidated user prompts straight into the sql field — wrap with input filtering or use parameterized helpers if exposing it to untrusted input.
  • slackTool({ webhookUrl }) — post to a Slack Incoming Webhook. For Bearer-token features (search, channel listing), use the slack() integration.

Safe outbound requests

safeFetch(input, init?, policy?) defaults to denying non-public hosts and re-checks every redirect hop. Address classification comes from @agentskit/net, so reserved, unspecified, multicast, CGNAT, IPv4-mapped private, and other non-unicast ranges are blocked as well as private, loopback, and link-local addresses. Hostname checks use Node DNS and fail closed if any result is non-public or lookup fails.

isPrivateIPv4 and isPrivateHost keep their legacy decimal handling for zero-padded dotted quads (010.0.0.1 means 10.0.0.1). safeFetch first applies WHATWG URL canonicalization; avoid ambiguous numeric URL forms.

For a vetted internal target, pass an exact allowedHosts entry or set allowPrivateHosts: true; redirects still pass through the selected policy. The DNS preflight does not pin the resolved address to the later connection, so it does not prevent DNS rebinding. webSearch() also reads provider responses through @agentskit/net with a 2 MiB default byte limit; set maxResponseBytes to change it.

Integrations (20+)

github, linear, slack, notion, discord, gmail, googleCalendar, stripe, postgres, s3, firecrawl, reader, documentParsers (PDF / DOCX / XLSX), openaiImages, elevenlabs, whisper, deepgram, maps, weather, coingecko, browserAgent (Puppeteer). Each integration exports granular sub-tools (e.g. githubCreateIssue, stripeCreatePaymentIntent) alongside the bundled set.

Authoring + composition

  • defineZodTool — Zod-based factory with runtime validation + type inference.
  • For composition, use composeTool and wrapToolWithSelfDebug from @agentskit/core.
  • For execution policy, use createMandatorySandbox from @agentskit/sandbox.

MCP bridge

  • createMcpClient + toolsFromMcpClient — consume any MCP server's tools.
  • createMcpServer — publish AgentsKit tools to an MCP host that supports the documented 2024-11-05 tools bridge. Tools marked requiresConfirmation fail closed unless authorizeToolCall returns an explicit approval. Pass validateArgs (for example, createAjvValidator()) to enforce advertised schemas before execution; remote errors are sanitized unless exposeErrors: true is explicitly enabled for trusted development.
  • Stdio + in-memory transports. HTTP/SSE adapters are host-owned.

McpToolDefinition (from @agentskit/tools/mcp) extends the core tool shape with optional title and annotations: title, readOnlyHint, destructiveHint, idempotentHint, and openWorldHint. Server listing and client import preserve these fields, including explicit false hints. Imported titles use the existing maxDescriptionBytes UTF-8 limit; malformed metadata is rejected. Hints remain untrusted advisory data and never grant confirmation or alter execution policy.

These fields follow the MCP tool metadata specification. They are optional descriptor extensions on the existing 2024-11-05 bridge; older clients may ignore unknown fields. This does not add negotiation or other features from newer protocol revisions.

Supported MCP protocol matrix

Protocol revisionLifecycleSupported transportsSupported methodsExplicitly outside this bridge
2024-11-05initialize with exact-version negotiation; tools/list and tools/call; close settles pending callsstdio, in-memory, or an injected transportinitialize, tools/list, tools/callresources, prompts, sampling, tasks, HTTP/WebSocket, authentication, rate limiting, and persistence

The client and server fail closed when initialize.params.protocolVersion is not 2024-11-05. Hosts that need an omitted capability must provide it around the injected transport; the bridge does not imply support or isolation that it does not implement.

All tools honor the ToolDefinition contract (ADR 0002) — parallel tool calling works with any adapter, @agentskit/runtime, useChat, or a custom loop.

Subpaths

SubpathContents
@agentskit/tools/mcpcreateMcpClient, createMcpServer, toolsFromMcpClient, stdio + in-memory transports. MCP bridge recipe.
@agentskit/tools/integrationsgithub, linear, slack, notion, discord, gmail, googleCalendar, stripe, postgres, s3, firecrawl, reader, documentParsers, openaiImages, elevenlabs, whisper, deepgram, maps, weather, coingecko, browserAgent. Integrations recipe + More integrations.
@agentskit/tools/mcp-devtoolsRuntime inspection tools for an injected RuntimeInspector; expose through @agentskit/tools/mcp.
@agentskit/tools/validationOptional Ajv-backed ArgsValidator for core and MCP argument enforcement.

Ecosystem

PackageRole
@agentskit/coreToolDefinition contract
@agentskit/runtimecreateRuntime({ tools })
@agentskit/reactuseChat + tools in the UI
@agentskit/templatesScaffold new tools

Contributors

AgentsKit contributors

License

MIT — see LICENSE.

Docs

Full documentation · GitHub

Maturity and compatibility

  • Stability: beta — see docs/STABILITY.md
  • Node.js 20+ and TypeScript strict mode
  • Published as @agentskit/tools

Contributing

See CONTRIBUTING.md and the monorepo LICENSE.

版本与发布记录

@agentskit/tools 共发布 48 个版本,首次发布于 2026/04/06;过去 12 个月发布了 48 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.13.16latest2026/10/2412 天前
0.13.152026/10/1026 天前
0.13.142026/10/031 个月前
0.13.132026/10/031 个月前
0.13.122026/09/291 个月前
0.13.112026/09/281 个月前

关于 @agentskit/tools 的常见问题

@agentskit/tools 是什么?

Reusable executable tools for AgentsKit agents.

如何安装 @agentskit/tools?

在项目目录运行 npm install @agentskit/tools,或使用 pnpm add / yarn add / bun add。

@agentskit/tools 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentskit/tools 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@agentskit/tools 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@agentskit/tools 可以商用吗?

@agentskit/tools 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agentskit/tools 的下载量有多少?

根据 npm 官方下载统计,@agentskit/tools 在 2026/10/05 – 2026/11/03 这 30 天内被下载 5,790 次,日均约 193 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentskit/tools 还在维护吗?

最新版本 0.13.16 发布于 2026/10/24(12 天前);至今共发布 48 个版本,其中过去 12 个月发布了 48 个;首次发布于 2026/04/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。