@fabricorg/sdk-mcp 0.1.9 → 0.1.10

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 CHANGED
@@ -1,145 +1,3 @@
1
- 'use strict';
2
-
3
- var mcp_js = require('@modelcontextprotocol/sdk/server/mcp.js');
4
- var zod = require('zod');
5
-
6
- var __async = (__this, __arguments, generator) => {
7
- return new Promise((resolve, reject) => {
8
- var fulfilled = (value) => {
9
- try {
10
- step(generator.next(value));
11
- } catch (e) {
12
- reject(e);
13
- }
14
- };
15
- var rejected = (value) => {
16
- try {
17
- step(generator.throw(value));
18
- } catch (e) {
19
- reject(e);
20
- }
21
- };
22
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
23
- step((generator = generator.apply(__this, __arguments)).next());
24
- });
25
- };
26
- function createFabricMcpServer(options) {
27
- var _a, _b;
28
- const fabric = options.fabric;
29
- const server = new mcp_js.McpServer({
30
- name: (_a = options.name) != null ? _a : "fabric",
31
- version: (_b = options.version) != null ? _b : "0.1.0"
32
- });
33
- server.registerTool(
34
- "fabric_list_integrations",
35
- {
36
- title: "List Fabric Integrations",
37
- description: "List integrations connected for the authenticated Fabric workspace. Returns slug, display name, current connection status, permission mode (open/cautious/strict/readonly), and source (plugin/mcp-server/connector).",
38
- inputSchema: {}
39
- },
40
- () => __async(null, null, function* () {
41
- const integrations = yield fabric.integrations.list();
42
- return {
43
- content: [
44
- {
45
- type: "text",
46
- text: JSON.stringify(integrations, null, 2)
47
- }
48
- ]
49
- };
50
- })
51
- );
52
- server.registerTool(
53
- "fabric_list_operations",
54
- {
55
- title: "List Operations for an Integration",
56
- description: "List the dot-notation operations available on a single Fabric integration. Returns an array of `{ operation, riskLevel, description }`. Supply the slug from `fabric_list_integrations`.",
57
- inputSchema: {
58
- slug: zod.z.string().describe(
59
- 'Integration slug, e.g. "slack", "github", "linear".'
60
- )
61
- }
62
- },
63
- (_0) => __async(null, [_0], function* ({ slug }) {
64
- var _a2;
65
- const integration = fabric.integrations[slug];
66
- if (!integration) {
67
- return {
68
- content: [
69
- {
70
- type: "text",
71
- text: `Integration "${slug}" is not registered for this workspace.`
72
- }
73
- ],
74
- isError: true
75
- };
76
- }
77
- try {
78
- const ops = yield (_a2 = integration.call) == null ? void 0 : _a2.call(integration, "__operations");
79
- return {
80
- content: [
81
- { type: "text", text: JSON.stringify(ops, null, 2) }
82
- ]
83
- };
84
- } catch (e) {
85
- return {
86
- content: [
87
- {
88
- type: "text",
89
- text: `Operation listing for "${slug}" requires portal endpoint /api/v1/integrations/${slug}/operations (not yet exposed). Use fabric_call with a known operation path in the meantime.`
90
- }
91
- ]
92
- };
93
- }
94
- })
95
- );
96
- server.registerTool(
97
- "fabric_call",
98
- {
99
- title: "Call a Fabric Integration Operation",
100
- description: "Execute an operation on a connected Fabric integration. Args is a JSON object whose shape depends on the specific operation. Returns the upstream response, or { status: 'pending_approval' | 'denied' } when the workspace permission policy gates the call.",
101
- inputSchema: {
102
- slug: zod.z.string().describe('Integration slug, e.g. "slack".'),
103
- operation: zod.z.string().describe(
104
- 'Dot-notation operation, e.g. "messages.send" or "channels.list".'
105
- ),
106
- args: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe(
107
- "Arguments object. Shape depends on the operation."
108
- )
109
- }
110
- },
111
- (_0) => __async(null, [_0], function* ({ slug, operation, args }) {
112
- const integration = fabric.integrations[slug];
113
- if (!(integration == null ? void 0 : integration.call)) {
114
- return {
115
- content: [
116
- {
117
- type: "text",
118
- text: `Integration "${slug}" is not registered for this workspace.`
119
- }
120
- ],
121
- isError: true
122
- };
123
- }
124
- try {
125
- const result = yield integration.call(operation, args != null ? args : {});
126
- return {
127
- content: [
128
- { type: "text", text: JSON.stringify(result, null, 2) }
129
- ]
130
- };
131
- } catch (err) {
132
- const message = err instanceof Error ? err.message : String(err);
133
- return {
134
- content: [{ type: "text", text: `Error: ${message}` }],
135
- isError: true
136
- };
137
- }
138
- })
139
- );
140
- return server;
141
- }
142
-
143
- exports.createFabricMcpServer = createFabricMcpServer;
144
- //# sourceMappingURL=index.cjs.map
145
- //# sourceMappingURL=index.cjs.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_src = require("./src-Dvp0pFUZ.cjs");
3
+ exports.createFabricMcpServer = require_src.createFabricMcpServer;
package/dist/index.d.cts CHANGED
@@ -1,56 +1,30 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
-
3
- /**
4
- * @fabricorg/sdk-mcp
5
- *
6
- * Builds an MCP (Model Context Protocol) server that exposes a Fabric
7
- * workspace's whole integration catalog as MCP tools — any MCP-compatible
8
- * agent (Claude Desktop, Cursor, Continue, OpenAI agents, …) can point at
9
- * one endpoint and get every connected vendor.
10
- *
11
- * Three generic tools (corsair-style):
12
- * - `fabric_list_integrations` — what's connected for this tenant
13
- * - `fabric_list_operations` — endpoints for one integration
14
- * - `fabric_call` — execute an operation
15
- *
16
- * Usage (stdio transport, e.g. Claude Desktop):
17
- * import { createFabricMcpServer } from "@fabricorg/sdk-mcp";
18
- * import { createFabric } from "@fabricorg/sdk";
19
- * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
20
- *
21
- * const fabric = createFabric({ apiKey: process.env.FABRIC_API_KEY });
22
- * const server = createFabricMcpServer({ fabric });
23
- * await server.connect(new StdioServerTransport());
24
- *
25
- * Or use the prebuilt stdio entry: `import "@fabricorg/sdk-mcp/stdio";`
26
- * (The `fabric mcp serve` CLI command is the recommended user-facing path.)
27
- */
28
-
29
- type FabricLike = {
30
- integrations: {
31
- list(): Promise<Array<{
32
- slug: string;
33
- name: string;
34
- status: string;
35
- mode: string;
36
- source: string;
37
- }>>;
38
- [slug: string]: unknown;
39
- };
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ //#region src/index.d.ts
3
+ export type FabricLike = {
4
+ integrations: {
5
+ list(): Promise<Array<{
6
+ slug: string;
7
+ name: string;
8
+ status: string;
9
+ mode: string;
10
+ source: string;
11
+ }>>;
12
+ [slug: string]: unknown;
13
+ };
40
14
  };
41
- interface CreateFabricMcpServerOptions {
42
- /** A configured FabricClient (createFabric) instance. Required. */
43
- fabric: FabricLike;
44
- /** Server name reported on the MCP handshake. Default `"fabric"`. */
45
- name?: string;
46
- /** Server version. Default `"0.1.0"`. */
47
- version?: string;
15
+ export interface CreateFabricMcpServerOptions {
16
+ /** A configured FabricClient (createFabric) instance. Required. */
17
+ fabric: FabricLike;
18
+ /** Server name reported on the MCP handshake. Default `"fabric"`. */
19
+ name?: string;
20
+ /** Server version. Default `"0.1.0"`. */
21
+ version?: string;
48
22
  }
49
23
  /**
50
24
  * Build a configured `McpServer` exposing the workspace catalog. Caller is
51
25
  * responsible for `.connect(transport)` so the same server works over stdio,
52
26
  * HTTP, or any other MCP transport.
53
27
  */
54
- declare function createFabricMcpServer(options: CreateFabricMcpServerOptions): McpServer;
55
-
56
- export { type CreateFabricMcpServerOptions, createFabricMcpServer };
28
+ export declare function createFabricMcpServer(options: CreateFabricMcpServerOptions): McpServer;
29
+ //#endregion
30
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,56 +1,30 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
-
3
- /**
4
- * @fabricorg/sdk-mcp
5
- *
6
- * Builds an MCP (Model Context Protocol) server that exposes a Fabric
7
- * workspace's whole integration catalog as MCP tools — any MCP-compatible
8
- * agent (Claude Desktop, Cursor, Continue, OpenAI agents, …) can point at
9
- * one endpoint and get every connected vendor.
10
- *
11
- * Three generic tools (corsair-style):
12
- * - `fabric_list_integrations` — what's connected for this tenant
13
- * - `fabric_list_operations` — endpoints for one integration
14
- * - `fabric_call` — execute an operation
15
- *
16
- * Usage (stdio transport, e.g. Claude Desktop):
17
- * import { createFabricMcpServer } from "@fabricorg/sdk-mcp";
18
- * import { createFabric } from "@fabricorg/sdk";
19
- * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
20
- *
21
- * const fabric = createFabric({ apiKey: process.env.FABRIC_API_KEY });
22
- * const server = createFabricMcpServer({ fabric });
23
- * await server.connect(new StdioServerTransport());
24
- *
25
- * Or use the prebuilt stdio entry: `import "@fabricorg/sdk-mcp/stdio";`
26
- * (The `fabric mcp serve` CLI command is the recommended user-facing path.)
27
- */
28
-
29
- type FabricLike = {
30
- integrations: {
31
- list(): Promise<Array<{
32
- slug: string;
33
- name: string;
34
- status: string;
35
- mode: string;
36
- source: string;
37
- }>>;
38
- [slug: string]: unknown;
39
- };
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ //#region src/index.d.ts
3
+ export type FabricLike = {
4
+ integrations: {
5
+ list(): Promise<Array<{
6
+ slug: string;
7
+ name: string;
8
+ status: string;
9
+ mode: string;
10
+ source: string;
11
+ }>>;
12
+ [slug: string]: unknown;
13
+ };
40
14
  };
41
- interface CreateFabricMcpServerOptions {
42
- /** A configured FabricClient (createFabric) instance. Required. */
43
- fabric: FabricLike;
44
- /** Server name reported on the MCP handshake. Default `"fabric"`. */
45
- name?: string;
46
- /** Server version. Default `"0.1.0"`. */
47
- version?: string;
15
+ export interface CreateFabricMcpServerOptions {
16
+ /** A configured FabricClient (createFabric) instance. Required. */
17
+ fabric: FabricLike;
18
+ /** Server name reported on the MCP handshake. Default `"fabric"`. */
19
+ name?: string;
20
+ /** Server version. Default `"0.1.0"`. */
21
+ version?: string;
48
22
  }
49
23
  /**
50
24
  * Build a configured `McpServer` exposing the workspace catalog. Caller is
51
25
  * responsible for `.connect(transport)` so the same server works over stdio,
52
26
  * HTTP, or any other MCP transport.
53
27
  */
54
- declare function createFabricMcpServer(options: CreateFabricMcpServerOptions): McpServer;
55
-
56
- export { type CreateFabricMcpServerOptions, createFabricMcpServer };
28
+ export declare function createFabricMcpServer(options: CreateFabricMcpServerOptions): McpServer;
29
+ //#endregion
30
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,143 +1,2 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
-
4
- var __async = (__this, __arguments, generator) => {
5
- return new Promise((resolve, reject) => {
6
- var fulfilled = (value) => {
7
- try {
8
- step(generator.next(value));
9
- } catch (e) {
10
- reject(e);
11
- }
12
- };
13
- var rejected = (value) => {
14
- try {
15
- step(generator.throw(value));
16
- } catch (e) {
17
- reject(e);
18
- }
19
- };
20
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
21
- step((generator = generator.apply(__this, __arguments)).next());
22
- });
23
- };
24
- function createFabricMcpServer(options) {
25
- var _a, _b;
26
- const fabric = options.fabric;
27
- const server = new McpServer({
28
- name: (_a = options.name) != null ? _a : "fabric",
29
- version: (_b = options.version) != null ? _b : "0.1.0"
30
- });
31
- server.registerTool(
32
- "fabric_list_integrations",
33
- {
34
- title: "List Fabric Integrations",
35
- description: "List integrations connected for the authenticated Fabric workspace. Returns slug, display name, current connection status, permission mode (open/cautious/strict/readonly), and source (plugin/mcp-server/connector).",
36
- inputSchema: {}
37
- },
38
- () => __async(null, null, function* () {
39
- const integrations = yield fabric.integrations.list();
40
- return {
41
- content: [
42
- {
43
- type: "text",
44
- text: JSON.stringify(integrations, null, 2)
45
- }
46
- ]
47
- };
48
- })
49
- );
50
- server.registerTool(
51
- "fabric_list_operations",
52
- {
53
- title: "List Operations for an Integration",
54
- description: "List the dot-notation operations available on a single Fabric integration. Returns an array of `{ operation, riskLevel, description }`. Supply the slug from `fabric_list_integrations`.",
55
- inputSchema: {
56
- slug: z.string().describe(
57
- 'Integration slug, e.g. "slack", "github", "linear".'
58
- )
59
- }
60
- },
61
- (_0) => __async(null, [_0], function* ({ slug }) {
62
- var _a2;
63
- const integration = fabric.integrations[slug];
64
- if (!integration) {
65
- return {
66
- content: [
67
- {
68
- type: "text",
69
- text: `Integration "${slug}" is not registered for this workspace.`
70
- }
71
- ],
72
- isError: true
73
- };
74
- }
75
- try {
76
- const ops = yield (_a2 = integration.call) == null ? void 0 : _a2.call(integration, "__operations");
77
- return {
78
- content: [
79
- { type: "text", text: JSON.stringify(ops, null, 2) }
80
- ]
81
- };
82
- } catch (e) {
83
- return {
84
- content: [
85
- {
86
- type: "text",
87
- text: `Operation listing for "${slug}" requires portal endpoint /api/v1/integrations/${slug}/operations (not yet exposed). Use fabric_call with a known operation path in the meantime.`
88
- }
89
- ]
90
- };
91
- }
92
- })
93
- );
94
- server.registerTool(
95
- "fabric_call",
96
- {
97
- title: "Call a Fabric Integration Operation",
98
- description: "Execute an operation on a connected Fabric integration. Args is a JSON object whose shape depends on the specific operation. Returns the upstream response, or { status: 'pending_approval' | 'denied' } when the workspace permission policy gates the call.",
99
- inputSchema: {
100
- slug: z.string().describe('Integration slug, e.g. "slack".'),
101
- operation: z.string().describe(
102
- 'Dot-notation operation, e.g. "messages.send" or "channels.list".'
103
- ),
104
- args: z.record(z.string(), z.unknown()).optional().describe(
105
- "Arguments object. Shape depends on the operation."
106
- )
107
- }
108
- },
109
- (_0) => __async(null, [_0], function* ({ slug, operation, args }) {
110
- const integration = fabric.integrations[slug];
111
- if (!(integration == null ? void 0 : integration.call)) {
112
- return {
113
- content: [
114
- {
115
- type: "text",
116
- text: `Integration "${slug}" is not registered for this workspace.`
117
- }
118
- ],
119
- isError: true
120
- };
121
- }
122
- try {
123
- const result = yield integration.call(operation, args != null ? args : {});
124
- return {
125
- content: [
126
- { type: "text", text: JSON.stringify(result, null, 2) }
127
- ]
128
- };
129
- } catch (err) {
130
- const message = err instanceof Error ? err.message : String(err);
131
- return {
132
- content: [{ type: "text", text: `Error: ${message}` }],
133
- isError: true
134
- };
135
- }
136
- })
137
- );
138
- return server;
139
- }
140
-
1
+ import { t as createFabricMcpServer } from "./src-OoM54hoY.js";
141
2
  export { createFabricMcpServer };
142
- //# sourceMappingURL=index.js.map
143
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,164 @@
1
+ let _modelcontextprotocol_sdk_server_mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
2
+ let zod = require("zod");
3
+ //#region \0@oxc-project+runtime@0.152.0/helpers/esm/asyncToGenerator.js
4
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
5
+ try {
6
+ var i = n[a](c), u = i.value;
7
+ } catch (n) {
8
+ e(n);
9
+ return;
10
+ }
11
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
12
+ }
13
+ function _asyncToGenerator(n) {
14
+ return function() {
15
+ var t = this, e = arguments;
16
+ return new Promise(function(r, o) {
17
+ var a = n.apply(t, e);
18
+ function _next(n) {
19
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
20
+ }
21
+ function _throw(n) {
22
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
23
+ }
24
+ _next(void 0);
25
+ });
26
+ };
27
+ }
28
+ //#endregion
29
+ //#region src/index.ts
30
+ /**
31
+ * @fabricorg/sdk-mcp
32
+ *
33
+ * Builds an MCP (Model Context Protocol) server that exposes a Fabric
34
+ * workspace's whole integration catalog as MCP tools — any MCP-compatible
35
+ * agent (Claude Desktop, Cursor, Continue, OpenAI agents, …) can point at
36
+ * one endpoint and get every connected vendor.
37
+ *
38
+ * Three generic tools (corsair-style):
39
+ * - `fabric_list_integrations` — what's connected for this tenant
40
+ * - `fabric_list_operations` — endpoints for one integration
41
+ * - `fabric_call` — execute an operation
42
+ *
43
+ * Usage (stdio transport, e.g. Claude Desktop):
44
+ * import { createFabricMcpServer } from "@fabricorg/sdk-mcp";
45
+ * import { createFabric } from "@fabricorg/sdk";
46
+ * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
47
+ *
48
+ * const fabric = createFabric({ apiKey: process.env.FABRIC_API_KEY });
49
+ * const server = createFabricMcpServer({ fabric });
50
+ * await server.connect(new StdioServerTransport());
51
+ *
52
+ * Or use the prebuilt stdio entry: `import "@fabricorg/sdk-mcp/stdio";`
53
+ * (The `fabric mcp serve` CLI command is the recommended user-facing path.)
54
+ */
55
+ /**
56
+ * Build a configured `McpServer` exposing the workspace catalog. Caller is
57
+ * responsible for `.connect(transport)` so the same server works over stdio,
58
+ * HTTP, or any other MCP transport.
59
+ */
60
+ function createFabricMcpServer(options) {
61
+ var _options$name, _options$version;
62
+ const fabric = options.fabric;
63
+ const server = new _modelcontextprotocol_sdk_server_mcp_js.McpServer({
64
+ name: (_options$name = options.name) !== null && _options$name !== void 0 ? _options$name : "fabric",
65
+ version: (_options$version = options.version) !== null && _options$version !== void 0 ? _options$version : "0.1.0"
66
+ });
67
+ server.registerTool("fabric_list_integrations", {
68
+ title: "List Fabric Integrations",
69
+ description: "List integrations connected for the authenticated Fabric workspace. Returns slug, display name, current connection status, permission mode (open/cautious/strict/readonly), and source (plugin/mcp-server/connector).",
70
+ inputSchema: {}
71
+ }, _asyncToGenerator(function* () {
72
+ const integrations = yield fabric.integrations.list();
73
+ return { content: [{
74
+ type: "text",
75
+ text: JSON.stringify(integrations, null, 2)
76
+ }] };
77
+ }));
78
+ server.registerTool("fabric_list_operations", {
79
+ title: "List Operations for an Integration",
80
+ description: "List the dot-notation operations available on a single Fabric integration. Returns an array of `{ operation, riskLevel, description }`. Supply the slug from `fabric_list_integrations`.",
81
+ inputSchema: { slug: zod.z.string().describe("Integration slug, e.g. \"slack\", \"github\", \"linear\".") }
82
+ }, function() {
83
+ var _ref = _asyncToGenerator(function* ({ slug }) {
84
+ const integration = fabric.integrations[slug];
85
+ if (!integration) return {
86
+ content: [{
87
+ type: "text",
88
+ text: `Integration "${slug}" is not registered for this workspace.`
89
+ }],
90
+ isError: true
91
+ };
92
+ try {
93
+ var _integration$call;
94
+ const ops = yield (_integration$call = integration.call) === null || _integration$call === void 0 ? void 0 : _integration$call.call(integration, "__operations");
95
+ return { content: [{
96
+ type: "text",
97
+ text: JSON.stringify(ops, null, 2)
98
+ }] };
99
+ } catch (_unused) {
100
+ return { content: [{
101
+ type: "text",
102
+ text: `Operation listing for "${slug}" requires portal endpoint /api/v1/integrations/${slug}/operations (not yet exposed). Use fabric_call with a known operation path in the meantime.`
103
+ }] };
104
+ }
105
+ });
106
+ return function(_x) {
107
+ return _ref.apply(this, arguments);
108
+ };
109
+ }());
110
+ server.registerTool("fabric_call", {
111
+ title: "Call a Fabric Integration Operation",
112
+ description: "Execute an operation on a connected Fabric integration. Args is a JSON object whose shape depends on the specific operation. Returns the upstream response, or { status: 'pending_approval' | 'denied' } when the workspace permission policy gates the call.",
113
+ inputSchema: {
114
+ slug: zod.z.string().describe("Integration slug, e.g. \"slack\"."),
115
+ operation: zod.z.string().describe("Dot-notation operation, e.g. \"messages.send\" or \"channels.list\"."),
116
+ args: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Arguments object. Shape depends on the operation.")
117
+ }
118
+ }, function() {
119
+ var _ref2 = _asyncToGenerator(function* ({ slug, operation, args }) {
120
+ const integration = fabric.integrations[slug];
121
+ if (!(integration === null || integration === void 0 ? void 0 : integration.call)) return {
122
+ content: [{
123
+ type: "text",
124
+ text: `Integration "${slug}" is not registered for this workspace.`
125
+ }],
126
+ isError: true
127
+ };
128
+ try {
129
+ const result = yield integration.call(operation, args !== null && args !== void 0 ? args : {});
130
+ return { content: [{
131
+ type: "text",
132
+ text: JSON.stringify(result, null, 2)
133
+ }] };
134
+ } catch (err) {
135
+ return {
136
+ content: [{
137
+ type: "text",
138
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`
139
+ }],
140
+ isError: true
141
+ };
142
+ }
143
+ });
144
+ return function(_x2) {
145
+ return _ref2.apply(this, arguments);
146
+ };
147
+ }());
148
+ return server;
149
+ }
150
+ //#endregion
151
+ Object.defineProperty(exports, "_asyncToGenerator", {
152
+ enumerable: true,
153
+ get: function() {
154
+ return _asyncToGenerator;
155
+ }
156
+ });
157
+ Object.defineProperty(exports, "createFabricMcpServer", {
158
+ enumerable: true,
159
+ get: function() {
160
+ return createFabricMcpServer;
161
+ }
162
+ });
163
+
164
+ //# sourceMappingURL=src-Dvp0pFUZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-Dvp0pFUZ.cjs","names":["McpServer","z"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @fabricorg/sdk-mcp\n *\n * Builds an MCP (Model Context Protocol) server that exposes a Fabric\n * workspace's whole integration catalog as MCP tools — any MCP-compatible\n * agent (Claude Desktop, Cursor, Continue, OpenAI agents, …) can point at\n * one endpoint and get every connected vendor.\n *\n * Three generic tools (corsair-style):\n * - `fabric_list_integrations` — what's connected for this tenant\n * - `fabric_list_operations` — endpoints for one integration\n * - `fabric_call` — execute an operation\n *\n * Usage (stdio transport, e.g. Claude Desktop):\n * import { createFabricMcpServer } from \"@fabricorg/sdk-mcp\";\n * import { createFabric } from \"@fabricorg/sdk\";\n * import { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n *\n * const fabric = createFabric({ apiKey: process.env.FABRIC_API_KEY });\n * const server = createFabricMcpServer({ fabric });\n * await server.connect(new StdioServerTransport());\n *\n * Or use the prebuilt stdio entry: `import \"@fabricorg/sdk-mcp/stdio\";`\n * (The `fabric mcp serve` CLI command is the recommended user-facing path.)\n */\n\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\n\n// Avoid importing @fabricorg/sdk concrete types at runtime; we only need its\n// shape so the server is decoupled from a specific SDK version. Consumers\n// pass an `FabricClient` instance. Exported because the declaration bundler\n// drops the `export {}` marker that keeps unexported types in a .d.ts private.\nexport type FabricLike = {\n\tintegrations: {\n\t\tlist(): Promise<\n\t\t\tArray<{\n\t\t\t\tslug: string;\n\t\t\t\tname: string;\n\t\t\t\tstatus: string;\n\t\t\t\tmode: string;\n\t\t\t\tsource: string;\n\t\t\t}>\n\t\t>;\n\t\t[slug: string]: unknown;\n\t};\n};\n\nexport interface CreateFabricMcpServerOptions {\n\t/** A configured FabricClient (createFabric) instance. Required. */\n\tfabric: FabricLike;\n\t/** Server name reported on the MCP handshake. Default `\"fabric\"`. */\n\tname?: string;\n\t/** Server version. Default `\"0.1.0\"`. */\n\tversion?: string;\n}\n\n/**\n * Build a configured `McpServer` exposing the workspace catalog. Caller is\n * responsible for `.connect(transport)` so the same server works over stdio,\n * HTTP, or any other MCP transport.\n */\nexport function createFabricMcpServer(\n\toptions: CreateFabricMcpServerOptions,\n): McpServer {\n\tconst fabric = options.fabric;\n\tconst server = new McpServer({\n\t\tname: options.name ?? \"fabric\",\n\t\tversion: options.version ?? \"0.1.0\",\n\t});\n\n\tserver.registerTool(\n\t\t\"fabric_list_integrations\",\n\t\t{\n\t\t\ttitle: \"List Fabric Integrations\",\n\t\t\tdescription:\n\t\t\t\t\"List integrations connected for the authenticated Fabric workspace. \" +\n\t\t\t\t\"Returns slug, display name, current connection status, permission mode \" +\n\t\t\t\t\"(open/cautious/strict/readonly), and source (plugin/mcp-server/connector).\",\n\t\t\tinputSchema: {},\n\t\t},\n\t\tasync () => {\n\t\t\tconst integrations = await fabric.integrations.list();\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: JSON.stringify(integrations, null, 2),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"fabric_list_operations\",\n\t\t{\n\t\t\ttitle: \"List Operations for an Integration\",\n\t\t\tdescription:\n\t\t\t\t\"List the dot-notation operations available on a single Fabric integration. \" +\n\t\t\t\t\"Returns an array of `{ operation, riskLevel, description }`. Supply the \" +\n\t\t\t\t\"slug from `fabric_list_integrations`.\",\n\t\t\tinputSchema: {\n\t\t\t\tslug: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.describe(\n\t\t\t\t\t\t'Integration slug, e.g. \"slack\", \"github\", \"linear\".',\n\t\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\tasync ({ slug }) => {\n\t\t\t// Endpoint metadata isn't exposed via the SDK's HTTP surface yet, so we\n\t\t\t// hit a known introspection path the portal returns under\n\t\t\t// `/integrations/:slug/operations`. Until that route lands, we surface a\n\t\t\t// helpful TODO so agents don't silently get an empty list.\n\t\t\tconst integration = (\n\t\t\t\tfabric.integrations as Record<string, unknown>\n\t\t\t)[slug] as\n\t\t\t\t| {\n\t\t\t\t\t\tcall?: (op: string, args?: unknown) => Promise<unknown>;\n\t\t\t\t }\n\t\t\t\t| undefined;\n\t\t\tif (!integration) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Integration \"${slug}\" is not registered for this workspace.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\ttry {\n\t\t\t\t// Best-effort: the portal may expose `__operations` as a\n\t\t\t\t// magic operation that returns the catalog.\n\t\t\t\tconst ops = await integration.call?.(\"__operations\");\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{ type: \"text\", text: JSON.stringify(ops, null, 2) },\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Operation listing for \"${slug}\" requires portal endpoint /api/v1/integrations/${slug}/operations (not yet exposed). Use fabric_call with a known operation path in the meantime.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t);\n\n\tserver.registerTool(\n\t\t\"fabric_call\",\n\t\t{\n\t\t\ttitle: \"Call a Fabric Integration Operation\",\n\t\t\tdescription:\n\t\t\t\t\"Execute an operation on a connected Fabric integration. Args is a JSON \" +\n\t\t\t\t\"object whose shape depends on the specific operation. Returns the \" +\n\t\t\t\t\"upstream response, or { status: 'pending_approval' | 'denied' } when \" +\n\t\t\t\t\"the workspace permission policy gates the call.\",\n\t\t\tinputSchema: {\n\t\t\t\tslug: z.string().describe('Integration slug, e.g. \"slack\".'),\n\t\t\t\toperation: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.describe(\n\t\t\t\t\t\t'Dot-notation operation, e.g. \"messages.send\" or \"channels.list\".',\n\t\t\t\t\t),\n\t\t\t\targs: z\n\t\t\t\t\t.record(z.string(), z.unknown())\n\t\t\t\t\t.optional()\n\t\t\t\t\t.describe(\n\t\t\t\t\t\t\"Arguments object. Shape depends on the operation.\",\n\t\t\t\t\t),\n\t\t\t},\n\t\t},\n\t\tasync ({ slug, operation, args }) => {\n\t\t\tconst integration = (\n\t\t\t\tfabric.integrations as Record<string, unknown>\n\t\t\t)[slug] as\n\t\t\t\t| {\n\t\t\t\t\t\tcall?: (op: string, args?: unknown) => Promise<unknown>;\n\t\t\t\t }\n\t\t\t\t| undefined;\n\t\t\tif (!integration?.call) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Integration \"${slug}\" is not registered for this workspace.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst result = await integration.call(operation, args ?? {});\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{ type: \"text\", text: JSON.stringify(result, null, 2) },\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t} catch (err) {\n\t\t\t\tconst message =\n\t\t\t\t\terr instanceof Error ? err.message : String(err);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Error: ${message}` }],\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t);\n\n\treturn server;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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