@salesforcebob/remote-mcp-bridge 1.0.2 → 1.0.3
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/dist/index.js +17 -7
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.d.ts +30 -6
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +204 -27
- package/dist/mcp-server.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -11,11 +11,15 @@ function loadConfig() {
|
|
|
11
11
|
if (!tunnelUrl) {
|
|
12
12
|
throw new Error('TUNNEL_URL environment variable is required (e.g. "https://mcp-bridge.yourdomain.com")');
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
// Transport mode: stdio if --stdio flag or MCP_TRANSPORT=stdio, else HTTP
|
|
15
|
+
const useStdio = process.argv.includes('--stdio') || process.env.MCP_TRANSPORT === 'stdio';
|
|
16
|
+
const port = useStdio ? undefined : parseInt(process.env.MCP_PORT || '3200', 10);
|
|
17
|
+
return { privateKey, tunnelUrl, port };
|
|
15
18
|
}
|
|
16
19
|
async function main() {
|
|
17
|
-
console.error('=== MCP Bridge — Remote Server (stdio) ===\n');
|
|
18
20
|
const config = loadConfig();
|
|
21
|
+
const mode = config.port ? `HTTP on port ${config.port}` : 'stdio';
|
|
22
|
+
console.error(`=== MCP Bridge — Remote Server (${mode}) ===\n`);
|
|
19
23
|
// Derive the public address from the private key for display
|
|
20
24
|
const wallet = new Wallet(config.privateKey);
|
|
21
25
|
console.error(`Signing address: ${wallet.address}`);
|
|
@@ -38,13 +42,13 @@ async function main() {
|
|
|
38
42
|
const msg = err instanceof Error ? err.message : 'Unknown error';
|
|
39
43
|
console.error(`[Main] Failed to connect to local server: ${msg}`);
|
|
40
44
|
console.error('\nMake sure:');
|
|
41
|
-
console.error(' 1. The local server is running
|
|
45
|
+
console.error(' 1. The local server is running');
|
|
42
46
|
console.error(` 2. Tunnel URL (${config.tunnelUrl}) is correct and the tunnel is active`);
|
|
43
47
|
console.error('');
|
|
44
48
|
process.exit(1);
|
|
45
49
|
}
|
|
46
|
-
// 2. Create the MCP server
|
|
47
|
-
const mcpServer = new RemoteMcpServer({ wsClient });
|
|
50
|
+
// 2. Create the MCP server (with optional port for HTTP mode)
|
|
51
|
+
const mcpServer = new RemoteMcpServer({ wsClient, port: config.port });
|
|
48
52
|
// 3. Discover tools from the local server and register them
|
|
49
53
|
try {
|
|
50
54
|
await mcpServer.discoverAndRegisterTools();
|
|
@@ -54,9 +58,15 @@ async function main() {
|
|
|
54
58
|
console.error(`[Main] Failed to discover tools: ${msg}`);
|
|
55
59
|
process.exit(1);
|
|
56
60
|
}
|
|
57
|
-
// 4. Start serving MCP requests
|
|
61
|
+
// 4. Start serving MCP requests
|
|
58
62
|
await mcpServer.start();
|
|
59
|
-
|
|
63
|
+
if (config.port) {
|
|
64
|
+
console.error(`\n=== Remote MCP Server is running (${mode}) ===`);
|
|
65
|
+
console.error(`MCP endpoint: http://localhost:${config.port}/mcp\n`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.error(`\n=== Remote MCP Server is running (stdio) ===\n`);
|
|
69
|
+
}
|
|
60
70
|
// Graceful shutdown
|
|
61
71
|
const shutdown = async () => {
|
|
62
72
|
console.error('\nShutting down...');
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,SAAS,UAAU;IACjB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAC3C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CA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C,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/mcp-server.d.ts
CHANGED
|
@@ -1,29 +1,53 @@
|
|
|
1
1
|
import type { BridgeWsClient } from './ws-client.js';
|
|
2
2
|
export interface McpServerConfig {
|
|
3
3
|
wsClient: BridgeWsClient;
|
|
4
|
+
/** If set, start an HTTP server on this port instead of stdio */
|
|
5
|
+
port?: number;
|
|
4
6
|
}
|
|
5
7
|
/**
|
|
6
|
-
* Remote MCP server that exposes browser tools
|
|
7
|
-
*
|
|
8
|
+
* Remote MCP server that exposes browser tools.
|
|
9
|
+
* Supports both stdio transport (for npx usage) and HTTP transport (for URL-based clients).
|
|
8
10
|
*
|
|
9
|
-
*
|
|
11
|
+
* - stdio: single McpServer + StdioServerTransport
|
|
12
|
+
* - HTTP: per-session McpServer + StreamableHTTPServerTransport (stateful)
|
|
10
13
|
*/
|
|
11
14
|
export declare class RemoteMcpServer {
|
|
12
15
|
private config;
|
|
13
16
|
private mcpServer;
|
|
14
|
-
private transport;
|
|
15
17
|
private discoveredTools;
|
|
18
|
+
private httpServer;
|
|
19
|
+
private transports;
|
|
16
20
|
constructor(config: McpServerConfig);
|
|
21
|
+
/**
|
|
22
|
+
* Create a new McpServer instance with all discovered tools registered.
|
|
23
|
+
*/
|
|
24
|
+
private createMcpServer;
|
|
17
25
|
/**
|
|
18
26
|
* Discover tools from the local server and register them on the MCP server.
|
|
19
27
|
*/
|
|
20
28
|
discoverAndRegisterTools(): Promise<void>;
|
|
21
29
|
/**
|
|
22
|
-
* Start the MCP server with
|
|
30
|
+
* Start the MCP server with the appropriate transport.
|
|
23
31
|
*/
|
|
24
32
|
start(): Promise<void>;
|
|
25
33
|
/**
|
|
26
|
-
*
|
|
34
|
+
* Start with stdio transport (for npx / CLI usage).
|
|
35
|
+
*/
|
|
36
|
+
private startStdio;
|
|
37
|
+
/**
|
|
38
|
+
* Start with HTTP transport (for URL-based MCP clients).
|
|
39
|
+
* Uses stateful sessions — each client gets its own transport.
|
|
40
|
+
*/
|
|
41
|
+
private startHttp;
|
|
42
|
+
/**
|
|
43
|
+
* Parse the request body as JSON.
|
|
44
|
+
*/
|
|
45
|
+
private parseBody;
|
|
46
|
+
private handleHttpPost;
|
|
47
|
+
private handleHttpGet;
|
|
48
|
+
private handleHttpDelete;
|
|
49
|
+
/**
|
|
50
|
+
* Shut down the MCP server and all transports.
|
|
27
51
|
*/
|
|
28
52
|
stop(): Promise<void>;
|
|
29
53
|
}
|
package/dist/mcp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmDD;;;;;;GAMG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,SAAS,CAA0B;IAC3C,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,UAAU,CAAgD;IAClE,OAAO,CAAC,UAAU,CAAyD;gBAE/D,MAAM,EAAE,eAAe;IAInC;;OAEG;IACH,OAAO,CAAC,eAAe;IAsCvB;;OAEG;IACG,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/C;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;OAEG;YACW,UAAU;IAOxB;;;OAGG;YACW,SAAS;IA4CvB;;OAEG;IACH,OAAO,CAAC,SAAS;YAeH,cAAc;YAyDd,aAAa;YAWb,gBAAgB;IAW9B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAyB5B"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
4
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { createServer } from 'node:http';
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
3
7
|
import { z } from 'zod';
|
|
4
8
|
/**
|
|
5
9
|
* Convert a JSON Schema object (from the tool's inputSchema) to a Zod schema.
|
|
@@ -43,40 +47,34 @@ function jsonSchemaToZod(schema) {
|
|
|
43
47
|
return z.any();
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
46
|
-
* Remote MCP server that exposes browser tools
|
|
47
|
-
*
|
|
50
|
+
* Remote MCP server that exposes browser tools.
|
|
51
|
+
* Supports both stdio transport (for npx usage) and HTTP transport (for URL-based clients).
|
|
48
52
|
*
|
|
49
|
-
*
|
|
53
|
+
* - stdio: single McpServer + StdioServerTransport
|
|
54
|
+
* - HTTP: per-session McpServer + StreamableHTTPServerTransport (stateful)
|
|
50
55
|
*/
|
|
51
56
|
export class RemoteMcpServer {
|
|
52
57
|
config;
|
|
53
|
-
mcpServer;
|
|
54
|
-
transport = null;
|
|
58
|
+
mcpServer = null;
|
|
55
59
|
discoveredTools = [];
|
|
60
|
+
httpServer = null;
|
|
61
|
+
transports = new Map();
|
|
56
62
|
constructor(config) {
|
|
57
63
|
this.config = config;
|
|
58
|
-
this.mcpServer = new McpServer({
|
|
59
|
-
name: 'remote-mcp-bridge',
|
|
60
|
-
version: '1.0.0',
|
|
61
|
-
});
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
|
-
*
|
|
66
|
+
* Create a new McpServer instance with all discovered tools registered.
|
|
65
67
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const result = response.result;
|
|
73
|
-
this.discoveredTools = result.tools;
|
|
74
|
-
console.error(`[McpServer] Discovered ${this.discoveredTools.length} tools`);
|
|
75
|
-
// Register each tool on the MCP server
|
|
68
|
+
createMcpServer() {
|
|
69
|
+
const server = new McpServer({
|
|
70
|
+
name: 'remote-mcp-bridge',
|
|
71
|
+
version: '1.0.0',
|
|
72
|
+
});
|
|
73
|
+
// Register each discovered tool
|
|
76
74
|
for (const tool of this.discoveredTools) {
|
|
77
75
|
const inputSchema = (tool.inputSchema || { type: 'object', properties: {} });
|
|
78
76
|
const zodSchema = jsonSchemaToZod(inputSchema);
|
|
79
|
-
|
|
77
|
+
server.tool(tool.name, tool.description || '', zodSchema instanceof z.ZodObject ? zodSchema.shape : {}, async (args) => {
|
|
80
78
|
console.error(`[McpServer] Proxying tool call: ${tool.name}`);
|
|
81
79
|
const wsResponse = await this.config.wsClient.sendRequest('tools/call', {
|
|
82
80
|
name: tool.name,
|
|
@@ -91,21 +89,200 @@ export class RemoteMcpServer {
|
|
|
91
89
|
return wsResponse.result;
|
|
92
90
|
});
|
|
93
91
|
}
|
|
94
|
-
|
|
92
|
+
return server;
|
|
95
93
|
}
|
|
96
94
|
/**
|
|
97
|
-
*
|
|
95
|
+
* Discover tools from the local server and register them on the MCP server.
|
|
96
|
+
*/
|
|
97
|
+
async discoverAndRegisterTools() {
|
|
98
|
+
console.error('[McpServer] Discovering tools from local server...');
|
|
99
|
+
const response = await this.config.wsClient.sendRequest('tools/list');
|
|
100
|
+
if (response.error) {
|
|
101
|
+
throw new Error(`tools/list failed: ${response.error.message}`);
|
|
102
|
+
}
|
|
103
|
+
const result = response.result;
|
|
104
|
+
this.discoveredTools = result.tools;
|
|
105
|
+
console.error(`[McpServer] Discovered ${this.discoveredTools.length} tools`);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Start the MCP server with the appropriate transport.
|
|
98
109
|
*/
|
|
99
110
|
async start() {
|
|
100
|
-
this.
|
|
101
|
-
|
|
111
|
+
if (this.config.port) {
|
|
112
|
+
await this.startHttp();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
await this.startStdio();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Start with stdio transport (for npx / CLI usage).
|
|
120
|
+
*/
|
|
121
|
+
async startStdio() {
|
|
122
|
+
this.mcpServer = this.createMcpServer();
|
|
123
|
+
const transport = new StdioServerTransport();
|
|
124
|
+
await this.mcpServer.connect(transport);
|
|
102
125
|
console.error('[McpServer] Connected to stdio transport');
|
|
103
126
|
}
|
|
104
127
|
/**
|
|
105
|
-
*
|
|
128
|
+
* Start with HTTP transport (for URL-based MCP clients).
|
|
129
|
+
* Uses stateful sessions — each client gets its own transport.
|
|
130
|
+
*/
|
|
131
|
+
async startHttp() {
|
|
132
|
+
const port = this.config.port;
|
|
133
|
+
this.httpServer = createServer(async (req, res) => {
|
|
134
|
+
// CORS headers for browser-based clients
|
|
135
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
136
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
|
|
137
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, mcp-session-id, Last-Event-ID');
|
|
138
|
+
res.setHeader('Access-Control-Expose-Headers', 'mcp-session-id');
|
|
139
|
+
if (req.method === 'OPTIONS') {
|
|
140
|
+
res.writeHead(204);
|
|
141
|
+
res.end();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
// Only handle /mcp path
|
|
145
|
+
const url = new URL(req.url || '/', `http://localhost:${port}`);
|
|
146
|
+
if (url.pathname !== '/mcp') {
|
|
147
|
+
res.writeHead(404);
|
|
148
|
+
res.end('Not found');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (req.method === 'GET') {
|
|
152
|
+
await this.handleHttpGet(req, res);
|
|
153
|
+
}
|
|
154
|
+
else if (req.method === 'POST') {
|
|
155
|
+
await this.handleHttpPost(req, res);
|
|
156
|
+
}
|
|
157
|
+
else if (req.method === 'DELETE') {
|
|
158
|
+
await this.handleHttpDelete(req, res);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
res.writeHead(405);
|
|
162
|
+
res.end('Method not allowed');
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
return new Promise((resolve) => {
|
|
166
|
+
this.httpServer.listen(port, '0.0.0.0', () => {
|
|
167
|
+
console.error(`[McpServer] HTTP server listening on http://0.0.0.0:${port}/mcp`);
|
|
168
|
+
resolve();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Parse the request body as JSON.
|
|
174
|
+
*/
|
|
175
|
+
parseBody(req) {
|
|
176
|
+
return new Promise((resolve, reject) => {
|
|
177
|
+
let body = '';
|
|
178
|
+
req.on('data', (chunk) => { body += chunk; });
|
|
179
|
+
req.on('end', () => {
|
|
180
|
+
try {
|
|
181
|
+
resolve(body ? JSON.parse(body) : undefined);
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
reject(new Error('Invalid JSON'));
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
req.on('error', reject);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async handleHttpPost(req, res) {
|
|
191
|
+
try {
|
|
192
|
+
const body = await this.parseBody(req);
|
|
193
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
194
|
+
if (sessionId && this.transports.has(sessionId)) {
|
|
195
|
+
// Existing session
|
|
196
|
+
const transport = this.transports.get(sessionId);
|
|
197
|
+
await transport.handleRequest(req, res, body);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (!sessionId && isInitializeRequest(body)) {
|
|
201
|
+
// New session — create a fresh McpServer + transport pair
|
|
202
|
+
const transport = new StreamableHTTPServerTransport({
|
|
203
|
+
sessionIdGenerator: () => randomUUID(),
|
|
204
|
+
onsessioninitialized: (sid) => {
|
|
205
|
+
console.error(`[McpServer] HTTP session initialized: ${sid}`);
|
|
206
|
+
this.transports.set(sid, transport);
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
transport.onclose = () => {
|
|
210
|
+
const sid = transport.sessionId;
|
|
211
|
+
if (sid && this.transports.has(sid)) {
|
|
212
|
+
console.error(`[McpServer] HTTP session closed: ${sid}`);
|
|
213
|
+
this.transports.delete(sid);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
// Each session gets its own McpServer with all tools registered
|
|
217
|
+
const server = this.createMcpServer();
|
|
218
|
+
await server.connect(transport);
|
|
219
|
+
await transport.handleRequest(req, res, body);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// Invalid request
|
|
223
|
+
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
224
|
+
res.end(JSON.stringify({
|
|
225
|
+
jsonrpc: '2.0',
|
|
226
|
+
error: { code: -32000, message: 'Bad Request: No valid session ID provided' },
|
|
227
|
+
id: null,
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
console.error('[McpServer] HTTP POST error:', err);
|
|
232
|
+
if (!res.headersSent) {
|
|
233
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
234
|
+
res.end(JSON.stringify({
|
|
235
|
+
jsonrpc: '2.0',
|
|
236
|
+
error: { code: -32603, message: 'Internal server error' },
|
|
237
|
+
id: null,
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
async handleHttpGet(req, res) {
|
|
243
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
244
|
+
if (!sessionId || !this.transports.has(sessionId)) {
|
|
245
|
+
res.writeHead(400);
|
|
246
|
+
res.end('Invalid or missing session ID');
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const transport = this.transports.get(sessionId);
|
|
250
|
+
await transport.handleRequest(req, res);
|
|
251
|
+
}
|
|
252
|
+
async handleHttpDelete(req, res) {
|
|
253
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
254
|
+
if (!sessionId || !this.transports.has(sessionId)) {
|
|
255
|
+
res.writeHead(400);
|
|
256
|
+
res.end('Invalid or missing session ID');
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const transport = this.transports.get(sessionId);
|
|
260
|
+
await transport.handleRequest(req, res);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Shut down the MCP server and all transports.
|
|
106
264
|
*/
|
|
107
265
|
async stop() {
|
|
108
|
-
|
|
266
|
+
// Close stdio server if running
|
|
267
|
+
if (this.mcpServer) {
|
|
268
|
+
await this.mcpServer.close();
|
|
269
|
+
}
|
|
270
|
+
// Close all HTTP session transports
|
|
271
|
+
for (const [sid, transport] of this.transports) {
|
|
272
|
+
try {
|
|
273
|
+
await transport.close();
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Ignore close errors
|
|
277
|
+
}
|
|
278
|
+
this.transports.delete(sid);
|
|
279
|
+
}
|
|
280
|
+
// Close HTTP server
|
|
281
|
+
if (this.httpServer) {
|
|
282
|
+
await new Promise((resolve) => {
|
|
283
|
+
this.httpServer.close(() => resolve());
|
|
284
|
+
});
|
|
285
|
+
}
|
|
109
286
|
console.error('[McpServer] Stopped');
|
|
110
287
|
}
|
|
111
288
|
}
|
package/dist/mcp-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","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AED,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACvC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcebob/remote-mcp-bridge",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Secure MCP bridge for remote browser control via WebSocket + ethers.js signing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "tsc",
|
|
18
18
|
"dev": "node --env-file=.env --import tsx/esm src/index.ts",
|
|
19
|
+
"dev:stdio": "MCP_TRANSPORT=stdio node --env-file=.env --import tsx/esm src/index.ts",
|
|
19
20
|
"start": "node dist/index.js",
|
|
20
21
|
"prepublishOnly": "npm run build"
|
|
21
22
|
},
|