@bigimpact/workspace-mcp 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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const readline = __importStar(require("readline"));
38
+ const ENDPOINT = "https://us-central1-studio-manager-c68eb.cloudfunctions.net/workspaceIntegrationsMCP";
39
+ const USER_ID = process.env.WORKSPACE_USER_ID;
40
+ if (!USER_ID) {
41
+ process.stderr.write("ERROR: WORKSPACE_USER_ID environment variable is required.\n");
42
+ process.exit(1);
43
+ }
44
+ const rl = readline.createInterface({ input: process.stdin, terminal: false });
45
+ let inFlight = 0;
46
+ let inputClosed = false;
47
+ function send(response) {
48
+ process.stdout.write(JSON.stringify(response) + "\n");
49
+ }
50
+ function sendError(id, code, message) {
51
+ send({ jsonrpc: "2.0", id, error: { code, message } });
52
+ }
53
+ function maybeExit() {
54
+ if (inputClosed && inFlight === 0)
55
+ process.exit(0);
56
+ }
57
+ function handleInitialize(id) {
58
+ send({
59
+ jsonrpc: "2.0",
60
+ id,
61
+ result: {
62
+ protocolVersion: "2024-11-05",
63
+ capabilities: { tools: {} },
64
+ serverInfo: { name: "workspace-mcp", version: "1.0.0" },
65
+ },
66
+ });
67
+ }
68
+ async function forward(request) {
69
+ inFlight++;
70
+ let body = {
71
+ jsonrpc: "2.0",
72
+ id: request.id,
73
+ method: request.method,
74
+ params: request.params,
75
+ };
76
+ if (request.method === "tools/call" && request.params) {
77
+ const args = request.params.arguments ?? {};
78
+ body = {
79
+ jsonrpc: "2.0",
80
+ id: request.id,
81
+ method: request.method,
82
+ params: { ...request.params, arguments: { ...args, userId: USER_ID } },
83
+ };
84
+ }
85
+ try {
86
+ process.stderr.write("forwarding to cloud function...\n");
87
+ const res = await fetch(ENDPOINT, {
88
+ method: "POST",
89
+ headers: { "Content-Type": "application/json" },
90
+ body: JSON.stringify(body),
91
+ });
92
+ process.stderr.write("got response: " + res.status + "\n");
93
+ if (!res.ok) {
94
+ const text = await res.text().catch(() => "");
95
+ sendError(request.id, -32000, `Cloud Function returned ${res.status}: ${text}`);
96
+ }
97
+ else {
98
+ const data = (await res.json());
99
+ send({ ...data, id: request.id });
100
+ }
101
+ }
102
+ catch (err) {
103
+ const message = err instanceof Error ? err.message : "Unknown fetch error";
104
+ process.stderr.write("fetch error: " + message + "\n");
105
+ sendError(request.id, -32000, `Fetch failed: ${message}`);
106
+ }
107
+ finally {
108
+ inFlight--;
109
+ maybeExit();
110
+ }
111
+ }
112
+ rl.on("line", (line) => {
113
+ const trimmed = line.trim();
114
+ if (!trimmed)
115
+ return;
116
+ process.stderr.write("got line: " + trimmed.substring(0, 50) + "\n");
117
+ let request;
118
+ try {
119
+ request = JSON.parse(trimmed);
120
+ }
121
+ catch {
122
+ sendError(null, -32700, "Parse error");
123
+ return;
124
+ }
125
+ if (!request.method) {
126
+ sendError(request.id, -32600, "Invalid request");
127
+ return;
128
+ }
129
+ if (request.method === "initialize") {
130
+ handleInitialize(request.id);
131
+ return;
132
+ }
133
+ if (request.method === "notifications/initialized") {
134
+ return;
135
+ }
136
+ if (request.method === "tools/list" || request.method === "tools/call") {
137
+ forward(request).catch((err) => {
138
+ sendError(request.id, -32000, err instanceof Error ? err.message : "Unknown error");
139
+ });
140
+ return;
141
+ }
142
+ sendError(request.id, -32601, `Method not found: ${request.method}`);
143
+ });
144
+ rl.on("close", () => {
145
+ process.stderr.write("stdin closed\n");
146
+ inputClosed = true;
147
+ maybeExit();
148
+ });
149
+ process.stderr.write("workspace-mcp: ready\n");
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@bigimpact/workspace-mcp",
3
+ "version": "1.0.0",
4
+ "description": "Stdio MCP wrapper that proxies workspace integration tools to the Cloud Function endpoint",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "workspace-mcp": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "start": "node dist/index.js"
12
+ },
13
+ "dependencies": {},
14
+ "devDependencies": {
15
+ "@types/node": "^20.11.0",
16
+ "typescript": "^5.3.0"
17
+ },
18
+ "engines": {
19
+ "node": ">=18"
20
+ }
21
+ }
22
+
23
+
package/test.json ADDED
@@ -0,0 +1 @@
1
+ {"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}