crewly 1.20.247 → 1.20.248

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.
Files changed (64) hide show
  1. package/dist/backend/backend/src/constants.d.ts +31 -0
  2. package/dist/backend/backend/src/constants.d.ts.map +1 -1
  3. package/dist/backend/backend/src/constants.js +31 -0
  4. package/dist/backend/backend/src/constants.js.map +1 -1
  5. package/dist/backend/backend/src/controllers/connector/connector.controller.d.ts +1 -0
  6. package/dist/backend/backend/src/controllers/connector/connector.controller.d.ts.map +1 -1
  7. package/dist/backend/backend/src/controllers/connector/connector.controller.js +7 -0
  8. package/dist/backend/backend/src/controllers/connector/connector.controller.js.map +1 -1
  9. package/dist/backend/backend/src/controllers/connector/connector.routes.d.ts +1 -0
  10. package/dist/backend/backend/src/controllers/connector/connector.routes.d.ts.map +1 -1
  11. package/dist/backend/backend/src/controllers/connector/connector.routes.js +7 -0
  12. package/dist/backend/backend/src/controllers/connector/connector.routes.js.map +1 -1
  13. package/dist/backend/backend/src/controllers/connector/remote-mcp.controller.d.ts +55 -0
  14. package/dist/backend/backend/src/controllers/connector/remote-mcp.controller.d.ts.map +1 -0
  15. package/dist/backend/backend/src/controllers/connector/remote-mcp.controller.js +148 -0
  16. package/dist/backend/backend/src/controllers/connector/remote-mcp.controller.js.map +1 -0
  17. package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
  18. package/dist/backend/backend/src/services/agent/agent-registration.service.js +5 -0
  19. package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
  20. package/dist/backend/backend/src/services/connector/connector-access.service.d.ts +8 -0
  21. package/dist/backend/backend/src/services/connector/connector-access.service.d.ts.map +1 -1
  22. package/dist/backend/backend/src/services/connector/connector-access.service.js +17 -0
  23. package/dist/backend/backend/src/services/connector/connector-access.service.js.map +1 -1
  24. package/dist/backend/backend/src/services/connector/remote-mcp-launch.service.d.ts +77 -0
  25. package/dist/backend/backend/src/services/connector/remote-mcp-launch.service.d.ts.map +1 -0
  26. package/dist/backend/backend/src/services/connector/remote-mcp-launch.service.js +132 -0
  27. package/dist/backend/backend/src/services/connector/remote-mcp-launch.service.js.map +1 -0
  28. package/dist/backend/backend/src/services/connector/remote-mcp-probe.service.d.ts +75 -0
  29. package/dist/backend/backend/src/services/connector/remote-mcp-probe.service.d.ts.map +1 -0
  30. package/dist/backend/backend/src/services/connector/remote-mcp-probe.service.js +155 -0
  31. package/dist/backend/backend/src/services/connector/remote-mcp-probe.service.js.map +1 -0
  32. package/dist/backend/backend/src/services/connector/remote-mcp.service.d.ts +192 -0
  33. package/dist/backend/backend/src/services/connector/remote-mcp.service.d.ts.map +1 -0
  34. package/dist/backend/backend/src/services/connector/remote-mcp.service.js +334 -0
  35. package/dist/backend/backend/src/services/connector/remote-mcp.service.js.map +1 -0
  36. package/dist/backend/backend/src/services/core/credential-files.d.ts.map +1 -1
  37. package/dist/backend/backend/src/services/core/credential-files.js +4 -1
  38. package/dist/backend/backend/src/services/core/credential-files.js.map +1 -1
  39. package/dist/backend/build-info.json +2 -2
  40. package/dist/cli/backend/src/constants.d.ts +31 -0
  41. package/dist/cli/backend/src/constants.d.ts.map +1 -1
  42. package/dist/cli/backend/src/constants.js +31 -0
  43. package/dist/cli/backend/src/constants.js.map +1 -1
  44. package/dist/cli/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
  45. package/dist/cli/backend/src/services/agent/agent-registration.service.js +5 -0
  46. package/dist/cli/backend/src/services/agent/agent-registration.service.js.map +1 -1
  47. package/dist/cli/backend/src/services/connector/connector-access.service.d.ts +85 -0
  48. package/dist/cli/backend/src/services/connector/connector-access.service.d.ts.map +1 -0
  49. package/dist/cli/backend/src/services/connector/connector-access.service.js +130 -0
  50. package/dist/cli/backend/src/services/connector/connector-access.service.js.map +1 -0
  51. package/dist/cli/backend/src/services/connector/remote-mcp-launch.service.d.ts +77 -0
  52. package/dist/cli/backend/src/services/connector/remote-mcp-launch.service.d.ts.map +1 -0
  53. package/dist/cli/backend/src/services/connector/remote-mcp-launch.service.js +132 -0
  54. package/dist/cli/backend/src/services/connector/remote-mcp-launch.service.js.map +1 -0
  55. package/dist/cli/backend/src/services/connector/remote-mcp.service.d.ts +192 -0
  56. package/dist/cli/backend/src/services/connector/remote-mcp.service.d.ts.map +1 -0
  57. package/dist/cli/backend/src/services/connector/remote-mcp.service.js +334 -0
  58. package/dist/cli/backend/src/services/connector/remote-mcp.service.js.map +1 -0
  59. package/dist/cli/backend/src/services/core/credential-files.d.ts.map +1 -1
  60. package/dist/cli/backend/src/services/core/credential-files.js +4 -1
  61. package/dist/cli/backend/src/services/core/credential-files.js.map +1 -1
  62. package/frontend/dist/assets/{index-c9630c55.js → index-8f4d482e.js} +277 -277
  63. package/frontend/dist/index.html +1 -1
  64. package/package.json +1 -1
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Remote MCP servers — streamable-HTTP MCP servers the owner connects once
3
+ * (Zoho MCP first, any other server the same way) and Crewly hands to every
4
+ * agent whose role may use them.
5
+ *
6
+ * Stored at `<CREWLY_HOME>/remote-mcp-servers.json` with mode 0600. The URL
7
+ * (Zoho's carries the server's API key) and any headers are secrets: they
8
+ * are never logged, never returned in full by {@link toView}, and never
9
+ * written into a project directory (a project `.mcp.json` would be
10
+ * committed). Agents get them through per-session files under CREWLY_HOME
11
+ * (see remote-mcp-launch.service).
12
+ *
13
+ * Each server is a gated connector `mcp:<id>` in
14
+ * {@link ConnectorAccessService}: open to every agent until the owner picks
15
+ * roles.
16
+ *
17
+ * @module services/connector/remote-mcp.service
18
+ */
19
+ import { ConnectorAccessService } from './connector-access.service.js';
20
+ /** Catalog preset a server was added from. */
21
+ export type RemoteMcpProvider = 'zoho' | 'custom';
22
+ /** One stored server (secrets included — never send this to a client). */
23
+ export interface RemoteMcpServer {
24
+ /** Stable id; also the MCP server name agents see and the `mcp:<id>` access key. */
25
+ id: string;
26
+ /** Owner-facing name. */
27
+ label: string;
28
+ /** Streamable-HTTP endpoint (secret). */
29
+ url: string;
30
+ /** Extra request headers (secret values). */
31
+ headers?: Record<string, string>;
32
+ /** Catalog preset. */
33
+ provider?: RemoteMcpProvider;
34
+ /** ISO time it was added. */
35
+ createdAt: string;
36
+ }
37
+ /** What the API returns: no secrets. */
38
+ export interface RemoteMcpServerView {
39
+ id: string;
40
+ label: string;
41
+ provider: RemoteMcpProvider;
42
+ /** Scheme + host only, e.g. `https://crm-123.zohomcp.com/…`. */
43
+ urlMasked: string;
44
+ /** Header names (values withheld). */
45
+ headerNames: string[];
46
+ createdAt: string;
47
+ /** Key of its role allowlist in connector access. */
48
+ connectorId: string;
49
+ }
50
+ /** Input for {@link RemoteMcpService.add}. */
51
+ export interface AddRemoteMcpInput {
52
+ label: string;
53
+ url: string;
54
+ headers?: Record<string, string>;
55
+ provider?: string;
56
+ }
57
+ /** A validation failure the API turns into a 400. */
58
+ export declare class RemoteMcpValidationError extends Error {
59
+ constructor(message: string);
60
+ }
61
+ /**
62
+ * The connector-access id of a server.
63
+ *
64
+ * @param id - Server id
65
+ * @returns `mcp:<id>`
66
+ */
67
+ export declare function remoteMcpConnectorId(id: string): string;
68
+ /**
69
+ * Show a URL without its secret parts: scheme and host only.
70
+ *
71
+ * @param url - Stored URL
72
+ * @returns e.g. `https://crm-123.zohomcp.com/…`, or `(hidden)` when it does not parse
73
+ */
74
+ export declare function maskRemoteMcpUrl(url: string): string;
75
+ /**
76
+ * Validate a server URL: https (http only for localhost), no whitespace,
77
+ * quotes or backslashes (it is embedded in launch files), bounded length.
78
+ *
79
+ * @param raw - Pasted URL
80
+ * @returns The trimmed URL
81
+ * @throws RemoteMcpValidationError when it is not usable (message never echoes the URL)
82
+ */
83
+ export declare function validateRemoteMcpUrl(raw: unknown): string;
84
+ /**
85
+ * Validate optional headers: token-shaped names, single-line values.
86
+ *
87
+ * @param raw - Headers object or undefined
88
+ * @returns Clean headers, or undefined when none
89
+ * @throws RemoteMcpValidationError on a bad name or value
90
+ */
91
+ export declare function validateRemoteMcpHeaders(raw: unknown): Record<string, string> | undefined;
92
+ /**
93
+ * Clean a label.
94
+ *
95
+ * @param raw - Label input
96
+ * @returns Trimmed label
97
+ * @throws RemoteMcpValidationError when empty
98
+ */
99
+ export declare function normalizeRemoteMcpLabel(raw: unknown): string;
100
+ /**
101
+ * Derive an id (MCP server name) from a label: lowercase slug, unique.
102
+ *
103
+ * @param label - Label
104
+ * @param taken - Ids already in use
105
+ * @returns e.g. `zoho`, `zoho-2`
106
+ */
107
+ export declare function deriveRemoteMcpId(label: string, taken: Set<string>): string;
108
+ /**
109
+ * Turn a stored server into its API shape.
110
+ *
111
+ * @param server - Stored server
112
+ * @returns The view (no URL, no header values)
113
+ */
114
+ export declare function toView(server: RemoteMcpServer): RemoteMcpServerView;
115
+ /**
116
+ * Reads and writes the remote MCP server store.
117
+ */
118
+ export declare class RemoteMcpService {
119
+ private static instance;
120
+ private readonly logger;
121
+ private readonly filePath;
122
+ private readonly access;
123
+ private writeChain;
124
+ /**
125
+ * @param crewlyHome - Override the home directory (tests)
126
+ * @param access - Connector access service (tests)
127
+ */
128
+ constructor(crewlyHome?: string, access?: ConnectorAccessService);
129
+ static getInstance(): RemoteMcpService;
130
+ /** Reset the singleton (tests). */
131
+ static resetInstance(): void;
132
+ /** Absolute path of the store file. */
133
+ getFilePath(): string;
134
+ /**
135
+ * Every stored server, with secrets. Unreadable entries are dropped.
136
+ *
137
+ * @returns Servers in the order they were added
138
+ */
139
+ list(): Promise<RemoteMcpServer[]>;
140
+ /**
141
+ * One server, with secrets.
142
+ *
143
+ * @param id - Server id
144
+ * @returns The server or undefined
145
+ */
146
+ get(id: string): Promise<RemoteMcpServer | undefined>;
147
+ /**
148
+ * Add a server.
149
+ *
150
+ * @param input - Label, URL, optional headers and provider
151
+ * @returns The stored server
152
+ * @throws RemoteMcpValidationError on bad input or a full store
153
+ */
154
+ add(input: AddRemoteMcpInput): Promise<RemoteMcpServer>;
155
+ /**
156
+ * Rename a server (its id, and so its MCP name and allowlist, stay).
157
+ *
158
+ * @param id - Server id
159
+ * @param label - New label
160
+ * @returns The updated server, or undefined when there is none
161
+ */
162
+ rename(id: string, label: string): Promise<RemoteMcpServer | undefined>;
163
+ /**
164
+ * Remove a server and its allowlist.
165
+ *
166
+ * @param id - Server id
167
+ * @returns True when it existed
168
+ */
169
+ remove(id: string): Promise<boolean>;
170
+ /**
171
+ * Servers an agent role may use (its `mcp:<id>` allowlist passes).
172
+ *
173
+ * @param role - Agent role
174
+ * @returns Allowed servers, with secrets
175
+ */
176
+ serversForRole(role: string): Promise<RemoteMcpServer[]>;
177
+ /**
178
+ * Serialised read-modify-write; the file is written 0600.
179
+ *
180
+ * @param fn - Change to apply
181
+ * @returns The change's result
182
+ */
183
+ private mutate;
184
+ }
185
+ /**
186
+ * Write JSON readable only by the owner (0600), atomically.
187
+ *
188
+ * @param filePath - Destination
189
+ * @param data - JSON value
190
+ */
191
+ export declare function writeSecretJson(filePath: string, data: unknown): Promise<void>;
192
+ //# sourceMappingURL=remote-mcp.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-mcp.service.d.ts","sourceRoot":"","sources":["../../../../../../backend/src/services/connector/remote-mcp.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAIvE,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAElD,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,oFAAoF;IACpF,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,sBAAsB;IACtB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,6BAA6B;IAC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
2
+ * Remote MCP servers — streamable-HTTP MCP servers the owner connects once
3
+ * (Zoho MCP first, any other server the same way) and Crewly hands to every
4
+ * agent whose role may use them.
5
+ *
6
+ * Stored at `<CREWLY_HOME>/remote-mcp-servers.json` with mode 0600. The URL
7
+ * (Zoho's carries the server's API key) and any headers are secrets: they
8
+ * are never logged, never returned in full by {@link toView}, and never
9
+ * written into a project directory (a project `.mcp.json` would be
10
+ * committed). Agents get them through per-session files under CREWLY_HOME
11
+ * (see remote-mcp-launch.service).
12
+ *
13
+ * Each server is a gated connector `mcp:<id>` in
14
+ * {@link ConnectorAccessService}: open to every agent until the owner picks
15
+ * roles.
16
+ *
17
+ * @module services/connector/remote-mcp.service
18
+ */
19
+ import * as fs from 'fs/promises';
20
+ import * as path from 'path';
21
+ import { getCrewlyHomePath } from '../core/crewly-home.utils.js';
22
+ import { LoggerService } from '../core/logger.service.js';
23
+ import { REMOTE_MCP_CONSTANTS } from '../../constants.js';
24
+ import { ConnectorAccessService } from './connector-access.service.js';
25
+ const C = REMOTE_MCP_CONSTANTS;
26
+ /** A validation failure the API turns into a 400. */
27
+ export class RemoteMcpValidationError extends Error {
28
+ constructor(message) {
29
+ super(message);
30
+ this.name = 'RemoteMcpValidationError';
31
+ }
32
+ }
33
+ /**
34
+ * The connector-access id of a server.
35
+ *
36
+ * @param id - Server id
37
+ * @returns `mcp:<id>`
38
+ */
39
+ export function remoteMcpConnectorId(id) {
40
+ return `${C.CONNECTOR_PREFIX}${id}`;
41
+ }
42
+ /**
43
+ * Show a URL without its secret parts: scheme and host only.
44
+ *
45
+ * @param url - Stored URL
46
+ * @returns e.g. `https://crm-123.zohomcp.com/…`, or `(hidden)` when it does not parse
47
+ */
48
+ export function maskRemoteMcpUrl(url) {
49
+ try {
50
+ const u = new URL(url);
51
+ return `${u.protocol}//${u.host}/…`;
52
+ }
53
+ catch {
54
+ return '(hidden)';
55
+ }
56
+ }
57
+ /**
58
+ * Validate a server URL: https (http only for localhost), no whitespace,
59
+ * quotes or backslashes (it is embedded in launch files), bounded length.
60
+ *
61
+ * @param raw - Pasted URL
62
+ * @returns The trimmed URL
63
+ * @throws RemoteMcpValidationError when it is not usable (message never echoes the URL)
64
+ */
65
+ export function validateRemoteMcpUrl(raw) {
66
+ const url = typeof raw === 'string' ? raw.trim() : '';
67
+ if (!url)
68
+ throw new RemoteMcpValidationError('Paste the server URL.');
69
+ if (url.length > C.MAX_URL_LENGTH)
70
+ throw new RemoteMcpValidationError('That URL is too long.');
71
+ if (/[\s"'`\\<>]/.test(url) || /[\u0000-\u001f\u007f]/.test(url)) {
72
+ throw new RemoteMcpValidationError('That URL contains spaces or quotes — paste only the URL.');
73
+ }
74
+ let parsed;
75
+ try {
76
+ parsed = new URL(url);
77
+ }
78
+ catch {
79
+ throw new RemoteMcpValidationError('That is not a valid URL.');
80
+ }
81
+ const local = ['localhost', '127.0.0.1', '[::1]'].includes(parsed.hostname);
82
+ if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && local)) {
83
+ throw new RemoteMcpValidationError('The URL must start with https://');
84
+ }
85
+ return url;
86
+ }
87
+ /**
88
+ * Validate optional headers: token-shaped names, single-line values.
89
+ *
90
+ * @param raw - Headers object or undefined
91
+ * @returns Clean headers, or undefined when none
92
+ * @throws RemoteMcpValidationError on a bad name or value
93
+ */
94
+ export function validateRemoteMcpHeaders(raw) {
95
+ if (raw === undefined || raw === null)
96
+ return undefined;
97
+ if (typeof raw !== 'object' || Array.isArray(raw))
98
+ throw new RemoteMcpValidationError('headers must be an object of name → value.');
99
+ const out = {};
100
+ for (const [name, value] of Object.entries(raw)) {
101
+ if (!/^[A-Za-z0-9!#$%&'*+.^_`|~-]{1,64}$/.test(name))
102
+ throw new RemoteMcpValidationError(`Header name "${name.slice(0, 64)}" is not valid.`);
103
+ if (typeof value !== 'string' || /[\r\n\u0000]/.test(value) || value.length > 4096) {
104
+ throw new RemoteMcpValidationError(`Header "${name}" needs a single-line text value.`);
105
+ }
106
+ out[name] = value;
107
+ }
108
+ return Object.keys(out).length > 0 ? out : undefined;
109
+ }
110
+ /**
111
+ * Clean a label.
112
+ *
113
+ * @param raw - Label input
114
+ * @returns Trimmed label
115
+ * @throws RemoteMcpValidationError when empty
116
+ */
117
+ export function normalizeRemoteMcpLabel(raw) {
118
+ const label = (typeof raw === 'string' ? raw : '').replace(/\s+/g, ' ').trim().slice(0, C.MAX_LABEL_LENGTH);
119
+ if (!label)
120
+ throw new RemoteMcpValidationError('Give the server a name.');
121
+ return label;
122
+ }
123
+ /**
124
+ * Derive an id (MCP server name) from a label: lowercase slug, unique.
125
+ *
126
+ * @param label - Label
127
+ * @param taken - Ids already in use
128
+ * @returns e.g. `zoho`, `zoho-2`
129
+ */
130
+ export function deriveRemoteMcpId(label, taken) {
131
+ let base = label.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 32);
132
+ if (!base || !/^[a-z0-9]/.test(base))
133
+ base = 'mcp';
134
+ let id = base;
135
+ for (let n = 2; taken.has(id); n++)
136
+ id = `${base}-${n}`;
137
+ return id;
138
+ }
139
+ /**
140
+ * Turn a stored server into its API shape.
141
+ *
142
+ * @param server - Stored server
143
+ * @returns The view (no URL, no header values)
144
+ */
145
+ export function toView(server) {
146
+ return {
147
+ id: server.id,
148
+ label: server.label,
149
+ provider: server.provider ?? 'custom',
150
+ urlMasked: maskRemoteMcpUrl(server.url),
151
+ headerNames: Object.keys(server.headers ?? {}),
152
+ createdAt: server.createdAt,
153
+ connectorId: remoteMcpConnectorId(server.id),
154
+ };
155
+ }
156
+ /**
157
+ * Reads and writes the remote MCP server store.
158
+ */
159
+ export class RemoteMcpService {
160
+ static instance = null;
161
+ logger;
162
+ filePath;
163
+ access;
164
+ writeChain = Promise.resolve();
165
+ /**
166
+ * @param crewlyHome - Override the home directory (tests)
167
+ * @param access - Connector access service (tests)
168
+ */
169
+ constructor(crewlyHome, access) {
170
+ this.logger = LoggerService.getInstance().createComponentLogger('RemoteMcp');
171
+ this.filePath = path.join(crewlyHome || getCrewlyHomePath(), C.STORE_FILE);
172
+ this.access = () => access ?? ConnectorAccessService.getInstance();
173
+ }
174
+ static getInstance() {
175
+ if (!RemoteMcpService.instance)
176
+ RemoteMcpService.instance = new RemoteMcpService();
177
+ return RemoteMcpService.instance;
178
+ }
179
+ /** Reset the singleton (tests). */
180
+ static resetInstance() {
181
+ RemoteMcpService.instance = null;
182
+ }
183
+ /** Absolute path of the store file. */
184
+ getFilePath() {
185
+ return this.filePath;
186
+ }
187
+ /**
188
+ * Every stored server, with secrets. Unreadable entries are dropped.
189
+ *
190
+ * @returns Servers in the order they were added
191
+ */
192
+ async list() {
193
+ let raw;
194
+ try {
195
+ raw = await fs.readFile(this.filePath, 'utf8');
196
+ }
197
+ catch (err) {
198
+ if (err.code === 'ENOENT')
199
+ return [];
200
+ throw err;
201
+ }
202
+ let parsed;
203
+ try {
204
+ parsed = JSON.parse(raw);
205
+ }
206
+ catch {
207
+ this.logger.error('Remote MCP store is not valid JSON — treating it as empty', { file: this.filePath });
208
+ return [];
209
+ }
210
+ const servers = parsed?.servers;
211
+ if (!Array.isArray(servers))
212
+ return [];
213
+ return servers.filter((s) => !!s && typeof s.id === 'string' && C.ID_PATTERN.test(s.id) && typeof s.url === 'string' && typeof s.label === 'string');
214
+ }
215
+ /**
216
+ * One server, with secrets.
217
+ *
218
+ * @param id - Server id
219
+ * @returns The server or undefined
220
+ */
221
+ async get(id) {
222
+ return (await this.list()).find((s) => s.id === id);
223
+ }
224
+ /**
225
+ * Add a server.
226
+ *
227
+ * @param input - Label, URL, optional headers and provider
228
+ * @returns The stored server
229
+ * @throws RemoteMcpValidationError on bad input or a full store
230
+ */
231
+ async add(input) {
232
+ const label = normalizeRemoteMcpLabel(input.label);
233
+ const url = validateRemoteMcpUrl(input.url);
234
+ const headers = validateRemoteMcpHeaders(input.headers);
235
+ const provider = input.provider === 'zoho' ? 'zoho' : 'custom';
236
+ return this.mutate(async (servers) => {
237
+ if (servers.length >= C.MAX_SERVERS)
238
+ throw new RemoteMcpValidationError(`At most ${C.MAX_SERVERS} servers.`);
239
+ if (servers.some((s) => s.url === url))
240
+ throw new RemoteMcpValidationError('That server is already connected.');
241
+ const id = deriveRemoteMcpId(label, new Set(servers.map((s) => s.id)));
242
+ const server = { id, label, url, ...(headers ? { headers } : {}), provider, createdAt: new Date().toISOString() };
243
+ this.logger.info('Remote MCP server added', { id, provider, host: maskRemoteMcpUrl(url) });
244
+ return { servers: [...servers, server], result: server };
245
+ });
246
+ }
247
+ /**
248
+ * Rename a server (its id, and so its MCP name and allowlist, stay).
249
+ *
250
+ * @param id - Server id
251
+ * @param label - New label
252
+ * @returns The updated server, or undefined when there is none
253
+ */
254
+ async rename(id, label) {
255
+ const clean = normalizeRemoteMcpLabel(label);
256
+ return this.mutate(async (servers) => {
257
+ const idx = servers.findIndex((s) => s.id === id);
258
+ if (idx < 0)
259
+ return { servers, result: undefined };
260
+ const next = [...servers];
261
+ next[idx] = { ...next[idx], label: clean };
262
+ this.logger.info('Remote MCP server renamed', { id });
263
+ return { servers: next, result: next[idx] };
264
+ });
265
+ }
266
+ /**
267
+ * Remove a server and its allowlist.
268
+ *
269
+ * @param id - Server id
270
+ * @returns True when it existed
271
+ */
272
+ async remove(id) {
273
+ const removed = await this.mutate(async (servers) => {
274
+ const next = servers.filter((s) => s.id !== id);
275
+ return { servers: next, result: next.length !== servers.length };
276
+ });
277
+ if (removed) {
278
+ await this.access().removeRule(remoteMcpConnectorId(id));
279
+ this.logger.info('Remote MCP server removed', { id });
280
+ }
281
+ return removed;
282
+ }
283
+ /**
284
+ * Servers an agent role may use (its `mcp:<id>` allowlist passes).
285
+ *
286
+ * @param role - Agent role
287
+ * @returns Allowed servers, with secrets
288
+ */
289
+ async serversForRole(role) {
290
+ const servers = await this.list();
291
+ const out = [];
292
+ for (const s of servers) {
293
+ // An empty role must not read as "the owner" here: launch always has one.
294
+ if (await this.access().isAllowed(remoteMcpConnectorId(s.id), role || 'unknown'))
295
+ out.push(s);
296
+ }
297
+ return out;
298
+ }
299
+ /**
300
+ * Serialised read-modify-write; the file is written 0600.
301
+ *
302
+ * @param fn - Change to apply
303
+ * @returns The change's result
304
+ */
305
+ async mutate(fn) {
306
+ const run = this.writeChain.then(async () => {
307
+ const { servers, result } = await fn(await this.list());
308
+ await writeSecretJson(this.filePath, { servers });
309
+ return result;
310
+ });
311
+ this.writeChain = run.catch(() => undefined);
312
+ return run;
313
+ }
314
+ }
315
+ /**
316
+ * Write JSON readable only by the owner (0600), atomically.
317
+ *
318
+ * @param filePath - Destination
319
+ * @param data - JSON value
320
+ */
321
+ export async function writeSecretJson(filePath, data) {
322
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
323
+ const tmp = `${filePath}.tmp.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}`;
324
+ try {
325
+ await fs.writeFile(tmp, `${JSON.stringify(data, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
326
+ await fs.chmod(tmp, 0o600);
327
+ await fs.rename(tmp, filePath);
328
+ }
329
+ catch (err) {
330
+ await fs.rm(tmp, { force: true }).catch(() => undefined);
331
+ throw err;
332
+ }
333
+ }
334
+ //# sourceMappingURL=remote-mcp.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-mcp.service.js","sourceRoot":"","sources":["../../../../../../backend/src/services/connector/remote-mcp.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAwB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,MAAM,CAAC,GAAG,oBAAoB,CAAC;A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AAC;IACX,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,WAAW,EAAE,OAAO,CAAC;CACrB;AAaD;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,EAAE,CA0BzD"}
1
+ {"version":3,"file":"credential-files.d.ts","sourceRoot":"","sources":["../../../../../../backend/src/services/core/credential-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC3B,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,WAAW,EAAE,OAAO,CAAC;CACrB;AAaD;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,EAAE,CA6BzD"}
@@ -12,7 +12,7 @@ import * as os from 'os';
12
12
  import * as path from 'path';
13
13
  import { getCrewlyHomePath } from './crewly-home.utils.js';
14
14
  import { getApiTokenFilePath } from './api-token.service.js';
15
- import { HARNESS_CONSTANTS, SLACK_AGENT_IDENTITY_CONSTANTS, SLACK_CLOUD_CONSTANTS, TELEGRAM_CONSTANTS, WHATSAPP_CONSTANTS } from '../../constants.js';
15
+ import { HARNESS_CONSTANTS, REMOTE_MCP_CONSTANTS, SLACK_AGENT_IDENTITY_CONSTANTS, SLACK_CLOUD_CONSTANTS, TELEGRAM_CONSTANTS, WHATSAPP_CONSTANTS } from '../../constants.js';
16
16
  import { CREWLY_CONSTANTS } from '../../../../config/constants.js';
17
17
  /**
18
18
  * `~/.crewly` as the modules that ignore CREWLY_HOME build it (Slack and
@@ -55,6 +55,9 @@ export function getGuardedCredentialPaths() {
55
55
  add('credential-store', path.join(home, 'credentials'), true);
56
56
  add('whatsapp-session', path.join(home, WHATSAPP_CONSTANTS.AUTH_DIR), true);
57
57
  add('claude-accounts', path.join(home, HARNESS_CONSTANTS.CLAUDE.ACCOUNTS.DIR), true);
58
+ // Remote MCP server URLs carry their key (Zoho MCP); runtimes read the launch files themselves.
59
+ add('remote-mcp-servers', path.join(home, REMOTE_MCP_CONSTANTS.STORE_FILE), false);
60
+ add('remote-mcp-launch-files', path.join(home, REMOTE_MCP_CONSTANTS.RUNTIME_DIR), true);
58
61
  return out;
59
62
  }
60
63
  //# sourceMappingURL=credential-files.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"credential-files.js","sourceRoot":"","sources":["../../../../../../backend/src/services/core/credential-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtJ,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAYnE;;;;;;GAMG;AACH,SAAS,aAAa;IACrB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACxF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACxC,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,CAAS,EAAE,WAAoB,EAAQ,EAAE;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;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-10-07T13:46:40.341Z"
4
4
  }
@@ -7009,4 +7009,35 @@ export declare const SCHEDULED_COMMANDS: {
7009
7009
  /** Milliseconds per minute */
7010
7010
  readonly MS_PER_MINUTE: 60000;
7011
7011
  };
7012
+ /**
7013
+ * Remote MCP servers (Zoho MCP and any other streamable-HTTP MCP server) the
7014
+ * owner connects in Connections. The URL usually carries the server's key,
7015
+ * so it is stored only under CREWLY_HOME and never logged or echoed.
7016
+ */
7017
+ export declare const REMOTE_MCP_CONSTANTS: {
7018
+ /** Store file under CREWLY_HOME (mode 0600). */
7019
+ readonly STORE_FILE: "remote-mcp-servers.json";
7020
+ /** Per-agent launch files under CREWLY_HOME (mode 0600, one dir per session). */
7021
+ readonly RUNTIME_DIR: "runtime/remote-mcp";
7022
+ /** Claude Code `--mcp-config` file name inside a session's runtime dir. */
7023
+ readonly CLAUDE_CONFIG_FILE: "claude-mcp.json";
7024
+ /** Connector-access id prefix: `mcp:<id>`. */
7025
+ readonly CONNECTOR_PREFIX: "mcp:";
7026
+ /** Server ids (also the MCP server name in the runtime config). */
7027
+ readonly ID_PATTERN: RegExp;
7028
+ /** Longest label kept. */
7029
+ readonly MAX_LABEL_LENGTH: 60;
7030
+ /** Longest URL accepted. */
7031
+ readonly MAX_URL_LENGTH: 2048;
7032
+ /** Most servers one instance may hold. */
7033
+ readonly MAX_SERVERS: 30;
7034
+ /** Test (initialize + tools/list) timeout per request, ms. */
7035
+ readonly TEST_TIMEOUT_MS: 15000;
7036
+ /** MCP protocol version sent on initialize. */
7037
+ readonly PROTOCOL_VERSION: "2025-03-26";
7038
+ /** Most tool names returned by a test. */
7039
+ readonly MAX_TOOL_NAMES: 50;
7040
+ /** Catalog presets the add form offers. */
7041
+ readonly PROVIDERS: readonly string[];
7042
+ };
7012
7043
  //# sourceMappingURL=constants.d.ts.map