@raytio/mcp-server 2.0.0 → 2.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/dist/authorization.d.ts +29 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/authorization.js +87 -0
- package/dist/authorization.js.map +1 -0
- package/dist/index.js +22 -58
- package/dist/index.js.map +1 -1
- package/dist/tools/dispatch.d.ts +18 -0
- package/dist/tools/dispatch.d.ts.map +1 -0
- package/dist/tools/dispatch.js +41 -0
- package/dist/tools/dispatch.js.map +1 -0
- package/dist/tools/role-mapping.d.ts +15 -8
- package/dist/tools/role-mapping.d.ts.map +1 -1
- package/dist/tools/role-mapping.js +28 -29
- package/dist/tools/role-mapping.js.map +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +25 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RaytioApiClient } from './raytio/api-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of resolving the effective tool domain set for the authenticated
|
|
4
|
+
* user. When `authorized` is `false`, the caller MUST expose no tools.
|
|
5
|
+
*/
|
|
6
|
+
export interface AuthorizationResult {
|
|
7
|
+
/** Comma-separated domain spec suitable for `resolveDomains()`, or `undefined` when no tools should be exposed. */
|
|
8
|
+
domainSpec: string | undefined;
|
|
9
|
+
/** Human-readable reason for the decision. Emitted to stderr for operator visibility. */
|
|
10
|
+
reason: string;
|
|
11
|
+
/** `true` when the caller should expose tools. `false` means fail closed — expose nothing. */
|
|
12
|
+
authorized: boolean;
|
|
13
|
+
}
|
|
14
|
+
type StderrLogger = Pick<Console, 'error'>;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the tool domain surface for the authenticated user.
|
|
17
|
+
*
|
|
18
|
+
* Behaviour:
|
|
19
|
+
* - Always queries the backend for the user's resolved roles. On any
|
|
20
|
+
* failure, fails closed and exposes no tools.
|
|
21
|
+
* - The static `RAYTIO_TOOL_DOMAINS` override may only *restrict* the
|
|
22
|
+
* user's resolved domain set. It never grants access to domains the
|
|
23
|
+
* user does not have.
|
|
24
|
+
* - If the intersection is empty (or the user has no recognised roles),
|
|
25
|
+
* fails closed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveToolDomains(apiClient: RaytioApiClient, envSpec: string | undefined, logger?: StderrLogger): Promise<AuthorizationResult>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=authorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,mHAAmH;IACnH,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,yFAAyF;IACzF,MAAM,EAAE,MAAM,CAAC;IACf,8FAA8F;IAC9F,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,KAAK,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAgD3C;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,eAAe,EAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,MAAM,GAAE,YAAsB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAyC9B"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { resolveUserDomains } from './tools/role-mapping.js';
|
|
2
|
+
/**
|
|
3
|
+
* Domains that a static override may resolve to when the user only holds
|
|
4
|
+
* the full-access parent. This preserves the useful "further restrict a
|
|
5
|
+
* privileged user to read-only tools" case without ever letting a static
|
|
6
|
+
* override grant access the user does not already have.
|
|
7
|
+
*/
|
|
8
|
+
const READONLY_PARENTS = {
|
|
9
|
+
'ppm-readonly': 'ppm',
|
|
10
|
+
'wrm-readonly': 'wrm',
|
|
11
|
+
'sfa-readonly': 'sfa',
|
|
12
|
+
};
|
|
13
|
+
function parseSpec(spec) {
|
|
14
|
+
if (!spec)
|
|
15
|
+
return [];
|
|
16
|
+
return spec
|
|
17
|
+
.split(',')
|
|
18
|
+
.map((s) => s.trim())
|
|
19
|
+
.filter(Boolean);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Intersect a static domain list with the user's resolved domain list.
|
|
23
|
+
* Static entries that ask for a read-only sub-domain of a full-access
|
|
24
|
+
* domain the user already holds are permitted (a further restriction).
|
|
25
|
+
* Anything else the user does not have is silently dropped — a static
|
|
26
|
+
* override is a restriction, never a grant.
|
|
27
|
+
*/
|
|
28
|
+
function restrictToUserDomains(staticDomains, userDomains) {
|
|
29
|
+
const userSet = new Set(userDomains);
|
|
30
|
+
const allowed = [];
|
|
31
|
+
for (const d of staticDomains) {
|
|
32
|
+
if (userSet.has(d)) {
|
|
33
|
+
allowed.push(d);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const parent = READONLY_PARENTS[d];
|
|
37
|
+
if (parent && userSet.has(parent)) {
|
|
38
|
+
allowed.push(d);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return allowed;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the tool domain surface for the authenticated user.
|
|
45
|
+
*
|
|
46
|
+
* Behaviour:
|
|
47
|
+
* - Always queries the backend for the user's resolved roles. On any
|
|
48
|
+
* failure, fails closed and exposes no tools.
|
|
49
|
+
* - The static `RAYTIO_TOOL_DOMAINS` override may only *restrict* the
|
|
50
|
+
* user's resolved domain set. It never grants access to domains the
|
|
51
|
+
* user does not have.
|
|
52
|
+
* - If the intersection is empty (or the user has no recognised roles),
|
|
53
|
+
* fails closed.
|
|
54
|
+
*/
|
|
55
|
+
export async function resolveToolDomains(apiClient, envSpec, logger = console) {
|
|
56
|
+
const staticDomains = parseSpec(envSpec);
|
|
57
|
+
let dynamicSpec;
|
|
58
|
+
try {
|
|
59
|
+
dynamicSpec = await resolveUserDomains(apiClient);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
const reason = `role query failed: ${err?.message ?? err}`;
|
|
63
|
+
logger.error(`Raytio MCP: authorization resolution failed (${reason}) — exposing no tools (fail closed)`);
|
|
64
|
+
return { domainSpec: undefined, reason, authorized: false };
|
|
65
|
+
}
|
|
66
|
+
const userDomains = parseSpec(dynamicSpec);
|
|
67
|
+
if (userDomains.length === 0) {
|
|
68
|
+
const reason = 'user has no recognised roles';
|
|
69
|
+
logger.error(`Raytio MCP: ${reason} — exposing no tools (fail closed)`);
|
|
70
|
+
return { domainSpec: undefined, reason, authorized: false };
|
|
71
|
+
}
|
|
72
|
+
if (staticDomains.length === 0) {
|
|
73
|
+
const spec = userDomains.join(',');
|
|
74
|
+
logger.error(`Raytio MCP: resolved domains from user roles: ${spec}`);
|
|
75
|
+
return { domainSpec: spec, reason: 'resolved from user roles', authorized: true };
|
|
76
|
+
}
|
|
77
|
+
const allowed = restrictToUserDomains(staticDomains, userDomains);
|
|
78
|
+
if (allowed.length === 0) {
|
|
79
|
+
const reason = `static RAYTIO_TOOL_DOMAINS "${staticDomains.join(',')}" does not intersect user roles "${userDomains.join(',')}"`;
|
|
80
|
+
logger.error(`Raytio MCP: ${reason} — exposing no tools (fail closed)`);
|
|
81
|
+
return { domainSpec: undefined, reason, authorized: false };
|
|
82
|
+
}
|
|
83
|
+
const spec = allowed.join(',');
|
|
84
|
+
logger.error(`Raytio MCP: static RAYTIO_TOOL_DOMAINS restricted user roles (${userDomains.join(',')}) to ${spec}`);
|
|
85
|
+
return { domainSpec: spec, reason: 'restricted by static override', authorized: true };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../src/authorization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,k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UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IAC9D,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,CAAC,KAAK,CACV,iEAAiE,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CACrG,CAAC;IACF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,+BAA+B,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;AACzF,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,9 @@ import { loadConfig } from './config.js';
|
|
|
7
7
|
import { CognitoAuth } from './raytio/auth.js';
|
|
8
8
|
import { RaytioApiClient } from './raytio/api-client.js';
|
|
9
9
|
import { resolveDomains } from './tools/domains.js';
|
|
10
|
-
import {
|
|
10
|
+
import { resolveToolDomains } from './authorization.js';
|
|
11
|
+
import { dispatchToolCall } from './tools/dispatch.js';
|
|
12
|
+
import { PACKAGE_VERSION } from './version.js';
|
|
11
13
|
// Load configuration
|
|
12
14
|
const config = loadConfig();
|
|
13
15
|
// Initialize authentication and API client
|
|
@@ -20,37 +22,22 @@ const auth = new CognitoAuth({
|
|
|
20
22
|
});
|
|
21
23
|
const apiClient = new RaytioApiClient(config.raytio.apiBaseUrl, auth);
|
|
22
24
|
const ctx = { apiClient, auth, config };
|
|
23
|
-
// Resolve tool domains
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
const dynamicDomains = await resolveUserDomains(apiClient);
|
|
34
|
-
if (dynamicDomains) {
|
|
35
|
-
console.error(`Raytio MCP: resolved domains from user roles: ${dynamicDomains}`);
|
|
36
|
-
return dynamicDomains;
|
|
37
|
-
}
|
|
38
|
-
console.error('Raytio MCP: user has no recognised roles, exposing all domains as fallback');
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
console.error(`Raytio MCP: role query failed (${err.message}), falling back to all domains`);
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const domainSpec = await resolveToolDomains();
|
|
47
|
-
const allTools = resolveDomains(domainSpec);
|
|
25
|
+
// Resolve tool domains. The static RAYTIO_TOOL_DOMAINS override may only
|
|
26
|
+
// restrict the user's resolved roles — it never grants access to a domain
|
|
27
|
+
// the user does not already hold. Any failure to resolve roles fails closed
|
|
28
|
+
// (expose no tools) rather than falling back to the full surface.
|
|
29
|
+
const authorization = await resolveToolDomains(apiClient, process.env.RAYTIO_TOOL_DOMAINS);
|
|
30
|
+
const allTools = authorization.authorized
|
|
31
|
+
? resolveDomains(authorization.domainSpec)
|
|
32
|
+
: [];
|
|
48
33
|
console.error(`Raytio MCP: exposing ${allTools.length} tools` +
|
|
49
|
-
(domainSpec
|
|
34
|
+
(authorization.domainSpec
|
|
35
|
+
? ` (domains: ${authorization.domainSpec})`
|
|
36
|
+
: ' (no domains — fail closed)'));
|
|
50
37
|
// Create MCP server
|
|
51
38
|
const server = new Server({
|
|
52
39
|
name: '@raytio/mcp-server',
|
|
53
|
-
version:
|
|
40
|
+
version: PACKAGE_VERSION,
|
|
54
41
|
}, {
|
|
55
42
|
capabilities: {
|
|
56
43
|
tools: {},
|
|
@@ -66,38 +53,15 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
66
53
|
})),
|
|
67
54
|
};
|
|
68
55
|
});
|
|
69
|
-
// Handle tool calls
|
|
56
|
+
// Handle tool calls — dispatch centrally so every input is parsed through
|
|
57
|
+
// its Zod schema before the tool handler is invoked.
|
|
70
58
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
71
59
|
const { name, arguments: args = {} } = request.params;
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
type: 'text',
|
|
78
|
-
text: JSON.stringify({ success: false, error: { code: 'TOOL_ERROR', message: `Unknown tool: ${name}` } }, null, 2),
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
isError: true,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
const result = await tool.handler(args, ctx);
|
|
86
|
-
return {
|
|
87
|
-
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
return {
|
|
92
|
-
content: [
|
|
93
|
-
{
|
|
94
|
-
type: 'text',
|
|
95
|
-
text: JSON.stringify({ success: false, error: { code: 'TOOL_ERROR', message: error.message } }, null, 2),
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
isError: true,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
60
|
+
const response = await dispatchToolCall(allTools, name, args, ctx);
|
|
61
|
+
return {
|
|
62
|
+
content: [{ type: 'text', text: JSON.stringify(response, null, 2) }],
|
|
63
|
+
...(response.success ? {} : { isError: true }),
|
|
64
|
+
};
|
|
101
65
|
});
|
|
102
66
|
// Start server
|
|
103
67
|
async function main() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBA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E,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACpE,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC/C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe;AACf,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC7C,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Tool, ToolContext } from './registry.js';
|
|
2
|
+
import { ToolResponse } from './types.js';
|
|
3
|
+
export declare const INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR";
|
|
4
|
+
export declare const UNKNOWN_TOOL = "UNKNOWN_TOOL";
|
|
5
|
+
export declare const TOOL_ERROR = "TOOL_ERROR";
|
|
6
|
+
/**
|
|
7
|
+
* Central dispatch entry point for every MCP `tools/call` request.
|
|
8
|
+
*
|
|
9
|
+
* Guarantees:
|
|
10
|
+
* - The advertised Zod schema is parsed before the tool handler runs,
|
|
11
|
+
* so handlers only ever see structurally valid input.
|
|
12
|
+
* - Unknown tool names return a stable `UNKNOWN_TOOL` error rather than
|
|
13
|
+
* passing an arbitrary name deeper into the stack.
|
|
14
|
+
* - Handler exceptions are converted to structured `TOOL_ERROR`
|
|
15
|
+
* responses so the MCP transport always sees a well-formed reply.
|
|
16
|
+
*/
|
|
17
|
+
export declare function dispatchToolCall(tools: Tool[], name: string, args: unknown, ctx: ToolContext): Promise<ToolResponse<unknown>>;
|
|
18
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../src/tools/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAiB,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAC/D,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,IAAI,EAAE,EACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAqBhC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { errorResponse } from './types.js';
|
|
2
|
+
export const INPUT_VALIDATION_ERROR = 'INPUT_VALIDATION_ERROR';
|
|
3
|
+
export const UNKNOWN_TOOL = 'UNKNOWN_TOOL';
|
|
4
|
+
export const TOOL_ERROR = 'TOOL_ERROR';
|
|
5
|
+
/**
|
|
6
|
+
* Central dispatch entry point for every MCP `tools/call` request.
|
|
7
|
+
*
|
|
8
|
+
* Guarantees:
|
|
9
|
+
* - The advertised Zod schema is parsed before the tool handler runs,
|
|
10
|
+
* so handlers only ever see structurally valid input.
|
|
11
|
+
* - Unknown tool names return a stable `UNKNOWN_TOOL` error rather than
|
|
12
|
+
* passing an arbitrary name deeper into the stack.
|
|
13
|
+
* - Handler exceptions are converted to structured `TOOL_ERROR`
|
|
14
|
+
* responses so the MCP transport always sees a well-formed reply.
|
|
15
|
+
*/
|
|
16
|
+
export async function dispatchToolCall(tools, name, args, ctx) {
|
|
17
|
+
const tool = tools.find((t) => t.name === name);
|
|
18
|
+
if (!tool) {
|
|
19
|
+
return errorResponse(UNKNOWN_TOOL, `Unknown tool: ${name}`);
|
|
20
|
+
}
|
|
21
|
+
const rawInput = args ?? {};
|
|
22
|
+
const parsed = tool.inputSchema.safeParse(rawInput);
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
return errorResponse(INPUT_VALIDATION_ERROR, `Invalid arguments for tool "${name}": ${formatZodError(parsed.error)}`, { issues: parsed.error.issues });
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return await tool.handler(parsed.data, ctx);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return errorResponse(TOOL_ERROR, error?.message ?? String(error));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function formatZodError(error) {
|
|
34
|
+
return error.issues
|
|
35
|
+
.map((issue) => {
|
|
36
|
+
const path = issue.path.length ? issue.path.join('.') : '(root)';
|
|
37
|
+
return `${path}: ${issue.message}`;
|
|
38
|
+
})
|
|
39
|
+
.join('; ');
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/tools/dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAgB,MAAM,YAAY,CAAC;AAEzD,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAC/D,MA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,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACjE,OAAO,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { RaytioApiClient } from '../raytio/api-client.js';
|
|
2
2
|
/**
|
|
3
|
-
* Shape returned by `fnd_authz_user_groups()` PostgREST RPC.
|
|
4
|
-
*
|
|
3
|
+
* Shape returned by `fnd_authz_user_groups()` PostgREST RPC. Each row
|
|
4
|
+
* represents one resolved role (direct or inherited via group membership).
|
|
5
|
+
*
|
|
6
|
+
* The Persist function returns a single column named `group_name` — the
|
|
7
|
+
* MCP server previously read `group_code`, which meant no user role ever
|
|
8
|
+
* mapped to a domain. This alignment is an interim compatibility fix
|
|
9
|
+
* pending the versioned Persist contract (see epic WI-0003496).
|
|
5
10
|
*/
|
|
6
11
|
export interface UserGroup {
|
|
7
|
-
|
|
12
|
+
group_name: string;
|
|
8
13
|
[key: string]: unknown;
|
|
9
14
|
}
|
|
10
15
|
/**
|
|
11
|
-
* Given a list of user group
|
|
16
|
+
* Given a list of user group names, resolve the set of tool domain IDs
|
|
12
17
|
* the user should have access to.
|
|
13
18
|
*
|
|
14
|
-
* When both
|
|
19
|
+
* When both a full-access and readonly domain are present (e.g. `ppm`
|
|
20
|
+
* and `ppm-readonly`), the full-access variant wins.
|
|
15
21
|
*/
|
|
16
|
-
export declare function mapRolesToDomains(
|
|
22
|
+
export declare function mapRolesToDomains(groupNames: string[]): string[];
|
|
17
23
|
/**
|
|
18
24
|
* Fetch the authenticated user's resolved role groups from the backend.
|
|
19
25
|
* Calls the `fnd_authz_user_groups()` PostgREST RPC endpoint.
|
|
@@ -24,8 +30,9 @@ export declare function fetchUserGroups(apiClient: RaytioApiClient): Promise<Use
|
|
|
24
30
|
* backend roles. Returns a comma-separated domain spec string compatible
|
|
25
31
|
* with `resolveDomains()`.
|
|
26
32
|
*
|
|
27
|
-
* Returns `undefined` when the user has no recognised roles
|
|
28
|
-
*
|
|
33
|
+
* Returns `undefined` when the user has no recognised roles — the caller
|
|
34
|
+
* (see `src/index.ts`) MUST fail closed in that case rather than fall
|
|
35
|
+
* back to the full tool surface.
|
|
29
36
|
*/
|
|
30
37
|
export declare function resolveUserDomains(apiClient: RaytioApiClient): Promise<string | undefined>;
|
|
31
38
|
//# sourceMappingURL=role-mapping.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-mapping.d.ts","sourceRoot":"","sources":["../../src/tools/role-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"role-mapping.d.ts","sourceRoot":"","sources":["../../src/tools/role-mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAsBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAqBhE;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,eAAe,GACzB,OAAO,CAAC,SAAS,EAAE,CAAC,CAEtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,eAAe,GACzB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAO7B"}
|
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Map role group
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* - PROJECT_USER, PROJECT_ADMINISTRATOR
|
|
6
|
-
*
|
|
7
|
-
* Role codes that grant read-only PPM access (SELECT only):
|
|
8
|
-
* - PROJECT_VIEWER
|
|
9
|
-
*
|
|
10
|
-
* Role codes that grant full DSM access:
|
|
11
|
-
* - DATA_SHARING_USER, DATA_SHARING_ADMINISTRATOR
|
|
2
|
+
* Map role group names (as returned by `fnd_authz_user_groups()`) to the
|
|
3
|
+
* tool domain IDs they unlock. Keys are the exact Persist seed values
|
|
4
|
+
* from `02435-seed-hrm-role-group-inheritance.sql`.
|
|
12
5
|
*/
|
|
13
6
|
const ROLE_TO_DOMAINS = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
'Project administrator': ['ppm', 'prm', 'wrm'],
|
|
8
|
+
'Project user': ['ppm', 'prm'],
|
|
9
|
+
'Project viewer': ['ppm-readonly', 'wrm-readonly'],
|
|
10
|
+
'Data sharing administrator': ['dsm'],
|
|
11
|
+
'Data sharing user': ['dsm'],
|
|
12
|
+
'Data sharing viewer': ['dsm'],
|
|
13
|
+
'Worker administrator': ['wrm', 'prm'],
|
|
14
|
+
'Worker user': ['wrm', 'prm'],
|
|
15
|
+
'Worker viewer': ['wrm-readonly'],
|
|
16
|
+
'Sales administrator': ['sfa', 'prm'],
|
|
17
|
+
'Sales user': ['sfa', 'prm'],
|
|
18
|
+
'Sales viewer': ['sfa-readonly'],
|
|
24
19
|
};
|
|
25
20
|
/**
|
|
26
|
-
* Given a list of user group
|
|
21
|
+
* Given a list of user group names, resolve the set of tool domain IDs
|
|
27
22
|
* the user should have access to.
|
|
28
23
|
*
|
|
29
|
-
* When both
|
|
24
|
+
* When both a full-access and readonly domain are present (e.g. `ppm`
|
|
25
|
+
* and `ppm-readonly`), the full-access variant wins.
|
|
30
26
|
*/
|
|
31
|
-
export function mapRolesToDomains(
|
|
27
|
+
export function mapRolesToDomains(groupNames) {
|
|
32
28
|
const domains = new Set();
|
|
33
|
-
for (const
|
|
34
|
-
const mapped = ROLE_TO_DOMAINS[
|
|
29
|
+
for (const name of groupNames) {
|
|
30
|
+
const mapped = ROLE_TO_DOMAINS[name];
|
|
35
31
|
if (mapped) {
|
|
36
32
|
for (const d of mapped)
|
|
37
33
|
domains.add(d);
|
|
@@ -61,13 +57,16 @@ export async function fetchUserGroups(apiClient) {
|
|
|
61
57
|
* backend roles. Returns a comma-separated domain spec string compatible
|
|
62
58
|
* with `resolveDomains()`.
|
|
63
59
|
*
|
|
64
|
-
* Returns `undefined` when the user has no recognised roles
|
|
65
|
-
*
|
|
60
|
+
* Returns `undefined` when the user has no recognised roles — the caller
|
|
61
|
+
* (see `src/index.ts`) MUST fail closed in that case rather than fall
|
|
62
|
+
* back to the full tool surface.
|
|
66
63
|
*/
|
|
67
64
|
export async function resolveUserDomains(apiClient) {
|
|
68
65
|
const groups = await fetchUserGroups(apiClient);
|
|
69
|
-
const
|
|
70
|
-
|
|
66
|
+
const names = groups
|
|
67
|
+
.map((g) => g.group_name)
|
|
68
|
+
.filter((n) => typeof n === 'string' && n.length > 0);
|
|
69
|
+
const domains = mapRolesToDomains(names);
|
|
71
70
|
return domains.length > 0 ? domains.join(',') : undefined;
|
|
72
71
|
}
|
|
73
72
|
//# sourceMappingURL=role-mapping.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role-mapping.js","sourceRoot":"","sources":["../../src/tools/role-mapping.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"role-mapping.js","sourceRoot":"","sources":["../../src/tools/role-mapping.ts"],"names":[],"mappings":"AAgBA;;;;GAIG;AACH,MAAM,eAAe,GAA6B;IAChD,uBAAuB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC;IAC9C,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;IAC9B,gBAAgB,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;IAClD,4BAA4B,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AED,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAA0B;IAE1B,OAAO,SAAS,CAAC,IAAI,CAAc,kCAAkC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,SAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,MAAM;SACjB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AA6BA,eAAO,MAAM,eAAe,EAAE,MAA6B,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { dirname, resolve } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the running package version from `package.json` at load time.
|
|
6
|
+
*
|
|
7
|
+
* The MCP server previously reported a hard-coded `1.0.0`, which desynced
|
|
8
|
+
* from the value clients had installed and made version-based bug reports
|
|
9
|
+
* impossible to triage. Reading `package.json` keeps the reported version
|
|
10
|
+
* in step with the shipped artifact.
|
|
11
|
+
*
|
|
12
|
+
* `package.json` lives one directory above both `src/` (dev via tsx) and
|
|
13
|
+
* `dist/` (built), so the relative path is identical in both layouts.
|
|
14
|
+
*/
|
|
15
|
+
function readPackageVersion() {
|
|
16
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const packageJsonPath = resolve(here, '..', 'package.json');
|
|
18
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
19
|
+
if (typeof parsed.version !== 'string' || parsed.version.length === 0) {
|
|
20
|
+
throw new Error(`Unable to read package version from ${packageJsonPath}: missing "version"`);
|
|
21
|
+
}
|
|
22
|
+
return parsed.version;
|
|
23
|
+
}
|
|
24
|
+
export const PACKAGE_VERSION = readPackageVersion();
|
|
25
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC;;;;;;;;;;GAUG;AACH,SAAS,kBAAkB;IACzB,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAE9D,CAAC;IACF,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CACb,uCAAuC,eAAe,qBAAqB,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAW,kBAAkB,EAAE,CAAC"}
|