@knocklabs/agent-toolkit 0.1.2 → 0.1.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/dist/ai-sdk/index.d.ts +1 -4
- package/dist/ai-sdk/index.js +7 -1076
- package/dist/ai-sdk/index.js.map +1 -1
- package/dist/{modelcontextprotocol/adapter.js → chunk-B6DIDKFY.js} +15 -2
- package/dist/chunk-B6DIDKFY.js.map +1 -0
- package/dist/{lib/tools/index.js → chunk-RPKDXX4O.js} +4 -3
- package/dist/{lib/utils.js.map → chunk-RPKDXX4O.js.map} +1 -1
- package/dist/chunk-ZV2SOIO7.js +91 -0
- package/dist/chunk-ZV2SOIO7.js.map +1 -0
- package/dist/modelcontextprotocol/index.d.ts +47 -6
- package/dist/modelcontextprotocol/index.js +4 -976
- package/dist/modelcontextprotocol/index.js.map +1 -1
- package/dist/modelcontextprotocol/local-server.js +10 -1041
- package/dist/modelcontextprotocol/local-server.js.map +1 -1
- package/dist/openai/index.d.ts +1 -4
- package/dist/openai/index.js +7 -1076
- package/dist/openai/index.js.map +1 -1
- package/dist/types-DyB12-Gk.d.ts +73 -0
- package/package.json +4 -4
- package/dist/ai-sdk/tool-converter.d.ts +0 -12
- package/dist/ai-sdk/tool-converter.js +0 -14
- package/dist/ai-sdk/tool-converter.js.map +0 -1
- package/dist/lib/knock-client.d.ts +0 -4
- package/dist/lib/knock-client.js +0 -28
- package/dist/lib/knock-client.js.map +0 -1
- package/dist/lib/knock-tool.d.ts +0 -4
- package/dist/lib/knock-tool.js +0 -29
- package/dist/lib/knock-tool.js.map +0 -1
- package/dist/lib/tools/channels.d.ts +0 -13
- package/dist/lib/tools/channels.js +0 -54
- package/dist/lib/tools/channels.js.map +0 -1
- package/dist/lib/tools/commits.d.ts +0 -16
- package/dist/lib/tools/commits.js +0 -98
- package/dist/lib/tools/commits.js.map +0 -1
- package/dist/lib/tools/email-layouts.d.ts +0 -13
- package/dist/lib/tools/email-layouts.js +0 -60
- package/dist/lib/tools/email-layouts.js.map +0 -1
- package/dist/lib/tools/environments.d.ts +0 -13
- package/dist/lib/tools/environments.js +0 -52
- package/dist/lib/tools/environments.js.map +0 -1
- package/dist/lib/tools/index.d.ts +0 -4
- package/dist/lib/tools/index.js.map +0 -1
- package/dist/lib/tools/message-types.d.ts +0 -15
- package/dist/lib/tools/message-types.js +0 -214
- package/dist/lib/tools/message-types.js.map +0 -1
- package/dist/lib/tools/messages.d.ts +0 -13
- package/dist/lib/tools/messages.js +0 -55
- package/dist/lib/tools/messages.js.map +0 -1
- package/dist/lib/tools/objects.d.ts +0 -19
- package/dist/lib/tools/objects.js +0 -163
- package/dist/lib/tools/objects.js.map +0 -1
- package/dist/lib/tools/partials.d.ts +0 -13
- package/dist/lib/tools/partials.js +0 -60
- package/dist/lib/tools/partials.js.map +0 -1
- package/dist/lib/tools/tenants.d.ts +0 -16
- package/dist/lib/tools/tenants.js +0 -98
- package/dist/lib/tools/tenants.js.map +0 -1
- package/dist/lib/tools/users.d.ts +0 -19
- package/dist/lib/tools/users.js +0 -233
- package/dist/lib/tools/users.js.map +0 -1
- package/dist/lib/tools/workflows.d.ts +0 -18
- package/dist/lib/tools/workflows.js +0 -207
- package/dist/lib/tools/workflows.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -33
- package/dist/lib/utils.js +0 -1077
- package/dist/modelcontextprotocol/adapter.d.ts +0 -11
- package/dist/modelcontextprotocol/adapter.js.map +0 -1
- package/dist/openai/tool-converter.d.ts +0 -15
- package/dist/openai/tool-converter.js +0 -18
- package/dist/openai/tool-converter.js.map +0 -1
- package/dist/types-B-9pppCQ.d.ts +0 -199
- package/dist/types.d.ts +0 -4
- package/dist/types.js +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/modelcontextprotocol/local-server.ts","../../src/lib/knock-client.ts","../../src/lib/knock-tool.ts","../../src/lib/tools/channels.ts","../../src/lib/tools/commits.ts","../../src/lib/tools/email-layouts.ts","../../src/lib/tools/environments.ts","../../src/lib/tools/messages.ts","../../src/lib/tools/message-types.ts","../../src/lib/tools/objects.ts","../../src/lib/tools/partials.ts","../../src/lib/tools/tenants.ts","../../src/lib/tools/users.ts","../../src/lib/tools/workflows.ts","../../src/lib/tools/index.ts","../../src/modelcontextprotocol/adapter.ts","../../src/modelcontextprotocol/index.ts","../../src/lib/utils.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","import { Knock } from \"@knocklabs/node\";\nimport KnockMgmt from \"@knocklabs/mgmt\";\nimport { Config } from \"../types.js\";\n\nconst serviceTokensToApiClients: Record<string, Record<string, Knock>> = {};\n\ntype KnockClient = ReturnType<typeof createKnockClient>;\n\nconst createKnockClient = (config: Config) => {\n const client = new KnockMgmt({\n serviceToken: config.serviceToken,\n });\n\n return Object.assign(client, {\n publicApi: async (_environment?: string): Promise<Knock> => {\n const environment = _environment ?? config.environment ?? \"development\";\n\n // If the client already exists for this service token and environment, return it\n if (serviceTokensToApiClients?.[config.serviceToken]?.[environment]) {\n return serviceTokensToApiClients[config.serviceToken][environment];\n }\n\n // Otherwise, fetch a public API key for this service token and environment\n const { api_key } = await client.apiKeys.exchange({ environment });\n\n // Create a new Knock client with the public API key\n const knock = new Knock(api_key);\n\n // Store the client in the cache\n if (!serviceTokensToApiClients[config.serviceToken]) {\n serviceTokensToApiClients[config.serviceToken] = {};\n }\n\n serviceTokensToApiClients[config.serviceToken][environment] = knock;\n\n return knock;\n },\n });\n};\n\nexport { createKnockClient, type KnockClient };\n","import type { ZodObject } from \"zod\";\nimport { z } from \"zod\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"./knock-client.js\";\n\nexport interface KnockToolDefinition {\n /**\n * The method name of the tool. This is a machine-readable string.\n */\n method: string;\n /**\n * The name of the tool. This can be used to reference the tool in the code.\n * A descriptive LLM-readable string.\n */\n name: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, including examples where useful.\n */\n description: string;\n\n /**\n * A descriptive prompt explaining the tool's purpose, usage and input parameters.\n * Ths is intended to be used by the underlying LLM.\n */\n fullDescription: string;\n\n /**\n * The Zod schema for the input parameters of the tool\n */\n parameters?: ZodObject<any>;\n /**\n * The actual implementation of the tool.\n */\n execute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nexport interface KnockTool extends Omit<KnockToolDefinition, \"execute\"> {\n bindExecute: (\n knockClient: KnockClient,\n config: Config\n ) => (input: any) => Promise<unknown>;\n}\n\nconst trimLines = (text: string) =>\n text\n .split(\"\\n\")\n .map((l) => l.trim())\n .filter(Boolean)\n .join(\"\\n\");\n\nexport const KnockTool = (\n args: Omit<KnockToolDefinition, \"fullDescription\">\n): KnockTool => {\n const { execute, ...restOfArgs } = args;\n const parameters = restOfArgs.parameters\n ? restOfArgs.parameters\n : z.object({});\n\n const schemaEntries = Object.entries(parameters.shape);\n\n const argsStr =\n schemaEntries.length === 0\n ? \"Takes no arguments\"\n : schemaEntries\n .map(([key, value]) => {\n return `- ${key}: ${(value as any).description || \"\"}`;\n })\n .join(\"\\n\");\n\n const fullDescription = trimLines(`\n Tool name:\n ${args.name}\n Description:\n ${args.description}.\n Arguments:\n ${argsStr}\n `);\n\n return {\n ...restOfArgs,\n parameters,\n fullDescription,\n bindExecute: (knockClient: KnockClient, config: Config) =>\n execute(knockClient, config),\n };\n};\n","import { KnockTool } from \"../knock-tool.js\";\nimport { Channel } from \"@knocklabs/mgmt/resources/channels.js\";\n\nconst listChannels = KnockTool({\n method: \"list_channels\",\n name: \"List channels\",\n description: `\n Returns a list of all of the channels configured in the account. Each channel returns information about the type of channel it is (email, sms, push, etc), and the provider that's used to power the channel.\n\n Use this tool when you need to know about the channels configured in the Knock account, like when configuring a workflow.\n `,\n execute: (knockClient) => async (params) => {\n const allChannels: Channel[] = [];\n for await (const channel of knockClient.channels.list()) {\n allChannels.push(channel);\n }\n return allChannels;\n },\n});\n\nexport const channels = {\n listChannels,\n};\n\nexport const permissions = {\n read: [\"listChannels\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listCommits = KnockTool({\n method: \"list_commits\",\n name: \"List commits\",\n description: `\n Returns all commits available in the environment. Use this tool when you are asked to see what changes are available to be deployed.\n `,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list commits for. Defaults to `development`.\"\n ),\n promoted: z\n .boolean()\n .describe(\n \"(boolean): Whether to only return promoted commits. Defaults to `false`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.list({\n environment: params.environment ?? config.environment ?? \"development\",\n promoted: params.promoted ?? false,\n });\n },\n});\n\nconst commitAllChanges = KnockTool({\n method: \"commit_all_changes\",\n name: \"Commit all changes\",\n description: `\n Commit all pending changes to the current environment. Use this tool when you are asked to save all changes to the current environment. This can only be used in the development environment.\n `,\n parameters: z.object({\n message: z\n .string()\n .describe(\"(string): The message to include in the commit.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.commits.commitAll({\n environment: config.environment ?? \"development\",\n commit_message: params.message,\n });\n },\n});\n\nconst promoteAllCommits = KnockTool({\n method: \"promote_all_commits\",\n name: \"Promote all commits\",\n description: `\n Promote all commits to the next environment. Use this tool when you are asked to deploy all changes. \n\n When not specified, the \\`toEnvironment\\` will default to the environment that comes after the environment specified in the config.\n `,\n parameters: z.object({\n toEnvironment: z\n .string()\n .describe(\"(string): The environment to promote all commits to.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.put(\"/v1/commits/promote\", {\n body: { to_environment: params.toEnvironment },\n });\n },\n});\n\nexport const commits = {\n listCommits,\n commitAllChanges,\n promoteAllCommits,\n};\n\nexport const permissions = {\n read: [\"listCommits\"],\n manage: [\"commitAllChanges\", \"promoteAllCommits\"],\n};\n","import { EmailLayout } from \"@knocklabs/mgmt/resources/email-layouts.js\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { z } from \"zod\";\n\nconst listEmailLayouts = KnockTool({\n method: \"list_email_layouts\",\n name: \"List email layouts\",\n description: `List all email layouts within the environment given. Returns information about the email layout, including the name and the key. \n \n Use this tool when building a workflow that is building an email notification when you need to know the available email layouts.`,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list email layouts for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allEmailLayouts: EmailLayout[] = [];\n for await (const emailLayout of knockClient.emailLayouts.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allEmailLayouts.push(emailLayout);\n }\n return allEmailLayouts;\n },\n});\n\nexport const emailLayouts = {\n listEmailLayouts,\n};\n\nexport const permissions = {\n read: [\"listEmailLayouts\"],\n};\n","import { Environment } from \"@knocklabs/mgmt/resources/environments.js\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listEnvironments = KnockTool({\n method: \"list_environments\",\n name: \"List environments\",\n description: `\n Lists all environments available, returning the slug, name, and the order of each environment. Use this tool when you need to see what environments are available to deploy to.\n `,\n execute: (knockClient) => async (params) => {\n const allEnvironments: Environment[] = [];\n for await (const environment of knockClient.environments.list()) {\n allEnvironments.push(environment);\n }\n return allEnvironments;\n },\n});\n\nexport const environments = {\n listEnvironments,\n};\n\nexport const permissions = {\n read: [\"listEnvironments\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getMessageContent = KnockTool({\n method: \"get_message_content\",\n name: \"Get message content\",\n description: `\n Retrieves the complete contents of a single message, specified by the messageId. The message contents includes the rendered template that was sent to the recipient. Use this tool when you want to surface information about the emails, SMS, and push notifications that were sent to a user.\n `,\n parameters: z.object({\n messageId: z\n .string()\n .describe(\"(string): The messageId of the message to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.messages.getContent(params.messageId);\n },\n});\n\nexport const messages = {\n getMessageContent,\n};\n\nexport const permissions = {\n read: [\"getMessageContent\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport { MessageType } from \"@knocklabs/mgmt/resources/message-types.js\";\n\nconst listMessageTypes = KnockTool({\n method: \"list_message_types\",\n name: \"List message types\",\n description:\n \"List all message types available for the environment. Each message type returns the schema, which includes information about the variants and the fields available per-variant. Use this tool when you need to understand the different message types that are available for the environment for use in Guides.\",\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list message types for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allMessageTypes: MessageType[] = [];\n for await (const messageType of knockClient.messageTypes.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allMessageTypes.push(messageType);\n }\n return allMessageTypes;\n },\n});\n\nconst createOrUpdateMessageType = KnockTool({\n method: \"create_or_update_message_type\",\n name: \"Create or update message type\",\n description: `\n Create or update a message type. A message type is a schema that defines fields available to an editor within Knock. Message types always have at least one variant, that MUST be named \"default\".\n \n Use this tool when you need to create a new message type, or update an existing message type. You must pass the FULL message type to this tool if you're going to update an existing message type.\n\n The preview is a string of HTML that will be rendered in the Knock UI as a representation of the message type. It is shared across all variants. It supports liquid, where the field name is available as a variable, so a field named \"text\" will be rendered as {{ text }}.\n\n <example>\n <description>\n Create a new message type for a banner component that has a text and an action URL.\n </description>\n <input>\n {\n \"messageTypeKey\": \"banner\",\n \"name\": \"Banner\",\n \"description\": \"A banner component that has a text and an action URL.\",\n \"preview\": \"<div>{{ text }}</div>\",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"text\",\n \"type\": \"text\",\n \"label\": \"Text\",\n \"settings\": {\n \"max_length\": 100,\n },\n },\n {\n \"key\": \"action_url\",\n \"type\": \"text\",\n \"label\": \"Action URL\",\n \"settings\": {\n \"placeholder\": \"https://example.com\",\n },\n }\n ]\n }\n ]\n }\n </input>\n </example>\n <example>\n <description>\n Create a message type for a card component that has an icon type, title, body, and a single action button.\n </description>\n <input>\n {\n \"messageTypeKey\": \"card\",\n \"name\": \"Card\",\n \"description\": \"A single-action card component.\",\n \"preview\": \"\n <div>\n <h2>{{ title }}</h2>\n <p>{{ body }}</p>\n <button>Action</button>\n </div>\n \",\n \"variants\": [\n {\n \"key\": \"default\",\n \"name\": \"Default\",\n \"fields\": [\n {\n \"key\": \"icon_type\",\n \"type\": \"select\",\n \"label\": \"Icon type\",\n \"settings\": {\n \"options\": [\n {\n \"value\": \"warning\",\n \"label\": \"Warning\",\n },\n {\n \"value\": \"success\",\n \"label\": \"Success\",\n },\n {\n \"value\": \"info\",\n \"label\": \"Info\",\n },\n {\n \"value\": \"error\",\n \"label\": \"Error\",\n },\n ]\n },\n },\n {\n \"key\": \"title\",\n \"type\": \"text\",\n \"label\": \"Title\",\n },\n {\n \"key\": \"description\",\n \"type\": \"markdown\",\n \"label\": \"Description\",\n },\n {\n \"key\": \"action_button\",\n \"type\": \"button\",\n \"label\": \"Action button\",\n },\n ]\n }\n ]\n }\n </input>\n </example>\n `,\n parameters: z.object({\n messageTypeKey: z\n .string()\n .describe(\"(string): The key of the message type to create or update.\"),\n name: z.string().describe(\"(string): The name of the message type.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the message type.\"),\n preview: z\n .string()\n .optional()\n .describe(\n \"(string): The preview of the variant. This is a string of HTML that will be rendered in the preview of the message type. There is a single preview shared by all variants.\"\n ),\n variants: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the variant.\"),\n name: z.string().describe(\"(string): The name of the variant.\"),\n description: z\n .string()\n .optional()\n .describe(\"(string): The description of the variant.\"),\n fields: z\n .array(\n z.object({\n key: z.string().describe(\"(string): The key of the field.\"),\n type: z\n .string()\n .describe(\n \"(string): The type of the field. One of `text`, `textarea`, `button`, `markdown`, `select`, `multi_select`.\"\n ),\n label: z.string().describe(\"(string): The label of the field.\"),\n settings: z\n .object({})\n .describe(\"(object): The settings of the field.\"),\n })\n )\n .describe(\"(array): The fields of the variant.\"),\n })\n )\n .describe(\"(array): The variants of the message type.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n return await knockClient.messageTypes.upsert(params.messageTypeKey, {\n message_type: {\n name: params.name,\n variants: params.variants,\n description: params.description ?? \"\",\n preview: params.preview ?? \"<div></div>\",\n },\n environment: params.environment ?? config.environment ?? \"development\",\n });\n },\n});\n\nexport const messageTypes = {\n listMessageTypes,\n createOrUpdateMessageType,\n};\n\nexport const permissions = {\n read: [\"listMessageTypes\"],\n manage: [\"createOrUpdateMessageType\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst listObjects = KnockTool({\n method: \"list_objects\",\n name: \"List objects\",\n description:\n \"List all objects in a single collection. Objects are used to model custom collections in Knock that are NOT users or tenants. Use this tool when you need to return a paginated list of objects in a single collection.\",\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to list objects from.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.list(params.collection);\n },\n});\n\nconst getObject = KnockTool({\n method: \"get_object\",\n name: \"Get object\",\n description:\n \"Get an object wihin a collection. Returns information about the object including any custom properties. Use this tool when you need to retrieve an object to understand it's properties.\",\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to get the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to get.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.get(params.collection, params.objectId);\n },\n});\n\nconst createOrUpdateObject = KnockTool({\n method: \"create_or_update_object\",\n name: \"Create or update object\",\n description: `Create or update an object in a specific collection. Objects are used to model custom collections in Knock that are NOT users or tenants. If the object does not exist, it will be created. If the object exists, it will be updated with the provided properties. The update will always perform an upsert operation, so you do not need to provide the full properties each time.\n \n Use this tool when you need to create a new object, or update an existing custom-object. Custom objects can be used to subscribe users' to as lists, and also send non-user facing notifications to.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to create or update the object in.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to create or update.\"),\n properties: z\n .record(z.string(), z.any())\n .describe(\"(object): The properties to set on the object.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.set(\n params.collection,\n params.objectId,\n params.properties\n );\n },\n});\n\nconst deleteObject = KnockTool({\n method: \"delete_object\",\n name: \"Delete object\",\n description: `Delete an object from a specific collection. Use this tool when you need to remove an object from the system.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to delete the object from.\"),\n objectId: z.string().describe(\"(string): The ID of the object to delete.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.objects.delete(params.collection, params.objectId);\n return { success: true };\n },\n});\n\nconst subscribeUsersToObject = KnockTool({\n method: \"subscribe_users_to_object\",\n name: \"Subscribe users to object\",\n description: `\n Subscribe a list of users to an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to subscribe one or more users to an object where you will then trigger workflows for those lists of users to send notifications to.\n\n Before using this tool, you should create the object in the collection using the createOrUpdateObject tool.\n `,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to subscribe the user to.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to subscribe the user to.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to subscribe to the object. If not provided, the current user will be subscribed.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.addSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nconst unsubscribeUsersFromObject = KnockTool({\n method: \"unsubscribe_users_from_object\",\n name: \"Unsubscribe users from object\",\n description: `Unsubscribe a list of users from an object in a specific collection. We use this to model lists of users, for pub-sub use cases.\n \n Use this tool when you need to unsubscribe one or more users from an object where you will then trigger workflows for those lists of users to send notifications to.`,\n parameters: z.object({\n collection: z\n .string()\n .describe(\"(string): The collection to unsubscribe the user from.\"),\n objectId: z\n .string()\n .describe(\"(string): The ID of the object to unsubscribe the user from.\"),\n userIds: z\n .array(z.string())\n .describe(\n \"(array): The IDs of the users to unsubscribe from the object.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.objects.deleteSubscriptions(\n params.collection,\n params.objectId,\n {\n recipients: params.userIds ?? [config.userId],\n }\n );\n },\n});\n\nexport const objects = {\n listObjects,\n getObject,\n createOrUpdateObject,\n deleteObject,\n subscribeUsersToObject,\n unsubscribeUsersFromObject,\n};\n\nexport const permissions = {\n read: [\"listObjects\", \"getObject\"],\n manage: [\n \"createOrUpdateObject\",\n \"deleteObject\",\n \"subscribeUsersToObject\",\n \"unsubscribeUsersFromObject\",\n ],\n};\n","import { KnockTool } from \"../knock-tool.js\";\nimport { z } from \"zod\";\nimport { Partial } from \"@knocklabs/mgmt/resources/partials.js\";\n\nconst listPartials = KnockTool({\n method: \"list_partials\",\n name: \"List partials\",\n description: `List all partials within the environment given. Partials provide common building blocks for notification templates. Returns information about the partial, including the name and the key.\n \n Use this tool when you need to know the available partials for the environment, like when building a notification template and wanting to use a partial to build the template.`,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list partials for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allPartials: Partial[] = [];\n for await (const partial of knockClient.partials.list({\n environment: params.environment ?? config.environment ?? \"development\",\n })) {\n allPartials.push(partial);\n }\n return allPartials;\n },\n});\n\nexport const partials = {\n listPartials,\n};\n\nexport const permissions = {\n read: [\"listPartials\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getTenant = KnockTool({\n method: \"get_tenant\",\n name: \"Get tenant\",\n description: `\n Retrieves a tenant by their ID. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you need to lookup the information about a tenant, including name, and if there are any custom properties set.\n `,\n parameters: z.object({\n tenantId: z\n .string()\n .describe(\"(string): The ID of the tenant to retrieve.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.tenants.get(params.tenantId);\n },\n});\n\nconst setTenant = KnockTool({\n method: \"set_tenant\",\n name: \"Set tenant\",\n description: `\n Creates or updates a tenant using the properties provided. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you need to create a new tenant, or update an existing tenant's properties.\n `,\n parameters: z.object({\n tenantId: z.string().describe(\"(string): The ID of the tenant to update.\"),\n name: z.string().describe(\"(string): The name of the tenant.\"),\n properties: z\n .record(z.string(), z.any())\n .describe(\"(object): The properties to set on the tenant.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n return await publicClient.tenants.set(params.tenantId, {\n name: params.name,\n ...params.properties,\n });\n },\n});\n\nconst deleteTenant = KnockTool({\n method: \"delete_tenant\",\n name: \"Delete tenant\",\n description: `\n Deletes a tenant. Tenants in Knock are used to model organizations, teams, and other groups of users. They are a special type of object.\n \n Use this tool when you've been asked to remove a tenant from the system.\n `,\n parameters: z.object({\n tenantId: z.string().describe(\"(string): The ID of the tenant to delete.\"),\n }),\n execute: (knockClient) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.tenants.delete(params.tenantId);\n return { success: true };\n },\n});\n\nexport const tenants = {\n getTenant,\n setTenant,\n deleteTenant,\n};\n\nexport const permissions = {\n read: [\"getTenant\"],\n manage: [\"setTenant\", \"deleteTenant\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\n\nconst getUser = KnockTool({\n method: \"get_user\",\n name: \"Get user\",\n description: `\n Retrieves the complete user object for the given userId, including email, name, phone number, and any custom properties. Use this tool when you need to retrieve a user's complete profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n userId: z\n .string()\n .describe(\"(string): The userId of the User to retrieve.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n return await publicClient.users.get(params.userId ?? config.userId);\n },\n});\n\nconst createOrUpdateUser = KnockTool({\n method: \"create_or_update_user\",\n name: \"Create or update user\",\n description: `\n Creates a new user if they don't exist, or updates the user object for the given userId, including email, name, phone number, and any custom properties.\n \n Use this tool when you need to update a user's profile.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n userId: z.string().describe(\"(string): The userId of the User to update.\"),\n email: z.string().describe(\"(string): The email of the User to update.\"),\n name: z.string().describe(\"(string): The name of the User to update.\"),\n phoneNumber: z\n .string()\n .describe(\"(string): The phone number of the User to update.\"),\n customProperties: z\n .record(z.string(), z.any())\n .describe(\n \"(object): A dictionary of custom properties to update for the User.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n return await publicClient.users.identify(params.userId, {\n email: params.email,\n name: params.name,\n phone_number: params.phoneNumber,\n ...(params.customProperties ?? {}),\n });\n },\n});\n\nconst deleteUser = KnockTool({\n method: \"delete_user\",\n name: \"Delete user\",\n description: `\n Deletes a user. Use this tool when you've been asked to remove a user from the system.\n `,\n parameters: z.object({\n userId: z.string().describe(\"(string): The userId of the User to delete.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n await publicClient.users.delete(params.userId);\n return { success: true };\n },\n});\n\nconst getUserPreferences = KnockTool({\n method: \"get_user_preferences\",\n name: \"Get user preferences\",\n description: `\n Retrieves the user's notification preferences for the given userId.\n\n If the userId is not provided, it will use the userId from the config. \n `,\n parameters: z.object({\n userId: z\n .string()\n .describe(\n \"(string): The userId of the User to retrieve Preferences for.\"\n ),\n preferenceSetId: z\n .string()\n .describe(\n \"(string): The preferenceSetId of the User to retrieve preferences for. Defaults to `default`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n return await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: params.preferenceSetId ?? \"default\",\n }\n );\n },\n});\n\nconst setUserPreferences = KnockTool({\n method: \"set_user_preferences\",\n name: \"Set user preferences\",\n description: `\n Overwrites the user's notification preferences for the given userId. Allows setting per-workflow, per-category, or per-channel notification preferences. Use this tool when you are asked to update a user's notification preferences.\n\n If the userId is not provided, it will use the userId from the config.\n\n Instructions:\n\n - You must ALWAYS provide a full preference set to this tool.\n - When setting per-workflow preferences, the key in the object should be the workflow key.\n - Workflow and category preferences should always have channel types underneath.\n - The channel types available to you are: email, sms, push, chat, and in_app_feed.\n - To turn OFF a preference, you must set it to false.\n - To turn ON a preference, you must set it to true.\n\n <examples>\n <example>\n <description>\n Update the user's preferences to turn off email notifications for the \"welcome\" workflow.\n </description>\n <input>\n {\n \"workflows\": {\n \"welcome\": {\n \"channel_types\": {\n \"email\": false\n }\n }\n }\n }\n </example>\n </examples>\n `,\n parameters: z.object({\n userId: z\n .string()\n .describe(\"(string): The userId of the User to update preferences for.\"),\n workflows: z\n .record(z.string(), z.any())\n .describe(\n \"(object): The workflows to update where the key is the workflow key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n categories: z\n .record(z.string(), z.any())\n .describe(\n \"(object): The categories to update where the key is the category key, and the value of the object is an object that contains a `channel_types` key with a boolean value for each channel type.\"\n ),\n channel_types: z\n .record(z.string(), z.boolean())\n .describe(\n \"(object): The channel types to update where the key is the channel type, and the value of the object is a boolean value.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n const existingPreferences = await publicClient.users.getPreferences(\n params.userId ?? config.userId,\n {\n preferenceSet: \"default\",\n }\n );\n\n const updatedPreferences = {\n ...existingPreferences,\n workflows: {\n ...existingPreferences.workflows,\n ...params.workflows,\n },\n categories: {\n ...existingPreferences.categories,\n ...params.categories,\n },\n channel_types: {\n ...existingPreferences.channel_types,\n ...params.channel_types,\n },\n };\n\n return await publicClient.users.setPreferences(\n params.userId ?? config.userId,\n updatedPreferences\n );\n },\n});\n\nconst getUserMessages = KnockTool({\n method: \"get_user_messages\",\n name: \"Get user messages\",\n description: `\n Retrieves the messages that this user has received from the service. Use this tool when you need information about the notifications that the user has received, including if the message has been read, seen, or interacted with. This will return a list of messages across all of the channels.\n\n If the userId is not provided, it will use the userId from the config.\n `,\n parameters: z.object({\n userId: z\n .string()\n .describe(\"(string): The userId of the User to retrieve messages for.\"),\n workflowRunId: z\n .string()\n .describe(\n \"(string): The workflowRunId of the User to retrieve. Use this when you want to retrieve messages sent from a workflow trigger.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n return await publicClient.users.getMessages(\n params.userId ?? config.userId,\n {\n workflow_run_id: params.workflowRunId,\n }\n );\n },\n});\n\nexport const users = {\n getUser,\n deleteUser,\n createOrUpdateUser,\n getUserPreferences,\n setUserPreferences,\n getUserMessages,\n};\n\nexport const permissions = {\n read: [\"getUser\", \"getUserPreferences\", \"getUserMessages\"],\n manage: [\"createOrUpdateUser\", \"deleteUser\", \"setUserPreferences\"],\n};\n","import { z } from \"zod\";\nimport { KnockTool } from \"../knock-tool.js\";\nimport {\n Workflow,\n WorkflowUpsertParams,\n} from \"@knocklabs/mgmt/resources/index.js\";\n\nconst listWorkflows = KnockTool({\n method: \"list_workflows\",\n name: \"List workflows\",\n description: `\n List all workflows available for the given environment. Returns structural information about the workflows, including the key, name, description, and categories. Will also return the steps that make up the workflow. \n\n Use this tool when you need to understand which workflows are available to be called. \n `,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to list workflows for. Defaults to `development`.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const allWorkflows: Workflow[] = [];\n const listParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n };\n\n for await (const workflow of knockClient.workflows.list(listParams)) {\n allWorkflows.push(workflow);\n }\n return allWorkflows;\n },\n});\n\nconst triggerWorkflow = KnockTool({\n method: \"trigger_workflow\",\n name: \"Trigger workflow\",\n description: `\n Trigger a workflow for one or more recipients.\n\n Use this tool when you need to trigger a workflow to send a notification across the channels configured for the workflow. The workflow must be committed in the environment for you to trigger it.\n\n When recipients aren't provided, the workflow will be triggered for the current user specified in the config.\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to trigger.\"),\n recipients: z\n .array(z.string())\n .describe(\"(array): The recipients to trigger the workflow for.\"),\n data: z\n .record(z.string(), z.any())\n .describe(\"(object): Data to pass to the workflow.\"),\n tenant: z\n .record(z.string(), z.any())\n .describe(\n \"(object): The tenant to trigger the workflow for. Must contain an id if being sent.\"\n ),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n const result = await publicClient.workflows.trigger(params.workflowKey, {\n recipients: params.recipients,\n data: params.data,\n tenant: params.tenant,\n });\n\n return result.workflow_run_id;\n },\n});\n\nconst createEmailWorkflow = KnockTool({\n method: \"create_email_workflow\",\n name: \"Create email workflow\",\n description: `\n Creates a simple email workflow with a single step that sends an email to the recipient. Use this tool when you need to need to create an email notification, and you don't need to specify any additional steps. You can only create workflows in the development environment.\n\n The content of the email you supply should ONLY ever be in markdown format for simplicity. You can supply dynamic variables to the subject and body of the email using the liquid template language.\n\n When writing markdown, be sure to use headings (##) to separate sections of the email. Use an informal writing style, and avoid using complex language.\n\n The following variables are available to use in the email subject and body:\n\n - \\`recipient.name\\`: The name of the recipient.\n - \\`recipient.email\\`: The email of the recipient.\n - \\`recipient.phone_number\\`: The phone number of the recipient.\n - \\`tenant.id\\`: The id of the tenant.\n - \\`tenant.name\\`: The name of the tenant.\n\n You can supply any other dynamic variables by referencing them under the \\`data\\` key in the \\`data\\` parameter when triggering the workflow. You add those like \\`{{ data.variable_name }}\\`.\n\n You can also supply a list of categories to the workflow. These are used to categorize workflows for notification preferences. Categories should be supplied as lowercase strings in kebab case.\n\n Once you've created the workflow, you should ask if you should commit the changes to the environment.\n `,\n parameters: z.object({\n environment: z\n .string()\n .describe(\n \"(string): The environment to create the workflow in. Defaults to `development`.\"\n ),\n workflowKey: z.string().describe(\"(string): The key of the workflow.\"),\n name: z.string().describe(\"(string): The name of the workflow.\"),\n categories: z\n .array(z.string())\n .describe(\"(array): The categories to add to the workflow.\"),\n subject: z.string().describe(\"(string): The subject of the email.\"),\n body: z.string().describe(\"(string): The body of the email.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const emailChannelsPage = await knockClient.channels.list();\n const emailChannels = emailChannelsPage.entries.filter(\n (channel) => channel.type === \"email\"\n );\n\n if (emailChannels.length === 0) {\n throw new Error(\"No email channels found\");\n }\n\n const workflowParams: WorkflowUpsertParams = {\n environment: params.environment ?? config.environment ?? \"development\",\n workflow: {\n name: params.name,\n categories: params.categories ?? [],\n steps: [\n {\n type: \"channel\",\n channel_key: emailChannels[0].key,\n template: {\n settings: {\n layout_key: \"default\",\n },\n subject: params.subject,\n visual_blocks: [\n // @ts-ignore\n {\n type: \"markdown\",\n content: params.body,\n },\n ],\n },\n name: \"Email\",\n ref: \"email_1\",\n },\n ],\n },\n };\n\n return await knockClient.workflows.upsert(\n params.workflowKey,\n workflowParams\n );\n },\n});\n\nconst createOneOffWorkflowSchedule = KnockTool({\n method: \"create_one_off_workflow_schedule\",\n name: \"Create one-off workflow schedule\",\n description: `\n Create a one-off workflow schedule for a user. Use this tool when you need to schedule the execution of a workflow for a specific user in the future, like to power a delayed notification.\n \n Schedules can accept a set of data that will be passed to the workflow trigger when it is executed. When the userId is not provided, the schedule will be created for the current user specified in the config.\n\n Examples:\n \n - In three days, send a welcome email to a user\n - In one hour, send a password reset email to a user\n - In two weeks, send a survey to a user\n `,\n parameters: z.object({\n workflowKey: z\n .string()\n .describe(\"(string): The key of the workflow to schedule.\"),\n userId: z\n .string()\n .describe(\n \"(string): The userId of the user to schedule the workflow for.\"\n ),\n scheduledAt: z\n .string()\n .describe(\n \"(string): The date and time to schedule the workflow for. Must be in ISO 8601 format.\"\n ),\n data: z\n .record(z.string(), z.any())\n .describe(\"(object): Data to pass to the workflow.\"),\n }),\n execute: (knockClient, config) => async (params) => {\n const publicClient = await knockClient.publicApi();\n\n return await publicClient.workflows.createSchedules(params.workflowKey, {\n recipients: [params.userId ?? config.userId],\n scheduled_at: params.scheduledAt,\n data: params.data,\n });\n },\n});\n\nexport const workflows = {\n listWorkflows,\n triggerWorkflow,\n createEmailWorkflow,\n createOneOffWorkflowSchedule,\n};\n\nexport const permissions = {\n read: [\"listWorkflows\"],\n manage: [\"createEmailWorkflow\", \"createOneOffWorkflowSchedule\"],\n trigger: [\"triggerWorkflow\"],\n};\n","import { channels, permissions as channelsPermissions } from \"./channels.js\";\nimport { commits, permissions as commitsPermissions } from \"./commits.js\";\nimport {\n emailLayouts,\n permissions as emailLayoutsPermissions,\n} from \"./email-layouts.js\";\nimport {\n environments,\n permissions as environmentsPermissions,\n} from \"./environments.js\";\nimport { messages, permissions as messagesPermissions } from \"./messages.js\";\nimport {\n messageTypes,\n permissions as messageTypesPermissions,\n} from \"./message-types.js\";\nimport { objects, permissions as objectsPermissions } from \"./objects.js\";\nimport { partials, permissions as partialsPermissions } from \"./partials.js\";\nimport { tenants, permissions as tenantsPermissions } from \"./tenants.js\";\nimport { users, permissions as usersPermissions } from \"./users.js\";\nimport { workflows, permissions as workflowsPermissions } from \"./workflows.js\";\n\nexport const tools = {\n channels,\n commits,\n emailLayouts,\n environments,\n messages,\n messageTypes,\n objects,\n partials,\n tenants,\n users,\n workflows,\n};\n\nexport const allTools = {\n ...channels,\n ...commits,\n ...emailLayouts,\n ...environments,\n ...messageTypes,\n ...messages,\n ...objects,\n ...partials,\n ...tenants,\n ...users,\n ...workflows,\n};\n\nexport const toolPermissions = {\n channels: channelsPermissions,\n commits: commitsPermissions,\n emailLayouts: emailLayoutsPermissions,\n environments: environmentsPermissions,\n messages: messagesPermissions,\n messageTypes: messageTypesPermissions,\n objects: objectsPermissions,\n partials: partialsPermissions,\n tenants: tenantsPermissions,\n users: usersPermissions,\n workflows: workflowsPermissions,\n};\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport type { KnockTool } from \"../lib/knock-tool.js\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"../lib/knock-client.js\";\n\nexport class KnockMcpServer extends McpServer {\n constructor(knockClient: KnockClient, config: Config, tools: KnockTool[]) {\n super({ name: \"Knock\", version: \"0.1.0\" });\n\n tools.forEach((tool) => {\n const toolParams = tool.parameters ?? z.object({});\n\n this.tool(\n tool.name,\n tool.description,\n toolParams.shape,\n async (arg: unknown) => {\n const res = await tool.bindExecute(knockClient, config)(arg);\n\n return {\n content: [{ type: \"text\" as const, text: JSON.stringify(res) }],\n };\n }\n );\n });\n }\n}\n","import type { KnockTool } from \"../lib/knock-tool.js\";\nimport { allTools } from \"../lib/tools/index.js\";\nimport { KnockMcpServer } from \"./adapter.js\";\nimport { Config } from \"../types.js\";\nimport { KnockClient } from \"../lib/knock-client.js\";\n\ntype CreateKnockMcpServerParams = {\n /**\n * Array of Knock tools to enable in the server.\n */\n tools?: KnockTool[];\n\n /**\n * A Knock client to use for the server.\n */\n knockClient: KnockClient;\n\n /**\n * The config to use for the server.\n */\n config: Config;\n};\n\n/**\n * Creates a Knock MCP Server with the given parameters.\n */\nexport const createKnockMcpServer = async (\n params: CreateKnockMcpServerParams\n): Promise<KnockMcpServer> => {\n const { tools, knockClient, config } = params;\n\n return Promise.resolve(\n new KnockMcpServer(knockClient, config, tools || Object.values(allTools))\n );\n};\n","import { KnockTool } from \"./knock-tool.js\";\nimport { toolPermissions, tools } from \"../lib/tools/index.js\";\nimport { ToolkitConfig } from \"../types.js\";\nimport { ToolCategory } from \"../types.js\";\n\n/**\n * Given a list of tools, and some config may describe the tools that should be provided to the LLM,\n * returns a filtered list of tools that match the config.\n *\n * Options:\n * `*` - All tools\n * `users.*` - All tools that start with `users.`\n * `users.getUser` - A specific tool\n *\n */\nexport function filterTools(\n tools: Record<string, Record<string, KnockTool>>,\n pattern: string | undefined\n): KnockTool[] {\n if (!pattern) {\n throw new Error(\"No pattern provided\");\n }\n\n // If the pattern is `*`, return all tools\n if (pattern === \"*\") {\n return Object.values(tools).flatMap((category) => Object.values(category));\n }\n\n const [category, tool] = pattern.split(\".\");\n\n // If the pattern is `*.*`, return all tools\n if (category === \"*\" && tool === \"*\") {\n return Object.values(tools).flatMap((category) => Object.values(category));\n }\n\n if (category && !tools[category]) {\n throw new Error(`Tool category ${category} not found`);\n }\n\n // If the pattern is `users.*`, return all tools that start with `users.`\n if (category && tool === \"*\") {\n return Object.values(tools[category]);\n }\n\n // If the pattern is `users.getUser`, return the `getUser` tool\n if (category && tool && !tools[category][tool]) {\n throw new Error(`Tool ${pattern} not found`);\n }\n\n return [tools[category][tool]];\n}\n\n/**\n * Given a category and a list of permissions, return a list of tools that the user has permission to use.\n *\n * @param category - The category to get tools for\n * @param categoryPermissions - The permissions to use\n * @returns A list of tools that the user has permission to use\n */\nexport function getToolsWithPermissions(\n category: keyof typeof toolPermissions,\n categoryPermissions: Record<string, boolean | undefined>\n) {\n // Return all of the tools for the category that have permission\n const toolsInCategory = tools[category] as Record<string, KnockTool>;\n const toolPermissionsInCategory = toolPermissions[category] as Record<\n string,\n string[]\n >;\n\n // Look over each permission type, like `read: true`\n // If it's `true`, then find all of the tools that have that permission\n return Object.entries(categoryPermissions).reduce(\n (acc: KnockTool[], [permissionType, hasPermission]) => {\n if (hasPermission) {\n return acc.concat(\n toolPermissionsInCategory[permissionType].map(\n (toolName) => toolsInCategory[toolName]\n )\n );\n }\n return acc;\n },\n []\n );\n}\n\n/**\n * Given a config, return a list of tools for each category that the user has permission to use.\n *\n * @param config - The config to use\n * @returns A list of tools for each category that the user has permission to use\n */\nexport function getToolsByPermissionsInCategories(\n config: ToolkitConfig\n): Record<ToolCategory, KnockTool[]> {\n return Object.keys(config.permissions).reduce(\n (acc, category) => {\n const categoryKey = category as ToolCategory;\n const categoryPermissions = config.permissions[categoryKey];\n\n if (tools[categoryKey] && categoryPermissions) {\n const tools = getToolsWithPermissions(categoryKey, categoryPermissions);\n\n return { ...acc, [categoryKey]: tools };\n }\n\n return acc;\n },\n {} as Record<ToolCategory, KnockTool[]>\n );\n}\n"],"mappings":";;;AAEA,SAAS,4BAA4B;AACrC,SAAS,WAAW,aAAa;AACjC,SAAS,eAAe;;;ACJxB,SAAS,aAAa;AACtB,OAAO,eAAe;AAGtB,IAAM,4BAAmE,CAAC;AAI1E,IAAM,oBAAoB,CAAC,WAAmB;AAC5C,QAAM,SAAS,IAAI,UAAU;AAAA,IAC3B,cAAc,OAAO;AAAA,EACvB,CAAC;AAED,SAAO,OAAO,OAAO,QAAQ;AAAA,IAC3B,WAAW,OAAO,iBAA0C;AAC1D,YAAM,cAAc,gBAAgB,OAAO,eAAe;AAG1D,UAAI,4BAA4B,OAAO,YAAY,IAAI,WAAW,GAAG;AACnE,eAAO,0BAA0B,OAAO,YAAY,EAAE,WAAW;AAAA,MACnE;AAGA,YAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,QAAQ,SAAS,EAAE,YAAY,CAAC;AAGjE,YAAM,QAAQ,IAAI,MAAM,OAAO;AAG/B,UAAI,CAAC,0BAA0B,OAAO,YAAY,GAAG;AACnD,kCAA0B,OAAO,YAAY,IAAI,CAAC;AAAA,MACpD;AAEA,gCAA0B,OAAO,YAAY,EAAE,WAAW,IAAI;AAE9D,aAAO;AAAA,IACT;AAAA,EACF,CAAC;AACH;;;ACrCA,SAAS,SAAS;AA8ClB,IAAM,YAAY,CAAC,SACjB,KACG,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO,EACd,KAAK,IAAI;AAEP,IAAM,YAAY,CACvB,SACc;AACd,QAAM,EAAE,SAAS,GAAG,WAAW,IAAI;AACnC,QAAM,aAAa,WAAW,aAC1B,WAAW,aACX,EAAE,OAAO,CAAC,CAAC;AAEf,QAAM,gBAAgB,O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AAE,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,6CAA6C,MAAM,OAAO;AAC1E,CAAC;","names":["z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","tools","tools","tools","category"]}
|
|
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":[]}
|
package/dist/openai/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { ChatCompletionTool, ChatCompletionMessageToolCall, ChatCompletionToolMessageParam } from 'openai/resources.mjs';
|
|
2
|
-
import { T as ToolkitConfig,
|
|
3
|
-
import 'zod';
|
|
4
|
-
import '@knocklabs/node';
|
|
5
|
-
import '@knocklabs/mgmt';
|
|
2
|
+
import { T as ToolkitConfig, a as ToolCategory } from '../types-DyB12-Gk.js';
|
|
6
3
|
|
|
7
4
|
declare const createKnockToolkit: (config: ToolkitConfig) => {
|
|
8
5
|
/**
|