@ax-llm/ax-tools

中文文档
25.4.9发布于 2026/11/07Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 3684

Ax tools package

原始使用文档
文档目录18 节
  1. Overview
  2. Features
  3. MCP Tools
  4. Persistent event runtime store
  5. Function Tools
  6. Installation
  7. Usage
  8. Basic MCP Stdio Transport
  9. With Factory Function
  10. JavaScript Code Execution
  11. Configuration Options
  12. Examples
  13. Memory Server
  14. Cleanup
  15. API Reference
  16. AxMCPStdioTransport
  17. axCreateMCPStdioTransport
  18. License

@ax-llm/ax-tools

Node.js-specific tools for the Ax LLM framework.

Overview

This package provides Node.js-specific functionality that cannot be included in the main @ax-llm/ax package due to browser compatibility requirements. The main package is designed to work in both Node.js and browser environments, while this package provides Node.js-only features.

Features

MCP Tools

AxMCPStdioTransport

A transport for the Model Context Protocol (MCP) that communicates with MCP servers via stdin/stdout. This enables running local MCP servers as child processes.

Persistent event runtime store

@ax-llm/ax-tools/event/sqlite exports AxSQLiteEventStore and AX_SQLITE_EVENT_STANDARD_RETENTION. It supports cooperating Node processes that share a local SQLite file. It is not intended for network filesystems.

Function Tools

AxJSRuntime has moved to @ax-llm/ax.

Installation

npm install @ax-llm/ax-tools

Usage

Basic MCP Stdio Transport

import { ax, AxMCPClient } from "@ax-llm/ax";
import { AxMCPStdioTransport } from "@ax-llm/ax-tools";

// Create a stdio transport for an MCP server
const transport = new AxMCPStdioTransport({
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-memory"],
  env: process.env,
});

// Create MCP client
const client = new AxMCPClient(transport, { debug: true });
await client.init();

// Attach the live client natively to AxGen, AxAgent, or AxFlow.
const program = ax('question:string -> answer:string', { mcp: client });

With Factory Function

import { axCreateMCPStdioTransport } from "@ax-llm/ax-tools";

const transport = axCreateMCPStdioTransport({
  command: "uvx",
  args: ["blender-mcp"],
});

JavaScript Code Execution

Use AxJSRuntime from @ax-llm/ax:

import { ai, AxJSRuntime, AxJSRuntimePermission } from "@ax-llm/ax";

Configuration Options

MCP Transport

interface StdioTransportConfig {
  command: string; // The command to execute
  args?: string[]; // Optional arguments
  env?: NodeJS.ProcessEnv; // Optional environment variables
}

JS Interpreter Permissions

See @ax-llm/ax docs for AxJSRuntimePermission.

Examples

Memory Server

import { ai, AxAgent, AxMCPClient } from "@ax-llm/ax";
import { AxMCPStdioTransport } from "@ax-llm/ax-tools";

// Initialize MCP client with memory server
const transport = new AxMCPStdioTransport({
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-memory"],
});

const client = new AxMCPClient(transport, { debug: false });
await client.init();

// Create agent with memory capabilities
const agent = new AxAgent({
  name: "MemoryAgent",
  description: "An agent that can remember information",
  signature: "userMessage -> response",
  functions: [client],
});

// Use with AI
const ai = ai({
  name: "openai",
  apiKey: process.env.OPENAI_APIKEY!,
});

const result = await agent.forward(ai, {
  userMessage: "Remember that my favorite color is blue",
});

Cleanup

Always clean up the transport when done:

// Terminate the child process
await transport.terminate();

API Reference

AxMCPStdioTransport

Constructor

new AxMCPStdioTransport(config: StdioTransportConfig)

Methods

  • send(message: AxMCPJSONRPCRequest): Promise<AxMCPJSONRPCResponse> - Send a request
  • sendNotification(message: AxMCPJSONRPCNotification): Promise<void> - Send a notification
  • connect(): Promise<void> - Connect (no-op for stdio)
  • terminate(): Promise<void> - Terminate the child process

axCreateMCPStdioTransport

Factory function to create a new transport instance:

axCreateMCPStdioTransport(config: StdioTransportConfig): AxMCPStdioTransport

License

Apache-2.0

版本与发布记录

@ax-llm/ax-tools 共发布 269 个版本,首次发布于 2025/07/15;过去 12 个月发布了 217 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
25.4.9latest2026/11/071 天前
25.4.82026/11/034 天前
25.4.72026/10/299 天前
25.4.62026/10/2612 天前
25.4.52026/10/2117 天前
25.4.42026/10/2118 天前

关于 @ax-llm/ax-tools 的常见问题

@ax-llm/ax-tools 是什么?

Ax tools package

如何安装 @ax-llm/ax-tools?

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

@ax-llm/ax-tools 支持 TypeScript 吗?

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

@ax-llm/ax-tools 支持 ESM 还是 CommonJS?

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

@ax-llm/ax-tools 可以商用吗?

@ax-llm/ax-tools 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@ax-llm/ax-tools 的下载量有多少?

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

@ax-llm/ax-tools 还在维护吗?

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