@alfe.ai/mcp-tools 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,80 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let zod = require("zod");
3
+ //#region src/types.ts
4
+ function ok(data) {
5
+ return { content: [{
6
+ type: "text",
7
+ text: JSON.stringify(data, null, 2)
8
+ }] };
9
+ }
10
+ function err(message) {
11
+ return {
12
+ content: [{
13
+ type: "text",
14
+ text: message
15
+ }],
16
+ isError: true
17
+ };
18
+ }
19
+ //#endregion
20
+ //#region src/integrations.ts
21
+ const OAUTH_PROVIDERS = [
22
+ "xero",
23
+ "google",
24
+ "notion",
25
+ "microsoft",
26
+ "atlassian",
27
+ "myob",
28
+ "github",
29
+ "discord",
30
+ "slack"
31
+ ];
32
+ /**
33
+ * Thin-slice subset of the `services/mcp` `integrations` domain — only
34
+ * the two subtools whose underlying calls already hit public
35
+ * `/agent/...` (or unauthenticated public) endpoints today. The rest of
36
+ * the domain stays in `services/mcp` until the per-domain endpoint
37
+ * promotion workstream lifts it (see
38
+ * `project_mcp_tool_lift_workstream.md`).
39
+ *
40
+ * - `integrations_browse_registry` — public `GET /integrations/registry`
41
+ * via `AgentApiClient.getRegistry()`.
42
+ * - `integrations_start_oauth` — generates the public
43
+ * `GET /<provider>/oauth/start` URL for the user to open in a browser.
44
+ * Pure URL builder; no server-side call.
45
+ */
46
+ const registerIntegrationsTools = (server, ctx) => {
47
+ server.registerTool("integrations_browse_registry", {
48
+ description: "Browse available integrations in the registry. Returns the catalogue of all published integrations with their manifests.",
49
+ inputSchema: {}
50
+ }, async () => {
51
+ try {
52
+ return ok(await ctx.client.getRegistry());
53
+ } catch (error) {
54
+ return err(error instanceof Error ? error.message : "Failed to browse integrations");
55
+ }
56
+ });
57
+ server.registerTool("integrations_start_oauth", {
58
+ description: "Start an OAuth connection flow for an integration. Returns a URL the user must open in their browser to authorize the connection. After authorization, use `integrations_check_oauth_status` (currently in services/mcp) to verify.",
59
+ inputSchema: {
60
+ provider: zod.z.enum(OAUTH_PROVIDERS).describe("The OAuth provider to connect"),
61
+ scopes: zod.z.string().optional().describe("Comma-separated scope groups (e.g. 'gmail,drive' for Google)")
62
+ }
63
+ }, ({ provider, scopes }) => {
64
+ const params = new URLSearchParams({
65
+ agentId: ctx.agentId,
66
+ tenantId: ctx.tenantId
67
+ });
68
+ if (scopes) params.set("scopes", scopes);
69
+ const url = `${ctx.apiUrl}/${provider}/oauth/start?${params.toString()}`;
70
+ return Promise.resolve(ok({
71
+ url,
72
+ provider,
73
+ message: `Open this URL to connect ${provider}: ${url}`
74
+ }));
75
+ });
76
+ };
77
+ //#endregion
78
+ exports.err = err;
79
+ exports.ok = ok;
80
+ exports.registerIntegrationsTools = registerIntegrationsTools;
@@ -0,0 +1,75 @@
1
+ import { AgentApiClient } from "@alfe.ai/agent-api-client";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+
4
+ //#region src/types.d.ts
5
+
6
+ /**
7
+ * Context every tool registration function receives. The same context is
8
+ * used by the CLI-bundled local server (`@alfe.ai/mcp-server`) and the
9
+ * eventual lift target for `services/mcp` once each domain's public
10
+ * `/agent/...` endpoints land.
11
+ *
12
+ * `agentId` / `tenantId` are derived from `client.whoami()` at the local
13
+ * server's startup. They're carried in the context so tools that need
14
+ * them (e.g. OAuth-URL builders) don't have to re-issue a whoami call
15
+ * per invocation.
16
+ */
17
+ interface ToolContext {
18
+ client: AgentApiClient;
19
+ apiUrl: string;
20
+ agentId: string;
21
+ tenantId: string;
22
+ }
23
+ /**
24
+ * Tool registration function shape. Each domain module exports one of
25
+ * these; the server calls them with the live `McpServer` and a
26
+ * `ToolContext`. Implementations call `server.registerTool(name, …)` for
27
+ * each subtool they own.
28
+ *
29
+ * Tool names follow the `<domain>_<verb>` convention (no `alfe_` prefix —
30
+ * the bundler namespaces the surface as `mcp__alfe-platform__<name>`).
31
+ */
32
+ type RegisterToolsFn = (server: McpServer, ctx: ToolContext) => void;
33
+ /**
34
+ * Standard error-result envelope mirroring the existing `services/mcp`
35
+ * shape so the lifted tool surface stays drop-in compatible for any
36
+ * downstream MCP client.
37
+ *
38
+ * The index signature satisfies the MCP SDK's `CallToolResult` shape —
39
+ * the SDK declares its result type with `[x: string]: unknown` so
40
+ * callers can add transport-level metadata. We don't use any, but the
41
+ * shape needs to be assignable for the registration callback to typecheck.
42
+ */
43
+ interface ToolResult {
44
+ content: {
45
+ type: 'text';
46
+ text: string;
47
+ }[];
48
+ isError?: boolean;
49
+ [key: string]: unknown;
50
+ }
51
+ declare function ok(data: unknown): ToolResult;
52
+ declare function err(message: string): ToolResult;
53
+ //# sourceMappingURL=types.d.ts.map
54
+ //#endregion
55
+ //#region src/integrations.d.ts
56
+ /**
57
+ * Thin-slice subset of the `services/mcp` `integrations` domain — only
58
+ * the two subtools whose underlying calls already hit public
59
+ * `/agent/...` (or unauthenticated public) endpoints today. The rest of
60
+ * the domain stays in `services/mcp` until the per-domain endpoint
61
+ * promotion workstream lifts it (see
62
+ * `project_mcp_tool_lift_workstream.md`).
63
+ *
64
+ * - `integrations_browse_registry` — public `GET /integrations/registry`
65
+ * via `AgentApiClient.getRegistry()`.
66
+ * - `integrations_start_oauth` — generates the public
67
+ * `GET /<provider>/oauth/start` URL for the user to open in a browser.
68
+ * Pure URL builder; no server-side call.
69
+ */
70
+ declare const registerIntegrationsTools: RegisterToolsFn;
71
+ //# sourceMappingURL=integrations.d.ts.map
72
+
73
+ //#endregion
74
+ export { type RegisterToolsFn, type ToolContext, type ToolResult, err, ok, registerIntegrationsTools };
75
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/integrations.ts"],"mappings":";;;;;;;AAcA;AAgBA;;;;;AAYA;AAMA;AAMA;UAxCiB,WAAA;UACP;;ECcG,OAAA,EAAA,MAAA;;;;;;;;;;;;KDCD,eAAA,YAA2B,gBAAgB;;;;;;;;;;;UAYtC,UAAA;;;;;;;;iBAMD,EAAA,iBAAmB;iBAMnB,GAAA,mBAAsB;;;;;;;AAxCtC;AAgBA;;;;;AAYA;AAMA;AAMA;;;cCzBa,2BAA2B;AAAxC"}
@@ -0,0 +1,75 @@
1
+ import { AgentApiClient } from "@alfe.ai/agent-api-client";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+
4
+ //#region src/types.d.ts
5
+
6
+ /**
7
+ * Context every tool registration function receives. The same context is
8
+ * used by the CLI-bundled local server (`@alfe.ai/mcp-server`) and the
9
+ * eventual lift target for `services/mcp` once each domain's public
10
+ * `/agent/...` endpoints land.
11
+ *
12
+ * `agentId` / `tenantId` are derived from `client.whoami()` at the local
13
+ * server's startup. They're carried in the context so tools that need
14
+ * them (e.g. OAuth-URL builders) don't have to re-issue a whoami call
15
+ * per invocation.
16
+ */
17
+ interface ToolContext {
18
+ client: AgentApiClient;
19
+ apiUrl: string;
20
+ agentId: string;
21
+ tenantId: string;
22
+ }
23
+ /**
24
+ * Tool registration function shape. Each domain module exports one of
25
+ * these; the server calls them with the live `McpServer` and a
26
+ * `ToolContext`. Implementations call `server.registerTool(name, …)` for
27
+ * each subtool they own.
28
+ *
29
+ * Tool names follow the `<domain>_<verb>` convention (no `alfe_` prefix —
30
+ * the bundler namespaces the surface as `mcp__alfe-platform__<name>`).
31
+ */
32
+ type RegisterToolsFn = (server: McpServer, ctx: ToolContext) => void;
33
+ /**
34
+ * Standard error-result envelope mirroring the existing `services/mcp`
35
+ * shape so the lifted tool surface stays drop-in compatible for any
36
+ * downstream MCP client.
37
+ *
38
+ * The index signature satisfies the MCP SDK's `CallToolResult` shape —
39
+ * the SDK declares its result type with `[x: string]: unknown` so
40
+ * callers can add transport-level metadata. We don't use any, but the
41
+ * shape needs to be assignable for the registration callback to typecheck.
42
+ */
43
+ interface ToolResult {
44
+ content: {
45
+ type: 'text';
46
+ text: string;
47
+ }[];
48
+ isError?: boolean;
49
+ [key: string]: unknown;
50
+ }
51
+ declare function ok(data: unknown): ToolResult;
52
+ declare function err(message: string): ToolResult;
53
+ //# sourceMappingURL=types.d.ts.map
54
+ //#endregion
55
+ //#region src/integrations.d.ts
56
+ /**
57
+ * Thin-slice subset of the `services/mcp` `integrations` domain — only
58
+ * the two subtools whose underlying calls already hit public
59
+ * `/agent/...` (or unauthenticated public) endpoints today. The rest of
60
+ * the domain stays in `services/mcp` until the per-domain endpoint
61
+ * promotion workstream lifts it (see
62
+ * `project_mcp_tool_lift_workstream.md`).
63
+ *
64
+ * - `integrations_browse_registry` — public `GET /integrations/registry`
65
+ * via `AgentApiClient.getRegistry()`.
66
+ * - `integrations_start_oauth` — generates the public
67
+ * `GET /<provider>/oauth/start` URL for the user to open in a browser.
68
+ * Pure URL builder; no server-side call.
69
+ */
70
+ declare const registerIntegrationsTools: RegisterToolsFn;
71
+ //# sourceMappingURL=integrations.d.ts.map
72
+
73
+ //#endregion
74
+ export { type RegisterToolsFn, type ToolContext, type ToolResult, err, ok, registerIntegrationsTools };
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/integrations.ts"],"mappings":";;;;;;;AAcA;AAgBA;;;;;AAYA;AAMA;AAMA;UAxCiB,WAAA;UACP;;ECcG,OAAA,EAAA,MAAA;;;;;;;;;;;;KDCD,eAAA,YAA2B,gBAAgB;;;;;;;;;;;UAYtC,UAAA;;;;;;;;iBAMD,EAAA,iBAAmB;iBAMnB,GAAA,mBAAsB;;;;;;;AAxCtC;AAgBA;;;;;AAYA;AAMA;AAMA;;;cCzBa,2BAA2B;AAAxC"}
package/dist/index.js ADDED
@@ -0,0 +1,79 @@
1
+ import { z } from "zod";
2
+ //#region src/types.ts
3
+ function ok(data) {
4
+ return { content: [{
5
+ type: "text",
6
+ text: JSON.stringify(data, null, 2)
7
+ }] };
8
+ }
9
+ function err(message) {
10
+ return {
11
+ content: [{
12
+ type: "text",
13
+ text: message
14
+ }],
15
+ isError: true
16
+ };
17
+ }
18
+ //#endregion
19
+ //#region src/integrations.ts
20
+ const OAUTH_PROVIDERS = [
21
+ "xero",
22
+ "google",
23
+ "notion",
24
+ "microsoft",
25
+ "atlassian",
26
+ "myob",
27
+ "github",
28
+ "discord",
29
+ "slack"
30
+ ];
31
+ /**
32
+ * Thin-slice subset of the `services/mcp` `integrations` domain — only
33
+ * the two subtools whose underlying calls already hit public
34
+ * `/agent/...` (or unauthenticated public) endpoints today. The rest of
35
+ * the domain stays in `services/mcp` until the per-domain endpoint
36
+ * promotion workstream lifts it (see
37
+ * `project_mcp_tool_lift_workstream.md`).
38
+ *
39
+ * - `integrations_browse_registry` — public `GET /integrations/registry`
40
+ * via `AgentApiClient.getRegistry()`.
41
+ * - `integrations_start_oauth` — generates the public
42
+ * `GET /<provider>/oauth/start` URL for the user to open in a browser.
43
+ * Pure URL builder; no server-side call.
44
+ */
45
+ const registerIntegrationsTools = (server, ctx) => {
46
+ server.registerTool("integrations_browse_registry", {
47
+ description: "Browse available integrations in the registry. Returns the catalogue of all published integrations with their manifests.",
48
+ inputSchema: {}
49
+ }, async () => {
50
+ try {
51
+ return ok(await ctx.client.getRegistry());
52
+ } catch (error) {
53
+ return err(error instanceof Error ? error.message : "Failed to browse integrations");
54
+ }
55
+ });
56
+ server.registerTool("integrations_start_oauth", {
57
+ description: "Start an OAuth connection flow for an integration. Returns a URL the user must open in their browser to authorize the connection. After authorization, use `integrations_check_oauth_status` (currently in services/mcp) to verify.",
58
+ inputSchema: {
59
+ provider: z.enum(OAUTH_PROVIDERS).describe("The OAuth provider to connect"),
60
+ scopes: z.string().optional().describe("Comma-separated scope groups (e.g. 'gmail,drive' for Google)")
61
+ }
62
+ }, ({ provider, scopes }) => {
63
+ const params = new URLSearchParams({
64
+ agentId: ctx.agentId,
65
+ tenantId: ctx.tenantId
66
+ });
67
+ if (scopes) params.set("scopes", scopes);
68
+ const url = `${ctx.apiUrl}/${provider}/oauth/start?${params.toString()}`;
69
+ return Promise.resolve(ok({
70
+ url,
71
+ provider,
72
+ message: `Open this URL to connect ${provider}: ${url}`
73
+ }));
74
+ });
75
+ };
76
+ //#endregion
77
+ export { err, ok, registerIntegrationsTools };
78
+
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/types.ts","../src/integrations.ts"],"sourcesContent":["import type { AgentApiClient } from '@alfe.ai/agent-api-client';\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\n\n/**\n * Context every tool registration function receives. The same context is\n * used by the CLI-bundled local server (`@alfe.ai/mcp-server`) and the\n * eventual lift target for `services/mcp` once each domain's public\n * `/agent/...` endpoints land.\n *\n * `agentId` / `tenantId` are derived from `client.whoami()` at the local\n * server's startup. They're carried in the context so tools that need\n * them (e.g. OAuth-URL builders) don't have to re-issue a whoami call\n * per invocation.\n */\nexport interface ToolContext {\n client: AgentApiClient;\n apiUrl: string;\n agentId: string;\n tenantId: string;\n}\n\n/**\n * Tool registration function shape. Each domain module exports one of\n * these; the server calls them with the live `McpServer` and a\n * `ToolContext`. Implementations call `server.registerTool(name, …)` for\n * each subtool they own.\n *\n * Tool names follow the `<domain>_<verb>` convention (no `alfe_` prefix —\n * the bundler namespaces the surface as `mcp__alfe-platform__<name>`).\n */\nexport type RegisterToolsFn = (server: McpServer, ctx: ToolContext) => void;\n\n/**\n * Standard error-result envelope mirroring the existing `services/mcp`\n * shape so the lifted tool surface stays drop-in compatible for any\n * downstream MCP client.\n *\n * The index signature satisfies the MCP SDK's `CallToolResult` shape —\n * the SDK declares its result type with `[x: string]: unknown` so\n * callers can add transport-level metadata. We don't use any, but the\n * shape needs to be assignable for the registration callback to typecheck.\n */\nexport interface ToolResult {\n content: { type: 'text'; text: string }[];\n isError?: boolean;\n [key: string]: unknown;\n}\n\nexport function ok(data: unknown): ToolResult {\n return {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n}\n\nexport function err(message: string): ToolResult {\n return {\n content: [{ type: 'text', text: message }],\n isError: true,\n };\n}\n","import { z } from 'zod';\nimport { err, ok, type RegisterToolsFn, type ToolContext } from './types.js';\n\nconst OAUTH_PROVIDERS = [\n 'xero',\n 'google',\n 'notion',\n 'microsoft',\n 'atlassian',\n 'myob',\n 'github',\n 'discord',\n 'slack',\n] as const;\n\n/**\n * Thin-slice subset of the `services/mcp` `integrations` domain — only\n * the two subtools whose underlying calls already hit public\n * `/agent/...` (or unauthenticated public) endpoints today. The rest of\n * the domain stays in `services/mcp` until the per-domain endpoint\n * promotion workstream lifts it (see\n * `project_mcp_tool_lift_workstream.md`).\n *\n * - `integrations_browse_registry` — public `GET /integrations/registry`\n * via `AgentApiClient.getRegistry()`.\n * - `integrations_start_oauth` — generates the public\n * `GET /<provider>/oauth/start` URL for the user to open in a browser.\n * Pure URL builder; no server-side call.\n */\nexport const registerIntegrationsTools: RegisterToolsFn = (server, ctx: ToolContext): void => {\n server.registerTool(\n 'integrations_browse_registry',\n {\n description:\n 'Browse available integrations in the registry. Returns the catalogue of all published integrations with their manifests.',\n inputSchema: {},\n },\n async () => {\n try {\n const data = await ctx.client.getRegistry();\n return ok(data);\n } catch (error: unknown) {\n return err(error instanceof Error ? error.message : 'Failed to browse integrations');\n }\n },\n );\n\n server.registerTool(\n 'integrations_start_oauth',\n {\n description:\n 'Start an OAuth connection flow for an integration. Returns a URL the user must open in their browser to authorize the connection. After authorization, use `integrations_check_oauth_status` (currently in services/mcp) to verify.',\n inputSchema: {\n provider: z\n .enum(OAUTH_PROVIDERS)\n .describe('The OAuth provider to connect'),\n scopes: z\n .string()\n .optional()\n .describe(\"Comma-separated scope groups (e.g. 'gmail,drive' for Google)\"),\n },\n },\n ({ provider, scopes }: { provider: (typeof OAUTH_PROVIDERS)[number]; scopes?: string }) => {\n const params = new URLSearchParams({ agentId: ctx.agentId, tenantId: ctx.tenantId });\n if (scopes) params.set('scopes', scopes);\n const url = `${ctx.apiUrl}/${provider}/oauth/start?${params.toString()}`;\n return Promise.resolve(\n ok({\n url,\n provider,\n message: `Open this URL to connect ${provider}: ${url}`,\n }),\n );\n },\n );\n};\n"],"mappings":";;AAgDA,SAAgB,GAAG,MAA2B;AAC5C,QAAO,EACL,SAAS,CAAC;EAAE,MAAM;EAAQ,MAAM,KAAK,UAAU,MAAM,MAAM,EAAE;EAAE,CAAC,EACjE;;AAGH,SAAgB,IAAI,SAA6B;AAC/C,QAAO;EACL,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM;GAAS,CAAC;EAC1C,SAAS;EACV;;;;ACvDH,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;;;;AAgBD,MAAa,6BAA8C,QAAQ,QAA2B;AAC5F,QAAO,aACL,gCACA;EACE,aACE;EACF,aAAa,EAAE;EAChB,EACD,YAAY;AACV,MAAI;AAEF,UAAO,GADM,MAAM,IAAI,OAAO,aAAa,CAC5B;WACR,OAAgB;AACvB,UAAO,IAAI,iBAAiB,QAAQ,MAAM,UAAU,gCAAgC;;GAGzF;AAED,QAAO,aACL,4BACA;EACE,aACE;EACF,aAAa;GACX,UAAU,EACP,KAAK,gBAAgB,CACrB,SAAS,gCAAgC;GAC5C,QAAQ,EACL,QAAQ,CACR,UAAU,CACV,SAAS,+DAA+D;GAC5E;EACF,GACA,EAAE,UAAU,aAA8E;EACzF,MAAM,SAAS,IAAI,gBAAgB;GAAE,SAAS,IAAI;GAAS,UAAU,IAAI;GAAU,CAAC;AACpF,MAAI,OAAQ,QAAO,IAAI,UAAU,OAAO;EACxC,MAAM,MAAM,GAAG,IAAI,OAAO,GAAG,SAAS,eAAe,OAAO,UAAU;AACtE,SAAO,QAAQ,QACb,GAAG;GACD;GACA;GACA,SAAS,4BAA4B,SAAS,IAAI;GACnD,CAAC,CACH;GAEJ"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@alfe.ai/mcp-tools",
3
+ "version": "0.1.0",
4
+ "description": "Shared MCP tool implementations for Alfe's local CLI-bundled MCP server and (later) the Fly-deployed services/mcp. All tools use AgentApiClient against public /agent/... endpoints — never InternalClient.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.cjs",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "@modelcontextprotocol/sdk": "^1.29.0",
20
+ "zod": "^3.25.0",
21
+ "@alfe.ai/agent-api-client": "0.1.4"
22
+ },
23
+ "license": "UNLICENSED",
24
+ "scripts": {
25
+ "build": "tsdown",
26
+ "dev": "tsdown --watch",
27
+ "test": "vitest run",
28
+ "typecheck": "tsc --noEmit",
29
+ "lint": "eslint ."
30
+ }
31
+ }