toolbox-co-mcp-bridge 1.0.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/README.md +32 -0
- package/index.js +58 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @toolbox-co/mcp
|
|
2
|
+
|
|
3
|
+
This is a lightweight executable bridge proxy designed to connect local AI Agents (like **Claude Desktop**) to the remote **ToolBox Co.** micro-services seamlessly using the Model Context Protocol (MCP).
|
|
4
|
+
|
|
5
|
+
## Why does this exist?
|
|
6
|
+
Claude Desktop and other standardized MCP clients communicate strictly over local standard I/O streams (`stdio`) for maximum security and local isolation. They do not natively support speaking to remote `SSE` (Server-Sent Events) HTTP endpoints.
|
|
7
|
+
|
|
8
|
+
This package bridges that gap by running locally on the user's machine, listening to Claude's `stdio`, and forwarding requests back and forth over HTTP to the hosted ToolBox Co. SaaS.
|
|
9
|
+
|
|
10
|
+
## How to execute
|
|
11
|
+
|
|
12
|
+
Paste the following into your `claude_desktop_config.json`:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"mcpServers": {
|
|
17
|
+
"toolbox-co": {
|
|
18
|
+
"command": "npx",
|
|
19
|
+
"args": ["-y", "@toolbox-co/mcp"]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## How to publish
|
|
26
|
+
|
|
27
|
+
1. Run `npm install` inside this directory to ensure `package-lock.json` is generated.
|
|
28
|
+
2. Ensure you are logged into NPM (`npm login`).
|
|
29
|
+
3. Publish to the public registry constraint free:
|
|
30
|
+
\`\`\`bash
|
|
31
|
+
npm publish --access public
|
|
32
|
+
\`\`\`
|
package/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import EventSource from "eventsource";
|
|
3
|
+
import fetch from "node-fetch";
|
|
4
|
+
|
|
5
|
+
// The hardcoded remote SSE endpoint for ToolBox Co. SaaS tools
|
|
6
|
+
const sseUrl = "https://toolbox-mcp-1058072229791.us-central1.run.app/sse";
|
|
7
|
+
|
|
8
|
+
const es = new EventSource(sseUrl);
|
|
9
|
+
let postEndpoint = '';
|
|
10
|
+
|
|
11
|
+
// When the MCP server initializes the connection, it emits an 'endpoint' event
|
|
12
|
+
// containing the specific URI we must POST messages to.
|
|
13
|
+
es.addEventListener("endpoint", (e) => {
|
|
14
|
+
try {
|
|
15
|
+
postEndpoint = new URL(e.data, sseUrl).toString();
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error("Failed to parse POST endpoint:", err);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Any messages received from the remote MCP server must be forwarded
|
|
22
|
+
// locally to Claude Desktop via standard output (stdout).
|
|
23
|
+
es.onmessage = (e) => {
|
|
24
|
+
console.log(e.data);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
es.onerror = (e) => {
|
|
28
|
+
console.error("SSE connection error:", e);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Listen directly on standard input (stdin) for JSON-RPC messages
|
|
32
|
+
// coming from the local MCP Client (Claude Desktop).
|
|
33
|
+
process.stdin.on('data', async (data) => {
|
|
34
|
+
if (!postEndpoint) {
|
|
35
|
+
// Can optionally log a warning but the protocol expects JSON-RPC responses only in stdout.
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Tools or clients might batch messages separated by newlines
|
|
40
|
+
const messages = data.toString().trim().split('\n');
|
|
41
|
+
|
|
42
|
+
for (const msg of messages) {
|
|
43
|
+
if (!msg.trim()) continue;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
await fetch(postEndpoint, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
headers: { 'Content-Type': 'application/json' },
|
|
49
|
+
body: msg
|
|
50
|
+
});
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.error("Failed to forward message from Claude to ToolBox:", e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Keep process alive indefinitely
|
|
58
|
+
setInterval(() => {}, 1000 * 60 * 60);
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "toolbox-co-mcp-bridge",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A bridge proxy to connect local STDIO-based MCP clients (like Claude Desktop) to the remote ToolBox Co. SSE endpoint.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"toolbox-mcp": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node index.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mcp",
|
|
14
|
+
"model context protocol",
|
|
15
|
+
"toolbox-co",
|
|
16
|
+
"sse",
|
|
17
|
+
"proxy"
|
|
18
|
+
],
|
|
19
|
+
"author": "ToolBox Co.",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"eventsource": "^2.0.2",
|
|
23
|
+
"node-fetch": "^3.3.2"
|
|
24
|
+
}
|
|
25
|
+
}
|