agent-tool-hub 1.0.2 → 1.0.3
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 +17 -212
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,230 +1,35 @@
|
|
|
1
1
|
# Agent Tool Hub
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**One registry, many protocols** — discover and run tools from MCP, LangChain, n8n, ComfyUI, and SKILL through a single PTC runtime.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
### Protocols / Tool Types
|
|
8
|
-
|
|
9
|
-
| Type | How it’s discovered/connected | Typical use |
|
|
10
|
-
| --- | --- | --- |
|
|
11
|
-
| MCP | `mcp.json` (stdio or SSE/HTTP) | Remote tool servers / ecosystem tools |
|
|
12
|
-
| LangChain Tool | `index.js/.mjs` or `langchain/` directory | Local code tools |
|
|
13
|
-
| n8n Workflow | `workflow.json` | Automation workflows |
|
|
14
|
-
| SKILL (Anthropic) | `SKILL.md` (optional `handler.js/.mjs`) | Instructional skills / subflows |
|
|
15
|
-
| Core Tools (built-in) | `roots: coreTools` | Safe FS / HTTP / Utils |
|
|
16
|
-
|
|
17
|
-
### Core Capabilities
|
|
18
|
-
|
|
19
|
-
- Unified ToolSpec abstraction with JSON Schema
|
|
20
|
-
- PTC runtime: validation, policy gating, budgets/retries, evidence
|
|
21
|
-
- Multi-root discovery with namespaces and optional hot-reload
|
|
22
|
-
- Security baseline: sandbox paths, allowlists, SSRF protections
|
|
23
|
-
- Observability: events, metrics, tracing
|
|
24
|
-
- Async workflows for n8n
|
|
25
|
-
|
|
26
|
-
## Quick Start
|
|
27
|
-
|
|
28
|
-
### Install
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm i agent-tool-hub
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
- Node >= 18
|
|
35
|
-
- Optional peers: `@langchain/core`, `@modelcontextprotocol/sdk`
|
|
36
|
-
|
|
37
|
-
After install, the `agent-tool-hub` CLI is available (or run via `npx agent-tool-hub`):
|
|
5
|
+
## Install
|
|
38
6
|
|
|
39
7
|
```bash
|
|
40
|
-
agent-tool-hub
|
|
8
|
+
npm install agent-tool-hub
|
|
41
9
|
```
|
|
42
10
|
|
|
43
|
-
|
|
44
|
-
| --- | --- |
|
|
45
|
-
| `scan` | Scan configured tool roots and load tools into the hub. |
|
|
46
|
-
| `verify` | Scan and verify tools; exit code 1 if any discovery errors. |
|
|
47
|
-
| `list` | List discovered tools. Use `--detail short \| normal \| full` for output level. |
|
|
48
|
-
|
|
49
|
-
Options: `--config, -c <path>` (default: `./toolhub.yaml`), `--detail, -d <level>` (for `list`), `--help, -h`.
|
|
11
|
+
Node 18+ required.
|
|
50
12
|
|
|
51
|
-
|
|
13
|
+
## Use
|
|
52
14
|
|
|
53
|
-
|
|
15
|
+
**CLI** — add a `toolhub.yaml` in your project, then:
|
|
54
16
|
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
namespace: app
|
|
60
|
-
- path: coreTools
|
|
61
|
-
namespace: core
|
|
62
|
-
config:
|
|
63
|
-
sandboxRoot: /tmp/toolhub-sandbox
|
|
64
|
-
allowedHosts:
|
|
65
|
-
- api.github.com
|
|
66
|
-
- "*.example.com"
|
|
67
|
-
|
|
68
|
-
adapters:
|
|
69
|
-
n8n:
|
|
70
|
-
mode: api
|
|
71
|
-
api:
|
|
72
|
-
apiBaseUrl: http://localhost:5678
|
|
73
|
-
apiKey: ""
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Your framework can load this config and initialize Agent Tool Hub accordingly.
|
|
77
|
-
|
|
78
|
-
### Initialize from a config file path
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
import { createAgentToolHub } from "agent-tool-hub";
|
|
82
|
-
|
|
83
|
-
const hub = await createAgentToolHub("./toolhub.yaml");
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### List tools
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
const tools = hub.listToolMetadata();
|
|
90
|
-
// [{ name, description }, ...]
|
|
17
|
+
```bash
|
|
18
|
+
npx agent-tool-hub scan # load tools from configured roots
|
|
19
|
+
npx agent-tool-hub verify # scan and exit 1 on errors
|
|
20
|
+
npx agent-tool-hub list # list discovered tools
|
|
91
21
|
```
|
|
92
22
|
|
|
93
|
-
|
|
23
|
+
**In code** — load from config, init, then invoke:
|
|
94
24
|
|
|
95
25
|
```ts
|
|
96
|
-
|
|
97
|
-
"core/http.fetchJson",
|
|
98
|
-
{ url: "https://api.github.com" },
|
|
99
|
-
{
|
|
100
|
-
permissions: ["network", "read:web"],
|
|
101
|
-
budget: { timeoutMs: 10_000, maxRetries: 1 },
|
|
102
|
-
},
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
if (!result.ok) {
|
|
106
|
-
console.error(result.error);
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Tool Discovery Rules
|
|
111
|
-
|
|
112
|
-
- All subdirectories under each `roots` entry are scanned.
|
|
113
|
-
- Tool kind is inferred by marker files:
|
|
114
|
-
`SKILL.md` / `workflow.json` / `mcp.json` / `index.js(.mjs)`
|
|
115
|
-
- Avoid mixing multiple marker files in the same folder.
|
|
116
|
-
|
|
117
|
-
Example structure:
|
|
118
|
-
|
|
119
|
-
```
|
|
120
|
-
tools/
|
|
121
|
-
weather/
|
|
122
|
-
mcp.json
|
|
123
|
-
notify/
|
|
124
|
-
workflow.json
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Add a New Tool (Recommended)
|
|
128
|
-
|
|
129
|
-
### 1) Create a tool folder
|
|
130
|
-
|
|
131
|
-
```
|
|
132
|
-
./tools/my-tool/
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### 2) Add the tool implementation by kind
|
|
136
|
-
|
|
137
|
-
#### MCP tool
|
|
138
|
-
|
|
139
|
-
Add `mcp.json`:
|
|
140
|
-
|
|
141
|
-
```json
|
|
142
|
-
{ "command": "npx", "args": ["-y", "your-mcp-server"] }
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
or remote:
|
|
146
|
-
|
|
147
|
-
```json
|
|
148
|
-
{ "url": "https://mcp.example.com" }
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
#### LangChain tool
|
|
152
|
-
|
|
153
|
-
Create `index.js/.mjs` that implements LangChain's interface (e.g., `StructuredTool`):
|
|
154
|
-
|
|
155
|
-
```js
|
|
156
|
-
import { StructuredTool } from "@langchain/core/tools";
|
|
157
|
-
import { z } from "zod";
|
|
158
|
-
|
|
159
|
-
class CalculatorTool extends StructuredTool {
|
|
160
|
-
name = "calculator";
|
|
161
|
-
description = "Evaluates simple arithmetic expressions";
|
|
26
|
+
import { createToolHubAndInitFromConfig } from "agent-tool-hub";
|
|
162
27
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
async _call({ expression }) {
|
|
168
|
-
const sanitized = expression.replace(/[^0-9+\\-*/().% ]/g, "");
|
|
169
|
-
if (sanitized !== expression) {
|
|
170
|
-
throw new Error("Invalid characters in expression");
|
|
171
|
-
}
|
|
172
|
-
const result = Function(`\"use strict\"; return (${sanitized})`)();
|
|
173
|
-
return String(result);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export default new CalculatorTool();
|
|
28
|
+
const hub = await createToolHubAndInitFromConfig("toolhub.yaml");
|
|
29
|
+
const result = await hub.invokeTool("utils.calculator", { expression: "1 + 2" });
|
|
30
|
+
// result.ok, result.data, result.error, etc.
|
|
178
31
|
```
|
|
179
32
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
Add `workflow.json` with a `nodes` array:
|
|
183
|
-
|
|
184
|
-
```json
|
|
185
|
-
{ "id": "wf-123", "name": "send-slack", "nodes": [] }
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
- Set `adapters.n8n.mode: api | local` in `toolhub.yaml`.
|
|
189
|
-
- Local mode auto-imports/syncs workflows.
|
|
190
|
-
|
|
191
|
-
#### SKILL
|
|
192
|
-
|
|
193
|
-
Add `SKILL.md` (Anthropic Skills format):
|
|
194
|
-
|
|
195
|
-
```md
|
|
196
|
-
---
|
|
197
|
-
name: send-email
|
|
198
|
-
description: Sends a confirmation email when user completes checkout.
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
Instructions go here.
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Optional `handler.js/.mjs` can provide executable logic.
|
|
205
|
-
|
|
206
|
-
## Core Tools (Built-in)
|
|
207
|
-
|
|
208
|
-
- FS: `core/fs.readText`, `core/fs.writeText`, `core/fs.listDir`, `core/fs.searchText`, `core/fs.sha256`, `core/fs.deletePath`
|
|
209
|
-
- HTTP: `core/http.fetchText`, `core/http.fetchJson`, `core/http.downloadFile`, `core/http.head`
|
|
210
|
-
- Utils: `core/util.jsonSelect`, `core/util.truncate`, `core/util.hashText`, `core/util.now`, `core/util.templateRender`
|
|
211
|
-
|
|
212
|
-
Enable via `roots` entry `coreTools` and provide `sandboxRoot` + `allowedHosts`.
|
|
213
|
-
|
|
214
|
-
## Permissions and Capabilities
|
|
215
|
-
|
|
216
|
-
Common capabilities:
|
|
217
|
-
|
|
218
|
-
- `read:web`, `network`
|
|
219
|
-
- `read:fs`, `write:fs`
|
|
220
|
-
- `read:db`, `write:db`
|
|
221
|
-
- `workflow`, `gpu`
|
|
222
|
-
- `danger:destructive`
|
|
223
|
-
|
|
224
|
-
Pass `permissions` when invoking tools to satisfy policy gates.
|
|
225
|
-
|
|
226
|
-
## Publishing (maintainers)
|
|
227
|
-
|
|
228
|
-
Releases are automated via GitHub Actions (`.github/workflows/release.yml`). On push to `master`, tests and build run, then [semantic-release](https://github.com/semantic-release/semantic-release) publishes to npm (patch-only).
|
|
33
|
+
Or build the hub yourself: `createToolHub(options)` → `await hub.initAllTools()`; run tools with `hub.invokeTool(name, args, options)`.
|
|
229
34
|
|
|
230
|
-
|
|
35
|
+
See `toolhub.yaml` for config and `examples/` for tool layouts.
|
package/package.json
CHANGED