tg2ai-mcp 0.1.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 +56 -0
- package/package.json +14 -0
- package/src/index.js +130 -0
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# tg2ai-mcp
|
|
2
|
+
|
|
3
|
+
> **TG2AI Remote SSE Bridge Client** ā Ultra-lightweight, zero-dependency proxy bridge connecting your local AI development environment (Claude Desktop, Cursor IDE, Windsurf) to your remote secure TG2AI API Gateway over Server-Sent Events (SSE).
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ā” Features
|
|
8
|
+
|
|
9
|
+
* **Zero-Dependencies:** Runs natively on standard Node.js without heavy compiler chains.
|
|
10
|
+
* **Instant Start:** Zero build time, starts in `< 5ms`.
|
|
11
|
+
* **Resource Efficient:** Consumes `< 15MB` of RAM.
|
|
12
|
+
* **Bi-directional Stream Pipe:** Translates local Standard I/O (stdio) streams of Claude Desktop / Cursor IDE into cloud-based SSE connection seamlessly.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## š Installation & Configuration
|
|
17
|
+
|
|
18
|
+
You do not need to install this package manually. You can execute it directly on the fly using `npx`.
|
|
19
|
+
|
|
20
|
+
### 1. Claude Desktop Configuration
|
|
21
|
+
|
|
22
|
+
Add the following block to your `claude_desktop_config.json` (typically located in `%APPDATA%\Claude\claude_desktop_config.json` on Windows or `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"tg2ai": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": [
|
|
30
|
+
"-y",
|
|
31
|
+
"tg2ai-mcp@latest",
|
|
32
|
+
"--url=https://your-api-gateway.com/api/mcp",
|
|
33
|
+
"--token=YOUR_SECURE_HMAC_TOKEN"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Cursor IDE / Windsurf Configuration
|
|
41
|
+
|
|
42
|
+
Add a new MCP server in your IDE settings:
|
|
43
|
+
* **Name:** `tg2ai`
|
|
44
|
+
* **Type:** `command`
|
|
45
|
+
* **Command:**
|
|
46
|
+
```bash
|
|
47
|
+
npx -y tg2ai-mcp@latest --url=https://your-api-gateway.com/api/mcp --token=YOUR_SECURE_HMAC_TOKEN
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## š Security & Privacy
|
|
53
|
+
|
|
54
|
+
This client is a simple transparent proxy bridge. It does not contain any business logic, scraping algorithms, database connections, or secret keys. It simply pipes JSON-RPC messages between your local IDE and your private TG2AI API server securely over HTTPS.
|
|
55
|
+
|
|
56
|
+
`Find the Delta. Close the Gap. ./GĪP 2026`
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tg2ai-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TG2AI Commercial Remote MCP Bridge Client",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": "./src/index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node src/index.js",
|
|
11
|
+
"dev": "node src/index.js"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {}
|
|
14
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import http from "http";
|
|
3
|
+
import https from "https";
|
|
4
|
+
import readline from "readline";
|
|
5
|
+
import { URL } from "url";
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// Parse arguments
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const urlArg = args.find(arg => arg.startsWith("--url="))?.split("=")[1];
|
|
12
|
+
const tokenArg = args.find(arg => arg.startsWith("--token="))?.split("=")[1];
|
|
13
|
+
|
|
14
|
+
if (!urlArg || !tokenArg) {
|
|
15
|
+
console.error("\n========================================================");
|
|
16
|
+
console.error("ā TG2AI Commercial Remote MCP Bridge Client Error");
|
|
17
|
+
console.error("========================================================");
|
|
18
|
+
console.error("This package requires '--url' and '--token' parameters to function.");
|
|
19
|
+
console.error("\nš How to configure in Claude Desktop (claude_desktop_config.json):");
|
|
20
|
+
console.error(JSON.stringify({
|
|
21
|
+
mcpServers: {
|
|
22
|
+
tg2ai: {
|
|
23
|
+
command: "npx",
|
|
24
|
+
args: [
|
|
25
|
+
"-y",
|
|
26
|
+
"tg2ai-mcp@latest",
|
|
27
|
+
"--url=https://your-render-app.onrender.com/api/mcp",
|
|
28
|
+
"--token=YOUR_GENERATED_TOKEN"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, null, 2));
|
|
33
|
+
console.error("\nš How to configure in Cursor IDE (stdio mode command):");
|
|
34
|
+
console.error("npx -y tg2ai-mcp@latest --url=https://your-render-app.onrender.com/api/mcp --token=YOUR_GENERATED_TOKEN");
|
|
35
|
+
console.error("========================================================\n");
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// =========================================================================
|
|
40
|
+
// Pure high-performance Stdio-to-SSE HTTP Proxy Bridge (Zero-Dependencies)
|
|
41
|
+
// =========================================================================
|
|
42
|
+
console.error(`[Bridge] Connecting to remote TG2AI API Gateway at ${urlArg}...`);
|
|
43
|
+
|
|
44
|
+
const urlObj = new URL(urlArg);
|
|
45
|
+
urlObj.searchParams.set("token", tokenArg);
|
|
46
|
+
|
|
47
|
+
const clientModule = urlObj.protocol === "https:" ? https : http;
|
|
48
|
+
let postUrlPath = "";
|
|
49
|
+
|
|
50
|
+
// 1. Establish long-lived Server-Sent Events stream connection
|
|
51
|
+
const sseReq = clientModule.get(urlObj.toString(), {
|
|
52
|
+
headers: {
|
|
53
|
+
"Accept": "text/event-stream",
|
|
54
|
+
"Cache-Control": "no-cache",
|
|
55
|
+
"Connection": "keep-alive"
|
|
56
|
+
}
|
|
57
|
+
}, (res) => {
|
|
58
|
+
let buffer = "";
|
|
59
|
+
res.setEncoding("utf-8");
|
|
60
|
+
res.on("data", (chunk) => {
|
|
61
|
+
buffer += chunk;
|
|
62
|
+
const lines = buffer.split("\n");
|
|
63
|
+
buffer = lines.pop() || "";
|
|
64
|
+
|
|
65
|
+
let currentEvent = "";
|
|
66
|
+
for (const line of lines) {
|
|
67
|
+
if (line.startsWith("event: ")) {
|
|
68
|
+
currentEvent = line.slice(7).trim();
|
|
69
|
+
} else if (line.startsWith("data: ")) {
|
|
70
|
+
const dataStr = line.slice(6).trim();
|
|
71
|
+
if (currentEvent === "endpoint") {
|
|
72
|
+
// Extracted POST destination endpoint
|
|
73
|
+
postUrlPath = dataStr;
|
|
74
|
+
console.error(`[Bridge] Connected successfully! Remote session established.`);
|
|
75
|
+
} else if (currentEvent === "message") {
|
|
76
|
+
// Forward remote JSON-RPC responses directly to Claude Desktop stdout
|
|
77
|
+
process.stdout.write(dataStr + "\n");
|
|
78
|
+
}
|
|
79
|
+
} else if (line.trim() === "") {
|
|
80
|
+
currentEvent = "";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
res.on("end", () => {
|
|
86
|
+
console.error("[Bridge] Remote SSE connection closed.");
|
|
87
|
+
process.exit(0);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
sseReq.on("error", (err) => {
|
|
92
|
+
console.error(`[Bridge] Remote SSE Connection Error: ${err.message}`);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// 2. Read JSON-RPC requests from Claude Desktop stdin and POST them to Render
|
|
97
|
+
const rl = readline.createInterface({
|
|
98
|
+
input: process.stdin,
|
|
99
|
+
output: process.stdout,
|
|
100
|
+
terminal: false
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
rl.on("line", (line) => {
|
|
104
|
+
if (!line.trim()) return;
|
|
105
|
+
|
|
106
|
+
// Pause processing stdin line until SSE handshake establishes postUrlPath
|
|
107
|
+
if (!postUrlPath) {
|
|
108
|
+
setTimeout(() => rl.emit("line", line), 100);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const postUrl = new URL(postUrlPath, urlArg);
|
|
113
|
+
const postReq = clientModule.request(postUrl.toString(), {
|
|
114
|
+
method: "POST",
|
|
115
|
+
headers: {
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
"Content-Length": Buffer.byteLength(line)
|
|
118
|
+
}
|
|
119
|
+
}, (res) => {
|
|
120
|
+
// Consume response stream
|
|
121
|
+
res.on("data", () => {});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
postReq.on("error", (err) => {
|
|
125
|
+
console.error(`[Bridge] POST request failed: ${err.message}`);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
postReq.write(line);
|
|
129
|
+
postReq.end();
|
|
130
|
+
});
|