@superblocksteam/sdk-api 2.0.170 → 2.0.171-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/base/request-body.d.ts +1 -0
- package/dist/integrations/base/request-body.d.ts.map +1 -1
- package/dist/integrations/base/request-body.js +4 -4
- package/dist/integrations/base/request-body.js.map +1 -1
- package/dist/integrations/declarations.d.ts +10 -0
- package/dist/integrations/declarations.d.ts.map +1 -1
- package/dist/integrations/declarations.js +9 -0
- package/dist/integrations/declarations.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/mcpintegration/client.d.ts +71 -0
- package/dist/integrations/mcpintegration/client.d.ts.map +1 -0
- package/dist/integrations/mcpintegration/client.js +353 -0
- package/dist/integrations/mcpintegration/client.js.map +1 -0
- package/dist/integrations/mcpintegration/client.test.d.ts +17 -0
- package/dist/integrations/mcpintegration/client.test.d.ts.map +1 -0
- package/dist/integrations/mcpintegration/client.test.js +432 -0
- package/dist/integrations/mcpintegration/client.test.js.map +1 -0
- package/dist/integrations/mcpintegration/index.d.ts +8 -0
- package/dist/integrations/mcpintegration/index.d.ts.map +1 -0
- package/dist/integrations/mcpintegration/index.js +7 -0
- package/dist/integrations/mcpintegration/index.js.map +1 -0
- package/dist/integrations/mcpintegration/types.d.ts +164 -0
- package/dist/integrations/mcpintegration/types.d.ts.map +1 -0
- package/dist/integrations/mcpintegration/types.js +9 -0
- package/dist/integrations/mcpintegration/types.js.map +1 -0
- package/dist/integrations/registry.d.ts +1 -0
- package/dist/integrations/registry.d.ts.map +1 -1
- package/dist/integrations/registry.js +5 -0
- package/dist/integrations/registry.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +12 -0
- package/src/integrations/base/request-body.ts +7 -4
- package/src/integrations/declarations.ts +16 -0
- package/src/integrations/index.ts +14 -0
- package/src/integrations/mcpintegration/README.md +149 -0
- package/src/integrations/mcpintegration/client.test.ts +588 -0
- package/src/integrations/mcpintegration/client.ts +544 -0
- package/src/integrations/mcpintegration/docs.manifest.json +5 -0
- package/src/integrations/mcpintegration/index.ts +16 -0
- package/src/integrations/mcpintegration/types.ts +185 -0
- package/src/integrations/registry.ts +6 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server client types.
|
|
3
|
+
*
|
|
4
|
+
* An MCP Server integration points at a remote Model Context Protocol server.
|
|
5
|
+
* The client exposes the tools surface of that server: list the tools it
|
|
6
|
+
* advertises and call one of them. Resources and prompts are not exposed yet.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { z } from "zod";
|
|
10
|
+
|
|
11
|
+
import type { BaseIntegrationClient } from "../../types.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* One block of a tool result's `content` array.
|
|
15
|
+
*
|
|
16
|
+
* MCP defines text, image, audio, resource link and embedded resource blocks.
|
|
17
|
+
* Only `type` is guaranteed; the remaining fields depend on the block type.
|
|
18
|
+
*/
|
|
19
|
+
export interface McpContentBlock {
|
|
20
|
+
type: string;
|
|
21
|
+
/** Present on `text` blocks. */
|
|
22
|
+
text?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The result of a `tools/call` request, as returned by the MCP server.
|
|
28
|
+
*/
|
|
29
|
+
export interface CallToolResult {
|
|
30
|
+
/** Unstructured result blocks. */
|
|
31
|
+
content: McpContentBlock[];
|
|
32
|
+
/** Structured result, present when the tool declares an output schema. */
|
|
33
|
+
structuredContent?: Record<string, unknown>;
|
|
34
|
+
/** True when the tool itself failed; `content` then carries the error text. */
|
|
35
|
+
isError?: boolean;
|
|
36
|
+
_meta?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Behavioral hints a server attaches to a tool. All hints are advisory.
|
|
41
|
+
*/
|
|
42
|
+
export interface ToolAnnotations {
|
|
43
|
+
title?: string;
|
|
44
|
+
readOnlyHint?: boolean;
|
|
45
|
+
destructiveHint?: boolean;
|
|
46
|
+
idempotentHint?: boolean;
|
|
47
|
+
openWorldHint?: boolean;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* One tool advertised by the MCP server through `tools/list`.
|
|
53
|
+
*/
|
|
54
|
+
export interface Tool {
|
|
55
|
+
name: string;
|
|
56
|
+
title?: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
/** JSON Schema describing the tool's `arguments` object. */
|
|
59
|
+
inputSchema: {
|
|
60
|
+
type: "object";
|
|
61
|
+
properties?: Record<string, unknown>;
|
|
62
|
+
required?: string[];
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
};
|
|
65
|
+
/** JSON Schema describing `structuredContent`, when the tool declares one. */
|
|
66
|
+
outputSchema?: Record<string, unknown>;
|
|
67
|
+
annotations?: ToolAnnotations;
|
|
68
|
+
_meta?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Options shared by every MCP request.
|
|
73
|
+
*
|
|
74
|
+
* **Security:** `label` is trace metadata and may be stored in logs; do not put
|
|
75
|
+
* secrets in it. Headers are sent to the MCP server as-is.
|
|
76
|
+
*/
|
|
77
|
+
export interface McpRequestOptions {
|
|
78
|
+
/** Short human-readable label shown in the Trace View for this call. */
|
|
79
|
+
label?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Extra HTTP headers for this request, on top of the headers configured on
|
|
82
|
+
* the integration. Use this for per-call values such as `Mcp-Param-*`.
|
|
83
|
+
*/
|
|
84
|
+
headers?: Record<string, string>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Options for {@link McpClient.callTool}. Always the third argument: a schema
|
|
89
|
+
* placed inside `args` is rejected with a `TypeError` instead of being sent to
|
|
90
|
+
* the server as tool arguments.
|
|
91
|
+
*/
|
|
92
|
+
export interface McpCallToolOptions<T = unknown> extends McpRequestOptions {
|
|
93
|
+
/**
|
|
94
|
+
* Zod schema for the tool result. When given, the call returns the validated
|
|
95
|
+
* value instead of the `CallToolResult`. The value validated is
|
|
96
|
+
* `structuredContent` when the server returns an object; otherwise the first
|
|
97
|
+
* `text` block. Text that is JSON is validated as the parsed value first and
|
|
98
|
+
* as the raw string second, so a string schema still accepts text such as
|
|
99
|
+
* "12345". Text that is not JSON is validated as a string.
|
|
100
|
+
*/
|
|
101
|
+
schema?: z.ZodSchema<T>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* MCP Server client for listing and calling tools.
|
|
106
|
+
*
|
|
107
|
+
* When the server needs an MCP session (handshake-era servers), the plugin
|
|
108
|
+
* opens one on the first call and the client sends it back on every later
|
|
109
|
+
* call of the same API run, so the handshake runs once per client instance.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const mcp = ctx.integrations.github;
|
|
114
|
+
*
|
|
115
|
+
* // Discover the server's tools
|
|
116
|
+
* const tools = await mcp.listTools();
|
|
117
|
+
*
|
|
118
|
+
* // Call a tool and get the raw CallToolResult
|
|
119
|
+
* const raw = await mcp.callTool("search_issues", { query: "is:open" });
|
|
120
|
+
*
|
|
121
|
+
* // Call a tool and validate the result
|
|
122
|
+
* const issues = await mcp.callTool(
|
|
123
|
+
* "search_issues",
|
|
124
|
+
* { query: "is:open" },
|
|
125
|
+
* { schema: z.object({ items: z.array(IssueSchema) }) },
|
|
126
|
+
* );
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export interface McpClient extends BaseIntegrationClient {
|
|
130
|
+
/**
|
|
131
|
+
* Call a tool and validate its result against `schema`.
|
|
132
|
+
*
|
|
133
|
+
* @param name - Tool name as advertised by `tools/list`
|
|
134
|
+
* @param args - Tool arguments; sent as `{}` when omitted
|
|
135
|
+
* @param options - Request options with a required `schema`
|
|
136
|
+
* @returns The validated result
|
|
137
|
+
* @throws IntegrationError when the server reports `isError: true`
|
|
138
|
+
* @throws RestApiValidationError when the result does not match `schema`
|
|
139
|
+
*/
|
|
140
|
+
callTool<T>(
|
|
141
|
+
name: string,
|
|
142
|
+
args: Record<string, unknown> | undefined,
|
|
143
|
+
options: McpCallToolOptions<T> & { schema: z.ZodSchema<T> },
|
|
144
|
+
): Promise<T>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Call a tool and return the server's `CallToolResult`, with the plugin's
|
|
148
|
+
* session bookkeeping fields removed and a `null` `structuredContent`
|
|
149
|
+
* normalized to absent.
|
|
150
|
+
*
|
|
151
|
+
* @param name - Tool name as advertised by `tools/list`
|
|
152
|
+
* @param args - Tool arguments; sent as `{}` when omitted
|
|
153
|
+
* @param options - Request options
|
|
154
|
+
* @returns The `CallToolResult`
|
|
155
|
+
* @throws IntegrationError when the server reports `isError: true`; the
|
|
156
|
+
* error's `details.cause` carries the tool name, the text and the result
|
|
157
|
+
*/
|
|
158
|
+
callTool(
|
|
159
|
+
name: string,
|
|
160
|
+
args?: Record<string, unknown>,
|
|
161
|
+
options?: McpRequestOptions,
|
|
162
|
+
): Promise<CallToolResult>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Call a tool. Returns the validated value when `options.schema` is set,
|
|
166
|
+
* otherwise the `CallToolResult`.
|
|
167
|
+
*/
|
|
168
|
+
callTool<T>(
|
|
169
|
+
name: string,
|
|
170
|
+
args?: Record<string, unknown>,
|
|
171
|
+
options?: McpCallToolOptions<T>,
|
|
172
|
+
): Promise<CallToolResult | T>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* List every tool the server advertises.
|
|
176
|
+
*
|
|
177
|
+
* Follows `nextCursor` until the server stops paginating, so the returned
|
|
178
|
+
* array is the complete catalog. Gives up with an `IntegrationError` after
|
|
179
|
+
* 50 pages or when a cursor repeats.
|
|
180
|
+
*
|
|
181
|
+
* @param options - Request options
|
|
182
|
+
* @returns All tools, in server order
|
|
183
|
+
*/
|
|
184
|
+
listTools(options?: McpRequestOptions): Promise<Tool[]>;
|
|
185
|
+
}
|
|
@@ -28,6 +28,7 @@ import { HubSpotClientImpl } from "./hubspot/index.js";
|
|
|
28
28
|
import { IntercomClientImpl } from "./intercom/index.js";
|
|
29
29
|
import { JiraClientImpl } from "./jira/index.js";
|
|
30
30
|
import { LaunchDarklyClientImpl } from "./launchdarkly/index.js";
|
|
31
|
+
import { McpClientImpl } from "./mcpintegration/index.js";
|
|
31
32
|
import { MistralClientImpl } from "./mistral/index.js";
|
|
32
33
|
import { NotionClientImpl } from "./notion/index.js";
|
|
33
34
|
import { OpenAIClientImpl } from "./openai_v2/index.js";
|
|
@@ -137,6 +138,8 @@ export const SUPPORTED_PLUGINS = {
|
|
|
137
138
|
snowflakepostgres: "snowflakepostgres",
|
|
138
139
|
// Email
|
|
139
140
|
smtp: "smtp",
|
|
141
|
+
// MCP servers
|
|
142
|
+
mcpintegration: "mcpintegration",
|
|
140
143
|
// REST API plugins
|
|
141
144
|
restapiintegration: "restapiintegration",
|
|
142
145
|
} as const;
|
|
@@ -406,6 +409,9 @@ export function createClient(
|
|
|
406
409
|
case SUPPORTED_PLUGINS.smtp:
|
|
407
410
|
return new SmtpClientImpl(config, executeQuery);
|
|
408
411
|
|
|
412
|
+
case SUPPORTED_PLUGINS.mcpintegration:
|
|
413
|
+
return new McpClientImpl(config, executeQuery);
|
|
414
|
+
|
|
409
415
|
case SUPPORTED_PLUGINS.restapiintegration:
|
|
410
416
|
return new RestApiIntegrationPluginClientImpl(config, executeQuery);
|
|
411
417
|
|