@sudohackin/toolring-mcp 0.0.0-stage → 0.10.0
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/AGENT-INSTRUCTIONS.ru.md +136 -0
- package/LICENSE +21 -0
- package/README.md +1144 -2
- package/RUN-BASH.ru.md +34 -0
- package/TOOL-STDOUT.md +50 -0
- package/bin/toolring.js +2 -0
- package/dist/argv-policy.d.ts +493 -0
- package/dist/argv-policy.js +211 -0
- package/dist/argv-policy.js.map +1 -0
- package/dist/bash-process.d.ts +3 -0
- package/dist/bash-process.js +98 -0
- package/dist/bash-process.js.map +1 -0
- package/dist/bash-when.d.ts +44 -0
- package/dist/bash-when.js +119 -0
- package/dist/bash-when.js.map +1 -0
- package/dist/call-policy.d.ts +20 -0
- package/dist/call-policy.js +74 -0
- package/dist/call-policy.js.map +1 -0
- package/dist/call.d.ts +107 -0
- package/dist/call.js +90 -0
- package/dist/call.js.map +1 -0
- package/dist/catalog.d.ts +30 -0
- package/dist/catalog.js +34 -0
- package/dist/catalog.js.map +1 -0
- package/dist/command-plan.d.ts +34 -0
- package/dist/command-plan.js +229 -0
- package/dist/command-plan.js.map +1 -0
- package/dist/config.d.ts +4559 -0
- package/dist/config.js +459 -0
- package/dist/config.js.map +1 -0
- package/dist/connections.d.ts +17 -0
- package/dist/connections.js +87 -0
- package/dist/connections.js.map +1 -0
- package/dist/default-tools.yaml +15 -0
- package/dist/executor.d.ts +39 -0
- package/dist/executor.js +166 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +288 -0
- package/dist/index.js.map +1 -0
- package/dist/module-contract.d.ts +98 -0
- package/dist/module-contract.js +4 -0
- package/dist/module-contract.js.map +1 -0
- package/dist/modules/json.d.ts +14 -0
- package/dist/modules/json.js +14 -0
- package/dist/modules/json.js.map +1 -0
- package/dist/modules/text.d.ts +14 -0
- package/dist/modules/text.js +14 -0
- package/dist/modules/text.js.map +1 -0
- package/dist/modules.d.ts +17 -0
- package/dist/modules.js +113 -0
- package/dist/modules.js.map +1 -0
- package/dist/pipeline-io.d.ts +15 -0
- package/dist/pipeline-io.js +112 -0
- package/dist/pipeline-io.js.map +1 -0
- package/dist/pipeline-parser.d.ts +8 -0
- package/dist/pipeline-parser.js +111 -0
- package/dist/pipeline-parser.js.map +1 -0
- package/dist/pipeline.d.ts +32 -0
- package/dist/pipeline.js +409 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/schema.d.ts +38 -0
- package/dist/schema.js +113 -0
- package/dist/schema.js.map +1 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.js +447 -0
- package/dist/server.js.map +1 -0
- package/dist/stdout-protocol.d.ts +4 -0
- package/dist/stdout-protocol.js +21 -0
- package/dist/stdout-protocol.js.map +1 -0
- package/dist/tool-stream.d.ts +6 -0
- package/dist/tool-stream.js +30 -0
- package/dist/tool-stream.js.map +1 -0
- package/docs/bash-policy.ru.md +211 -0
- package/package.json +68 -4
- package/skills/toolring/SKILL.md +22 -0
- package/skills/toolring-authoring/SKILL.md +63 -0
package/README.md
CHANGED
|
@@ -1,3 +1,1145 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Toolring
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/sudoHackIn/toolring/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
**One ring to scope them all.** Choose which CLI commands and Node.js handlers your agent can call over MCP, and which commands it can compose in Bash pipelines.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
tools:
|
|
11
|
+
- name: probe
|
|
12
|
+
description: Probe a media file, return JSON metadata
|
|
13
|
+
command: ffprobe
|
|
14
|
+
args: ["-print_format", "json", "-show_format"]
|
|
15
|
+
params:
|
|
16
|
+
- name: input
|
|
17
|
+
positional: true
|
|
18
|
+
type: string
|
|
19
|
+
required: true
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @sudohackin/toolring-mcp serve ./ffmpeg.yaml
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
That's it — your agent now has a `ffmpeg_probe` tool it can call with a
|
|
27
|
+
typed, validated `input` parameter.
|
|
28
|
+
|
|
29
|
+
## Why
|
|
30
|
+
|
|
31
|
+
Agents are only as useful as the tools you give them. There are thousands of
|
|
32
|
+
battle-tested CLIs (`ffmpeg`, `kubectl`, `pdftk`, `imagemagick`, `git`) that
|
|
33
|
+
agents cannot reach, and wrapping each one by hand means writing a full MCP
|
|
34
|
+
server every time. **toolring makes the wrapper a config file instead of a
|
|
35
|
+
project.**
|
|
36
|
+
|
|
37
|
+
The YAML selects the tools clients can call through this MCP server.
|
|
38
|
+
|
|
39
|
+
The server sends the [agent instructions (RU)](AGENT-INSTRUCTIONS.ru.md) to MCP
|
|
40
|
+
clients during initialization, along with the active profile and external registry
|
|
41
|
+
paths when available. Clients with their own project-instructions mechanism can
|
|
42
|
+
also reference the copy shipped in the installed @sudohackin/toolring-mcp package.
|
|
43
|
+
|
|
44
|
+
Toolring builds on [config2mcp](https://github.com/linwanwanwa/config2mcp), distributed under the [MIT license](LICENSE).
|
|
45
|
+
|
|
46
|
+
## Migrating from config2mcp
|
|
47
|
+
|
|
48
|
+
Change the executable to `toolring` and update explicit management tool names from `config2mcp_*` to `toolring_*` in client settings and tool approval rules. Your profile's tool names and YAML syntax stay the same. Toolring reads `TOOLRING_CONFIG` and still recognizes `CONFIG2MCP_CONFIG` and the old default filenames. The bundled PostgreSQL profiles now reference `TOOLRING_POSTGRES_*` environment variables.
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
To build from source and link the CLI locally:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/sudoHackIn/toolring.git
|
|
56
|
+
cd toolring
|
|
57
|
+
pnpm install --frozen-lockfile
|
|
58
|
+
pnpm build
|
|
59
|
+
npm link
|
|
60
|
+
toolring --version
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To run or install the published package from npm:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Use directly (recommended)
|
|
67
|
+
npx @sudohackin/toolring-mcp serve ./my-tools.yaml
|
|
68
|
+
|
|
69
|
+
# Or install globally
|
|
70
|
+
npm install -g @sudohackin/toolring-mcp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Requires Node 18+.
|
|
74
|
+
|
|
75
|
+
Run `toolring --version` to print the installed version.
|
|
76
|
+
|
|
77
|
+
### Project skills for agents
|
|
78
|
+
|
|
79
|
+
Run `toolring skills` to list the bundled skill names, one per line.
|
|
80
|
+
|
|
81
|
+
| Export command | When to use the skill |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `toolring skill` | Call published MCP tools and compose Bash pipelines. |
|
|
84
|
+
| `toolring skill toolring-authoring` | Write YAML profiles and configure Bash and module call policies. |
|
|
85
|
+
|
|
86
|
+
For an agent that reads project skills from `.agents/skills`, install the
|
|
87
|
+
usage skill from the project root:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
mkdir -p .agents/skills/toolring
|
|
91
|
+
toolring skill > .agents/skills/toolring/SKILL.md
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
After upgrading Toolring, repeat the export to refresh the project's copy.
|
|
95
|
+
You can give the agent the same instruction for installation and updates:
|
|
96
|
+
|
|
97
|
+
> Run `toolring skills`. For each name it lists, run `toolring skill <name>`
|
|
98
|
+
> and save its stdout verbatim to `.agents/skills/<name>/SKILL.md` in this
|
|
99
|
+
> project. Create the directory if needed and replace each file only after
|
|
100
|
+
> its export succeeds.
|
|
101
|
+
|
|
102
|
+
## Quick start
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# 1. Describe your tool
|
|
106
|
+
cat > ./echo.yaml <<'EOF'
|
|
107
|
+
tools:
|
|
108
|
+
- name: shout
|
|
109
|
+
description: Print a message in upper case
|
|
110
|
+
command: tr
|
|
111
|
+
args: ["a-z", "A-Z"]
|
|
112
|
+
params:
|
|
113
|
+
- name: message
|
|
114
|
+
positional: true
|
|
115
|
+
type: string
|
|
116
|
+
required: true
|
|
117
|
+
EOF
|
|
118
|
+
|
|
119
|
+
# 2. Check what the agent will see
|
|
120
|
+
npx @sudohackin/toolring-mcp inspect ./echo.yaml
|
|
121
|
+
|
|
122
|
+
# 3. Validate
|
|
123
|
+
npx @sudohackin/toolring-mcp validate ./echo.yaml
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Select a project policy
|
|
127
|
+
|
|
128
|
+
Save a profile as `toolring.yaml` to use it with `validate`, `inspect`, `call`,
|
|
129
|
+
`serve`, or a bare `toolring` launch. Toolring starts in the current directory
|
|
130
|
+
and uses the first `toolring.yaml` it finds on the way up to the Git worktree
|
|
131
|
+
root, inclusive. A nested profile replaces the parent profile in its subtree.
|
|
132
|
+
Outside a Git worktree, discovery checks only the current directory.
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
toolring validate
|
|
136
|
+
toolring call status service=api
|
|
137
|
+
toolring -f ./my-folder/policy.yaml validate
|
|
138
|
+
toolring -f ./my-folder/policy.yaml call status service=api
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
An explicit file (`-f <file>` or the existing positional path) takes precedence
|
|
142
|
+
over `TOOLRING_CONFIG`, then `CONFIG2MCP_CONFIG`, then discovery. A bare server
|
|
143
|
+
launch also checks the legacy filenames in the current directory before using
|
|
144
|
+
the bundled profile. An unreadable or invalid selected file reports an error.
|
|
145
|
+
|
|
146
|
+
### Reload tools while the server is running
|
|
147
|
+
|
|
148
|
+
After saving the YAML, call the built-in MCP tool `toolring_reload` with
|
|
149
|
+
no arguments. It reads the file that the current server instance started
|
|
150
|
+
with and updates the tool list, schemas, and handlers on the existing MCP
|
|
151
|
+
connection. The server reads the file at startup and on demand.
|
|
152
|
+
|
|
153
|
+
The server sends `notifications/tools/list_changed` after applying changes.
|
|
154
|
+
Clients can also request the updated list with `tools/list`. Calls in progress
|
|
155
|
+
finish with the configuration they started with.
|
|
156
|
+
|
|
157
|
+
If reload returns an error, fix the YAML and call the tool again. The last
|
|
158
|
+
valid configuration stays active. Changes to connection settings or the
|
|
159
|
+
module paths used by those connections require a restart.
|
|
160
|
+
`toolring_reload`, `toolring_catalog`, and `toolring_call` are reserved tool names.
|
|
161
|
+
|
|
162
|
+
### Call a tool from the terminal
|
|
163
|
+
|
|
164
|
+
Use `inspect` to find the published tool name (including its prefix) and its parameters.
|
|
165
|
+
Then run `call` with the same profile. From a built checkout:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
node bin/toolring.js inspect examples/git.yaml
|
|
169
|
+
node bin/toolring.js call examples/git.yaml git_log repoPath=. count=3
|
|
170
|
+
node bin/toolring.js call examples/node.yaml status service=api details=true
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Published tools accept `--name value`, `--name=value`, declared short aliases, and the existing `name=value` form. Quote values with spaces. Put the global `-f <profile>` before the tool name. After the name, `-f` is a tool flag. Use `--` before tool flags that overlap other global options. The CLI uses the
|
|
174
|
+
declared parameter types, accepts `true` and `false` for booleans, and applies
|
|
175
|
+
the tool's defaults to omitted optional parameters. You can also pass a single
|
|
176
|
+
JSON object with typed values:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
node bin/toolring.js call examples/node.yaml status '{"service":"api","details":true}'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`call` runs one configured command, handler, module function, or sequence and exits.
|
|
183
|
+
It writes the result to stdout and diagnostics to stderr. A failed call exits
|
|
184
|
+
with a nonzero status. Use `--dry-run` to preview the call or `--registry <path>`
|
|
185
|
+
to load the same module registry used by `serve`.
|
|
186
|
+
|
|
187
|
+
When a Node.js handler returns an async iterable, `call` writes each chunk as
|
|
188
|
+
it arrives. For example, `toolring call jenkins_logs_tail | head -n 1` can
|
|
189
|
+
print the first line while the handler is still running. Strings are encoded
|
|
190
|
+
as UTF-8, byte arrays pass through unchanged, and the handler supplies its own
|
|
191
|
+
line endings. A slow reader throttles the producer. If a write detects a closed
|
|
192
|
+
pipe, Toolring aborts the handler's signal and ends the call successfully.
|
|
193
|
+
|
|
194
|
+
### One-prompt install (let your AI set it up)
|
|
195
|
+
|
|
196
|
+
Copy the block below, paste it to Claude / Cursor / DSH / any MCP-capable
|
|
197
|
+
agent, and it will set everything up for you — package, config, and client
|
|
198
|
+
registration. Just tell it which CLI tools you want to expose.
|
|
199
|
+
|
|
200
|
+
```text
|
|
201
|
+
Install the MCP server "toolring" for me. Steps:
|
|
202
|
+
1. Create a tools config file at ~/.toolring/tools.yaml that exposes these CLI tools: <list your commands here, e.g. ffmpeg for media conversion, git for repo status>
|
|
203
|
+
2. For each tool write: name (snake_case), a one-line description, the command, its args, and typed params (flag / positional / boolean with trueFlag).
|
|
204
|
+
3. Config format reference: https://github.com/sudoHackIn/toolring#config-reference — only commands declared in the YAML are reachable (allow-list), keep it read-only if unsure.
|
|
205
|
+
4. Validate with: npx -y @sudohackin/toolring-mcp validate ~/.toolring/tools.yaml
|
|
206
|
+
5. Register the server with your own MCP client config as:
|
|
207
|
+
npx -y @sudohackin/toolring-mcp serve ~/.toolring/tools.yaml
|
|
208
|
+
6. Tell me which tools got registered and how to test one.
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Connect to Claude Desktop
|
|
212
|
+
|
|
213
|
+
Add to `claude_desktop_config.json`:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"mcpServers": {
|
|
218
|
+
"my-cli-tools": {
|
|
219
|
+
"command": "npx",
|
|
220
|
+
"args": ["-y", "@sudohackin/toolring-mcp", "serve", "/absolute/path/to/echo.yaml"]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Works the same with any MCP client (Claude Code, Cursor, Windsurf, ...).
|
|
227
|
+
|
|
228
|
+
## Node.js handlers
|
|
229
|
+
|
|
230
|
+
Use `handler` in place of `command` to publish a local `.mjs` module. See
|
|
231
|
+
[examples/node.yaml](examples/node.yaml) and its [status handler](examples/tools/status.mjs).
|
|
232
|
+
Run the example from a Toolring checkout:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
pnpm install --frozen-lockfile
|
|
236
|
+
pnpm build
|
|
237
|
+
node dist/index.js serve examples/node.yaml
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Call `status` from your MCP client with `{"service":"api","details":true}`.
|
|
241
|
+
The handler's first argument is an object with the declared, validated
|
|
242
|
+
parameters. Optional parameters use their YAML defaults when omitted. Extra
|
|
243
|
+
parameters are rejected. The returned string or JSON-serializable value is
|
|
244
|
+
sent as MCP text. Load errors and thrown errors return an MCP tool error.
|
|
245
|
+
|
|
246
|
+
Relative handler paths resolve from the YAML file's directory. Node loads the
|
|
247
|
+
module on the first valid call and caches it for the life of the server. Install
|
|
248
|
+
any npm dependencies where Node can resolve them from the handler module.
|
|
249
|
+
Handlers share the server's working directory and environment. Use the global
|
|
250
|
+
`console` or stderr for logs and reserve stdout for MCP traffic.
|
|
251
|
+
YAML `env` and the command execution options apply to spawned commands only.
|
|
252
|
+
|
|
253
|
+
### Stream tool output
|
|
254
|
+
|
|
255
|
+
Node.js operations can return an async iterable to stream bytes into a Bash pipeline such as `jenkins_logs_tail | grep ERROR`. Independent MCP servers and clients can implement the optional stdout v1 extension for direct calls. [Handler API and wire protocol](TOOL-STDOUT.md)
|
|
256
|
+
|
|
257
|
+
### Report progress
|
|
258
|
+
|
|
259
|
+
Node.js handlers and named module functions receive `reportProgress` in their
|
|
260
|
+
second argument. A function bound to a connection receives the client in
|
|
261
|
+
that same context. TypeScript modules can import `ToolContext`,
|
|
262
|
+
`ConnectionContext`, and `ToolProgress` as types from `@sudohackin/toolring-mcp/module`.
|
|
263
|
+
Use the usual YAML tool definition. In the module, call `await reportProgress(...)`
|
|
264
|
+
at the points you want the caller to see, such as after each batch of records.
|
|
265
|
+
An ordinary `await` just waits for the underlying operation.
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
import { setTimeout as wait } from "node:timers/promises";
|
|
269
|
+
|
|
270
|
+
export default async function ({ service }, { reportProgress }) {
|
|
271
|
+
await reportProgress({ progress: 0, total: 2, message: "Starting" });
|
|
272
|
+
await wait(250);
|
|
273
|
+
await reportProgress({ progress: 1, total: 2, message: "Check complete" });
|
|
274
|
+
await wait(250);
|
|
275
|
+
return `${service}: ready`;
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Await each update and use increasing `progress` values across the whole tool
|
|
280
|
+
call, including across `steps`. `total` and `message` are optional.
|
|
281
|
+
|
|
282
|
+
The MCP client is the application that calls the tool on the agent's behalf.
|
|
283
|
+
It requests updates by including `_meta.progressToken` in its `tools/call`
|
|
284
|
+
request. Each `reportProgress` call then sends a standard `notifications/progress`
|
|
285
|
+
notification carrying that token, so the client can match updates to the right
|
|
286
|
+
call even when several tools run concurrently. If the client omits the token,
|
|
287
|
+
`reportProgress` resolves silently. In both cases, the handler's `return`
|
|
288
|
+
supplies the final tool result. [MCP progress](https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/progress)
|
|
289
|
+
|
|
290
|
+
The client decides how to display updates and whether they extend its timeout.
|
|
291
|
+
For example, with a connected TypeScript MCP SDK client, `onprogress` requests
|
|
292
|
+
updates and `resetTimeoutOnProgress` restarts the 60-second timer each time
|
|
293
|
+
one arrives. [MCP timeouts](https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle#timeouts)
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
const result = await client.callTool(
|
|
297
|
+
{ name: "status", arguments: { service: "api" } },
|
|
298
|
+
undefined,
|
|
299
|
+
{
|
|
300
|
+
onprogress: ({ progress, message }) => console.error(progress, message),
|
|
301
|
+
timeout: 60_000,
|
|
302
|
+
resetTimeoutOnProgress: true,
|
|
303
|
+
},
|
|
304
|
+
);
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Reusable modules
|
|
308
|
+
|
|
309
|
+
[Как добавить, собрать и подключить корпоративный модуль (RU)](docs/modules.ru.md)
|
|
310
|
+
|
|
311
|
+
For an end-to-end package example, see [Author an internal npm module](#author-an-internal-npm-module).
|
|
312
|
+
For an installable TypeScript module with seven Postgres MCP Pro operations, see the
|
|
313
|
+
[PostgreSQL module](modules/postgres/README.md).
|
|
314
|
+
For direct Kubernetes API access using an existing kubeconfig, see
|
|
315
|
+
[Kubernetes connections](modules/k8s/README.md).
|
|
316
|
+
|
|
317
|
+
Declare each custom alias under `modules`, then select a named export with
|
|
318
|
+
`call: alias.function`. The source can be a relative file, an absolute file, or
|
|
319
|
+
an installed npm package. Built-in modules are available directly by name.
|
|
320
|
+
|
|
321
|
+
```yaml
|
|
322
|
+
modules:
|
|
323
|
+
services: ./tools/status.mjs
|
|
324
|
+
reports: /opt/company/tools/reports.js
|
|
325
|
+
postgres: "@sudohackin/toolring-postgres"
|
|
326
|
+
|
|
327
|
+
tools:
|
|
328
|
+
- name: service_status
|
|
329
|
+
description: Read the status of a demo service
|
|
330
|
+
call: services.status
|
|
331
|
+
params:
|
|
332
|
+
- { name: service, enum: [api, worker], required: true }
|
|
333
|
+
|
|
334
|
+
- name: normalize_text
|
|
335
|
+
description: Trim and collapse whitespace in text
|
|
336
|
+
call: text.normalizeWhitespace
|
|
337
|
+
params:
|
|
338
|
+
- { name: text, required: true }
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
The module contract is a named JavaScript function export, such as
|
|
342
|
+
`export async function status({ service }) { /* … */ }`. Its first argument
|
|
343
|
+
contains the validated YAML parameters. It may return a string or a
|
|
344
|
+
JSON-serializable value, directly or through a promise. Module functions share
|
|
345
|
+
the handler execution behavior described above. Each `tools` entry supplies
|
|
346
|
+
its own MCP name, description, and params. The server publishes the functions
|
|
347
|
+
selected by those entries.
|
|
348
|
+
|
|
349
|
+
Relative paths resolve from the YAML file's directory. Use `./` for a file
|
|
350
|
+
in that directory. File sources support `.mjs`, `.js`, and `.cjs`. For a package,
|
|
351
|
+
install it in the profile project (for example, `pnpm add @sudohackin/toolring-postgres`)
|
|
352
|
+
or globally with `npm install -g @sudohackin/toolring-postgres`. Toolring looks
|
|
353
|
+
from the YAML directory first, then in the active npm installation's `npm root -g`.
|
|
354
|
+
Both locations use the package's ESM import entry point. If the project copy
|
|
355
|
+
exists but fails to load, Toolring reports its error.
|
|
356
|
+
The same aliases work in the CLI, MCP, and Bash pipelines.
|
|
357
|
+
|
|
358
|
+
For unbound tools,
|
|
359
|
+
`validate` and `inspect` check aliases and reference syntax. Their first live
|
|
360
|
+
call checks that the referenced export exists and is callable. For tools with
|
|
361
|
+
a connection, the schema and export are also checked during validation.
|
|
362
|
+
|
|
363
|
+
A named operation can use a connection provided by another module. For
|
|
364
|
+
example, `call: reports.check_db` with `connection: pg_read` loads
|
|
365
|
+
`check_db` from `reports` and passes the client for `pg_read` as
|
|
366
|
+
`ctx.connection`. If `connections.pg_read.module` is `postgresql`, that
|
|
367
|
+
module validates the settings and provides the client. Calls using the same
|
|
368
|
+
connection alias share the client. The operation must accept that client's type.
|
|
369
|
+
|
|
370
|
+
| Built-in function | Parameters | Result |
|
|
371
|
+
|---|---|---|
|
|
372
|
+
| `text.normalizeWhitespace` | `text` (string) | Text with trimmed edges and collapsed whitespace |
|
|
373
|
+
| `json.format` | `text` (JSON string) | Indented JSON text |
|
|
374
|
+
|
|
375
|
+
The aliases `text` and `json` are reserved. See [examples/modules.yaml](examples/modules.yaml)
|
|
376
|
+
for a runnable configuration with a local module and both built-ins.
|
|
377
|
+
|
|
378
|
+
### Discover modules from an MCP client
|
|
379
|
+
|
|
380
|
+
Call `toolring_catalog` with `{}` to list the available aliases. This reads
|
|
381
|
+
the active registry and YAML module aliases without running their loaders.
|
|
382
|
+
Call it again with an alias such as `{"module":"postgres"}` to inspect its
|
|
383
|
+
named function exports. This can import the chosen module and run its top-level
|
|
384
|
+
initialization. Discovery does not invoke its operations or call `connect`.
|
|
385
|
+
|
|
386
|
+
Each entry gives the YAML `call`, its directly published MCP names
|
|
387
|
+
(`publishedAs`), and any tools using it in a sequence (`usedInSteps`). The
|
|
388
|
+
response also lists configured connection names. To document an operation before
|
|
389
|
+
publication, export an optional `operationMetadata` object from the module entry
|
|
390
|
+
point. Key it by the exact function export name and give each entry a
|
|
391
|
+
`description`, optionally with YAML-style `params` and an `example` argument
|
|
392
|
+
object. TypeScript packages can generate this export during their own build using
|
|
393
|
+
[TSDoc and the catalog generator](packages/catalog-gen/README.md).
|
|
394
|
+
The catalog returns those fields alongside the operation. See the
|
|
395
|
+
[typed module example](docs/modules.ru.md). Use `tools/list` for the input
|
|
396
|
+
schema published by the active profile.
|
|
397
|
+
|
|
398
|
+
### Call a module function directly with `toolring_call`
|
|
399
|
+
|
|
400
|
+
Starting in **0.2.0**, an operator can enable direct calls to named function
|
|
401
|
+
exports from built-in modules, the shared registry and local YAML modules.
|
|
402
|
+
The default is off. Set the top-level YAML boolean `allow-unpublished-tools: true`
|
|
403
|
+
to register `toolring_call`, even when `tools: []`.
|
|
404
|
+
|
|
405
|
+
To try the Jenkins fixture from a built checkout, save this as
|
|
406
|
+
`examples/jenkins/discovery.yaml` and start
|
|
407
|
+
`node bin/toolring.js serve examples/jenkins/discovery.yaml` from your MCP client.
|
|
408
|
+
|
|
409
|
+
```yaml
|
|
410
|
+
allow-unpublished-tools: true
|
|
411
|
+
modules:
|
|
412
|
+
jenkins: ./jenkins.mjs
|
|
413
|
+
tools: []
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
Call `toolring_catalog` with `{"module":"jenkins"}` to find the export, then
|
|
417
|
+
send these parameters to MCP `tools/call`:
|
|
418
|
+
|
|
419
|
+
```json
|
|
420
|
+
{"name":"toolring_call","arguments":{"call":"jenkins.getJobInfo","args":{"job":"mobile/app"}}}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
| Argument | Value |
|
|
424
|
+
|---|---|
|
|
425
|
+
| `call` | Required. Exact `module.function` from the catalog. |
|
|
426
|
+
| `args` | JSON object passed to the function. Defaults to `{}`. |
|
|
427
|
+
| `connection` | For a bound function, a connection alias listed for that module in the active profile. |
|
|
428
|
+
|
|
429
|
+
The server awaits the function and returns its result in `content[0].text`.
|
|
430
|
+
Objects and arrays are rendered as JSON. A failed operation sets `isError: true`.
|
|
431
|
+
In the fixture, `property[0].parameterDefinitions` gives the branch default
|
|
432
|
+
(`main`), target choices (`android` or `ios`, default `android`), and the
|
|
433
|
+
boolean `runTests` (default `true`).
|
|
434
|
+
|
|
435
|
+
The [build profile](examples/jenkins/tools.yaml) uses these definitions for
|
|
436
|
+
`build_app`. To switch to it in the same session, copy its contents into the
|
|
437
|
+
active `discovery.yaml`, run `node bin/toolring.js validate examples/jenkins/discovery.yaml`,
|
|
438
|
+
then call `toolring_reload` with `{}`. The build profile omits the flag, so
|
|
439
|
+
`tools/list` now includes `build_app` and the server rejects further calls to
|
|
440
|
+
`toolring_call`. An explicit `false` has the same effect.
|
|
441
|
+
|
|
442
|
+
By default, direct calls can invoke any named function export with their own
|
|
443
|
+
arguments. To limit them, add a top-level `call-policy` to the server profile.
|
|
444
|
+
For example, with the PostgreSQL registry and connections from the
|
|
445
|
+
[guarded profile](modules/postgres/guarded.yaml):
|
|
446
|
+
|
|
447
|
+
```yaml
|
|
448
|
+
allow-unpublished-tools: true
|
|
449
|
+
call-policy:
|
|
450
|
+
default: deny
|
|
451
|
+
rules:
|
|
452
|
+
- call: postgres.describeTable
|
|
453
|
+
connection: pg_read
|
|
454
|
+
action: allow
|
|
455
|
+
allowed-args: [table]
|
|
456
|
+
when: { table: orders }
|
|
457
|
+
- call: postgres.execute_update
|
|
458
|
+
connection: pg_update
|
|
459
|
+
action: confirm
|
|
460
|
+
allowed-args: [sql]
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
In this example, a direct call to `postgres.describeTable` must supply exactly
|
|
464
|
+
`{"table":"orders"}` on `pg_read`. A different table, an extra argument, DDL,
|
|
465
|
+
general SQL and SQL files all receive a policy error. For an UPDATE, the MCP
|
|
466
|
+
client prompts with the connection and the complete SQL batch on every invocation.
|
|
467
|
+
|
|
468
|
+
- A rule names an exact `module.export` or all callable exports of one module with `module.*`, including future exports. Omitting `connection` matches all bindings, including an unbound call.
|
|
469
|
+
- An exact name takes precedence over `module.*` regardless of rule order. If any rules name that export, only those rules are considered. If none of them match the connection and arguments, the policy uses `default`.
|
|
470
|
+
- `allowed-args` lists the only argument names a matching call may supply. An empty list requires zero arguments. Omit the field to allow any keys.
|
|
471
|
+
- `when` requires each named argument to be present with the specified JSON value. Types, nested values and array order participate in equality. These arguments can be absent from every published tool schema.
|
|
472
|
+
- Matching rules take precedence in the order `deny`, `confirm`, `allow`. Unmatched calls use `default`. An empty policy defaults to `deny`. Use `call-policy: {default: confirm}` to prompt for every call through `toolring_call`.
|
|
473
|
+
|
|
474
|
+
The default scope is `toolring_call`. Both `default` and `rules` apply only
|
|
475
|
+
to the generic caller. You can publish the same operation as a named tool
|
|
476
|
+
with a narrower input schema, even when direct calls to it are denied.
|
|
477
|
+
|
|
478
|
+
With explicit `scope: all`, the server checks direct calls, published module
|
|
479
|
+
tools (including CLI calls) and every step in a sequence. Published tools apply schema defaults
|
|
480
|
+
first. A sequence prompts once with its ordered calls and shared arguments.
|
|
481
|
+
Approval applies only to that invocation. Declining, cancelling, using the
|
|
482
|
+
one-shot CLI or using an MCP client without form elicitation blocks execution
|
|
483
|
+
when confirmation is required. Dry runs skip the prompt and honor denials.
|
|
484
|
+
|
|
485
|
+
Use a server build that supports `call-policy`. Older builds can ignore unknown
|
|
486
|
+
YAML keys. The profile, registry, module code and MCP client are trusted.
|
|
487
|
+
Keep them under operator control when the agent has filesystem tools. The policy
|
|
488
|
+
covers named module dispatch. Shell commands and local handlers have their own
|
|
489
|
+
permissions.
|
|
490
|
+
|
|
491
|
+
### Optional shared registry
|
|
492
|
+
|
|
493
|
+
A separate npm package can supply modules for several profiles. Install the
|
|
494
|
+
registry package alongside `@sudohackin/toolring-mcp`, with the operation packages listed in
|
|
495
|
+
the registry package's `dependencies`. Include a file such as `registry.mjs`
|
|
496
|
+
in the registry package:
|
|
497
|
+
|
|
498
|
+
```js
|
|
499
|
+
export default {
|
|
500
|
+
jenkins: () => import("@company/jenkins-tools"),
|
|
501
|
+
postgres: () => import("@company/postgres-tools"),
|
|
502
|
+
};
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
Set `--registry` once in the MCP server's launch arguments:
|
|
506
|
+
|
|
507
|
+
```bash
|
|
508
|
+
npx @sudohackin/toolring-mcp serve ./profile.yaml --registry ./node_modules/@company/mcp-modules/registry.mjs
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
The profile can use `call: jenkins.buildStatus` directly in a tool entry with
|
|
512
|
+
its name, description, and params. The registry's default export maps
|
|
513
|
+
snake_case aliases to loader functions that resolve to modules with named
|
|
514
|
+
exports. Node resolves package imports from the registry's own location.
|
|
515
|
+
Aliases must be unique across the built-in modules, the shared registry, and
|
|
516
|
+
the profile's `modules` map.
|
|
517
|
+
|
|
518
|
+
`serve`, `call`, `validate`, and `inspect` accept `--registry`. A relative registry
|
|
519
|
+
path resolves from the current working directory. The registry file is trusted
|
|
520
|
+
JavaScript evaluated at startup. Put imports inside the registered loader
|
|
521
|
+
functions. The server loads modules when it needs to validate their connection
|
|
522
|
+
schemas or invoke their functions. `tools` selects which functions are published
|
|
523
|
+
through MCP.
|
|
524
|
+
|
|
525
|
+
Try the shared registry from a built checkout with
|
|
526
|
+
`node dist/index.js serve examples/preloaded.yaml --registry examples/registry.mjs`.
|
|
527
|
+
|
|
528
|
+
### Select modules for a profile
|
|
529
|
+
|
|
530
|
+
`enabled-modules` lists the built-in, registry, and YAML module aliases available
|
|
531
|
+
to the profile. An omitted list enables all registered and YAML aliases for
|
|
532
|
+
compatibility. An empty list disables every module. The catalog, published tools,
|
|
533
|
+
connections, direct calls and Bash stages all use this selection.
|
|
534
|
+
|
|
535
|
+
```yaml
|
|
536
|
+
enabled-modules: [text]
|
|
537
|
+
allow-unpublished-tools: true
|
|
538
|
+
call-policy:
|
|
539
|
+
default: deny
|
|
540
|
+
rules:
|
|
541
|
+
- { call: text.normalizeWhitespace, action: allow }
|
|
542
|
+
- { call: postgres.describeTable, action: allow }
|
|
543
|
+
tools: []
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
With this file saved as `toolring.yaml`, run
|
|
547
|
+
`toolring call text.normalizeWhitespace 'text= hello world '`. The result is
|
|
548
|
+
`hello world`. Running `toolring inspect` succeeds and prints a warning on stderr
|
|
549
|
+
for the dormant PostgreSQL rule. Enabling an unknown alias, or using a disabled
|
|
550
|
+
module in a published tool, sequence or connection, is a configuration error.
|
|
551
|
+
|
|
552
|
+
Direct CLI calls use the same `allow-unpublished-tools` switch and `call-policy`
|
|
553
|
+
as the MCP generic caller. Arguments written as `name=value` are strings. Pass
|
|
554
|
+
one quoted JSON object for typed values, and use `--connection <alias>` to select
|
|
555
|
+
a configured connection. To use the guarded PostgreSQL profile, install
|
|
556
|
+
`@sudohackin/toolring-postgres` in the project, copy its `guarded.yaml` to
|
|
557
|
+
`toolring.yaml`, and add the package under `modules`.
|
|
558
|
+
|
|
559
|
+
```yaml
|
|
560
|
+
modules:
|
|
561
|
+
postgres: "@sudohackin/toolring-postgres"
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
```bash
|
|
565
|
+
toolring call postgres.describeTable --connection pg_read table=orders
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
When a profile sets `enabled-modules` or enables unpublished tools, `run_bash`
|
|
569
|
+
reserves stage names of the form `module.function` for direct module calls.
|
|
570
|
+
An unavailable module stops the pipeline before any stage executes. To run an
|
|
571
|
+
external executable with a name of that form, publish it under a tool name.
|
|
572
|
+
|
|
573
|
+
### Configure a connection
|
|
574
|
+
|
|
575
|
+
An operation package can export a `connection` definition containing `schema`
|
|
576
|
+
and `connect(settings)`. The schema implements synchronous `safeParse`, as
|
|
577
|
+
Zod schemas do. It receives the settings under the connection alias, with
|
|
578
|
+
the `module` selector removed. `connect` receives the validated settings,
|
|
579
|
+
including any defaults applied by the schema. For TypeScript modules, import
|
|
580
|
+
`ConnectionDefinition<Settings, Client>` and `ConnectionContext<Client>` as
|
|
581
|
+
types from `@sudohackin/toolring-mcp/module`.
|
|
582
|
+
|
|
583
|
+
```yaml
|
|
584
|
+
connections:
|
|
585
|
+
jenkins_read:
|
|
586
|
+
module: jenkins
|
|
587
|
+
url: https://jenkins.company.example
|
|
588
|
+
tokenEnv: JENKINS_READ_TOKEN
|
|
589
|
+
|
|
590
|
+
tools:
|
|
591
|
+
- name: build_status
|
|
592
|
+
description: Read the latest build status
|
|
593
|
+
call: jenkins.buildStatus
|
|
594
|
+
connection: jenkins_read
|
|
595
|
+
params:
|
|
596
|
+
- { name: job, enum: [billing, catalog], required: true }
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Here the module's schema defines `url` and `tokenEnv`. The module can read the
|
|
600
|
+
named environment variable in `connect`. A bound function receives
|
|
601
|
+
`(params, { connection })`, where `connection` is the client returned by
|
|
602
|
+
`connect`. Only the declared `params` appear in the MCP input schema.
|
|
603
|
+
|
|
604
|
+
`validate`, `inspect`, and server startup load connection schemas and report
|
|
605
|
+
errors with paths such as `connections.jenkins_read.url`. Keep module imports
|
|
606
|
+
and schema validation free of service calls. The server creates a client on
|
|
607
|
+
the first live call that needs it and shares it across tools bound to the same
|
|
608
|
+
alias. If initialization fails, MCP reports the connection alias and a later
|
|
609
|
+
call can retry. Modules can write sanitized diagnostic details to stderr.
|
|
610
|
+
|
|
611
|
+
The [connection example](examples/connections.yaml) uses a [local fixture](examples/tools/demo-service.mjs).
|
|
612
|
+
Run it from a built checkout with
|
|
613
|
+
`TOOLRING_DEMO_TOKEN=demo node dist/index.js serve examples/connections.yaml`.
|
|
614
|
+
|
|
615
|
+
### Author an internal npm module
|
|
616
|
+
|
|
617
|
+
**1. Package the operations.** An operation module is an ordinary Node.js
|
|
618
|
+
package with an ES module entry point. Start with the runnable
|
|
619
|
+
[demo service module](examples/tools/demo-service.mjs) as `index.mjs`:
|
|
620
|
+
|
|
621
|
+
```json
|
|
622
|
+
{
|
|
623
|
+
"name": "@company/service-tools",
|
|
624
|
+
"version": "0.1.0",
|
|
625
|
+
"exports": "./index.mjs",
|
|
626
|
+
"files": ["index.mjs"],
|
|
627
|
+
"dependencies": { "zod": "^3.25.0" }
|
|
628
|
+
}
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
The example exports `status({ service }, { connection })` and a `connection`
|
|
632
|
+
definition. Its Zod schema declares a URL and the name of an environment
|
|
633
|
+
variable. In your package, put the real client setup in `connect(settings)`
|
|
634
|
+
and use that client inside each named operation. Zod's `.strict()` reports
|
|
635
|
+
unrecognized settings. A module that only
|
|
636
|
+
exports standalone operations can use `operation(params)` by itself.
|
|
637
|
+
|
|
638
|
+
For a TypeScript package, use `ConnectionDefinition` to check the schema and
|
|
639
|
+
factory together. Ship the compiled ES module as the package's export.
|
|
640
|
+
|
|
641
|
+
```ts
|
|
642
|
+
import type { ConnectionContext, ConnectionDefinition } from "@sudohackin/toolring-mcp/module";
|
|
643
|
+
import type { z } from "zod";
|
|
644
|
+
|
|
645
|
+
// schema is your Zod schema. ServiceClient is the client your factory creates.
|
|
646
|
+
export const connection = {
|
|
647
|
+
schema,
|
|
648
|
+
connect: createServiceClient,
|
|
649
|
+
} satisfies ConnectionDefinition<z.infer<typeof schema>, ServiceClient>;
|
|
650
|
+
|
|
651
|
+
export function status({ service }: { service: string }, { connection }: ConnectionContext<ServiceClient>) {
|
|
652
|
+
return connection.status(service);
|
|
653
|
+
}
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
**2. Install the package in the profile project.** Run `pnpm add @company/service-tools`
|
|
657
|
+
from the project that owns the YAML file.
|
|
658
|
+
|
|
659
|
+
**3. Write and validate a profile.** Declare the module alongside its connection
|
|
660
|
+
and published tool.
|
|
661
|
+
|
|
662
|
+
```yaml
|
|
663
|
+
modules:
|
|
664
|
+
services: "@company/service-tools"
|
|
665
|
+
|
|
666
|
+
connections:
|
|
667
|
+
demo_read:
|
|
668
|
+
module: services
|
|
669
|
+
url: https://status.company.example
|
|
670
|
+
tokenEnv: TOOLRING_DEMO_TOKEN
|
|
671
|
+
|
|
672
|
+
tools:
|
|
673
|
+
- name: service_status
|
|
674
|
+
description: Read the status of a demo service
|
|
675
|
+
call: services.status
|
|
676
|
+
connection: demo_read
|
|
677
|
+
params:
|
|
678
|
+
- { name: service, enum: [api, worker], required: true }
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
```bash
|
|
682
|
+
toolring validate ./profile.yaml
|
|
683
|
+
toolring inspect ./profile.yaml
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
`validate` reports connection setting errors by YAML path. `inspect` shows
|
|
687
|
+
the published tools and their parameters. For a live test with the demo
|
|
688
|
+
module, set `TOOLRING_DEMO_TOKEN=demo`, run `serve` with the same profile,
|
|
689
|
+
and call `service_status` with `{"service":"api"}` over MCP.
|
|
690
|
+
|
|
691
|
+
### Run a sequence of module calls
|
|
692
|
+
|
|
693
|
+
A `steps` list publishes an ordered sequence as one MCP tool.
|
|
694
|
+
|
|
695
|
+
```yaml
|
|
696
|
+
tools:
|
|
697
|
+
- name: refresh_status
|
|
698
|
+
description: Refresh and read the demo service status
|
|
699
|
+
params:
|
|
700
|
+
- { name: service, enum: [api, worker], required: true }
|
|
701
|
+
steps:
|
|
702
|
+
- call: services.refresh
|
|
703
|
+
- call: services.status
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
Each step takes a `call` and an optional `connection` for that module. The
|
|
707
|
+
server checks the tool's arguments once, passes the same input values to
|
|
708
|
+
each step, and awaits each call before starting the next. Only the last step's
|
|
709
|
+
result is sent to the agent. The server resolves all named exports before
|
|
710
|
+
running the first step. If a step throws or rejects, the tool error names the
|
|
711
|
+
step and the sequence stops. Completed steps retain their effects. `inspect`
|
|
712
|
+
and `--dry-run` show the configured order.
|
|
713
|
+
|
|
714
|
+
Try [the sequence example](examples/steps.yaml) from a built checkout with
|
|
715
|
+
`node dist/index.js serve examples/steps.yaml`.
|
|
716
|
+
|
|
717
|
+
### Pipe commands and tools with `run_bash`
|
|
718
|
+
|
|
719
|
+
The optional top-level `bash-policy` publishes the MCP tool `run_bash`.
|
|
720
|
+
Start the [local Jenkins fixture](examples/pipeline.yaml) with
|
|
721
|
+
`toolring serve examples/pipeline.yaml`. With Bash, printf and jq on the
|
|
722
|
+
server's PATH, send this MCP tool call:
|
|
723
|
+
|
|
724
|
+
```json
|
|
725
|
+
{"name":"run_bash","arguments":{"script":"printf '%s' '{\"name\":\"mobile/app\"}' | jq -r '.name' | jenkins_build --job @stdin"}}
|
|
726
|
+
```
|
|
727
|
+
|
|
728
|
+
The returned JSON is the fixture's build preview. Bash streams adjacent
|
|
729
|
+
external processes together with `pipefail`. A published tool name, including
|
|
730
|
+
its configured prefix, invokes its existing handler. A name from the management
|
|
731
|
+
interface cannot be invoked as a stage. The agent receives the last stage's result.
|
|
732
|
+
|
|
733
|
+
`grep` exit status 1 means no matches. The stage succeeds and forwards its stdout,
|
|
734
|
+
which is usually empty. Other command failures still fail the pipeline.
|
|
735
|
+
|
|
736
|
+
With `allow-unpublished-tools: true`, use the exact `module.function` name
|
|
737
|
+
from `toolring_catalog` as a stage. Both `bash-policy` (under that stage
|
|
738
|
+
name) and the direct `call-policy` apply. For example, a profile that allows
|
|
739
|
+
both Jenkins operations can run:
|
|
740
|
+
|
|
741
|
+
```bash
|
|
742
|
+
jenkins.getJobInfo --job mobile/app --field fullName | jenkins.buildJob --job @stdin
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
Named flags pass strings to the function. Use one quoted JSON object for
|
|
746
|
+
typed arguments, or pipe a JSON object into a stage with no argument flags.
|
|
747
|
+
Use `--connection ALIAS` for operations that need a configured connection.
|
|
748
|
+
|
|
749
|
+
```yaml
|
|
750
|
+
bash-policy:
|
|
751
|
+
default: deny
|
|
752
|
+
rules:
|
|
753
|
+
- { command: jq, argv: [-r, .name], action: allow }
|
|
754
|
+
- { command: jenkins_build, action: confirm }
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
Use `bash-policy.rules[].when` to test only the options or subcommand you care about. Combine `subcommand` and `option` predicates with `not`, `anyOf`, and `allOf`. An option lists its aliases and accepts either `equals` or `oneOf`. A malformed or ambiguous invocation is denied. See the [complete profile](examples/bash-when.yaml) and [condition reference](docs/bash-policy.ru.md#условия-when-для-внешних-команд).
|
|
758
|
+
|
|
759
|
+
External command argument slots can also use `{ startsWith: "prefix" }` (a nonempty literal prefix of one argument), `{ oneOf: [...] }` or `{ jsonPatch: { paths: [...] } }` to check a full JSON Patch argument. Use `match.positionals` and `match.flags` to allow a CLI invocation independently of flag order. Each flag lists its accepted names and value, for example `{ names: [-n, --namespace], required: true, value: mobile }`. Unknown and duplicate flags fail the match.
|
|
760
|
+
|
|
761
|
+
For CLIs with a subcommand, target and named `key=value` arguments, use `match.subcommand`, `match.target` and `match.assignments`. In this form, command-wide option guards apply to every operation and their aliases are recognized alongside the operation's own flags. See the [deployment image profile](examples/deployment-image.yaml).
|
|
762
|
+
|
|
763
|
+
The [scoped writes profile](examples/scoped-writes.yaml) restricts kubectl fields, PostgreSQL DML targets and Jenkins jobs. The [policy guide (RU)](docs/bash-policy.ru.md) covers the working configuration and proposed extensions.
|
|
764
|
+
|
|
765
|
+
An `argv` rule matches the command name and its **entire** argument vector
|
|
766
|
+
after unquoting. For tool stages the runner normalizes named flags to
|
|
767
|
+
`--name=value` in both the call and rule, preserving their order. Output
|
|
768
|
+
selectors are excluded from matching. Omitting both `argv` and `match` matches all arguments. `argv: []` matches
|
|
769
|
+
zero arguments. Matching decisions have precedence `deny`, `confirm`,
|
|
770
|
+
`allow`. An unmatched invocation uses `bash-policy.command-defaults[command]` when present, then the global `default` (initially `deny`). For example, combine `default: allow` and `command-defaults: { kubectl: deny }` with explicit `kubectl` allow rules. Setting `default: allow` grants execution of arbitrary executables
|
|
771
|
+
on the server's PATH. An allowed external program runs with the server's OS
|
|
772
|
+
permissions and interprets its own flags, stdin and any child commands.
|
|
773
|
+
These rules do not sandbox programs or inspect Kubernetes manifests.
|
|
774
|
+
|
|
775
|
+
The runner checks every stage before starting the pipeline. A command-wide
|
|
776
|
+
`deny` rule vetoes the entire `run_bash` request, including when a more
|
|
777
|
+
specific `allow` rule matches the same command and arguments. Put `default: deny`
|
|
778
|
+
in the policy to allow a command only for the argument vectors listed in its
|
|
779
|
+
`allow` rules.
|
|
780
|
+
|
|
781
|
+
Supply known variables in the optional `vars` object of the MCP request. For
|
|
782
|
+
example, the Jenkins profile accepts the following:
|
|
783
|
+
|
|
784
|
+
```json
|
|
785
|
+
{"name":"run_bash","arguments":{"script":"jenkins_info --job \"$JOB\" --field fullName","vars":{"JOB":"mobile/app"}}}
|
|
786
|
+
```
|
|
787
|
+
|
|
788
|
+
The runner resolves `$JOB` or `${JOB}` in argument positions before checking
|
|
789
|
+
the whole pipeline. It passes those same argv values to the executor. A
|
|
790
|
+
different job fails the example profile's exact-argv rule. Names must be
|
|
791
|
+
literal commands. Variable lookup uses only the supplied `vars` object.
|
|
792
|
+
Double quotes preserve a single argument, including an empty string or
|
|
793
|
+
spaces. Single quotes and an escaped dollar sign preserve the literal dollar.
|
|
794
|
+
|
|
795
|
+
Use a standalone, unquoted `@stdin` to take one argument from the previous
|
|
796
|
+
stage, for example `jq -r '.namespace' | kubectl get pods -n @stdin`.
|
|
797
|
+
The runner waits for the producer to succeed and accepts one nonempty UTF-8
|
|
798
|
+
line, with an optional final LF or CRLF. Spaces and shell punctuation stay in
|
|
799
|
+
that argument. Repeating the marker reuses the same line, up to 256 KiB of
|
|
800
|
+
resolved arguments per marked stage. Quote `'@stdin'`
|
|
801
|
+
to pass the literal text. A process using the marker receives empty stdin.
|
|
802
|
+
Other adjacent process stages continue to stream through ordinary pipes.
|
|
803
|
+
|
|
804
|
+
For a marked stage, the runner checks the command and known arguments before
|
|
805
|
+
starting the pipeline, then checks the exact resolved arguments before starting
|
|
806
|
+
that stage. A `confirm` decision shows the resolved invocation for approval.
|
|
807
|
+
|
|
808
|
+
Published tools also enforce their input schema, `command-policy` and applicable
|
|
809
|
+
`call-policy`. A value derived from stdin is validated when it arrives.
|
|
810
|
+
Earlier completed stages retain their effects if validation or execution
|
|
811
|
+
later fails. Pass `dryRun: true` alongside `script` in a `run_bash` call to preview each stage, its policy decision and the reason. The preview returns `structuredContent.stages` without executing or asking for approval. A downstream stage needing stdin is marked `pending` until an actual run supplies the value. Starting the server with `--dry-run` forces previews even if the caller passes `dryRun: false`.
|
|
812
|
+
|
|
813
|
+
#### Published tool input and output
|
|
814
|
+
|
|
815
|
+
The following pipeline uses the same Jenkins fixture. It reads a job, passes
|
|
816
|
+
its full name into the build tool and returns just the branch from the preview.
|
|
817
|
+
|
|
818
|
+
```bash
|
|
819
|
+
jenkins_info --job mobile/app --field fullName | jenkins_build --job @stdin --branch main --runTests --field /parameters/branch
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
| Input or output | Contract |
|
|
823
|
+
|---|---|
|
|
824
|
+
| Named arguments | Use `--job mobile/app` or `--job=mobile/app`. The published schema determines the type. A bare boolean flag means true. Use `--runTests=false` for false. Quote values containing spaces. |
|
|
825
|
+
| JSON arguments | A single quoted JSON object supplies all explicit arguments, including a parameter literally named `field`. Output flags may accompany it. |
|
|
826
|
+
| Tool stdin | Use `--name @stdin` to bind a line to a typed flag. Without a marker the tool consumes a JSON argument object, or one line for the configured string parameter if the profile supplies a `bash-policy.stdin` binding. Supplying the bound parameter twice or receiving multiple lines fails. Each stage invokes the tool once. |
|
|
827
|
+
| Tool stdout | The runner serializes `structuredContent` as JSON when present. Otherwise it forwards the single text block verbatim. Ambiguous or non-text content fails the pipeline. |
|
|
828
|
+
| Last stage | An external process returns stdout. A published tool returns its original MCP result unless an output selector requests a projected value. Tool errors stop the pipeline before the next stage. |
|
|
829
|
+
|
|
830
|
+
`--field` reads from structured output or from a text block containing JSON.
|
|
831
|
+
A top-level key (`--field fullName`) or slash path (`--field /items/0/name`)
|
|
832
|
+
selects one value. A string is passed as raw text. Numbers, booleans, null,
|
|
833
|
+
arrays and objects are emitted as JSON. In slash paths, `~1` denotes a
|
|
834
|
+
literal slash and `~0` denotes a literal tilde in a key.
|
|
835
|
+
|
|
836
|
+
To produce a JSON argument object, give each selection a distinct alias:
|
|
837
|
+
|
|
838
|
+
```bash
|
|
839
|
+
jenkins_info --job mobile/app --field job=/fullName --field branch=/property/0/parameterDefinitions/0/defaultParameterValue/value
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
The result is `{"job":"mobile/app","branch":"main"}`. It can feed a tool
|
|
843
|
+
configured to consume a JSON object. A missing path is an error, including
|
|
844
|
+
when the next tool would otherwise accept an empty value. External commands
|
|
845
|
+
receive their own flags verbatim.
|
|
846
|
+
|
|
847
|
+
Supported shell syntax includes literal words, single and double quotes,
|
|
848
|
+
backslash escapes, and up to 32 stages separated by unquoted pipes.
|
|
849
|
+
Command substitutions, redirects, shell lists and assignments are unsupported.
|
|
850
|
+
The runner supplies each validated word as a separate Bash argument.
|
|
851
|
+
Each group of external processes has a 30-second timeout and a combined
|
|
852
|
+
256 KiB limit on captured stdout and stderr. Intermediate process pipes stream;
|
|
853
|
+
published tool boundaries exchange UTF-8 text.
|
|
854
|
+
|
|
855
|
+
### Module commands and external commands
|
|
856
|
+
|
|
857
|
+
In a pipeline profile, Toolring discovers the `commandAdapters` exported by enabled
|
|
858
|
+
modules. A Kubernetes connection makes `kubectl` available to `run_bash` and
|
|
859
|
+
`toolring call`. Use the same command in either place:
|
|
860
|
+
|
|
861
|
+
```sh
|
|
862
|
+
# run_bash
|
|
863
|
+
kubectl get pod api -n mobile -o json | jq .metadata.name
|
|
864
|
+
|
|
865
|
+
# terminal (the surrounding shell runs jq)
|
|
866
|
+
toolring call kubectl get pod api -n mobile -o json | jq .metadata.name
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
The [Kubernetes profile](examples/kubectl-read.yaml) publishes `k8s.get_pod` and
|
|
870
|
+
`k8s.list_pods`. It selects the only Kubernetes connection automatically. With
|
|
871
|
+
several connections, set `command-connections: {kubectl: mobile}`. The adapter
|
|
872
|
+
checks explicit context, namespace and kubeconfig against that connection.
|
|
873
|
+
Unsupported syntax, a conflicting selector, or an unpublished destination stops
|
|
874
|
+
the call. For a local dry run, use:
|
|
875
|
+
|
|
876
|
+
```sh
|
|
877
|
+
node bin/toolring.js -f examples/kubectl-read.yaml --registry modules/k8s/registry.mjs --dry-run call kubectl get pod api -o json
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
The optional `--` after the command name forwards the remaining arguments
|
|
881
|
+
verbatim, including flags that Toolring also recognizes. Place Toolring flags
|
|
882
|
+
such as `--dry-run` before the command name in that form.
|
|
883
|
+
|
|
884
|
+
Set `bash-policy: {external-commands: [jq]}` to allow `jq` with any arguments.
|
|
885
|
+
An empty list enables pipelines consisting only of module commands and published
|
|
886
|
+
tools (and direct calls if explicitly enabled). Each external stage is checked by
|
|
887
|
+
executable name. Listing a module-owned command here still runs its adapter.
|
|
888
|
+
The list governs raw external invocations through Toolring. Commands run directly
|
|
889
|
+
in a system shell use that shell's credentials and permissions.
|
|
890
|
+
|
|
891
|
+
A module exports a `commandAdapters` object keyed by executable name. Each
|
|
892
|
+
`ModuleCommandAdapter<Parsed, Bound>` implements `parse({command, argv})`,
|
|
893
|
+
`bind(parsed, settings)` and `operation(bound)`. The last method returns
|
|
894
|
+
`{call, args}` with a local operation name. Toolring finds its unique published
|
|
895
|
+
schema on the bound connection, applies defaults and authorizes the operation.
|
|
896
|
+
The operation's handler implements the service call.
|
|
897
|
+
|
|
898
|
+
### Tool policy and short flags
|
|
899
|
+
|
|
900
|
+
Use `tool-policy.validators` for every admitted module operation, including
|
|
901
|
+
direct calls to unpublished exports. Add `validators` to a rule to check
|
|
902
|
+
only calls matching its operation, connection and arguments. A published
|
|
903
|
+
`call` or `steps` tool can also declare `validators` directly. These run
|
|
904
|
+
for each operation reached through that tool, including adapter dispatch.
|
|
905
|
+
A direct module call uses the global and matching rule checks. Use
|
|
906
|
+
`tool-policy.operations` for additional checks keyed by operation across routes.
|
|
907
|
+
A declarative denial skips validators. A validator denial stops execution,
|
|
908
|
+
and a confirmation requirement survives subsequent approvals. A repeated
|
|
909
|
+
reference runs once per operation. Each validator receives
|
|
910
|
+
`{call, connection, args}`. The same policy applies to named MCP tools, CLI
|
|
911
|
+
calls, sequences, and module commands in a pipeline. The default is deny
|
|
912
|
+
when a tool policy is supplied. Direct calls to unpublished exports additionally
|
|
913
|
+
require `allow-unpublished-tools: true`.
|
|
914
|
+
|
|
915
|
+
```yaml
|
|
916
|
+
tool-policy:
|
|
917
|
+
default: deny
|
|
918
|
+
rules:
|
|
919
|
+
- call: jenkins.logs
|
|
920
|
+
connection: ci
|
|
921
|
+
action: allow
|
|
922
|
+
validators: ["./ci-policy.mjs#reviewFollow"]
|
|
923
|
+
|
|
924
|
+
tools:
|
|
925
|
+
- name: jenkins_logs
|
|
926
|
+
description: Read a build log
|
|
927
|
+
call: jenkins.logs
|
|
928
|
+
connection: ci
|
|
929
|
+
params:
|
|
930
|
+
- { name: build, required: true }
|
|
931
|
+
- { name: follow, type: boolean, default: false, aliases: [-f] }
|
|
932
|
+
```
|
|
933
|
+
|
|
934
|
+
In `ci-policy.mjs`, next to the profile, export the policy function directly:
|
|
935
|
+
|
|
936
|
+
```js
|
|
937
|
+
export function reviewFollow({ connection, args }) {
|
|
938
|
+
return connection === "ci" && args.follow
|
|
939
|
+
? { action: "confirm", reason: "Follow the live CI log" }
|
|
940
|
+
: { action: "allow" };
|
|
941
|
+
}
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
For this profile, `toolring call jenkins_logs --build my-build -f` in the terminal and
|
|
945
|
+
`jenkins_logs --build my-build -f` in an allowed Bash stage resolve to the MCP arguments
|
|
946
|
+
`{"build":"my-build","follow":true}`. Each invocation evaluates the operation policy
|
|
947
|
+
once before execution. A pipeline checks static calls before starting any stage and
|
|
948
|
+
checks calls using `@stdin` when the input arrives. A dry run evaluates available arguments
|
|
949
|
+
without prompting. The one-shot CLI stops if the decision requires confirmation.
|
|
950
|
+
|
|
951
|
+
Node scripts can use the same one-shot dispatcher as the CLI. Pass the profile
|
|
952
|
+
path when it contains relative module paths:
|
|
953
|
+
|
|
954
|
+
```js
|
|
955
|
+
import { readFile } from "node:fs/promises";
|
|
956
|
+
import { parseConfig, callConfiguredTool } from "@sudohackin/toolring-mcp/client";
|
|
957
|
+
|
|
958
|
+
const configPath = "./toolring.yaml";
|
|
959
|
+
const profile = parseConfig(await readFile(configPath, "utf8"));
|
|
960
|
+
const result = await callConfiguredTool(profile, "jenkins_logs", ["--build", "my-build"], { configPath });
|
|
961
|
+
if (result.isError) throw new Error(JSON.stringify(result.content));
|
|
962
|
+
```
|
|
963
|
+
|
|
964
|
+
Existing profiles can keep their explicit `command-policies` adapters, backend
|
|
965
|
+
choices, Bash argument rules, `call-policy` scope and `operation-policies`.
|
|
966
|
+
When migrating, move operation rules and validators into `tool-policy`, replace
|
|
967
|
+
explicit command parsers with module-owned adapters, and use `external-commands`
|
|
968
|
+
for the raw executables the profile permits.
|
|
969
|
+
|
|
970
|
+
## Config reference
|
|
971
|
+
|
|
972
|
+
| Field | Type | Default | Description |
|
|
973
|
+
|---|---|---|---|
|
|
974
|
+
| `allow-unpublished-tools` | boolean | `false` | Enable direct module exports in the CLI, `toolring_call`, and `run_bash` |
|
|
975
|
+
| `tool-policy` | object | omitted | Shared module operation rules and optional custom validators. |
|
|
976
|
+
| `command-connections` | map | inferred | Select a connection by native command name. |
|
|
977
|
+
| `call-policy` | object | omitted | Rules and default action for named module calls. An omitted policy permits calls reachable through the profile. |
|
|
978
|
+
| `operation-policies` | object | omitted | Validators keyed by named module operation. |
|
|
979
|
+
| `bash-policy` | object | omitted | Publish `run_bash` with pipeline stage rules and optional tool stdin bindings. |
|
|
980
|
+
| `prefix` | string | — | Tool name prefix, e.g. `ffmpeg` → `ffmpeg_probe` |
|
|
981
|
+
| `env` | map | — | Extra env vars for every spawned command |
|
|
982
|
+
| `modules` | map | — | Map snake_case aliases to JavaScript file paths or installed npm package names |
|
|
983
|
+
| `enabled-modules` | array | all available aliases | Select the built-in, registered, and YAML-declared modules this profile can use |
|
|
984
|
+
| `connections` | map | — | Named settings validated by the selected module's schema |
|
|
985
|
+
| `tools` | array | *required* | The tools to expose |
|
|
986
|
+
|
|
987
|
+
### Tool fields
|
|
988
|
+
|
|
989
|
+
Choose exactly one of `command`, `handler`, `call`, and `steps` per tool.
|
|
990
|
+
|
|
991
|
+
| Field | Type | Default | Description |
|
|
992
|
+
|---|---|---|---|
|
|
993
|
+
| `name` | string | *required* | snake_case tool name |
|
|
994
|
+
| `description` | string | *required* | What the tool does — the agent reads this |
|
|
995
|
+
| `command` | string | — | Executable to run (resolved from PATH) |
|
|
996
|
+
| `handler` | string | — | Local `.mjs` file with a default function export |
|
|
997
|
+
| `call` | string | — | Named function export in a local, registered, or built-in module, in `alias.function` form |
|
|
998
|
+
| `connection` | string | — | For `call` tools, name of a configured connection whose client is passed to the function |
|
|
999
|
+
| `steps` | array | — | Ordered list of module calls, each with `call` and optional `connection` |
|
|
1000
|
+
| `args` | array | `[]` | Command-only. Literal argv tokens before any params |
|
|
1001
|
+
| `params` | array | `[]` | Typed parameters (below) |
|
|
1002
|
+
| `cwd` | string | — | Command-only. Working directory |
|
|
1003
|
+
| `timeoutMs` | number | `30000` | Command-only. Kill the process after this long (max 600000) |
|
|
1004
|
+
| `jsonOutput` | boolean | `false` | Command-only. Parse stdout as JSON into structured content |
|
|
1005
|
+
| `includeStderr` | boolean | `false` | Command-only. Also return stderr on success |
|
|
1006
|
+
|
|
1007
|
+
### Param fields
|
|
1008
|
+
|
|
1009
|
+
| Field | Type | Default | Description |
|
|
1010
|
+
|---|---|---|---|
|
|
1011
|
+
| `name` | string | *required* | lowerCamelCase parameter name |
|
|
1012
|
+
| `description` | string | auto | Agent-facing description |
|
|
1013
|
+
| `type` | `string\|number\|boolean` | `string` | Value type. Node tools also accept `"string[]"` for a nonempty array of strings. |
|
|
1014
|
+
| `required` | boolean | `false` | Agent must provide it |
|
|
1015
|
+
| `aliases` | array of strings | — | Published tool input flags such as `["-f"]`. Each short flag identifies one parameter in the tool. |
|
|
1016
|
+
| `flag` | string | — | Command-only. CLI flag, e.g. `-i` or `--format` |
|
|
1017
|
+
| `equalsForm` | boolean | `false` | Command-only. Emit `--flag=value` instead of `--flag value` |
|
|
1018
|
+
| `trueFlag` | string | — | Command-only. Token emitted when a boolean is true |
|
|
1019
|
+
| `positional` | boolean | `false` | Command-only. Pass value as positional arg (in declaration order) |
|
|
1020
|
+
| `placement` | `global\|local` | `local` | Command-only. `global` puts the flag right after the executable (e.g. `git -C <path> log`) |
|
|
1021
|
+
| `enum` | array of strings | — | Allowed values for a `string` parameter |
|
|
1022
|
+
| `default` | `string\|number\|boolean` | — | Used when the agent omits an optional param. For `"string[]"`, supply a nonempty array of strings. |
|
|
1023
|
+
|
|
1024
|
+
For `call`, `handler`, and `steps` tools, the server rejects extra input fields. A
|
|
1025
|
+
parameter default must match its type and any enum. The module's own schema
|
|
1026
|
+
defines the shape of `connections` settings and can include nested objects
|
|
1027
|
+
and arrays.
|
|
1028
|
+
|
|
1029
|
+
## Docker
|
|
1030
|
+
|
|
1031
|
+
```bash
|
|
1032
|
+
docker build -t toolring .
|
|
1033
|
+
# mount your own config over the bundled safe default
|
|
1034
|
+
docker run -i --rm -v $PWD/tools.yaml:/config/tools.yaml:ro toolring
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
## Trying it safely
|
|
1038
|
+
|
|
1039
|
+
Want to see exactly what an agent could run before granting anything?
|
|
1040
|
+
|
|
1041
|
+
```bash
|
|
1042
|
+
toolring serve ./ffmpeg.yaml --dry-run
|
|
1043
|
+
```
|
|
1044
|
+
|
|
1045
|
+
Each call shows the exact argv for a command, the resolved path for a Node.js
|
|
1046
|
+
handler, or the configured `alias.function` references in order. `--dry-run`,
|
|
1047
|
+
`validate`, and `inspect` read the registry and any configured connection
|
|
1048
|
+
schemas. They leave connection clients unopened. Unbound operation modules
|
|
1049
|
+
are loaded on their first live call.
|
|
1050
|
+
|
|
1051
|
+
## Security model
|
|
1052
|
+
|
|
1053
|
+
For command tools:
|
|
1054
|
+
|
|
1055
|
+
- **Local execution.** The runner spawns the configured executable directly.
|
|
1056
|
+
Each argument is a separate argv token. The executable determines how it
|
|
1057
|
+
interprets those arguments, including any remote shell processing by SSH.
|
|
1058
|
+
- **Configured invocations.** The YAML selects the commands and how the
|
|
1059
|
+
declared parameters become argv tokens.
|
|
1060
|
+
- **Bounded by design.** Every command has a timeout (default 30 s) and
|
|
1061
|
+
captured output is capped at 256 KiB to protect the agent's context window.
|
|
1062
|
+
- **Failures are data, not exceptions.** Non-zero exits and timeouts are
|
|
1063
|
+
returned to the agent as readable results, so it can react.
|
|
1064
|
+
|
|
1065
|
+
You are still responsible for *which* commands you expose: an agent with
|
|
1066
|
+
access to `rm` can remove files. Expose read-only subcommands (see
|
|
1067
|
+
[examples/git.yaml](examples/git.yaml) for a deliberately read-only git set).
|
|
1068
|
+
|
|
1069
|
+
Node.js handlers, local modules, and their dependencies are trusted operator
|
|
1070
|
+
code. Keep the YAML and code outside agent-writable locations. The function
|
|
1071
|
+
enforces which resources and actions its inputs can select. It runs with the
|
|
1072
|
+
full permissions of the process running the tool through MCP or the CLI.
|
|
1073
|
+
|
|
1074
|
+
### Project-scoped SSH commands
|
|
1075
|
+
|
|
1076
|
+
Keep the tool definitions in the project's YAML profile and start the project's
|
|
1077
|
+
MCP server with that file. For example, `toolring serve examples/billing-ssh.yaml`
|
|
1078
|
+
publishes `billing_restart_api` with zero parameters. Its SSH destination and
|
|
1079
|
+
the full remote command `systemctl --user restart billing-api.service` are
|
|
1080
|
+
fixed in YAML. The unit name selects the project service within the remote
|
|
1081
|
+
user's systemd manager. The companion tool `billing_service_state` accepts a
|
|
1082
|
+
unit from a two-value enum, so the same profile can grant read access to both
|
|
1083
|
+
units while granting restart access only to the API.
|
|
1084
|
+
|
|
1085
|
+
Both tools invoke OpenSSH with the same project-specific control socket under
|
|
1086
|
+
the local user's private `~/.ssh` directory. OpenSSH reuses the established
|
|
1087
|
+
connection and keeps it for five minutes after the last channel closes.
|
|
1088
|
+
Replace the example destination and units, use a distinct socket prefix for
|
|
1089
|
+
each project, and provision the verified host key and noninteractive SSH
|
|
1090
|
+
authentication for the account running the MCP server.
|
|
1091
|
+
[OpenSSH connection sharing](https://man.openbsd.org/ssh_config#ControlMaster)
|
|
1092
|
+
|
|
1093
|
+
OpenSSH passes the remote command through the remote user's shell. Keep
|
|
1094
|
+
command words and flags fixed, and use exact enums of shell-safe literals for
|
|
1095
|
+
selectable arguments, as in the unit selector below.
|
|
1096
|
+
[Billing project profile](examples/billing-ssh.yaml)
|
|
1097
|
+
|
|
1098
|
+
## Examples
|
|
1099
|
+
|
|
1100
|
+
- [examples/billing-ssh.yaml](examples/billing-ssh.yaml) — project-scoped SSH commands for systemd user services
|
|
1101
|
+
- [examples/ffmpeg.yaml](examples/ffmpeg.yaml) — media probing & conversion
|
|
1102
|
+
- [examples/git.yaml](examples/git.yaml) — a read-only git window
|
|
1103
|
+
|
|
1104
|
+
```bash
|
|
1105
|
+
npx @sudohackin/toolring-mcp inspect examples/ffmpeg.yaml
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
## Development
|
|
1109
|
+
|
|
1110
|
+
Use the pnpm version pinned in `package.json`. The workspace contains the CLI at
|
|
1111
|
+
the root and independently packable operation packages under `modules/*`.
|
|
1112
|
+
|
|
1113
|
+
```bash
|
|
1114
|
+
pnpm install --frozen-lockfile
|
|
1115
|
+
pnpm build # compile the CLI and its module contract, then the operation packages
|
|
1116
|
+
pnpm test # core unit tests
|
|
1117
|
+
node scripts/e2e.mjs # full MCP protocol test over stdio
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
CI runs the unit suite on a 3-OS × 4-Node matrix and the E2E protocol test
|
|
1121
|
+
on all three OSes.
|
|
1122
|
+
|
|
1123
|
+
### Publishing the CLI and PostgreSQL module
|
|
1124
|
+
|
|
1125
|
+
Run **Actions → Release → Run workflow** on `main` to build and test all three release packages.
|
|
1126
|
+
Download the `npm-packages` artifact for the three tested tarballs.
|
|
1127
|
+
|
|
1128
|
+
For a change to any workspace package, run `pnpm changeset`, choose the
|
|
1129
|
+
release type and commit the generated Markdown file with the change.
|
|
1130
|
+
Run `pnpm version:packages` to apply pending changesets. The CLI, catalog
|
|
1131
|
+
generator, PostgreSQL module, and Kubernetes module share one version. The command also updates
|
|
1132
|
+
the MCP bundle manifest and writes each package's changelog.
|
|
1133
|
+
|
|
1134
|
+
Commit the version changes on `main` and push the matching tag (for example,
|
|
1135
|
+
`git tag v0.9.2 && git push origin v0.9.2`). The tag workflow publishes
|
|
1136
|
+
`@sudohackin/toolring-mcp`, `@sudohackin/toolring-postgres`, and
|
|
1137
|
+
`@sudohackin/toolring-k8s` to npm using OIDC and
|
|
1138
|
+
attaches the three tested tarballs to the GitHub Release. Configure the npm trusted
|
|
1139
|
+
publisher for each package with repository `sudoHackIn/toolring` and workflow
|
|
1140
|
+
`release.yml`. If one publish job fails, rerun failed jobs to retry that package. Stable versions receive the `latest` dist-tag and prereleases
|
|
1141
|
+
receive `next`.
|
|
1142
|
+
|
|
1143
|
+
## License
|
|
1144
|
+
|
|
1145
|
+
MIT
|