Skip to content

Commit 70843ad

Browse files
ochafikclaude
andcommitted
Add example-tool-loop binary wrapper for npx usage
Created a wrapper script that properly launches the backfill proxy with the tool loop server, making it easy to run via npx. The bin entry now points to dist/esm/bin/examples-tool-loop.js which spawns the backfill proxy with the server as a child process. Usage: npx -y --package=https://github.com/modelcontextprotocol/typescript-sdk.git#ochafik/sep1577 -- example-tool-loop 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3377665 commit 70843ad

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
],
2121
"bin": {
2222
"backfill-sampling": "./dist/esm/examples/backfill/backfillSampling.js",
23-
"example-tool-loop": "./dist/esm/examples/server/toolLoopSampling.js"
23+
"example-tool-loop": "./dist/esm/bin/examples-tool-loop.js"
2424
},
2525
"exports": {
2626
".": {

src/bin/examples-tool-loop.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import { spawn } from 'node:child_process';
4+
import { fileURLToPath } from 'node:url';
5+
import { dirname, join } from 'node:path';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = dirname(__filename);
9+
10+
// Navigate from dist/esm/bin/ to dist/esm/examples/
11+
const backfillScript = join(__dirname, '../examples/backfill/backfillSampling.js');
12+
const serverScript = join(__dirname, '../examples/server/toolLoopSampling.js');
13+
14+
// Run the backfill proxy with the tool loop server
15+
const child = spawn('node', [backfillScript, 'node', serverScript], {
16+
stdio: 'inherit',
17+
env: process.env
18+
});
19+
20+
child.on('exit', (code) => {
21+
process.exit(code || 0);
22+
});

0 commit comments

Comments
 (0)