@knocklabs/agent-toolkit 0.1.1 → 0.1.3
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/ai-sdk/index.d.ts +21 -0
- package/dist/ai-sdk/index.js +47 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/ai-sdk/tool-converter.d.ts +12 -0
- package/dist/ai-sdk/tool-converter.js +7 -0
- package/dist/ai-sdk/tool-converter.js.map +1 -0
- package/dist/chunk-2CNJ4XX6.js +33 -0
- package/dist/chunk-2CNJ4XX6.js.map +1 -0
- package/dist/chunk-3LZK6RH6.js +29 -0
- package/dist/chunk-3LZK6RH6.js.map +1 -0
- package/dist/chunk-4VR65G5W.js +66 -0
- package/dist/chunk-4VR65G5W.js.map +1 -0
- package/dist/chunk-6H3BXH2Y.js +15 -0
- package/dist/chunk-6H3BXH2Y.js.map +1 -0
- package/dist/chunk-BY4KQPUO.js +39 -0
- package/dist/chunk-BY4KQPUO.js.map +1 -0
- package/dist/chunk-DSRTYV37.js +39 -0
- package/dist/chunk-DSRTYV37.js.map +1 -0
- package/dist/chunk-JTYQTWCX.js +75 -0
- package/dist/chunk-JTYQTWCX.js.map +1 -0
- package/dist/chunk-NZB2TMJW.js +92 -0
- package/dist/chunk-NZB2TMJW.js.map +1 -0
- package/dist/chunk-O6DWF42E.js +31 -0
- package/dist/chunk-O6DWF42E.js.map +1 -0
- package/dist/chunk-OD5VHBGN.js +32 -0
- package/dist/chunk-OD5VHBGN.js.map +1 -0
- package/dist/chunk-PDMA6RIB.js +19 -0
- package/dist/chunk-PDMA6RIB.js.map +1 -0
- package/dist/chunk-RYMJEH6P.js +140 -0
- package/dist/chunk-RYMJEH6P.js.map +1 -0
- package/dist/chunk-THLK376Y.js +191 -0
- package/dist/chunk-THLK376Y.js.map +1 -0
- package/dist/chunk-TLHETJRF.js +75 -0
- package/dist/chunk-TLHETJRF.js.map +1 -0
- package/dist/chunk-TOBLV65T.js +30 -0
- package/dist/chunk-TOBLV65T.js.map +1 -0
- package/dist/chunk-VJFA3ZVW.js +210 -0
- package/dist/chunk-VJFA3ZVW.js.map +1 -0
- package/dist/chunk-WB4XCCUS.js +19 -0
- package/dist/chunk-WB4XCCUS.js.map +1 -0
- package/dist/chunk-XRQWR3LY.js +184 -0
- package/dist/chunk-XRQWR3LY.js.map +1 -0
- package/dist/chunk-XUYE3AGB.js +27 -0
- package/dist/chunk-XUYE3AGB.js.map +1 -0
- package/dist/lib/knock-client.d.ts +4 -0
- package/dist/lib/knock-client.js +7 -0
- package/dist/lib/knock-client.js.map +1 -0
- package/dist/lib/knock-tool.d.ts +4 -0
- package/dist/lib/knock-tool.js +7 -0
- package/dist/lib/knock-tool.js.map +1 -0
- package/dist/lib/tools/channels.d.ts +13 -0
- package/dist/lib/tools/channels.js +10 -0
- package/dist/lib/tools/channels.js.map +1 -0
- package/dist/lib/tools/commits.d.ts +16 -0
- package/dist/lib/tools/commits.js +10 -0
- package/dist/lib/tools/commits.js.map +1 -0
- package/dist/lib/tools/email-layouts.d.ts +13 -0
- package/dist/lib/tools/email-layouts.js +10 -0
- package/dist/lib/tools/email-layouts.js.map +1 -0
- package/dist/lib/tools/environments.d.ts +13 -0
- package/dist/lib/tools/environments.js +10 -0
- package/dist/lib/tools/environments.js.map +1 -0
- package/dist/lib/tools/index.d.ts +4 -0
- package/dist/lib/tools/index.js +23 -0
- package/dist/lib/tools/index.js.map +1 -0
- package/dist/lib/tools/message-types.d.ts +15 -0
- package/dist/lib/tools/message-types.js +10 -0
- package/dist/lib/tools/message-types.js.map +1 -0
- package/dist/lib/tools/messages.d.ts +13 -0
- package/dist/lib/tools/messages.js +10 -0
- package/dist/lib/tools/messages.js.map +1 -0
- package/dist/lib/tools/objects.d.ts +19 -0
- package/dist/lib/tools/objects.js +10 -0
- package/dist/lib/tools/objects.js.map +1 -0
- package/dist/lib/tools/partials.d.ts +13 -0
- package/dist/lib/tools/partials.js +10 -0
- package/dist/lib/tools/partials.js.map +1 -0
- package/dist/lib/tools/tenants.d.ts +16 -0
- package/dist/lib/tools/tenants.js +10 -0
- package/dist/lib/tools/tenants.js.map +1 -0
- package/dist/lib/tools/users.d.ts +19 -0
- package/dist/lib/tools/users.js +10 -0
- package/dist/lib/tools/users.js.map +1 -0
- package/dist/lib/tools/workflows.d.ts +18 -0
- package/dist/lib/tools/workflows.js +10 -0
- package/dist/lib/tools/workflows.js.map +1 -0
- package/dist/lib/utils.d.ts +33 -0
- package/dist/lib/utils.js +24 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/modelcontextprotocol/adapter.d.ts +11 -0
- package/dist/modelcontextprotocol/adapter.js +7 -0
- package/dist/modelcontextprotocol/adapter.js.map +1 -0
- package/dist/modelcontextprotocol/index.d.ts +27 -0
- package/dist/modelcontextprotocol/index.js +21 -0
- package/dist/modelcontextprotocol/index.js.map +1 -0
- package/dist/modelcontextprotocol/local-server.d.ts +1 -0
- package/dist/modelcontextprotocol/local-server.js +86 -0
- package/dist/modelcontextprotocol/local-server.js.map +1 -0
- package/dist/openai/index.d.ts +36 -0
- package/dist/openai/index.js +86 -0
- package/dist/openai/index.js.map +1 -0
- package/dist/openai/tool-converter.d.ts +15 -0
- package/dist/openai/tool-converter.js +7 -0
- package/dist/openai/tool-converter.js.map +1 -0
- package/dist/types-B-9pppCQ.d.ts +199 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
allTools,
|
|
3
|
+
toolPermissions,
|
|
4
|
+
tools
|
|
5
|
+
} from "../../chunk-NZB2TMJW.js";
|
|
6
|
+
import "../../chunk-THLK376Y.js";
|
|
7
|
+
import "../../chunk-OD5VHBGN.js";
|
|
8
|
+
import "../../chunk-RYMJEH6P.js";
|
|
9
|
+
import "../../chunk-BY4KQPUO.js";
|
|
10
|
+
import "../../chunk-JTYQTWCX.js";
|
|
11
|
+
import "../../chunk-VJFA3ZVW.js";
|
|
12
|
+
import "../../chunk-XRQWR3LY.js";
|
|
13
|
+
import "../../chunk-2CNJ4XX6.js";
|
|
14
|
+
import "../../chunk-TLHETJRF.js";
|
|
15
|
+
import "../../chunk-DSRTYV37.js";
|
|
16
|
+
import "../../chunk-O6DWF42E.js";
|
|
17
|
+
import "../../chunk-TOBLV65T.js";
|
|
18
|
+
export {
|
|
19
|
+
allTools,
|
|
20
|
+
toolPermissions,
|
|
21
|
+
tools
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const messageTypes: {
|
|
7
|
+
listMessageTypes: KnockTool;
|
|
8
|
+
createOrUpdateMessageType: KnockTool;
|
|
9
|
+
};
|
|
10
|
+
declare const permissions: {
|
|
11
|
+
read: string[];
|
|
12
|
+
manage: string[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { messageTypes, permissions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const messages: {
|
|
7
|
+
getMessageContent: KnockTool;
|
|
8
|
+
};
|
|
9
|
+
declare const permissions: {
|
|
10
|
+
read: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { messages, permissions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const objects: {
|
|
7
|
+
listObjects: KnockTool;
|
|
8
|
+
getObject: KnockTool;
|
|
9
|
+
createOrUpdateObject: KnockTool;
|
|
10
|
+
deleteObject: KnockTool;
|
|
11
|
+
subscribeUsersToObject: KnockTool;
|
|
12
|
+
unsubscribeUsersFromObject: KnockTool;
|
|
13
|
+
};
|
|
14
|
+
declare const permissions: {
|
|
15
|
+
read: string[];
|
|
16
|
+
manage: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { objects, permissions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const partials: {
|
|
7
|
+
listPartials: KnockTool;
|
|
8
|
+
};
|
|
9
|
+
declare const permissions: {
|
|
10
|
+
read: string[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { partials, permissions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const tenants: {
|
|
7
|
+
getTenant: KnockTool;
|
|
8
|
+
setTenant: KnockTool;
|
|
9
|
+
deleteTenant: KnockTool;
|
|
10
|
+
};
|
|
11
|
+
declare const permissions: {
|
|
12
|
+
read: string[];
|
|
13
|
+
manage: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { permissions, tenants };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const users: {
|
|
7
|
+
getUser: KnockTool;
|
|
8
|
+
deleteUser: KnockTool;
|
|
9
|
+
createOrUpdateUser: KnockTool;
|
|
10
|
+
getUserPreferences: KnockTool;
|
|
11
|
+
setUserPreferences: KnockTool;
|
|
12
|
+
getUserMessages: KnockTool;
|
|
13
|
+
};
|
|
14
|
+
declare const permissions: {
|
|
15
|
+
read: string[];
|
|
16
|
+
manage: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { permissions, users };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { a as KnockTool } from '../../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
declare const workflows: {
|
|
7
|
+
listWorkflows: KnockTool;
|
|
8
|
+
triggerWorkflow: KnockTool;
|
|
9
|
+
createEmailWorkflow: KnockTool;
|
|
10
|
+
createOneOffWorkflowSchedule: KnockTool;
|
|
11
|
+
};
|
|
12
|
+
declare const permissions: {
|
|
13
|
+
read: string[];
|
|
14
|
+
manage: string[];
|
|
15
|
+
trigger: string[];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { permissions, workflows };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { a as KnockTool, t as toolPermissions, T as ToolkitConfig, b as ToolCategory } from '../types-B-9pppCQ.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import '@knocklabs/node';
|
|
4
|
+
import '@knocklabs/mgmt';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Given a list of tools, and some config may describe the tools that should be provided to the LLM,
|
|
8
|
+
* returns a filtered list of tools that match the config.
|
|
9
|
+
*
|
|
10
|
+
* Options:
|
|
11
|
+
* `*` - All tools
|
|
12
|
+
* `users.*` - All tools that start with `users.`
|
|
13
|
+
* `users.getUser` - A specific tool
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
declare function filterTools(tools: Record<string, Record<string, KnockTool>>, pattern: string | undefined): KnockTool[];
|
|
17
|
+
/**
|
|
18
|
+
* Given a category and a list of permissions, return a list of tools that the user has permission to use.
|
|
19
|
+
*
|
|
20
|
+
* @param category - The category to get tools for
|
|
21
|
+
* @param categoryPermissions - The permissions to use
|
|
22
|
+
* @returns A list of tools that the user has permission to use
|
|
23
|
+
*/
|
|
24
|
+
declare function getToolsWithPermissions(category: keyof typeof toolPermissions, categoryPermissions: Record<string, boolean | undefined>): KnockTool[];
|
|
25
|
+
/**
|
|
26
|
+
* Given a config, return a list of tools for each category that the user has permission to use.
|
|
27
|
+
*
|
|
28
|
+
* @param config - The config to use
|
|
29
|
+
* @returns A list of tools for each category that the user has permission to use
|
|
30
|
+
*/
|
|
31
|
+
declare function getToolsByPermissionsInCategories(config: ToolkitConfig): Record<ToolCategory, KnockTool[]>;
|
|
32
|
+
|
|
33
|
+
export { filterTools, getToolsByPermissionsInCategories, getToolsWithPermissions };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
filterTools,
|
|
3
|
+
getToolsByPermissionsInCategories,
|
|
4
|
+
getToolsWithPermissions
|
|
5
|
+
} from "../chunk-4VR65G5W.js";
|
|
6
|
+
import "../chunk-NZB2TMJW.js";
|
|
7
|
+
import "../chunk-THLK376Y.js";
|
|
8
|
+
import "../chunk-OD5VHBGN.js";
|
|
9
|
+
import "../chunk-RYMJEH6P.js";
|
|
10
|
+
import "../chunk-BY4KQPUO.js";
|
|
11
|
+
import "../chunk-JTYQTWCX.js";
|
|
12
|
+
import "../chunk-VJFA3ZVW.js";
|
|
13
|
+
import "../chunk-XRQWR3LY.js";
|
|
14
|
+
import "../chunk-2CNJ4XX6.js";
|
|
15
|
+
import "../chunk-TLHETJRF.js";
|
|
16
|
+
import "../chunk-DSRTYV37.js";
|
|
17
|
+
import "../chunk-O6DWF42E.js";
|
|
18
|
+
import "../chunk-TOBLV65T.js";
|
|
19
|
+
export {
|
|
20
|
+
filterTools,
|
|
21
|
+
getToolsByPermissionsInCategories,
|
|
22
|
+
getToolsWithPermissions
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { K as KnockClient, C as Config, a as KnockTool } from '../types-B-9pppCQ.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
import '@knocklabs/node';
|
|
5
|
+
import '@knocklabs/mgmt';
|
|
6
|
+
|
|
7
|
+
declare class KnockMcpServer extends McpServer {
|
|
8
|
+
constructor(knockClient: KnockClient, config: Config, tools: KnockTool[]);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { KnockMcpServer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { a as KnockTool, K as KnockClient, C as Config } from '../types-B-9pppCQ.js';
|
|
2
|
+
import { KnockMcpServer } from './adapter.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
import '@knocklabs/node';
|
|
5
|
+
import '@knocklabs/mgmt';
|
|
6
|
+
import '@modelcontextprotocol/sdk/server/mcp.js';
|
|
7
|
+
|
|
8
|
+
type CreateKnockMcpServerParams = {
|
|
9
|
+
/**
|
|
10
|
+
* Array of Knock tools to enable in the server.
|
|
11
|
+
*/
|
|
12
|
+
tools?: KnockTool[];
|
|
13
|
+
/**
|
|
14
|
+
* A Knock client to use for the server.
|
|
15
|
+
*/
|
|
16
|
+
knockClient: KnockClient;
|
|
17
|
+
/**
|
|
18
|
+
* The config to use for the server.
|
|
19
|
+
*/
|
|
20
|
+
config: Config;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Knock MCP Server with the given parameters.
|
|
24
|
+
*/
|
|
25
|
+
declare const createKnockMcpServer: (params: CreateKnockMcpServerParams) => Promise<KnockMcpServer>;
|
|
26
|
+
|
|
27
|
+
export { createKnockMcpServer };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createKnockMcpServer
|
|
3
|
+
} from "../chunk-PDMA6RIB.js";
|
|
4
|
+
import "../chunk-NZB2TMJW.js";
|
|
5
|
+
import "../chunk-THLK376Y.js";
|
|
6
|
+
import "../chunk-OD5VHBGN.js";
|
|
7
|
+
import "../chunk-RYMJEH6P.js";
|
|
8
|
+
import "../chunk-BY4KQPUO.js";
|
|
9
|
+
import "../chunk-JTYQTWCX.js";
|
|
10
|
+
import "../chunk-VJFA3ZVW.js";
|
|
11
|
+
import "../chunk-XRQWR3LY.js";
|
|
12
|
+
import "../chunk-2CNJ4XX6.js";
|
|
13
|
+
import "../chunk-TLHETJRF.js";
|
|
14
|
+
import "../chunk-DSRTYV37.js";
|
|
15
|
+
import "../chunk-O6DWF42E.js";
|
|
16
|
+
import "../chunk-TOBLV65T.js";
|
|
17
|
+
import "../chunk-XUYE3AGB.js";
|
|
18
|
+
export {
|
|
19
|
+
createKnockMcpServer
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createKnockClient
|
|
4
|
+
} from "../chunk-3LZK6RH6.js";
|
|
5
|
+
import {
|
|
6
|
+
filterTools
|
|
7
|
+
} from "../chunk-4VR65G5W.js";
|
|
8
|
+
import {
|
|
9
|
+
createKnockMcpServer
|
|
10
|
+
} from "../chunk-PDMA6RIB.js";
|
|
11
|
+
import {
|
|
12
|
+
tools
|
|
13
|
+
} from "../chunk-NZB2TMJW.js";
|
|
14
|
+
import "../chunk-THLK376Y.js";
|
|
15
|
+
import "../chunk-OD5VHBGN.js";
|
|
16
|
+
import "../chunk-RYMJEH6P.js";
|
|
17
|
+
import "../chunk-BY4KQPUO.js";
|
|
18
|
+
import "../chunk-JTYQTWCX.js";
|
|
19
|
+
import "../chunk-VJFA3ZVW.js";
|
|
20
|
+
import "../chunk-XRQWR3LY.js";
|
|
21
|
+
import "../chunk-2CNJ4XX6.js";
|
|
22
|
+
import "../chunk-TLHETJRF.js";
|
|
23
|
+
import "../chunk-DSRTYV37.js";
|
|
24
|
+
import "../chunk-O6DWF42E.js";
|
|
25
|
+
import "../chunk-TOBLV65T.js";
|
|
26
|
+
import "../chunk-XUYE3AGB.js";
|
|
27
|
+
|
|
28
|
+
// src/modelcontextprotocol/local-server.ts
|
|
29
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
30
|
+
import { default as yargs } from "yargs";
|
|
31
|
+
import { hideBin } from "yargs/helpers";
|
|
32
|
+
var main = async () => {
|
|
33
|
+
const {
|
|
34
|
+
serviceToken,
|
|
35
|
+
environment,
|
|
36
|
+
userId,
|
|
37
|
+
tenantId,
|
|
38
|
+
tools: patterns
|
|
39
|
+
} = await yargs(hideBin(process.argv)).version("0.1.0").option("tools", {
|
|
40
|
+
alias: "t",
|
|
41
|
+
type: "string",
|
|
42
|
+
array: true,
|
|
43
|
+
description: `List of tools to enable. Use "*" to enable all tools. Use "category" or "category.*" to enable all tools from a category. Use "category.toolName" to pick a single tool. Available categories: ${Object.keys(
|
|
44
|
+
tools
|
|
45
|
+
)}`
|
|
46
|
+
}).option("service-token", {
|
|
47
|
+
alias: "st",
|
|
48
|
+
type: "string",
|
|
49
|
+
description: `Knock service token`
|
|
50
|
+
}).option("environment", {
|
|
51
|
+
alias: "e",
|
|
52
|
+
type: "string",
|
|
53
|
+
description: `The environment to operate in from your Knock account`
|
|
54
|
+
}).option("user-id", {
|
|
55
|
+
alias: "u",
|
|
56
|
+
type: "string",
|
|
57
|
+
description: `The user id to operate as`
|
|
58
|
+
}).option("tenant-id", {
|
|
59
|
+
alias: "t",
|
|
60
|
+
type: "string",
|
|
61
|
+
description: `The tenant id to operate as`
|
|
62
|
+
}).parse();
|
|
63
|
+
const SERVICE_TOKEN = serviceToken || process.env.KNOCK_SERVICE_TOKEN;
|
|
64
|
+
if (!SERVICE_TOKEN) {
|
|
65
|
+
throw new Error("Knock service token is required");
|
|
66
|
+
}
|
|
67
|
+
const config = {
|
|
68
|
+
serviceToken: SERVICE_TOKEN,
|
|
69
|
+
userId,
|
|
70
|
+
tenantId,
|
|
71
|
+
environment
|
|
72
|
+
};
|
|
73
|
+
const knockClient = createKnockClient(config);
|
|
74
|
+
const filteredTools = patterns ? patterns.map((pattern) => filterTools(tools, pattern)).flat() : void 0;
|
|
75
|
+
const mcpServer = await createKnockMcpServer({
|
|
76
|
+
config,
|
|
77
|
+
knockClient,
|
|
78
|
+
tools: filteredTools
|
|
79
|
+
});
|
|
80
|
+
const transport = new StdioServerTransport();
|
|
81
|
+
await mcpServer.connect(transport);
|
|
82
|
+
};
|
|
83
|
+
main().catch((error) => {
|
|
84
|
+
console.error("\nKnock: Error initializing MCP server:\n", error.message);
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=local-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/modelcontextprotocol/local-server.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { default as yargs } from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { Config } from \"../types.js\";\nimport { createKnockMcpServer } from \"./index.js\";\nimport { tools } from \"../lib/tools/index.js\";\nimport { filterTools } from \"../lib/utils.js\";\n\n/**\n * Main entry point for the Knock MCP server.\n * Runs as a standalone process, as defined in package.json#bin.\n * An entrypoint for this file exists in the tsup configuration of the package.\n */\nconst main = async () => {\n const {\n serviceToken,\n environment,\n userId,\n tenantId,\n tools: patterns,\n } = await yargs(hideBin(process.argv))\n .version(\"0.1.0\")\n .option(\"tools\", {\n alias: \"t\",\n type: \"string\",\n array: true,\n description: `List of tools to enable. Use \"*\" to enable all tools. Use \"category\" or \"category.*\" to enable all tools from a category. Use \"category.toolName\" to pick a single tool. Available categories: ${Object.keys(\n tools\n )}`,\n })\n .option(\"service-token\", {\n alias: \"st\",\n type: \"string\",\n description: `Knock service token`,\n })\n .option(\"environment\", {\n alias: \"e\",\n type: \"string\",\n description: `The environment to operate in from your Knock account`,\n })\n .option(\"user-id\", {\n alias: \"u\",\n type: \"string\",\n description: `The user id to operate as`,\n })\n .option(\"tenant-id\", {\n alias: \"t\",\n type: \"string\",\n description: `The tenant id to operate as`,\n })\n .parse();\n\n const SERVICE_TOKEN = serviceToken || process.env.KNOCK_SERVICE_TOKEN;\n\n if (!SERVICE_TOKEN) {\n throw new Error(\"Knock service token is required\");\n }\n\n const config: Config = {\n serviceToken: SERVICE_TOKEN,\n userId,\n tenantId,\n environment,\n };\n\n const knockClient = createKnockClient(config);\n\n const filteredTools = patterns\n ? patterns.map((pattern) => filterTools(tools, pattern)).flat()\n : undefined;\n\n const mcpServer = await createKnockMcpServer({\n config,\n knockClient,\n tools: filteredTools,\n });\n\n const transport = new StdioServerTransport();\n await mcpServer.connect(transport);\n};\n\nmain().catch((error) => {\n console.error(\"\\nKnock: Error initializing MCP server:\\n\", error.message);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,4BAA4B;AACrC,SAAS,WAAW,aAAa;AACjC,SAAS,eAAe;AAaxB,IAAM,OAAO,YAAY;AACvB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,IAAI,MAAM,MAAM,QAAQ,QAAQ,IAAI,CAAC,EAClC,QAAQ,OAAO,EACf,OAAO,SAAS;AAAA,IACf,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,aAAa,kMAAkM,OAAO;AAAA,MACpN;AAAA,IACF,CAAC;AAAA,EACH,CAAC,EACA,OAAO,iBAAiB;AAAA,IACvB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,OAAO,eAAe;AAAA,IACrB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,OAAO,WAAW;AAAA,IACjB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,OAAO,aAAa;AAAA,IACnB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC,EACA,MAAM;AAET,QAAM,gBAAgB,gBAAgB,QAAQ,IAAI;AAElD,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,QAAM,SAAiB;AAAA,IACrB,cAAc;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,cAAc,kBAAkB,MAAM;AAE5C,QAAM,gBAAgB,WAClB,SAAS,IAAI,CAAC,YAAY,YAAY,OAAO,OAAO,CAAC,EAAE,KAAK,IAC5D;AAEJ,QAAM,YAAY,MAAM,qBAAqB;AAAA,IAC3C;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AAED,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,UAAU,QAAQ,SAAS;AACnC;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,6CAA6C,MAAM,OAAO;AAC1E,CAAC;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ChatCompletionTool, ChatCompletionMessageToolCall, ChatCompletionToolMessageParam } from 'openai/resources.mjs';
|
|
2
|
+
import { T as ToolkitConfig, b as ToolCategory } from '../types-B-9pppCQ.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
import '@knocklabs/node';
|
|
5
|
+
import '@knocklabs/mgmt';
|
|
6
|
+
|
|
7
|
+
declare const createKnockToolkit: (config: ToolkitConfig) => {
|
|
8
|
+
/**
|
|
9
|
+
* Get all tools as a flat list.
|
|
10
|
+
*
|
|
11
|
+
* @returns An array of all tools
|
|
12
|
+
*/
|
|
13
|
+
getAllTools: () => ChatCompletionTool[];
|
|
14
|
+
/**
|
|
15
|
+
* Get all tools for a specific category.
|
|
16
|
+
*
|
|
17
|
+
* @param category - The category of too ls to get
|
|
18
|
+
* @returns An array of tools for the given category
|
|
19
|
+
*/
|
|
20
|
+
getTools: (category: ToolCategory) => ChatCompletionTool[];
|
|
21
|
+
/**
|
|
22
|
+
* Get a map of all tools by method name.
|
|
23
|
+
*
|
|
24
|
+
* @returns A map of all tools by method name
|
|
25
|
+
*/
|
|
26
|
+
getToolMap: () => Record<string, ChatCompletionTool>;
|
|
27
|
+
/**
|
|
28
|
+
* Handle a tool call from the OpenAI API. Call this to invoke the tool.
|
|
29
|
+
*
|
|
30
|
+
* @param toolCall - The tool call to handle
|
|
31
|
+
* @returns The result of the tool call
|
|
32
|
+
*/
|
|
33
|
+
handleToolCall: (toolCall: ChatCompletionMessageToolCall) => Promise<ChatCompletionToolMessageParam>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { createKnockToolkit };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
knockToolToChatCompletionTool
|
|
3
|
+
} from "../chunk-WB4XCCUS.js";
|
|
4
|
+
import {
|
|
5
|
+
createKnockClient
|
|
6
|
+
} from "../chunk-3LZK6RH6.js";
|
|
7
|
+
import {
|
|
8
|
+
getToolsByPermissionsInCategories
|
|
9
|
+
} from "../chunk-4VR65G5W.js";
|
|
10
|
+
import "../chunk-NZB2TMJW.js";
|
|
11
|
+
import "../chunk-THLK376Y.js";
|
|
12
|
+
import "../chunk-OD5VHBGN.js";
|
|
13
|
+
import "../chunk-RYMJEH6P.js";
|
|
14
|
+
import "../chunk-BY4KQPUO.js";
|
|
15
|
+
import "../chunk-JTYQTWCX.js";
|
|
16
|
+
import "../chunk-VJFA3ZVW.js";
|
|
17
|
+
import "../chunk-XRQWR3LY.js";
|
|
18
|
+
import "../chunk-2CNJ4XX6.js";
|
|
19
|
+
import "../chunk-TLHETJRF.js";
|
|
20
|
+
import "../chunk-DSRTYV37.js";
|
|
21
|
+
import "../chunk-O6DWF42E.js";
|
|
22
|
+
import "../chunk-TOBLV65T.js";
|
|
23
|
+
|
|
24
|
+
// src/openai/index.ts
|
|
25
|
+
var createKnockToolkit = (config) => {
|
|
26
|
+
const knockClient = createKnockClient(config);
|
|
27
|
+
const allowedToolsByCategory = getToolsByPermissionsInCategories(config);
|
|
28
|
+
const toolsByMethod = Object.values(allowedToolsByCategory).flat().reduce(
|
|
29
|
+
(acc, tool) => ({ ...acc, [tool.method]: tool }),
|
|
30
|
+
{}
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
/**
|
|
34
|
+
* Get all tools as a flat list.
|
|
35
|
+
*
|
|
36
|
+
* @returns An array of all tools
|
|
37
|
+
*/
|
|
38
|
+
getAllTools: () => Object.values(toolsByMethod).map((t) => knockToolToChatCompletionTool(t)),
|
|
39
|
+
/**
|
|
40
|
+
* Get all tools for a specific category.
|
|
41
|
+
*
|
|
42
|
+
* @param category - The category of too ls to get
|
|
43
|
+
* @returns An array of tools for the given category
|
|
44
|
+
*/
|
|
45
|
+
getTools: (category) => allowedToolsByCategory[category].map(
|
|
46
|
+
(t) => knockToolToChatCompletionTool(t)
|
|
47
|
+
),
|
|
48
|
+
/**
|
|
49
|
+
* Get a map of all tools by method name.
|
|
50
|
+
*
|
|
51
|
+
* @returns A map of all tools by method name
|
|
52
|
+
*/
|
|
53
|
+
getToolMap: () => Object.entries(toolsByMethod).reduce(
|
|
54
|
+
(acc, [method, tool]) => {
|
|
55
|
+
acc[method] = knockToolToChatCompletionTool(tool);
|
|
56
|
+
return acc;
|
|
57
|
+
},
|
|
58
|
+
{}
|
|
59
|
+
),
|
|
60
|
+
/**
|
|
61
|
+
* Handle a tool call from the OpenAI API. Call this to invoke the tool.
|
|
62
|
+
*
|
|
63
|
+
* @param toolCall - The tool call to handle
|
|
64
|
+
* @returns The result of the tool call
|
|
65
|
+
*/
|
|
66
|
+
handleToolCall: async (toolCall) => {
|
|
67
|
+
const tool = toolsByMethod[toolCall.function.name];
|
|
68
|
+
if (!tool) {
|
|
69
|
+
throw new Error(`Tool ${toolCall.function.name} not found`);
|
|
70
|
+
}
|
|
71
|
+
const result = await tool.bindExecute(
|
|
72
|
+
knockClient,
|
|
73
|
+
config
|
|
74
|
+
)(toolCall.function.arguments);
|
|
75
|
+
return {
|
|
76
|
+
role: "tool",
|
|
77
|
+
tool_call_id: toolCall.id,
|
|
78
|
+
content: result
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
createKnockToolkit
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/openai/index.ts"],"sourcesContent":["import {\n ChatCompletionTool,\n ChatCompletionMessageToolCall,\n ChatCompletionToolMessageParam,\n} from \"openai/resources.mjs\";\nimport { ToolCategory, ToolkitConfig } from \"../types.js\";\nimport { getToolsByPermissionsInCategories } from \"../lib/utils.js\";\nimport { createKnockClient } from \"../lib/knock-client.js\";\nimport { knockToolToChatCompletionTool } from \"./tool-converter.js\";\nimport { KnockTool } from \"../lib/knock-tool.js\";\n\nconst createKnockToolkit = (config: ToolkitConfig) => {\n const knockClient = createKnockClient(config);\n const allowedToolsByCategory = getToolsByPermissionsInCategories(config);\n\n const toolsByMethod = Object.values(allowedToolsByCategory)\n .flat()\n .reduce(\n (acc, tool) => ({ ...acc, [tool.method]: tool }),\n {} as Record<string, KnockTool>\n );\n\n return {\n /**\n * Get all tools as a flat list.\n *\n * @returns An array of all tools\n */\n getAllTools: (): ChatCompletionTool[] =>\n Object.values(toolsByMethod).map((t) => knockToolToChatCompletionTool(t)),\n\n /**\n * Get all tools for a specific category.\n *\n * @param category - The category of too ls to get\n * @returns An array of tools for the given category\n */\n getTools: (category: ToolCategory): ChatCompletionTool[] =>\n allowedToolsByCategory[category].map((t) =>\n knockToolToChatCompletionTool(t)\n ),\n\n /**\n * Get a map of all tools by method name.\n *\n * @returns A map of all tools by method name\n */\n getToolMap: () =>\n Object.entries(toolsByMethod).reduce(\n (acc, [method, tool]) => {\n acc[method] = knockToolToChatCompletionTool(tool);\n return acc;\n },\n {} as Record<string, ChatCompletionTool>\n ),\n /**\n * Handle a tool call from the OpenAI API. Call this to invoke the tool.\n *\n * @param toolCall - The tool call to handle\n * @returns The result of the tool call\n */\n handleToolCall: async (toolCall: ChatCompletionMessageToolCall) => {\n const tool = toolsByMethod[toolCall.function.name];\n\n if (!tool) {\n throw new Error(`Tool ${toolCall.function.name} not found`);\n }\n\n const result = await tool.bindExecute(\n knockClient,\n config\n )(toolCall.function.arguments);\n\n return {\n role: \"tool\",\n tool_call_id: toolCall.id,\n content: result,\n } as ChatCompletionToolMessageParam;\n },\n };\n};\n\nexport { createKnockToolkit };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAWA,IAAM,qBAAqB,CAAC,WAA0B;AACpD,QAAM,cAAc,kBAAkB,MAAM;AAC5C,QAAM,yBAAyB,kCAAkC,MAAM;AAEvE,QAAM,gBAAgB,OAAO,OAAO,sBAAsB,EACvD,KAAK,EACL;AAAA,IACC,CAAC,KAAK,UAAU,EAAE,GAAG,KAAK,CAAC,KAAK,MAAM,GAAG,KAAK;AAAA,IAC9C,CAAC;AAAA,EACH;AAEF,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAML,aAAa,MACX,OAAO,OAAO,aAAa,EAAE,IAAI,CAAC,MAAM,8BAA8B,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQ1E,UAAU,CAAC,aACT,uBAAuB,QAAQ,EAAE;AAAA,MAAI,CAAC,MACpC,8BAA8B,CAAC;AAAA,IACjC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOF,YAAY,MACV,OAAO,QAAQ,aAAa,EAAE;AAAA,MAC5B,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM;AACvB,YAAI,MAAM,IAAI,8BAA8B,IAAI;AAChD,eAAO;AAAA,MACT;AAAA,MACA,CAAC;AAAA,IACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOF,gBAAgB,OAAO,aAA4C;AACjE,YAAM,OAAO,cAAc,SAAS,SAAS,IAAI;AAEjD,UAAI,CAAC,MAAM;AACT,cAAM,IAAI,MAAM,QAAQ,SAAS,SAAS,IAAI,YAAY;AAAA,MAC5D;AAEA,YAAM,SAAS,MAAM,KAAK;AAAA,QACxB;AAAA,QACA;AAAA,MACF,EAAE,SAAS,SAAS,SAAS;AAE7B,aAAO;AAAA,QACL,MAAM;AAAA,QACN,cAAc,SAAS;AAAA,QACvB,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { a as KnockTool } from '../types-B-9pppCQ.js';
|
|
2
|
+
import { ChatCompletionTool } from 'openai/resources.mjs';
|
|
3
|
+
import 'zod';
|
|
4
|
+
import '@knocklabs/node';
|
|
5
|
+
import '@knocklabs/mgmt';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert a KnockTool to a ChatCompletionTool, ready to be used with the OpenAI API.
|
|
9
|
+
*
|
|
10
|
+
* @param knockTool - The KnockTool to convert
|
|
11
|
+
* @returns The converted ChatCompletionTool
|
|
12
|
+
*/
|
|
13
|
+
declare function knockToolToChatCompletionTool(knockTool: KnockTool): ChatCompletionTool;
|
|
14
|
+
|
|
15
|
+
export { knockToolToChatCompletionTool };
|