@poe-platform/safe-bash 0.1.40 → 0.1.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 +34 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -177,6 +177,40 @@ package/local-module loading, `process.exit()`, or native module fallback.
|
|
|
177
177
|
Pass `limits` for source/input/output bytes, timeout, and interpreter budgets;
|
|
178
178
|
see [defaults and configuration](src/commands/node/README.md#configuration).
|
|
179
179
|
|
|
180
|
+
## Wire an individual MCP tool
|
|
181
|
+
|
|
182
|
+
There is no generic safe-bash MCP server. Define each server and tool around the
|
|
183
|
+
specific operation it grants, then call `Shell.exec()` with fixed shell source.
|
|
184
|
+
For example, this server exposes name normalization without accepting arbitrary
|
|
185
|
+
Bash from the MCP client:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { Shell, agentCommands, createMemoryFileSystem } from "poe-code/safe-bash";
|
|
189
|
+
import { createServer, defineSchema } from "tiny-stdio-mcp-server";
|
|
190
|
+
|
|
191
|
+
const shell = new Shell({ fs: createMemoryFileSystem() }).use(agentCommands());
|
|
192
|
+
const input = defineSchema({ names: { type: "string" } });
|
|
193
|
+
|
|
194
|
+
const server = createServer({ name: "contacts-tools", version: "1.0.0" })
|
|
195
|
+
.tool("normalize_names", "Sort and deduplicate newline-separated names", input,
|
|
196
|
+
async ({ names }) => {
|
|
197
|
+
const result = await shell.exec("sort | uniq", { stdin: names });
|
|
198
|
+
if (result.exitCode !== 0) throw new Error(result.stderr);
|
|
199
|
+
return result.stdout;
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
await server.listen();
|
|
204
|
+
} finally {
|
|
205
|
+
await shell.dispose();
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Install `poe-code` and the MCP transport package in that server's own project.
|
|
210
|
+
Choose its filesystem, command bundle, limits, and opt-in capabilities there;
|
|
211
|
+
do not expose caller-supplied shell source unless arbitrary shell execution is
|
|
212
|
+
the deliberate API.
|
|
213
|
+
|
|
180
214
|
## Add a command
|
|
181
215
|
|
|
182
216
|
A `CommandDefinition` has a name and an `execute(context)` handler. This example
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poe-platform/safe-bash",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "Extensible virtual shell with pluggable filesystems and streaming commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"access": "public"
|
|
138
138
|
},
|
|
139
139
|
"dependencies": {
|
|
140
|
-
"@poe-platform/safe-fs": "0.1.
|
|
140
|
+
"@poe-platform/safe-fs": "0.1.41",
|
|
141
141
|
"@types/node": "^25.2.2"
|
|
142
142
|
}
|
|
143
143
|
}
|