@jupiterone/jupiterone-mcp 1.2.0 → 1.4.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/client/graphql/queries.d.ts +1 -0
- package/dist/client/graphql/queries.d.ts.map +1 -1
- package/dist/client/graphql/queries.js +19 -1
- package/dist/client/graphql/queries.js.map +1 -1
- package/dist/client/jupiterone-client.d.ts +1 -0
- package/dist/client/jupiterone-client.d.ts.map +1 -1
- package/dist/client/jupiterone-client.js +3 -0
- package/dist/client/jupiterone-client.js.map +1 -1
- package/dist/client/services/account-service.d.ts +16 -0
- package/dist/client/services/account-service.d.ts.map +1 -1
- package/dist/client/services/account-service.js +19 -0
- package/dist/client/services/account-service.js.map +1 -1
- package/dist/client/services/j1ql-service.d.ts +44 -3
- package/dist/client/services/j1ql-service.d.ts.map +1 -1
- package/dist/client/services/j1ql-service.js +82 -31
- package/dist/client/services/j1ql-service.js.map +1 -1
- package/dist/generated/description-map.d.ts.map +1 -1
- package/dist/generated/description-map.js +47 -6
- package/dist/generated/description-map.js.map +1 -1
- package/dist/server/mcp-server.d.ts +10 -0
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/server/mcp-server.js +55 -35
- package/dist/server/mcp-server.js.map +1 -1
- package/dist/server/tools/account.d.ts +25 -0
- package/dist/server/tools/account.d.ts.map +1 -1
- package/dist/server/tools/account.js +97 -5
- package/dist/server/tools/account.js.map +1 -1
- package/dist/server/tools/errors.d.ts +14 -6
- package/dist/server/tools/errors.d.ts.map +1 -1
- package/dist/server/tools/errors.js +22 -7
- package/dist/server/tools/errors.js.map +1 -1
- package/dist/server/tools/j1ql.d.ts.map +1 -1
- package/dist/server/tools/j1ql.js +215 -22
- package/dist/server/tools/j1ql.js.map +1 -1
- package/dist/server/tools/types.d.ts +4 -0
- package/dist/server/tools/types.d.ts.map +1 -1
- package/dist/server/tools/types.js.map +1 -1
- package/dist/server/tools/usage.d.ts.map +1 -1
- package/dist/server/tools/usage.js +4 -0
- package/dist/server/tools/usage.js.map +1 -1
- package/node_modules/dtrace-provider/build/Makefile +1 -1
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ class JupiterOneMcpServer {
|
|
|
49
49
|
* resolver, consumed by the account-discovery tool.
|
|
50
50
|
*/
|
|
51
51
|
toolContext() {
|
|
52
|
-
return { resolveAccounts: this.resolveAccounts };
|
|
52
|
+
return { resolveAccounts: this.resolveAccounts, pinnedAccountId: this.envAccountId };
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Single registration chokepoint: injects the per-request `accountId` parameter when no env
|
|
@@ -57,8 +57,24 @@ class JupiterOneMcpServer {
|
|
|
57
57
|
* error formatting (C2), and per-call telemetry (O1).
|
|
58
58
|
*/
|
|
59
59
|
register(tool) {
|
|
60
|
+
const registerTool = this.server.registerTool.bind(this.server);
|
|
61
|
+
registerTool(tool.name, this.toolConfig(tool), (params) => this.invoke(tool, params));
|
|
62
|
+
}
|
|
63
|
+
/** Build the SDK registration config for a tool. */
|
|
64
|
+
toolConfig(tool) {
|
|
65
|
+
return {
|
|
66
|
+
title: tool.title,
|
|
67
|
+
description: tool.description,
|
|
68
|
+
inputSchema: this.buildInputSchema(tool),
|
|
69
|
+
...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),
|
|
70
|
+
// The connector directory validates `annotations.title`, so mirror the per-tool title into
|
|
71
|
+
// annotations (the SDK's top-level `title` above is a separate field it does not check).
|
|
72
|
+
annotations: { ...tool.annotations, title: tool.title },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
buildInputSchema(tool) {
|
|
60
76
|
const needsAccount = this.isMultiTenant && !tool.accountAgnostic;
|
|
61
|
-
|
|
77
|
+
return {
|
|
62
78
|
...tool.inputSchema,
|
|
63
79
|
reason: zod_1.z
|
|
64
80
|
.string()
|
|
@@ -72,41 +88,38 @@ class JupiterOneMcpServer {
|
|
|
72
88
|
}
|
|
73
89
|
: {}),
|
|
74
90
|
};
|
|
75
|
-
const registerTool = this.server.registerTool.bind(this.server);
|
|
76
|
-
registerTool(tool.name, {
|
|
77
|
-
title: tool.title,
|
|
78
|
-
description: tool.description,
|
|
79
|
-
inputSchema,
|
|
80
|
-
...(tool.outputSchema ? { outputSchema: tool.outputSchema } : {}),
|
|
81
|
-
// The connector directory validates `annotations.title`, so mirror the per-tool title into
|
|
82
|
-
// annotations (the SDK's top-level `title` above is a separate field it does not check).
|
|
83
|
-
annotations: { ...tool.annotations, title: tool.title },
|
|
84
|
-
}, (params) => this.invoke(tool, params));
|
|
85
91
|
}
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Resolve a call's execution scope: strip the injected `reason`, and in multi-tenant mode
|
|
94
|
+
* consume `accountId` into an account-scoped client clone. Returns null when a required
|
|
95
|
+
* accountId is missing.
|
|
96
|
+
*/
|
|
97
|
+
scopeCall(tool, params) {
|
|
88
98
|
const { reason: rawReason, ...rest } = params;
|
|
89
99
|
const reason = typeof rawReason === 'string' && rawReason.length > 0 ? (0, usage_js_1.truncateReason)(rawReason) : undefined;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
if (!this.isMultiTenant || tool.accountAgnostic) {
|
|
101
|
+
return { client: this.client, toolParams: rest, accountId: this.envAccountId, reason };
|
|
102
|
+
}
|
|
103
|
+
const { accountId: requested, ...toolParams } = rest;
|
|
104
|
+
if (!requested || typeof requested !== 'string')
|
|
105
|
+
return null;
|
|
106
|
+
return {
|
|
107
|
+
client: this.client.cloneWithAccountId(requested),
|
|
108
|
+
toolParams,
|
|
109
|
+
accountId: requested,
|
|
110
|
+
reason,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
static MISSING_ACCOUNT_MESSAGE = 'accountId is required for this operation. Call `list-accounts` to discover the accounts you can access, then retry with the accountId parameter set.';
|
|
114
|
+
async invoke(tool, params) {
|
|
115
|
+
const scoped = this.scopeCall(tool, params);
|
|
116
|
+
if (!scoped) {
|
|
117
|
+
return {
|
|
118
|
+
content: [{ type: 'text', text: `Error: ${JupiterOneMcpServer.MISSING_ACCOUNT_MESSAGE}` }],
|
|
119
|
+
isError: true,
|
|
120
|
+
};
|
|
109
121
|
}
|
|
122
|
+
const { client, toolParams, accountId, reason } = scoped;
|
|
110
123
|
const startedAt = Date.now();
|
|
111
124
|
let outcome = 'success';
|
|
112
125
|
let errorClass;
|
|
@@ -114,8 +127,12 @@ class JupiterOneMcpServer {
|
|
|
114
127
|
let result;
|
|
115
128
|
try {
|
|
116
129
|
result = await tool.handler(toolParams, client, this.validator, this.toolContext());
|
|
117
|
-
if (result.isError)
|
|
130
|
+
if (result.isError) {
|
|
118
131
|
outcome = 'error';
|
|
132
|
+
// Returned error envelopes (not-found, validation, authz frames) carry their message in the
|
|
133
|
+
// first text block; capture it so NR can categorize them like thrown errors.
|
|
134
|
+
errorMessage = result.content[0]?.text?.slice(0, 200);
|
|
135
|
+
}
|
|
119
136
|
return result;
|
|
120
137
|
}
|
|
121
138
|
catch (error) {
|
|
@@ -127,7 +144,10 @@ class JupiterOneMcpServer {
|
|
|
127
144
|
const deniedStatus = (0, errors_js_1.accessDeniedStatus)(error);
|
|
128
145
|
result =
|
|
129
146
|
deniedStatus !== null
|
|
130
|
-
? (0, errors_js_1.accessDeniedResult)(deniedStatus,
|
|
147
|
+
? (0, errors_js_1.accessDeniedResult)(deniedStatus, {
|
|
148
|
+
hasAccountDiscovery: !!this.resolveAccounts,
|
|
149
|
+
pinnedAccountId: this.envAccountId,
|
|
150
|
+
})
|
|
131
151
|
: tool.formatError
|
|
132
152
|
? tool.formatError(error, toolParams, this.validator)
|
|
133
153
|
: (0, errors_js_1.toErrorResponse)(error, tool.errorContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/server/mcp-server.ts"],"names":[],"mappings":";;;AAAA,oEAAoE;AACpE,wEAAiF;AACjF,6BAAwB;AACxB,yEAAkE;AAElE,qDAA6C;AAE7C,kEAA2D;AAC3D,+CAA4C;AAC5C,iDAA4F;AAE5F,uDAA2E;AAC3E,uCAA4C;AAC5C,+CAAmF;AAgCnF,MAAa,mBAAmB;IACvB,MAAM,CAAY;IACjB,MAAM,CAAmB;IACzB,SAAS,CAAgB;IACzB,aAAa,CAAU;IACvB,SAAS,CAAgB;IACzB,YAAY,CAAU;IACtB,eAAe,CAAmB;IAE1C,YAAY,MAAwB,EAAE,UAAsC,EAAE;QAC5E,IAAI,CAAC,MAAM,GAAG,IAAI,uCAAgB,CAAC,MAAM,CAAC,CAAC;QAC3C,4FAA4F;QAC5F,gDAAgD;QAChD,IAAI,CAAC,SAAS,GAAG,IAAI,iCAAa,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CAAC;YAC1B,IAAI,EAAE,gBAAgB;YACtB,KAAK,EAAE,YAAY;YACnB,OAAO,EAAP,sBAAO;YACP,UAAU,EAAE,4BAA4B;YACxC,KAAK,EAAE,CAAC,yBAAe,CAAC;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,IAAI,SAAS,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,8BAAe,CAAC;QACtD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;QAE/C,KAAK,MAAM,IAAI,IAAI,mBAAQ,EAAE,CAAC;YAC5B,6FAA6F;YAC7F,2FAA2F;YAC3F,IAAI,IAAI,CAAC,uBAAuB,IAAI,CAAC,IAAI,CAA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0LC"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
1
|
import { type ToolDefinition } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether the caller is a full account admin. RBAC `resourceAreas` can be all-false for such users
|
|
4
|
+
* (they have no per-resource-group rows), so this flags that `resourceAreas` may understate access —
|
|
5
|
+
* a caller seeing a false area should still attempt the operation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hasBroadAbacAccess(statements: string[]): boolean;
|
|
8
|
+
type AreaSummary = {
|
|
9
|
+
create: boolean;
|
|
10
|
+
read: boolean;
|
|
11
|
+
update: boolean;
|
|
12
|
+
delete: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Coarse any-grant fold of iamGetCurrentUser resourcePermissions rows: true means at least one
|
|
16
|
+
* grant exists for that action in that area. The authoritative check stays with the API — a user
|
|
17
|
+
* with broad ABAC access may legitimately have zero rows here.
|
|
18
|
+
*/
|
|
19
|
+
export declare function summarizeResourceAreas(rows: Array<{
|
|
20
|
+
resourceArea: string;
|
|
21
|
+
canCreate: boolean;
|
|
22
|
+
canRead: boolean;
|
|
23
|
+
canUpdate: boolean;
|
|
24
|
+
canDelete: boolean;
|
|
25
|
+
}>): Record<string, AreaSummary>;
|
|
2
26
|
export declare const accountTools: ToolDefinition[];
|
|
27
|
+
export {};
|
|
3
28
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/server/tools/account.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/server/tools/account.ts"],"names":[],"mappings":"AAKA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAmCxE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAEhE;AAED,KAAK,WAAW,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AAExF;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,KAAK,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,GAClH,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAe7B;AAeD,eAAO,MAAM,YAAY,EAAE,cAAc,EAyExC,CAAC"}
|
|
@@ -1,22 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.accountTools = void 0;
|
|
4
|
+
exports.hasBroadAbacAccess = hasBroadAbacAccess;
|
|
5
|
+
exports.summarizeResourceAreas = summarizeResourceAreas;
|
|
4
6
|
const zod_1 = require("zod");
|
|
5
7
|
const package_json_1 = require("../../../package.json");
|
|
6
8
|
const load_description_js_1 = require("../../utils/load-description.js");
|
|
7
9
|
const errors_js_1 = require("./errors.js");
|
|
8
10
|
const result_js_1 = require("./result.js");
|
|
9
11
|
const types_js_1 = require("./types.js");
|
|
12
|
+
const resourceAreaPermissions = zod_1.z.object({
|
|
13
|
+
create: zod_1.z.boolean(),
|
|
14
|
+
read: zod_1.z.boolean(),
|
|
15
|
+
update: zod_1.z.boolean(),
|
|
16
|
+
delete: zod_1.z.boolean(),
|
|
17
|
+
});
|
|
10
18
|
const testConnectionOutput = {
|
|
11
19
|
connected: zod_1.z.boolean(),
|
|
12
20
|
account: zod_1.z.record(zod_1.z.any()).nullable().optional(),
|
|
13
|
-
|
|
21
|
+
user: zod_1.z.object({ email: zod_1.z.string().nullish() }).nullish(),
|
|
22
|
+
permissions: zod_1.z
|
|
23
|
+
.object({
|
|
24
|
+
resourceAreas: zod_1.z.record(resourceAreaPermissions),
|
|
25
|
+
hasBroadAccess: zod_1.z.boolean(),
|
|
26
|
+
})
|
|
27
|
+
.nullish(),
|
|
14
28
|
version: zod_1.z.string().optional(),
|
|
15
29
|
};
|
|
30
|
+
/** Resource areas MCP tools write to; always reported explicitly, even with no grant rows. */
|
|
31
|
+
const MCP_RESOURCE_AREAS = ['dashboard', 'rule', 'integration'];
|
|
32
|
+
/**
|
|
33
|
+
* The full-account-admin ABAC statement. `accessAdmin` is `fullAdminRuleName` in jupiter-types, and
|
|
34
|
+
* the iam-authorizer maps it to `*` (all operations) — a holder can perform any MCP operation
|
|
35
|
+
* regardless of their fine-grained RBAC rows. Every other statement is area-scoped, read-only, or a
|
|
36
|
+
* narrow operation grant (fullReadAccess, writeGraph, writeQuestions, adminGalaxy/Landing/…) and does
|
|
37
|
+
* not imply broad access, so none are surfaced. (`accountAdmin` also maps to `*` at the authorizer
|
|
38
|
+
* but is intentionally excluded: it is not the frontend's admin gate and is being kept out here.)
|
|
39
|
+
*/
|
|
40
|
+
const BROAD_ACCESS_ABAC = new Set(['accessAdmin']);
|
|
41
|
+
/**
|
|
42
|
+
* Whether the caller is a full account admin. RBAC `resourceAreas` can be all-false for such users
|
|
43
|
+
* (they have no per-resource-group rows), so this flags that `resourceAreas` may understate access —
|
|
44
|
+
* a caller seeing a false area should still attempt the operation.
|
|
45
|
+
*/
|
|
46
|
+
function hasBroadAbacAccess(statements) {
|
|
47
|
+
return statements.some((s) => BROAD_ACCESS_ABAC.has(s));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Coarse any-grant fold of iamGetCurrentUser resourcePermissions rows: true means at least one
|
|
51
|
+
* grant exists for that action in that area. The authoritative check stays with the API — a user
|
|
52
|
+
* with broad ABAC access may legitimately have zero rows here.
|
|
53
|
+
*/
|
|
54
|
+
function summarizeResourceAreas(rows) {
|
|
55
|
+
const areas = {};
|
|
56
|
+
const blank = () => ({ create: false, read: false, update: false, delete: false });
|
|
57
|
+
for (const area of MCP_RESOURCE_AREAS)
|
|
58
|
+
areas[area] = blank();
|
|
59
|
+
for (const row of rows) {
|
|
60
|
+
// Only fold the MCP-relevant areas — the API returns rows for many other areas (collector,
|
|
61
|
+
// control, …) that would bloat the output and mean nothing to an MCP caller.
|
|
62
|
+
const area = areas[row.resourceArea];
|
|
63
|
+
if (!area)
|
|
64
|
+
continue;
|
|
65
|
+
area.create = area.create || !!row.canCreate;
|
|
66
|
+
area.read = area.read || !!row.canRead;
|
|
67
|
+
area.update = area.update || !!row.canUpdate;
|
|
68
|
+
area.delete = area.delete || !!row.canDelete;
|
|
69
|
+
}
|
|
70
|
+
return areas;
|
|
71
|
+
}
|
|
16
72
|
// `.nullish()`: one account with a null displayName must not fail validation for the whole list.
|
|
17
73
|
const accountSummary = zod_1.z.object({
|
|
18
74
|
accountId: zod_1.z.string().nullish(),
|
|
19
75
|
displayName: zod_1.z.string().nullish(),
|
|
76
|
+
// `.optional()` (not `.nullish()`): the host either constructs a URL string or omits the key —
|
|
77
|
+
// it is never null, and the AccountSummary type is `mcpUrl?: string`.
|
|
78
|
+
mcpUrl: zod_1.z.string().optional(),
|
|
20
79
|
});
|
|
21
80
|
const listAccountsOutput = {
|
|
22
81
|
accounts: zod_1.z.array(accountSummary),
|
|
@@ -33,16 +92,49 @@ exports.accountTools = [
|
|
|
33
92
|
handler: async (_params, client, _validator, context) => {
|
|
34
93
|
try {
|
|
35
94
|
const account = await client.getAccountInfo();
|
|
36
|
-
|
|
95
|
+
// Enrichment is best-effort: an iamGetCurrentUser failure must not fail a working connection.
|
|
96
|
+
const currentUser = await client.getCurrentUser().catch(() => null);
|
|
97
|
+
return (0, result_js_1.structuredResult)({
|
|
98
|
+
connected: true,
|
|
99
|
+
account,
|
|
100
|
+
...(currentUser
|
|
101
|
+
? {
|
|
102
|
+
user: { email: currentUser.email ?? null },
|
|
103
|
+
permissions: {
|
|
104
|
+
resourceAreas: summarizeResourceAreas(currentUser.resourcePermissions),
|
|
105
|
+
hasBroadAccess: hasBroadAbacAccess(currentUser.abacStatements),
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
: {}),
|
|
109
|
+
version: package_json_1.version,
|
|
110
|
+
});
|
|
37
111
|
}
|
|
38
112
|
catch (error) {
|
|
39
113
|
const deniedStatus = (0, errors_js_1.accessDeniedStatus)(error);
|
|
40
|
-
|
|
41
|
-
? (0, errors_js_1.accessDeniedMessage)(deniedStatus,
|
|
114
|
+
let reason = deniedStatus !== null
|
|
115
|
+
? (0, errors_js_1.accessDeniedMessage)(deniedStatus, {
|
|
116
|
+
hasAccountDiscovery: !!context.resolveAccounts,
|
|
117
|
+
pinnedAccountId: context.pinnedAccountId,
|
|
118
|
+
})
|
|
42
119
|
: error instanceof Error
|
|
43
120
|
? error.message
|
|
44
121
|
: 'Unknown error';
|
|
45
|
-
|
|
122
|
+
// On an authz failure with discovery available, list what the caller CAN reach — this turns a
|
|
123
|
+
// wrong-account binding from a multi-day loop into a one-shot diagnosis.
|
|
124
|
+
if (deniedStatus !== null && context.resolveAccounts) {
|
|
125
|
+
const accounts = await context.resolveAccounts().catch(() => null);
|
|
126
|
+
if (accounts && accounts.length > 0) {
|
|
127
|
+
reason +=
|
|
128
|
+
'\n\nAccounts your sign-in can access:\n' +
|
|
129
|
+
accounts
|
|
130
|
+
.map((a) => `- ${a.displayName} (${a.accountId})${a.mcpUrl ? ` — ${a.mcpUrl}` : ''}`)
|
|
131
|
+
.join('\n');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
content: [{ type: 'text', text: `Connection test failed: ${reason}` }],
|
|
136
|
+
isError: true,
|
|
137
|
+
};
|
|
46
138
|
}
|
|
47
139
|
},
|
|
48
140
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/server/tools/account.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/server/tools/account.ts"],"names":[],"mappings":";;;AA6CA,gDAEC;AASD,wDAiBC;AAzED,6BAAwB;AACxB,wDAAgD;AAChD,yEAAkE;AAClE,2CAAsE;AACtE,2CAA+C;AAC/C,yCAAwE;AAExE,MAAM,uBAAuB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;IACnB,IAAI,EAAE,OAAC,CAAC,OAAO,EAAE;IACjB,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;IACnB,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,oBAAoB,GAAG;IAC3B,SAAS,EAAE,OAAC,CAAC,OAAO,EAAE;IACtB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IAChD,IAAI,EAAE,OAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;IACzD,WAAW,EAAE,OAAC;SACX,MAAM,CAAC;QACN,aAAa,EAAE,OAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC;QAChD,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE;KAC5B,CAAC;SACD,OAAO,EAAE;IACZ,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC;AAEF,8FAA8F;AAC9F,MAAM,kBAAkB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEnD;;;;GAIG;AACH,SAAgB,kBAAk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IAAA,qCAAe,EAAC,kBAAkB,CAAC;QAChD,WAAW,EAAE,EAAE;QACf,YAAY,EAAE,kBAAkB;QAChC,WAAW,EAAE,oBAAS;QACtB,eAAe,EAAE,IAAI;QACrB,uBAAuB,EAAE,IAAI;QAC7B,YAAY,EAAE,yBAAyB;QACvC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;YACvD,MAAM,QAAQ,GAAG,CAAC,MAAM,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;YAC3D,OAAO,IAAA,4BAAgB,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;CACH,CAAC"}
|
|
@@ -10,14 +10,22 @@ import type { ToolResult } from './types.js';
|
|
|
10
10
|
* status so callers get a consistent access-denied frame.
|
|
11
11
|
*/
|
|
12
12
|
export declare function accessDeniedStatus(error: unknown): number | null;
|
|
13
|
+
/** How the current server instance is bound to an account, for access-denied phrasing. */
|
|
14
|
+
export interface AccessDeniedContext {
|
|
15
|
+
/** Whether the `list-accounts` discovery tool is registered on this server instance. */
|
|
16
|
+
hasAccountDiscovery: boolean;
|
|
17
|
+
/** The fixed account this instance is bound to (URL subdomain / env config), when single-tenant. */
|
|
18
|
+
pinnedAccountId?: string;
|
|
19
|
+
}
|
|
13
20
|
/**
|
|
14
|
-
* Agent-facing message for an access-denied upstream response.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* no discovery
|
|
21
|
+
* Agent-facing message for an access-denied upstream response. Three shapes:
|
|
22
|
+
* - pinned + discovery (remote with a URL-pinned account): the binding is the problem — name it,
|
|
23
|
+
* steer to list-accounts + fixing the connector URL. Re-authenticating cannot fix a bad binding.
|
|
24
|
+
* - pinned, no discovery (stdio env account): point at the configured account and credentials.
|
|
25
|
+
* - multi-tenant: per-call accountId — steer to list-accounts and a different accountId.
|
|
18
26
|
*/
|
|
19
|
-
export declare function accessDeniedMessage(statusCode: number,
|
|
20
|
-
export declare function accessDeniedResult(statusCode: number,
|
|
27
|
+
export declare function accessDeniedMessage(statusCode: number, context: AccessDeniedContext): string;
|
|
28
|
+
export declare function accessDeniedResult(statusCode: number, context: AccessDeniedContext): ToolResult;
|
|
21
29
|
/**
|
|
22
30
|
* Generic error envelope for a thrown handler. Upstream GraphQL errors are already sanitized at
|
|
23
31
|
* the shared client (S9), so `error.message` is safe to surface here. Access-denied (401/403)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAiB7C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAYhE;AAED
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAiB7C;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAYhE;AAED,0FAA0F;AAC1F,MAAM,WAAW,mBAAmB;IAClC,wFAAwF;IACxF,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oGAAoG;IACpG,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAwB5F;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,GAAG,UAAU,CAK/F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,UAAU,CAM3E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,KAAK,EAAE,GAAG,SAAS,EAC5B,SAAS,EAAE,aAAa,GACvB,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBjE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,UAAU,CAYb;AAED,+FAA+F;AAC/F,wBAAgB,6BAA6B,CAC3C,iBAAiB,EAAE,KAAK,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GACjF,UAAU,CAYZ;AAED,qGAAqG;AACrG,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,aAAa,GACvB,UAAU,CAiBZ"}
|
|
@@ -45,12 +45,27 @@ function accessDeniedStatus(error) {
|
|
|
45
45
|
return null;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Agent-facing message for an access-denied upstream response.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* no discovery
|
|
48
|
+
* Agent-facing message for an access-denied upstream response. Three shapes:
|
|
49
|
+
* - pinned + discovery (remote with a URL-pinned account): the binding is the problem — name it,
|
|
50
|
+
* steer to list-accounts + fixing the connector URL. Re-authenticating cannot fix a bad binding.
|
|
51
|
+
* - pinned, no discovery (stdio env account): point at the configured account and credentials.
|
|
52
|
+
* - multi-tenant: per-call accountId — steer to list-accounts and a different accountId.
|
|
52
53
|
*/
|
|
53
|
-
function accessDeniedMessage(statusCode,
|
|
54
|
+
function accessDeniedMessage(statusCode, context) {
|
|
55
|
+
const { hasAccountDiscovery, pinnedAccountId } = context;
|
|
56
|
+
if (pinnedAccountId) {
|
|
57
|
+
const preamble = `Not authorized (HTTP ${statusCode}). This connection is pinned to account ` +
|
|
58
|
+
`"${pinnedAccountId}"; your sign-in succeeded but has no access to it (not a member, or ` +
|
|
59
|
+
`access was revoked), so re-authenticating alone will not fix this.`;
|
|
60
|
+
const recovery = hasAccountDiscovery
|
|
61
|
+
? ' Call `list-accounts` to see the accounts your sign-in can access (with their connector ' +
|
|
62
|
+
'URLs where available), then have the user update the accountId in the connector/server ' +
|
|
63
|
+
'URL. If the account you expect is not listed, it may be hosted in a different region and ' +
|
|
64
|
+
"needs that region's MCP URL."
|
|
65
|
+
: ' Verify the configured account (e.g. JUPITERONE_ACCOUNT_ID) and that your credentials ' +
|
|
66
|
+
'have access to it, or ask an account admin to grant access.';
|
|
67
|
+
return preamble + recovery;
|
|
68
|
+
}
|
|
54
69
|
const guidance = hasAccountDiscovery
|
|
55
70
|
? 'Use `list-accounts` to review your account memberships and try another accountId — note ' +
|
|
56
71
|
'that a listed account is not a guarantee of live access.'
|
|
@@ -58,9 +73,9 @@ function accessDeniedMessage(statusCode, hasAccountDiscovery) {
|
|
|
58
73
|
return (`Not authorized for this account (HTTP ${statusCode}). Your access may have been revoked, ` +
|
|
59
74
|
`or the account may require a different sign-in method such as SSO. ${guidance}`);
|
|
60
75
|
}
|
|
61
|
-
function accessDeniedResult(statusCode,
|
|
76
|
+
function accessDeniedResult(statusCode, context) {
|
|
62
77
|
return {
|
|
63
|
-
content: [{ type: 'text', text: accessDeniedMessage(statusCode,
|
|
78
|
+
content: [{ type: 'text', text: accessDeniedMessage(statusCode, context) }],
|
|
64
79
|
isError: true,
|
|
65
80
|
};
|
|
66
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":";;AA4BA,gDAYC;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/server/tools/errors.ts"],"names":[],"mappings":";;AA4BA,gDAYC;AAiBD,kDAwBC;AAED,gDAKC;AAOD,0CAMC;AAMD,0CAoBC;AAMD,oDAeC;AAGD,sEAcC;AAGD,4DAqBC;AA7LD,sEAAoE;AAEpE,qEAAoF;AAGpF,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEjD,kGAAkG;AAClG,yGAAyG;AACzG,6CAA6C;AAC7C,MAAM,yBAAyB,GAA2B;IACxD,SAAS,EAAE,GAAG;IACd,eAAe,EAAE,GAAG;IACpB,YAAY,EAAE,GAAG;CAClB,CAAC;AAEF,iGAAiG;AACjG,qGAAqG;AACrG,MAAM,qBAAqB,GAAG,yDAAyD,CAAC;AAExF;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,IAAI,CAAC,CAAC,KAAK,YAAY,sCAAkB,CAAC;QAAE,OAAO,IAAI,CAAC;IACxD,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS,IAAI,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACjF,OAAO,KAAK,CAAC,UAAU,CAAC;IAC1B,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,yBAAyB,EAAE,CAAC;QAC1D,OAAO,yBAAyB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,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SAAS,YAAY,CAAC,CAAC,KAAK,iBAAiB,CAAC,CAAC,UAAU,EAAE,CAAC;qBACnF,IAAI,CAAC,MAAM,CAAC,4EAA4E;aAC5F;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,qGAAqG;AACrG,SAAgB,wBAAwB,CACtC,KAAc,EACd,KAAa,EACb,SAAwB;IAExB,qFAAqF;IACrF,IAAI,KAAK,YAAY,mCAAe,EAAE,CAAC;QACrC,OAAO,oBAAoB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAE7D,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,kCAAkC,WAAW,CAAC,KAAK,mBAAmB,WAAW,CAAC,UAAU,qWAAqW;aACxc;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"j1ql.d.ts","sourceRoot":"","sources":["../../../src/server/tools/j1ql.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"j1ql.d.ts","sourceRoot":"","sources":["../../../src/server/tools/j1ql.ts"],"names":[],"mappings":"AAMA,OAAO,EAAyB,KAAK,cAAc,EAAmB,MAAM,YAAY,CAAC;AAiNzF,eAAO,MAAM,SAAS,EAAE,cAAc,EAkIrC,CAAC"}
|