@ax-llm/ax-tools 19.0.39 → 19.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# @ax-llm/ax-tools
|
|
2
|
+
|
|
3
|
+
Node.js-specific tools for the Ax LLM framework.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This package provides Node.js-specific functionality that cannot be included in
|
|
8
|
+
the main `@ax-llm/ax` package due to browser compatibility requirements. The
|
|
9
|
+
main package is designed to work in both Node.js and browser environments, while
|
|
10
|
+
this package provides Node.js-only features.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
### MCP Tools
|
|
15
|
+
|
|
16
|
+
#### AxMCPStdioTransport
|
|
17
|
+
|
|
18
|
+
A transport for the Model Context Protocol (MCP) that communicates with MCP
|
|
19
|
+
servers via stdin/stdout. This enables running local MCP servers as child
|
|
20
|
+
processes.
|
|
21
|
+
|
|
22
|
+
### Function Tools
|
|
23
|
+
|
|
24
|
+
`AxJSRuntime` has moved to `@ax-llm/ax`.
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @ax-llm/ax-tools
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Basic MCP Stdio Transport
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { AxMCPClient } from "@ax-llm/ax";
|
|
38
|
+
import { AxMCPStdioTransport } from "@ax-llm/ax-tools";
|
|
39
|
+
|
|
40
|
+
// Create a stdio transport for an MCP server
|
|
41
|
+
const transport = new AxMCPStdioTransport({
|
|
42
|
+
command: "npx",
|
|
43
|
+
args: ["-y", "@modelcontextprotocol/server-memory"],
|
|
44
|
+
env: process.env,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Create MCP client
|
|
48
|
+
const client = new AxMCPClient(transport, { debug: true });
|
|
49
|
+
await client.init();
|
|
50
|
+
|
|
51
|
+
// Use the client as a function provider
|
|
52
|
+
const functions = client.toFunction();
|
|
53
|
+
console.log(`Available functions: ${functions.map((f) => f.name).join(", ")}`);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### With Factory Function
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { axCreateMCPStdioTransport } from "@ax-llm/ax-tools";
|
|
60
|
+
|
|
61
|
+
const transport = axCreateMCPStdioTransport({
|
|
62
|
+
command: "uvx",
|
|
63
|
+
args: ["blender-mcp"],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### JavaScript Code Execution
|
|
68
|
+
|
|
69
|
+
Use `AxJSRuntime` from `@ax-llm/ax`:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { AxJSRuntime, AxJSRuntimePermission } from "@ax-llm/ax";
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Configuration Options
|
|
76
|
+
|
|
77
|
+
#### MCP Transport
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
interface StdioTransportConfig {
|
|
81
|
+
command: string; // The command to execute
|
|
82
|
+
args?: string[]; // Optional arguments
|
|
83
|
+
env?: NodeJS.ProcessEnv; // Optional environment variables
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### JS Interpreter Permissions
|
|
88
|
+
|
|
89
|
+
See `@ax-llm/ax` docs for `AxJSRuntimePermission`.
|
|
90
|
+
|
|
91
|
+
## Examples
|
|
92
|
+
|
|
93
|
+
### Memory Server
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { AxAgent, AxAI, AxMCPClient } from "@ax-llm/ax";
|
|
97
|
+
import { AxMCPStdioTransport } from "@ax-llm/ax-tools";
|
|
98
|
+
|
|
99
|
+
// Initialize MCP client with memory server
|
|
100
|
+
const transport = new AxMCPStdioTransport({
|
|
101
|
+
command: "npx",
|
|
102
|
+
args: ["-y", "@modelcontextprotocol/server-memory"],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const client = new AxMCPClient(transport, { debug: false });
|
|
106
|
+
await client.init();
|
|
107
|
+
|
|
108
|
+
// Create agent with memory capabilities
|
|
109
|
+
const agent = new AxAgent({
|
|
110
|
+
name: "MemoryAgent",
|
|
111
|
+
description: "An agent that can remember information",
|
|
112
|
+
signature: "userMessage -> response",
|
|
113
|
+
functions: [client],
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Use with AI
|
|
117
|
+
const ai = new AxAI({
|
|
118
|
+
name: "openai",
|
|
119
|
+
apiKey: process.env.OPENAI_APIKEY!,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const result = await agent.forward(ai, {
|
|
123
|
+
userMessage: "Remember that my favorite color is blue",
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Cleanup
|
|
128
|
+
|
|
129
|
+
Always clean up the transport when done:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Terminate the child process
|
|
133
|
+
await transport.terminate();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## API Reference
|
|
137
|
+
|
|
138
|
+
### AxMCPStdioTransport
|
|
139
|
+
|
|
140
|
+
#### Constructor
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
new AxMCPStdioTransport(config: StdioTransportConfig)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Methods
|
|
147
|
+
|
|
148
|
+
- `send(message: AxMCPJSONRPCRequest): Promise<AxMCPJSONRPCResponse>` - Send a
|
|
149
|
+
request
|
|
150
|
+
- `sendNotification(message: AxMCPJSONRPCNotification): Promise<void>` - Send a
|
|
151
|
+
notification
|
|
152
|
+
- `connect(): Promise<void>` - Connect (no-op for stdio)
|
|
153
|
+
- `terminate(): Promise<void>` - Terminate the child process
|
|
154
|
+
|
|
155
|
+
### axCreateMCPStdioTransport
|
|
156
|
+
|
|
157
|
+
Factory function to create a new transport instance:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
axCreateMCPStdioTransport(config: StdioTransportConfig): AxMCPStdioTransport
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ax-llm/ax-tools",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ax tools package",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"keywords": [],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ax-llm/ax": "19.0.
|
|
16
|
+
"@ax-llm/ax": "19.0.41"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"**/*"
|