@relaycast/mcp 0.5.0 → 0.5.2
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/piggyback.d.ts +12 -1
- package/dist/piggyback.d.ts.map +1 -1
- package/dist/piggyback.js +39 -16
- package/dist/piggyback.js.map +1 -1
- package/dist/prompts.d.ts +1 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +9 -9
- package/dist/resources/definitions.d.ts +6 -1
- package/dist/resources/definitions.d.ts.map +1 -1
- package/dist/resources/definitions.js +38 -12
- package/dist/resources/definitions.js.map +1 -1
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +177 -38
- package/dist/server.js.map +1 -1
- package/dist/stdio.js +8 -0
- package/dist/stdio.js.map +1 -1
- package/dist/tool-aliases.d.ts +67 -0
- package/dist/tool-aliases.d.ts.map +1 -0
- package/dist/tool-aliases.js +71 -0
- package/dist/tool-aliases.js.map +1 -0
- package/dist/tools/channels.d.ts +5 -2
- package/dist/tools/channels.d.ts.map +1 -1
- package/dist/tools/channels.js +32 -21
- package/dist/tools/channels.js.map +1 -1
- package/dist/tools/features.d.ts +4 -1
- package/dist/tools/features.d.ts.map +1 -1
- package/dist/tools/features.js +28 -20
- package/dist/tools/features.js.map +1 -1
- package/dist/tools/messaging.d.ts +7 -1
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +34 -21
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/programmability.d.ts +7 -1
- package/dist/tools/programmability.d.ts.map +1 -1
- package/dist/tools/programmability.js +22 -18
- package/dist/tools/programmability.js.map +1 -1
- package/dist/tools/registration.d.ts +4 -1
- package/dist/tools/registration.d.ts.map +1 -1
- package/dist/tools/registration.js +317 -21
- package/dist/tools/registration.js.map +1 -1
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +118 -1
- package/dist/transports.js.map +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/dist/workspaces.d.ts +69 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +134 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +3 -3
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import type { WsBridge } from './resources/ws-bridge.js';
|
|
2
2
|
import type { SubscriptionManager } from './resources/subscriptions.js';
|
|
3
|
+
export interface RegisteredAgent {
|
|
4
|
+
agentName: string;
|
|
5
|
+
agentToken: string;
|
|
6
|
+
}
|
|
7
|
+
/** Saved context for a single workspace membership. */
|
|
8
|
+
export interface WorkspaceContext {
|
|
9
|
+
workspaceKey: string;
|
|
10
|
+
agentToken: string;
|
|
11
|
+
agentName: string;
|
|
12
|
+
/** Registered agent tokens for this workspace, keyed by agent name. */
|
|
13
|
+
agents: Map<string, RegisteredAgent>;
|
|
14
|
+
/** Canonical workspace name from the Relaycast API. */
|
|
15
|
+
workspaceName?: string;
|
|
16
|
+
/** Optional user-saved label for switching. */
|
|
17
|
+
workspaceLabel?: string;
|
|
18
|
+
wsBridge: WsBridge | null;
|
|
19
|
+
subscriptions: SubscriptionManager | null;
|
|
20
|
+
wsInitAttempted: boolean;
|
|
21
|
+
}
|
|
3
22
|
export interface SessionState {
|
|
4
23
|
workspaceKey: string | null;
|
|
5
24
|
agentToken: string | null;
|
|
6
25
|
agentName: string | null;
|
|
26
|
+
/** Registered agent tokens for the active workspace, keyed by agent name. */
|
|
27
|
+
agents: Map<string, RegisteredAgent>;
|
|
7
28
|
wsBridge: WsBridge | null;
|
|
8
29
|
subscriptions: SubscriptionManager | null;
|
|
9
30
|
wsInitAttempted: boolean;
|
|
31
|
+
/** Map of workspace key → saved context for joined workspaces. */
|
|
32
|
+
workspaces: Map<string, WorkspaceContext>;
|
|
10
33
|
}
|
|
11
34
|
export interface InitialSessionOptions {
|
|
12
35
|
workspaceKey?: string | null;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,eAAe,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACrC,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,6EAA6E;IAC7E,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACrC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,eAAe,EAAE,OAAO,CAAC;IACzB,kEAAkE;IAClE,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAClC,qBAAqB,GAAE,MAAM,GAAG,IAAI,GAAG,qBAA4B,GAClE,YAAY,CAmBd"}
|
package/dist/types.js
CHANGED
|
@@ -6,9 +6,13 @@ export function createInitialSession(workspaceKeyOrOptions = null) {
|
|
|
6
6
|
workspaceKey: opts.workspaceKey ?? null,
|
|
7
7
|
agentToken: opts.agentToken ?? null,
|
|
8
8
|
agentName: opts.agentName ?? null,
|
|
9
|
+
agents: opts.agentName && opts.agentToken
|
|
10
|
+
? new Map([[opts.agentName, { agentName: opts.agentName, agentToken: opts.agentToken }]])
|
|
11
|
+
: new Map(),
|
|
9
12
|
wsBridge: null,
|
|
10
13
|
subscriptions: null,
|
|
11
14
|
wsInitAttempted: false,
|
|
15
|
+
workspaces: new Map(),
|
|
12
16
|
};
|
|
13
17
|
}
|
|
14
18
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2CA,MAAM,UAAU,oBAAoB,CAClC,wBAA+D,IAAI;IAEnE,MAAM,IAAI,GACR,OAAO,qBAAqB,KAAK,QAAQ,IAAI,qBAAqB,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,cAAc,IAAI,qBAAqB;QAC7J,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,EAAE,YAAY,EAAE,qBAAsC,EAAE,CAAC;IAE/D,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI;QACvC,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;QACnC,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI;QACjC,MAAM,EACJ,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU;YAC/B,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;YACzF,CAAC,CAAC,IAAI,GAAG,EAAE;QACf,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,KAAK;QACtB,UAAU,EAAE,IAAI,GAAG,EAAE;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { SessionState, WorkspaceContext } from './types.js';
|
|
3
|
+
export type WorkspaceRouting = {
|
|
4
|
+
workspace_id?: string;
|
|
5
|
+
workspace_alias?: string;
|
|
6
|
+
};
|
|
7
|
+
export type AgentRouting = WorkspaceRouting & {
|
|
8
|
+
as?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for a single workspace provided via RELAY_WORKSPACES_JSON.
|
|
12
|
+
*/
|
|
13
|
+
export interface McpWorkspaceConfig {
|
|
14
|
+
workspace_id: string;
|
|
15
|
+
workspace_alias?: string;
|
|
16
|
+
workspace_name?: string;
|
|
17
|
+
api_key: string;
|
|
18
|
+
agent_token?: string;
|
|
19
|
+
agent_name?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse RELAY_WORKSPACES_JSON env var into an array of workspace configs.
|
|
23
|
+
* Returns an empty array if the env var is not set or empty.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseWorkspaceEnv(raw?: string): McpWorkspaceConfig[];
|
|
26
|
+
/**
|
|
27
|
+
* Validate an array of workspace config objects.
|
|
28
|
+
* Ensures each entry has the required fields.
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateWorkspaceConfigs(configs: unknown[]): McpWorkspaceConfig[];
|
|
31
|
+
/**
|
|
32
|
+
* Resolve which workspace ID should be the default/active workspace.
|
|
33
|
+
* Falls back to the first workspace in the list.
|
|
34
|
+
*/
|
|
35
|
+
export declare function resolveDefaultWorkspaceId(configs: McpWorkspaceConfig[], defaultWorkspace?: string): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Optional workspace routing params added to messaging tools.
|
|
38
|
+
* When provided, the tool targets a specific workspace instead of the active one.
|
|
39
|
+
*/
|
|
40
|
+
export declare const workspaceRoutingInputShape: {
|
|
41
|
+
workspace_id: z.ZodOptional<z.ZodString>;
|
|
42
|
+
workspace_alias: z.ZodOptional<z.ZodString>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Optional agent identity override for tools whose behavior depends on the
|
|
46
|
+
* authenticated agent.
|
|
47
|
+
*/
|
|
48
|
+
export declare const identityOverrideInputShape: {
|
|
49
|
+
as: z.ZodOptional<z.ZodString>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Extract optional workspace and identity routing from loose request params.
|
|
53
|
+
* Throws on invalid types so resource requests match tool-layer validation.
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseAgentRouting(raw: unknown): AgentRouting | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Extract workspace routing info from tool arguments.
|
|
58
|
+
* Returns the workspace_id or workspace_alias if provided, or undefined.
|
|
59
|
+
*/
|
|
60
|
+
export declare function workspaceRefFromArgs(args: WorkspaceRouting): WorkspaceRouting | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Find a WorkspaceContext in the session by workspace_id or workspace_alias.
|
|
63
|
+
* Falls back to matching a saved workspace label or canonical workspace name.
|
|
64
|
+
*/
|
|
65
|
+
export declare function findWorkspaceContext(session: SessionState, ref: {
|
|
66
|
+
workspace_id?: string;
|
|
67
|
+
workspace_alias?: string;
|
|
68
|
+
}, configs?: McpWorkspaceConfig[]): WorkspaceContext | undefined;
|
|
69
|
+
//# sourceMappingURL=workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAAG;IAC5C,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAWD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAcpE;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAYjF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,kBAAkB,EAAE,EAC7B,gBAAgB,CAAC,EAAE,MAAM,GACxB,MAAM,GAAG,SAAS,CASpB;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;CAOtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;CAItC,CAAC;AAOF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CASxE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,gBAAgB,GACrB,gBAAgB,GAAG,SAAS,CAQ9B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,EACxD,OAAO,CAAC,EAAE,kBAAkB,EAAE,GAC7B,gBAAgB,GAAG,SAAS,CA0B9B"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const mcpWorkspaceConfigSchema = z.object({
|
|
3
|
+
workspace_id: z.string({ error: 'is required and must be a string' }),
|
|
4
|
+
workspace_alias: z.string().optional(),
|
|
5
|
+
workspace_name: z.string().optional(),
|
|
6
|
+
api_key: z.string({ error: 'is required and must be a string' }),
|
|
7
|
+
agent_token: z.string().optional(),
|
|
8
|
+
agent_name: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Parse RELAY_WORKSPACES_JSON env var into an array of workspace configs.
|
|
12
|
+
* Returns an empty array if the env var is not set or empty.
|
|
13
|
+
*/
|
|
14
|
+
export function parseWorkspaceEnv(raw) {
|
|
15
|
+
if (!raw || !raw.trim())
|
|
16
|
+
return [];
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
if (!Array.isArray(parsed)) {
|
|
20
|
+
throw new Error('RELAY_WORKSPACES_JSON must be a JSON array');
|
|
21
|
+
}
|
|
22
|
+
return validateWorkspaceConfigs(parsed);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err instanceof SyntaxError) {
|
|
26
|
+
throw new Error(`RELAY_WORKSPACES_JSON is not valid JSON: ${err.message}`);
|
|
27
|
+
}
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate an array of workspace config objects.
|
|
33
|
+
* Ensures each entry has the required fields.
|
|
34
|
+
*/
|
|
35
|
+
export function validateWorkspaceConfigs(configs) {
|
|
36
|
+
return configs.map((cfg, i) => {
|
|
37
|
+
const result = mcpWorkspaceConfigSchema.safeParse(cfg);
|
|
38
|
+
if (!result.success) {
|
|
39
|
+
const issue = result.error.issues[0];
|
|
40
|
+
if (!issue.path.length) {
|
|
41
|
+
throw new Error(`RELAY_WORKSPACES_JSON[${i}] must be an object`);
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`RELAY_WORKSPACES_JSON[${i}].${issue.path.join('.')} ${issue.message}`);
|
|
44
|
+
}
|
|
45
|
+
return result.data;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve which workspace ID should be the default/active workspace.
|
|
50
|
+
* Falls back to the first workspace in the list.
|
|
51
|
+
*/
|
|
52
|
+
export function resolveDefaultWorkspaceId(configs, defaultWorkspace) {
|
|
53
|
+
if (!configs.length)
|
|
54
|
+
return undefined;
|
|
55
|
+
if (defaultWorkspace) {
|
|
56
|
+
const match = configs.find(c => c.workspace_id === defaultWorkspace || c.workspace_alias === defaultWorkspace);
|
|
57
|
+
if (match)
|
|
58
|
+
return match.workspace_id;
|
|
59
|
+
}
|
|
60
|
+
return configs[0].workspace_id;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Optional workspace routing params added to messaging tools.
|
|
64
|
+
* When provided, the tool targets a specific workspace instead of the active one.
|
|
65
|
+
*/
|
|
66
|
+
export const workspaceRoutingInputShape = {
|
|
67
|
+
workspace_id: z.string().optional().describe('Target a specific workspace by its workspace_id (from RELAY_WORKSPACES_JSON). If omitted, uses the active workspace.'),
|
|
68
|
+
workspace_alias: z.string().optional().describe('Target a specific workspace by its alias (from RELAY_WORKSPACES_JSON). If omitted, uses the active workspace.'),
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Optional agent identity override for tools whose behavior depends on the
|
|
72
|
+
* authenticated agent.
|
|
73
|
+
*/
|
|
74
|
+
export const identityOverrideInputShape = {
|
|
75
|
+
as: z.string().optional().describe('Act as a specific registered agent name in the target workspace. If omitted, uses the active agent identity.'),
|
|
76
|
+
};
|
|
77
|
+
const agentRoutingSchema = z.object({
|
|
78
|
+
...workspaceRoutingInputShape,
|
|
79
|
+
...identityOverrideInputShape,
|
|
80
|
+
}).passthrough();
|
|
81
|
+
/**
|
|
82
|
+
* Extract optional workspace and identity routing from loose request params.
|
|
83
|
+
* Throws on invalid types so resource requests match tool-layer validation.
|
|
84
|
+
*/
|
|
85
|
+
export function parseAgentRouting(raw) {
|
|
86
|
+
const parsed = agentRoutingSchema.parse(raw ?? {});
|
|
87
|
+
const { workspace_id, workspace_alias, as } = parsed;
|
|
88
|
+
if (!workspace_id && !workspace_alias && !as) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return { workspace_id, workspace_alias, as };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Extract workspace routing info from tool arguments.
|
|
95
|
+
* Returns the workspace_id or workspace_alias if provided, or undefined.
|
|
96
|
+
*/
|
|
97
|
+
export function workspaceRefFromArgs(args) {
|
|
98
|
+
if (args.workspace_id || args.workspace_alias) {
|
|
99
|
+
return {
|
|
100
|
+
workspace_id: args.workspace_id,
|
|
101
|
+
workspace_alias: args.workspace_alias,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Find a WorkspaceContext in the session by workspace_id or workspace_alias.
|
|
108
|
+
* Falls back to matching a saved workspace label or canonical workspace name.
|
|
109
|
+
*/
|
|
110
|
+
export function findWorkspaceContext(session, ref, configs) {
|
|
111
|
+
// Try to find the matching config first to get the api_key
|
|
112
|
+
const config = configs?.find(c => {
|
|
113
|
+
if (ref.workspace_id && c.workspace_id === ref.workspace_id)
|
|
114
|
+
return true;
|
|
115
|
+
if (ref.workspace_alias && c.workspace_alias === ref.workspace_alias)
|
|
116
|
+
return true;
|
|
117
|
+
return false;
|
|
118
|
+
});
|
|
119
|
+
if (config) {
|
|
120
|
+
return session.workspaces.get(config.api_key);
|
|
121
|
+
}
|
|
122
|
+
// Fall back to matching by workspace_alias against saved workspace metadata.
|
|
123
|
+
if (ref.workspace_alias) {
|
|
124
|
+
const target = ref.workspace_alias.toLowerCase();
|
|
125
|
+
for (const ctx of session.workspaces.values()) {
|
|
126
|
+
if (ctx.workspaceLabel?.toLowerCase() === target
|
|
127
|
+
|| ctx.workspaceName?.toLowerCase() === target) {
|
|
128
|
+
return ctx;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../src/workspaces.ts"],"names":[],"mappings":"AA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Y;YAAE,OAAO,IAAI,CAAC;QACzE,IAAI,GAAG,CAAC,eAAe,IAAI,CAAC,CAAC,eAAe,KAAK,GAAG,CAAC,eAAe;YAAE,OAAO,IAAI,CAAC;QAClF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAED,6EAA6E;IAC7E,IAAI,GAAG,CAAC,eAAe,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC;QACjD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,IACE,GAAG,CAAC,cAAc,EAAE,WAAW,EAAE,KAAK,MAAM;mBACzC,GAAG,CAAC,aAAa,EAAE,WAAW,EAAE,KAAK,MAAM,EAC9C,CAAC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@relaycast/mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"lint": "eslint src/"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@relaycast/sdk": "0.5.
|
|
17
|
-
"@relaycast/types": "0.5.
|
|
16
|
+
"@relaycast/sdk": "0.5.2",
|
|
17
|
+
"@relaycast/types": "0.5.2",
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
19
19
|
"express": "^5.2.1",
|
|
20
20
|
"zod": "^4.3.6"
|