@openintentai/mcp-server 0.13.4
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/README.md +123 -0
- package/dist/client.d.ts +302 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +470 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +42 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +106 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/resources.d.ts +25 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +96 -0
- package/dist/resources.js.map +1 -0
- package/dist/security.d.ts +75 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +248 -0
- package/dist/security.js.map +1 -0
- package/dist/tools.d.ts +21 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +1485 -0
- package/dist/tools.js.map +1 -0
- package/openintent-mcp.config.json +18 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
7
|
+
const config_js_1 = require("./config.js");
|
|
8
|
+
const security_js_1 = require("./security.js");
|
|
9
|
+
const client_js_1 = require("./client.js");
|
|
10
|
+
const tools_js_1 = require("./tools.js");
|
|
11
|
+
const resources_js_1 = require("./resources.js");
|
|
12
|
+
async function main() {
|
|
13
|
+
const config = (0, config_js_1.loadConfig)();
|
|
14
|
+
const warnings = (0, security_js_1.validateConfig)(config);
|
|
15
|
+
for (const w of warnings) {
|
|
16
|
+
process.stderr.write(`[openintent-mcp] WARNING: ${w}\n`);
|
|
17
|
+
}
|
|
18
|
+
const visibleTools = (0, security_js_1.getVisibleTools)(config);
|
|
19
|
+
const apiClient = new client_js_1.OpenIntentClient(config);
|
|
20
|
+
const server = new index_js_1.Server({
|
|
21
|
+
name: "openintent-mcp",
|
|
22
|
+
version: "0.13.2",
|
|
23
|
+
}, {
|
|
24
|
+
capabilities: {
|
|
25
|
+
tools: {},
|
|
26
|
+
resources: {},
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
|
|
30
|
+
tools: tools_js_1.TOOL_DEFINITIONS
|
|
31
|
+
.filter((t) => visibleTools.has(t.name))
|
|
32
|
+
.map((t) => ({
|
|
33
|
+
name: t.name,
|
|
34
|
+
description: t.description,
|
|
35
|
+
inputSchema: t.inputSchema,
|
|
36
|
+
})),
|
|
37
|
+
}));
|
|
38
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
39
|
+
const { name, arguments: args } = request.params;
|
|
40
|
+
return (0, tools_js_1.handleToolCall)(name, (args ?? {}), apiClient, config);
|
|
41
|
+
});
|
|
42
|
+
server.setRequestHandler(types_js_1.ListResourceTemplatesRequestSchema, async () => ({
|
|
43
|
+
resourceTemplates: resources_js_1.RESOURCE_TEMPLATES.map((r) => ({
|
|
44
|
+
uriTemplate: r.uriTemplate,
|
|
45
|
+
name: r.name,
|
|
46
|
+
description: r.description,
|
|
47
|
+
mimeType: r.mimeType,
|
|
48
|
+
})),
|
|
49
|
+
}));
|
|
50
|
+
server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => {
|
|
51
|
+
return (0, resources_js_1.handleReadResource)(request.params.uri, apiClient);
|
|
52
|
+
});
|
|
53
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
54
|
+
await server.connect(transport);
|
|
55
|
+
const toolCount = visibleTools.size;
|
|
56
|
+
const totalCount = tools_js_1.TOOL_DEFINITIONS.length;
|
|
57
|
+
process.stderr.write(`[openintent-mcp] Server started – role="${config.security.role}", ` +
|
|
58
|
+
`tools=${toolCount}/${totalCount}, connected to ${config.server.url}\n`);
|
|
59
|
+
}
|
|
60
|
+
main().catch((err) => {
|
|
61
|
+
process.stderr.write(`[openintent-mcp] Fatal error: ${err}\n`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,wEAAmE;AACnE,wEAAiF;AACjF,iEAK4C;AAE5C,2CAAyC;AACzC,+CAAgE;AAChE,2CAA+C;AAC/C,yCAA8D;AAC9D,iDAAwE;AAExE,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAA,sBAAU,GAAE,CAAC;IAE5B,MAAM,QAAQ,GAAG,IAAA,4BAAc,EAAC,MAAM,CAAC,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,YAAY,GAAG,IAAA,6BAAe,EAAC,MAAM,CAAC,CAAC;IAE7C,MAAM,SAAS,GAAG,IAAI,4BAAgB,CAAC,MAAM,CAAC,CAAC;IAE/C,MAAM,MAAM,GAAG,IAAI,iBAAM,CACvB;QACE,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,QAAQ;KAClB,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;SACd;KACF,CACF,CAAC;IAEF,MAAM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AAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;IACpC,MAAM,UAAU,GAAG,2BAAgB,CAAC,MAAM,CAAC;IAC3C,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,2CAA2C,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK;QACpE,SAAS,SAAS,IAAI,UAAU,kBAAkB,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,CACxE,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,GAAG,IAAI,CAAC,CAAC;IAC/D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OpenIntentClient } from "./client.js";
|
|
2
|
+
export interface ResourceDefinition {
|
|
3
|
+
uri: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ResourceTemplateDefinition {
|
|
9
|
+
uriTemplate: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const RESOURCE_TEMPLATES: ResourceTemplateDefinition[];
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a resource URI to data by calling the OpenIntent API.
|
|
17
|
+
*/
|
|
18
|
+
export declare function handleReadResource(uri: string, client: OpenIntentClient): Promise<{
|
|
19
|
+
contents: Array<{
|
|
20
|
+
uri: string;
|
|
21
|
+
mimeType: string;
|
|
22
|
+
text: string;
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,EAAE,0BAA0B,EA+B1D,CAAC;AAEF;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CA6D/E"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RESOURCE_TEMPLATES = void 0;
|
|
4
|
+
exports.handleReadResource = handleReadResource;
|
|
5
|
+
exports.RESOURCE_TEMPLATES = [
|
|
6
|
+
{
|
|
7
|
+
uriTemplate: "openintent://intents",
|
|
8
|
+
name: "All Intents",
|
|
9
|
+
description: "List all intents. Append ?status=active to filter by status.",
|
|
10
|
+
mimeType: "application/json",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
uriTemplate: "openintent://intents/{intent_id}",
|
|
14
|
+
name: "Intent Details",
|
|
15
|
+
description: "Get full details for a specific intent including status, state, and metadata.",
|
|
16
|
+
mimeType: "application/json",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
uriTemplate: "openintent://intents/{intent_id}/events",
|
|
20
|
+
name: "Intent Events",
|
|
21
|
+
description: "Get the immutable event log for an intent.",
|
|
22
|
+
mimeType: "application/json",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
uriTemplate: "openintent://intents/{intent_id}/state",
|
|
26
|
+
name: "Intent State",
|
|
27
|
+
description: "Get the current state key-value data for an intent.",
|
|
28
|
+
mimeType: "application/json",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
uriTemplate: "openintent://channels/{channel_id}/messages",
|
|
32
|
+
name: "Channel Messages",
|
|
33
|
+
description: "Get messages from a messaging channel.",
|
|
34
|
+
mimeType: "application/json",
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a resource URI to data by calling the OpenIntent API.
|
|
39
|
+
*/
|
|
40
|
+
async function handleReadResource(uri, client) {
|
|
41
|
+
const parsed = new URL(uri);
|
|
42
|
+
const path = parsed.hostname + parsed.pathname;
|
|
43
|
+
// openintent://intents
|
|
44
|
+
if (path === "intents" || path === "intents/") {
|
|
45
|
+
const status = parsed.searchParams.get("status") ?? undefined;
|
|
46
|
+
const data = await client.listIntents({ status });
|
|
47
|
+
return {
|
|
48
|
+
contents: [
|
|
49
|
+
{ uri, mimeType: "application/json", text: JSON.stringify(data, null, 2) },
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// openintent://intents/{id}/events
|
|
54
|
+
const eventsMatch = path.match(/^intents\/([^/]+)\/events$/);
|
|
55
|
+
if (eventsMatch) {
|
|
56
|
+
const data = await client.getEvents({ intent_id: eventsMatch[1] });
|
|
57
|
+
return {
|
|
58
|
+
contents: [
|
|
59
|
+
{ uri, mimeType: "application/json", text: JSON.stringify(data, null, 2) },
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// openintent://intents/{id}/state
|
|
64
|
+
const stateMatch = path.match(/^intents\/([^/]+)\/state$/);
|
|
65
|
+
if (stateMatch) {
|
|
66
|
+
const intent = (await client.getIntent(stateMatch[1]));
|
|
67
|
+
const state = intent.state ?? {};
|
|
68
|
+
return {
|
|
69
|
+
contents: [
|
|
70
|
+
{ uri, mimeType: "application/json", text: JSON.stringify(state, null, 2) },
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// openintent://intents/{id}
|
|
75
|
+
const intentMatch = path.match(/^intents\/([^/]+)$/);
|
|
76
|
+
if (intentMatch) {
|
|
77
|
+
const data = await client.getIntent(intentMatch[1]);
|
|
78
|
+
return {
|
|
79
|
+
contents: [
|
|
80
|
+
{ uri, mimeType: "application/json", text: JSON.stringify(data, null, 2) },
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// openintent://channels/{id}/messages
|
|
85
|
+
const channelMatch = path.match(/^channels\/([^/]+)\/messages$/);
|
|
86
|
+
if (channelMatch) {
|
|
87
|
+
const data = await client.getChannelMessages({ channel_id: channelMatch[1] });
|
|
88
|
+
return {
|
|
89
|
+
contents: [
|
|
90
|
+
{ uri, mimeType: "application/json", text: JSON.stringify(data, null, 2) },
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
throw new Error(`Unknown resource URI: ${uri}`);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":";;;AAoDA,gDAgEC;AApGY,QAAA,kBAAkB,GAAiC;IAC9D;QACE,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,8DAA8D;QAC3E,QAAQ,EAAE,kBAAkB;KAC7B;IACD;QACE,WAAW,E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,CAAC;IACjE,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9E,OAAO;YACL,QAAQ,EAAE;gBACR,EAAE,GAAG,EAAE,QAAQ,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;aAC3E;SACF,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { MCPConfig, MCPRole } from "./config.js";
|
|
2
|
+
export interface AuditEntry {
|
|
3
|
+
timestamp: string;
|
|
4
|
+
operation: string;
|
|
5
|
+
params: Record<string, unknown>;
|
|
6
|
+
result: "success" | "error";
|
|
7
|
+
duration_ms: number;
|
|
8
|
+
agent_id: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Tool permission tiers.
|
|
12
|
+
*
|
|
13
|
+
* Each tool belongs to exactly one tier. Tiers are cumulative — higher roles
|
|
14
|
+
* inherit all tools from lower tiers.
|
|
15
|
+
*
|
|
16
|
+
* read — Observe protocol state without side effects.
|
|
17
|
+
* write — Progress work within an intent (create content, send messages).
|
|
18
|
+
* admin — Lifecycle control, coordination primitives, structural changes.
|
|
19
|
+
*/
|
|
20
|
+
export type ToolTier = "read" | "write" | "admin";
|
|
21
|
+
export declare const TOOL_TIERS: Record<string, ToolTier>;
|
|
22
|
+
/**
|
|
23
|
+
* Map each role to the set of tiers it grants access to.
|
|
24
|
+
*
|
|
25
|
+
* reader → read
|
|
26
|
+
* operator → read + write
|
|
27
|
+
* admin → read + write + admin
|
|
28
|
+
*/
|
|
29
|
+
export declare const ROLE_TIERS: Record<MCPRole, Set<ToolTier>>;
|
|
30
|
+
export declare function getToolTier(toolName: string): ToolTier | undefined;
|
|
31
|
+
export declare function getTiersForRole(role: MCPRole): Set<ToolTier>;
|
|
32
|
+
export declare function getToolsForRole(role: MCPRole): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Check whether a tool is permitted by the configured role.
|
|
35
|
+
* Returns `true` if the tool's tier is within the role's granted tiers.
|
|
36
|
+
* Unknown tools are denied by default.
|
|
37
|
+
*/
|
|
38
|
+
export declare function checkToolAllowedByRole(toolName: string, config: MCPConfig): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check whether a tool name is permitted by the explicit allowlist.
|
|
41
|
+
* Returns `true` if the tool is allowed, `false` otherwise.
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkToolAllowed(toolName: string, config: MCPConfig): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Combined check: a tool must pass BOTH the role gate AND the allowlist.
|
|
46
|
+
* Returns an object with allowed status and a reason string for denials.
|
|
47
|
+
*/
|
|
48
|
+
export declare function isToolPermitted(toolName: string, config: MCPConfig): {
|
|
49
|
+
allowed: boolean;
|
|
50
|
+
reason?: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Return the list of tool names visible to the current configuration.
|
|
54
|
+
* A tool is visible only if it passes both the role gate and the allowlist.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getVisibleTools(config: MCPConfig): Set<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Validate the loaded configuration, emitting warnings to stderr for
|
|
59
|
+
* potentially dangerous settings (e.g. TLS not required on a non-localhost URL).
|
|
60
|
+
*/
|
|
61
|
+
export declare function validateConfig(config: MCPConfig): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Remove sensitive fields from a params object before writing to audit logs.
|
|
64
|
+
*/
|
|
65
|
+
export declare function sanitizeForAudit(operation: string, params: Record<string, unknown>): Record<string, unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Enforce TLS transport requirements. Throws if a non-HTTPS URL is used
|
|
68
|
+
* when `tls_required` is enabled.
|
|
69
|
+
*/
|
|
70
|
+
export declare function enforceTransport(url: string, config: MCPConfig): void;
|
|
71
|
+
/**
|
|
72
|
+
* Build a structured audit log entry.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createAuditEntry(operation: string, params: Record<string, unknown>, result: "success" | "error", duration: number, agentId: string): AuditEntry;
|
|
75
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtD,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAID;;;;;;;;;GASG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAElD,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAgG/C,CAAC;AAIF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAIrD,CAAC;AAEF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAElE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,CAE5D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,EAAE,CAKvD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAKnF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO,CAK7E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,GAChB;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAmBvC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAO9D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,EAAE,CAqC1D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAOrE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,SAAS,GAAG,OAAO,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,UAAU,CASZ"}
|
package/dist/security.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROLE_TIERS = exports.TOOL_TIERS = void 0;
|
|
4
|
+
exports.getToolTier = getToolTier;
|
|
5
|
+
exports.getTiersForRole = getTiersForRole;
|
|
6
|
+
exports.getToolsForRole = getToolsForRole;
|
|
7
|
+
exports.checkToolAllowedByRole = checkToolAllowedByRole;
|
|
8
|
+
exports.checkToolAllowed = checkToolAllowed;
|
|
9
|
+
exports.isToolPermitted = isToolPermitted;
|
|
10
|
+
exports.getVisibleTools = getVisibleTools;
|
|
11
|
+
exports.validateConfig = validateConfig;
|
|
12
|
+
exports.sanitizeForAudit = sanitizeForAudit;
|
|
13
|
+
exports.enforceTransport = enforceTransport;
|
|
14
|
+
exports.createAuditEntry = createAuditEntry;
|
|
15
|
+
const config_js_1 = require("./config.js");
|
|
16
|
+
const SENSITIVE_KEYS = new Set(["api_key", "password", "secret", "token", "authorization"]);
|
|
17
|
+
exports.TOOL_TIERS = {
|
|
18
|
+
// ── Participation Tools (16) ──────────────────────────────────────
|
|
19
|
+
openintent_get_intent: "read",
|
|
20
|
+
openintent_list_intents: "read",
|
|
21
|
+
openintent_get_events: "read",
|
|
22
|
+
openintent_get_messages: "read",
|
|
23
|
+
openintent_create_intent: "write",
|
|
24
|
+
openintent_update_state: "write",
|
|
25
|
+
openintent_log_event: "write",
|
|
26
|
+
openintent_send_message: "write",
|
|
27
|
+
openintent_ask: "write",
|
|
28
|
+
openintent_broadcast: "write",
|
|
29
|
+
openintent_set_status: "admin",
|
|
30
|
+
openintent_acquire_lease: "admin",
|
|
31
|
+
openintent_release_lease: "admin",
|
|
32
|
+
openintent_assign_agent: "admin",
|
|
33
|
+
openintent_unassign_agent: "admin",
|
|
34
|
+
openintent_create_channel: "admin",
|
|
35
|
+
// ── Advanced Tools (46) ───────────────────────────────────────────
|
|
36
|
+
// Workflows (RFC-0011)
|
|
37
|
+
openintent_get_workflow: "read",
|
|
38
|
+
openintent_list_workflows: "read",
|
|
39
|
+
openintent_create_workflow: "write",
|
|
40
|
+
openintent_trigger_workflow: "admin",
|
|
41
|
+
// Plans & Task Decomposition (RFC-0012)
|
|
42
|
+
openintent_get_plan: "read",
|
|
43
|
+
openintent_create_plan: "write",
|
|
44
|
+
openintent_decompose_task: "write",
|
|
45
|
+
// Coordinator Governance (RFC-0013)
|
|
46
|
+
openintent_get_arbitration: "read",
|
|
47
|
+
openintent_set_coordinator: "admin",
|
|
48
|
+
openintent_record_decision: "admin",
|
|
49
|
+
// Governance Enforcement (RFC-0013)
|
|
50
|
+
openintent_set_governance_policy: "admin",
|
|
51
|
+
openintent_get_governance_policy: "read",
|
|
52
|
+
openintent_approve_approval: "admin",
|
|
53
|
+
openintent_deny_approval: "admin",
|
|
54
|
+
// Human Escalation (RFC-0013)
|
|
55
|
+
openintent_escalate_to_human: "write",
|
|
56
|
+
openintent_list_escalations: "read",
|
|
57
|
+
openintent_resolve_escalation: "admin",
|
|
58
|
+
openintent_request_approval: "write",
|
|
59
|
+
openintent_get_approval_status: "read",
|
|
60
|
+
// Portfolios (RFC-0004)
|
|
61
|
+
openintent_get_portfolio: "read",
|
|
62
|
+
openintent_create_portfolio: "write",
|
|
63
|
+
openintent_add_to_portfolio: "write",
|
|
64
|
+
// Access Control (RFC-0011)
|
|
65
|
+
openintent_get_permissions: "read",
|
|
66
|
+
openintent_set_permissions: "admin",
|
|
67
|
+
openintent_grant_access: "admin",
|
|
68
|
+
// Credential Vaults (RFC-0014)
|
|
69
|
+
openintent_store_credential: "admin",
|
|
70
|
+
openintent_get_credential: "admin",
|
|
71
|
+
openintent_grant_tool: "admin",
|
|
72
|
+
// Agent Memory (RFC-0015)
|
|
73
|
+
openintent_memory_get: "read",
|
|
74
|
+
openintent_memory_list: "read",
|
|
75
|
+
openintent_memory_set: "write",
|
|
76
|
+
// Agent Lifecycle (RFC-0016)
|
|
77
|
+
openintent_get_health: "read",
|
|
78
|
+
openintent_heartbeat: "write",
|
|
79
|
+
openintent_set_agent_status: "admin",
|
|
80
|
+
// Triggers (RFC-0017)
|
|
81
|
+
openintent_list_triggers: "read",
|
|
82
|
+
openintent_create_trigger: "admin",
|
|
83
|
+
openintent_delete_trigger: "admin",
|
|
84
|
+
// Cryptographic Identity (RFC-0018)
|
|
85
|
+
openintent_register_identity: "admin",
|
|
86
|
+
openintent_verify_challenge: "admin",
|
|
87
|
+
openintent_rotate_key: "admin",
|
|
88
|
+
// Verifiable Event Logs (RFC-0019)
|
|
89
|
+
openintent_get_hash_chain: "read",
|
|
90
|
+
openintent_verify_inclusion: "read",
|
|
91
|
+
openintent_get_checkpoint: "read",
|
|
92
|
+
// Distributed Tracing (RFC-0020)
|
|
93
|
+
openintent_get_trace: "read",
|
|
94
|
+
openintent_start_trace: "write",
|
|
95
|
+
openintent_link_spans: "write",
|
|
96
|
+
};
|
|
97
|
+
const TIER_ORDER = ["read", "write", "admin"];
|
|
98
|
+
/**
|
|
99
|
+
* Map each role to the set of tiers it grants access to.
|
|
100
|
+
*
|
|
101
|
+
* reader → read
|
|
102
|
+
* operator → read + write
|
|
103
|
+
* admin → read + write + admin
|
|
104
|
+
*/
|
|
105
|
+
exports.ROLE_TIERS = {
|
|
106
|
+
reader: new Set(["read"]),
|
|
107
|
+
operator: new Set(["read", "write"]),
|
|
108
|
+
admin: new Set(["read", "write", "admin"]),
|
|
109
|
+
};
|
|
110
|
+
function getToolTier(toolName) {
|
|
111
|
+
return exports.TOOL_TIERS[toolName];
|
|
112
|
+
}
|
|
113
|
+
function getTiersForRole(role) {
|
|
114
|
+
return exports.ROLE_TIERS[role] ?? exports.ROLE_TIERS["reader"];
|
|
115
|
+
}
|
|
116
|
+
function getToolsForRole(role) {
|
|
117
|
+
const allowedTiers = getTiersForRole(role);
|
|
118
|
+
return Object.entries(exports.TOOL_TIERS)
|
|
119
|
+
.filter(([, tier]) => allowedTiers.has(tier))
|
|
120
|
+
.map(([name]) => name);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Check whether a tool is permitted by the configured role.
|
|
124
|
+
* Returns `true` if the tool's tier is within the role's granted tiers.
|
|
125
|
+
* Unknown tools are denied by default.
|
|
126
|
+
*/
|
|
127
|
+
function checkToolAllowedByRole(toolName, config) {
|
|
128
|
+
const tier = getToolTier(toolName);
|
|
129
|
+
if (!tier)
|
|
130
|
+
return false;
|
|
131
|
+
const allowedTiers = getTiersForRole(config.security.role);
|
|
132
|
+
return allowedTiers.has(tier);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check whether a tool name is permitted by the explicit allowlist.
|
|
136
|
+
* Returns `true` if the tool is allowed, `false` otherwise.
|
|
137
|
+
*/
|
|
138
|
+
function checkToolAllowed(toolName, config) {
|
|
139
|
+
if (config.security.allowed_tools === null) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
return config.security.allowed_tools.includes(toolName);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Combined check: a tool must pass BOTH the role gate AND the allowlist.
|
|
146
|
+
* Returns an object with allowed status and a reason string for denials.
|
|
147
|
+
*/
|
|
148
|
+
function isToolPermitted(toolName, config) {
|
|
149
|
+
if (!checkToolAllowedByRole(toolName, config)) {
|
|
150
|
+
const tier = getToolTier(toolName) ?? "unknown";
|
|
151
|
+
return {
|
|
152
|
+
allowed: false,
|
|
153
|
+
reason: `Tool "${toolName}" requires "${tier}" permission but the current role ` +
|
|
154
|
+
`"${config.security.role}" does not grant it. ` +
|
|
155
|
+
`Upgrade to a role that includes the "${tier}" tier ` +
|
|
156
|
+
`(${TIER_ORDER.filter((t) => TIER_ORDER.indexOf(t) >= TIER_ORDER.indexOf(tier)).join(", ")}).`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!checkToolAllowed(toolName, config)) {
|
|
160
|
+
return {
|
|
161
|
+
allowed: false,
|
|
162
|
+
reason: `Tool "${toolName}" is not in the allowed_tools list.`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return { allowed: true };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Return the list of tool names visible to the current configuration.
|
|
169
|
+
* A tool is visible only if it passes both the role gate and the allowlist.
|
|
170
|
+
*/
|
|
171
|
+
function getVisibleTools(config) {
|
|
172
|
+
const roleTools = getToolsForRole(config.security.role);
|
|
173
|
+
if (config.security.allowed_tools === null) {
|
|
174
|
+
return new Set(roleTools);
|
|
175
|
+
}
|
|
176
|
+
const allowSet = new Set(config.security.allowed_tools);
|
|
177
|
+
return new Set(roleTools.filter((t) => allowSet.has(t)));
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Validate the loaded configuration, emitting warnings to stderr for
|
|
181
|
+
* potentially dangerous settings (e.g. TLS not required on a non-localhost URL).
|
|
182
|
+
*/
|
|
183
|
+
function validateConfig(config) {
|
|
184
|
+
const warnings = [];
|
|
185
|
+
if (!config.server.api_key) {
|
|
186
|
+
warnings.push("OPENINTENT_API_KEY is not set – requests will fail authentication.");
|
|
187
|
+
}
|
|
188
|
+
const url = config.server.url;
|
|
189
|
+
const isLocal = url.includes("localhost") || url.includes("127.0.0.1");
|
|
190
|
+
if (!config.security.tls_required && !isLocal) {
|
|
191
|
+
warnings.push(`TLS is not required but server URL "${url}" is not localhost. ` +
|
|
192
|
+
"Set security.tls_required = true for production deployments.");
|
|
193
|
+
}
|
|
194
|
+
if (config.security.max_timeout > 300) {
|
|
195
|
+
warnings.push(`max_timeout is ${config.security.max_timeout}s which exceeds the recommended 300s limit.`);
|
|
196
|
+
}
|
|
197
|
+
if (!config_js_1.VALID_ROLES.includes(config.security.role)) {
|
|
198
|
+
warnings.push(`Unknown role "${config.security.role}". Valid roles: ${config_js_1.VALID_ROLES.join(", ")}. Falling back to "reader".`);
|
|
199
|
+
config.security.role = "reader";
|
|
200
|
+
}
|
|
201
|
+
if (config.security.role === "admin") {
|
|
202
|
+
warnings.push('Role is set to "admin" which grants access to all tools including lifecycle ' +
|
|
203
|
+
"and coordination primitives. Use this only for trusted orchestrators.");
|
|
204
|
+
}
|
|
205
|
+
return warnings;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Remove sensitive fields from a params object before writing to audit logs.
|
|
209
|
+
*/
|
|
210
|
+
function sanitizeForAudit(operation, params) {
|
|
211
|
+
const sanitized = { _operation: operation };
|
|
212
|
+
for (const [key, value] of Object.entries(params)) {
|
|
213
|
+
if (SENSITIVE_KEYS.has(key.toLowerCase())) {
|
|
214
|
+
sanitized[key] = "[REDACTED]";
|
|
215
|
+
}
|
|
216
|
+
else if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
217
|
+
sanitized[key] = sanitizeForAudit("", value);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
sanitized[key] = value;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return sanitized;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Enforce TLS transport requirements. Throws if a non-HTTPS URL is used
|
|
227
|
+
* when `tls_required` is enabled.
|
|
228
|
+
*/
|
|
229
|
+
function enforceTransport(url, config) {
|
|
230
|
+
if (config.security.tls_required && !url.startsWith("https://")) {
|
|
231
|
+
throw new Error(`TLS is required but the server URL "${url}" does not use HTTPS. ` +
|
|
232
|
+
"Set security.tls_required to false or use an HTTPS endpoint.");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Build a structured audit log entry.
|
|
237
|
+
*/
|
|
238
|
+
function createAuditEntry(operation, params, result, duration, agentId) {
|
|
239
|
+
return {
|
|
240
|
+
timestamp: new Date().toISOString(),
|
|
241
|
+
operation,
|
|
242
|
+
params: sanitizeForAudit(operation, params),
|
|
243
|
+
result,
|
|
244
|
+
duration_ms: Math.round(duration),
|
|
245
|
+
agent_id: agentId,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../src/security.ts"],"names":[],"mappings":";;;AA2IA,kCAEC;AAED,0CAEC;AAED,0CAKC;AAOD,wDAKC;AAMD,4CAKC;AAMD,0CAsBC;AAMD,0CAOC;AAMD,wCAqCC;AAKD,4CAeC;AAMD,4CAOC;AAKD,4CAeC;AAvTD,2CA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|
|
|
1
|
+
import type { OpenIntentClient } from "./client.js";
|
|
2
|
+
import type { MCPConfig } from "./config.js";
|
|
3
|
+
import type { ToolTier } from "./security.js";
|
|
4
|
+
export interface ToolDefinition {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: Record<string, unknown>;
|
|
8
|
+
tier: ToolTier;
|
|
9
|
+
}
|
|
10
|
+
export declare const TOOL_DEFINITIONS: ToolDefinition[];
|
|
11
|
+
/**
|
|
12
|
+
* Route an incoming tool call to the appropriate client method.
|
|
13
|
+
* The tool must pass both the role gate and the allowlist before execution.
|
|
14
|
+
*/
|
|
15
|
+
export declare function handleToolCall(name: string, args: Record<string, unknown>, client: OpenIntentClient, config: MCPConfig): Promise<{
|
|
16
|
+
content: {
|
|
17
|
+
type: "text";
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,QAAQ,CAAC;CAChB;AAeD,eAAO,MAAM,gBAAgB,EAAE,cAAc,EAslC5C,CAAC;AAEF;;;GAGG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,SAAS;;;;;GA4dlB"}
|