@powerduck/openapi-request 0.2.2
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 +711 -0
- package/dist/credentials-Cl0G4KpE.d.cts +783 -0
- package/dist/credentials-rqEKODvf.d.ts +783 -0
- package/dist/index-1jRrFc3d.d.cts +215 -0
- package/dist/index-CsRXyS7O.d.ts +215 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +350 -0
- package/dist/index.d.ts +350 -0
- package/dist/index.js +1 -0
- package/dist/protocol-D7sEx8IP.d.ts +62 -0
- package/dist/protocol-Dh-wN2nY.d.cts +62 -0
- package/dist/protocols/graphql/index.cjs +1 -0
- package/dist/protocols/graphql/index.d.cts +95 -0
- package/dist/protocols/graphql/index.d.ts +95 -0
- package/dist/protocols/graphql/index.js +1 -0
- package/dist/protocols/grpc/index.cjs +1 -0
- package/dist/protocols/grpc/index.d.cts +61 -0
- package/dist/protocols/grpc/index.d.ts +61 -0
- package/dist/protocols/grpc/index.js +1 -0
- package/dist/protocols/http/index.cjs +1 -0
- package/dist/protocols/http/index.d.cts +161 -0
- package/dist/protocols/http/index.d.ts +161 -0
- package/dist/protocols/http/index.js +1 -0
- package/dist/protocols/mcp/index.cjs +1 -0
- package/dist/protocols/mcp/index.d.cts +3 -0
- package/dist/protocols/mcp/index.d.ts +3 -0
- package/dist/protocols/mcp/index.js +1 -0
- package/dist/protocols/ws/index.cjs +1 -0
- package/dist/protocols/ws/index.d.cts +35 -0
- package/dist/protocols/ws/index.d.ts +35 -0
- package/dist/protocols/ws/index.js +1 -0
- package/dist/types-C9ifzKqk.d.cts +1226 -0
- package/dist/types-C9ifzKqk.d.ts +1226 -0
- package/package.json +93 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { L as LocatedOperation, E as ExecuteContext, P as ProtocolAdapter, A as AdapterContext } from './protocol-Dh-wN2nY.cjs';
|
|
2
|
+
import { a as SendOptions, ak as ResolvedMcpConfig, E as ExecResult, W as InitializeSessionInit, a2 as McpDiscoveryResult, a1 as McpCapability, Z as JsonRpcOutcome, ad as McpTerminateOutcome, a5 as McpManualSessionOptions, a4 as McpManualSession, ac as McpStdioSessionOptions } from './types-C9ifzKqk.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the effective MCP call.
|
|
6
|
+
*
|
|
7
|
+
* Precedence: `options.mcp.*` (per-call override) > `operation['x-mcp'].*`
|
|
8
|
+
* (the document's declared capability, normally produced by
|
|
9
|
+
* {@link writeMcpOperations}).
|
|
10
|
+
*/
|
|
11
|
+
declare function resolveMcpConfig(located: LocatedOperation, spec: any, options: SendOptions): ResolvedMcpConfig;
|
|
12
|
+
|
|
13
|
+
declare function runMcp(config: ResolvedMcpConfig, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
14
|
+
|
|
15
|
+
declare const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
16
|
+
/**
|
|
17
|
+
* Handshake with an MCP server and establish a session.
|
|
18
|
+
* Every MCP interaction begins here: `initialize` negotiates the protocol
|
|
19
|
+
* version and capabilities, and the client must follow up with the
|
|
20
|
+
* `notifications/initialized` notification before issuing any other call.
|
|
21
|
+
*/
|
|
22
|
+
declare function initializeSession(endpoint: string, init?: InitializeSessionInit): Promise<{
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
serverInfo?: {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
};
|
|
28
|
+
protocolVersion?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Auto-fetch everything an MCP server exposes: tools, resources, resource
|
|
32
|
+
* templates and prompts. This is the MCP analogue of gRPC's reflection
|
|
33
|
+
* `discover()` and GraphQL's schema introspection — one call that hands back
|
|
34
|
+
* every operation the endpoint can perform.
|
|
35
|
+
*/
|
|
36
|
+
declare function discoverMcpCapabilities(endpoint: string, options?: InitializeSessionInit): Promise<McpDiscoveryResult>;
|
|
37
|
+
|
|
38
|
+
interface GeneratedMcpCall {
|
|
39
|
+
capability: McpCapability;
|
|
40
|
+
/** JSON-RPC method for this capability. */
|
|
41
|
+
method: "tools/call" | "resources/read" | "prompts/get";
|
|
42
|
+
/** Sampled params, ready to send as-is or edit. */
|
|
43
|
+
params: Record<string, unknown>;
|
|
44
|
+
/** JSON Schema describing the editable portion of `params`. */
|
|
45
|
+
argumentsSchema: any;
|
|
46
|
+
notes: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Turn one discovered capability into a runnable call, sampling its
|
|
50
|
+
* argument schema the same way the HTTP adapter samples request bodies.
|
|
51
|
+
* This is the MCP counterpart of the gRPC adapter's `buildMessageTemplate`.
|
|
52
|
+
*/
|
|
53
|
+
declare function generateMcpCall(capability: McpCapability): GeneratedMcpCall;
|
|
54
|
+
declare function generateAllMcpCalls(capabilities: McpCapability[]): GeneratedMcpCall[];
|
|
55
|
+
|
|
56
|
+
interface WriteMcpOptions {
|
|
57
|
+
/** Overwrite an existing path for the same capability. Defaults to true. */
|
|
58
|
+
overwrite?: boolean;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
clientInfo?: {
|
|
62
|
+
name: string;
|
|
63
|
+
version: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* "Upload" step: merge generated MCP calls into `spec.paths` as synthetic
|
|
68
|
+
* POST operations carrying an `x-mcp` extension, each independently
|
|
69
|
+
* addressable via `locateOperation({ operationId })` — the MCP counterpart of
|
|
70
|
+
* {@link writeGraphQLOperations}.
|
|
71
|
+
*/
|
|
72
|
+
declare function writeMcpOperations(spec: any, endpoint: string, calls: GeneratedMcpCall[], options?: WriteMcpOptions): any;
|
|
73
|
+
interface DiscoverAndWriteMcpResult {
|
|
74
|
+
spec: any;
|
|
75
|
+
capabilities: McpCapability[];
|
|
76
|
+
warnings: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* One-shot "auto-fetch + upload" for MCP: handshake, list every tool,
|
|
80
|
+
* resource and prompt the server exposes, sample arguments for each, and
|
|
81
|
+
* merge the results into the document.
|
|
82
|
+
*/
|
|
83
|
+
declare function discoverAndWriteMcpCapabilities(spec: any, endpoint: string, options?: WriteMcpOptions): Promise<DiscoverAndWriteMcpResult>;
|
|
84
|
+
|
|
85
|
+
interface McpStdioOptions {
|
|
86
|
+
command: string;
|
|
87
|
+
args?: string[];
|
|
88
|
+
cwd?: string;
|
|
89
|
+
/** Undefined values explicitly remove inherited environment variables. */
|
|
90
|
+
env?: Record<string, string | undefined>;
|
|
91
|
+
timeoutMs?: number;
|
|
92
|
+
maxBufferBytes?: number;
|
|
93
|
+
}
|
|
94
|
+
interface McpStdioConnection {
|
|
95
|
+
readonly pid: number | undefined;
|
|
96
|
+
request<T = unknown>(method: string, params?: unknown, signal?: AbortSignal): Promise<T>;
|
|
97
|
+
notify(method: string, params?: unknown, signal?: AbortSignal): Promise<void>;
|
|
98
|
+
close(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
declare function createMcpStdioConnection(options: McpStdioOptions): McpStdioConnection;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* MCP transport abstraction.
|
|
104
|
+
*
|
|
105
|
+
* A manual MCP session is transport-agnostic: it drives initialize, JSON-RPC
|
|
106
|
+
* calls, notifications and termination through a small adapter, so the same
|
|
107
|
+
* session logic serves both Streamable HTTP and stdio. New transports plug in
|
|
108
|
+
* by implementing this interface; the session core never branches on the wire.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
interface McpTransportOpenInit {
|
|
112
|
+
clientInfo?: {
|
|
113
|
+
name: string;
|
|
114
|
+
version: string;
|
|
115
|
+
};
|
|
116
|
+
/** Client capabilities advertised at initialize. Default: {}. */
|
|
117
|
+
capabilities?: Record<string, unknown>;
|
|
118
|
+
/** Client protocol version to negotiate. Default: latest supported. */
|
|
119
|
+
protocolVersion?: string;
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}
|
|
122
|
+
interface McpTransportCallInit {
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
timeoutMs?: number;
|
|
125
|
+
/** Started timestamp used for first-byte timings. */
|
|
126
|
+
startedAt: number;
|
|
127
|
+
/** Negotiated protocol version, when the transport needs it. */
|
|
128
|
+
protocolVersion?: string;
|
|
129
|
+
/** Session id from the handshake, when the transport needs it. */
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
headers?: Record<string, string>;
|
|
132
|
+
}
|
|
133
|
+
interface McpTransport {
|
|
134
|
+
readonly transport: "streamable-http" | "stdio";
|
|
135
|
+
/** Perform the MCP handshake (initialize + notifications/initialized). */
|
|
136
|
+
open(init: McpTransportOpenInit): Promise<{
|
|
137
|
+
sessionId?: string;
|
|
138
|
+
serverInfo?: {
|
|
139
|
+
name: string;
|
|
140
|
+
version: string;
|
|
141
|
+
};
|
|
142
|
+
protocolVersion?: string;
|
|
143
|
+
}>;
|
|
144
|
+
/** One JSON-RPC request/response exchange. Never throws on JSON-RPC errors. */
|
|
145
|
+
call(body: Record<string, unknown>, init: McpTransportCallInit): Promise<JsonRpcOutcome>;
|
|
146
|
+
/** One JSON-RPC notification. No response is expected. */
|
|
147
|
+
notify(body: Record<string, unknown>, init: McpTransportCallInit): Promise<JsonRpcOutcome>;
|
|
148
|
+
/** Best-effort session termination (HTTP DELETE / stdio no-op). */
|
|
149
|
+
terminate(init: {
|
|
150
|
+
sessionId?: string;
|
|
151
|
+
protocolVersion?: string;
|
|
152
|
+
signal?: AbortSignal;
|
|
153
|
+
headers?: Record<string, string>;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
status?: number;
|
|
156
|
+
outcome: McpTerminateOutcome;
|
|
157
|
+
reason?: string;
|
|
158
|
+
}>;
|
|
159
|
+
/** Release transport resources (e.g. kill the stdio child). Idempotent. */
|
|
160
|
+
dispose(): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
declare function createHttpMcpTransport(options: {
|
|
163
|
+
endpoint: string;
|
|
164
|
+
headers?: Record<string, string>;
|
|
165
|
+
}): McpTransport;
|
|
166
|
+
declare function createStdioMcpTransport(options: McpStdioOptions): McpTransport;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Long-lived, stateful MCP manual sessions.
|
|
170
|
+
*
|
|
171
|
+
* One session core drives both supported transports (Streamable HTTP and
|
|
172
|
+
* stdio) through the `McpTransport` adapter in "./transport". The session
|
|
173
|
+
* mirrors `createWsManualSession` / `createGrpcManualSession`: open, drive
|
|
174
|
+
* list/call methods by hand, then close.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Build a manual session over any transport. All state, event recording,
|
|
179
|
+
* pagination and close orchestration live here; only the wire differs.
|
|
180
|
+
*/
|
|
181
|
+
declare function createMcpSessionCore(transport: McpTransport, options: McpManualSessionOptions): McpManualSession;
|
|
182
|
+
/**
|
|
183
|
+
* Create a manual MCP session over either transport.
|
|
184
|
+
*
|
|
185
|
+
* - `{ transport: "streamable-http", endpoint }` (default)
|
|
186
|
+
* - `{ transport: "stdio", command, args?, cwd?, env? }`
|
|
187
|
+
*/
|
|
188
|
+
declare function createMcpManualSession(options: McpManualSessionOptions): McpManualSession;
|
|
189
|
+
/** stdio-only convenience factory. */
|
|
190
|
+
declare function createMcpStdioSession(options: McpStdioSessionOptions): McpManualSession;
|
|
191
|
+
/** @deprecated Use {@link createMcpManualSession}. */
|
|
192
|
+
declare const runMcpManualSession: typeof createMcpManualSession;
|
|
193
|
+
|
|
194
|
+
interface McpPlan {
|
|
195
|
+
config: ResolvedMcpConfig;
|
|
196
|
+
environment: Record<string, any>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* MCP (Model Context Protocol) adapter, covering the Streamable HTTP and
|
|
200
|
+
* stdio transports.
|
|
201
|
+
*
|
|
202
|
+
* An operation is claimed when it declares `x-protocol: mcp`, carries an
|
|
203
|
+
* `x-mcp` extension (normally produced by {@link writeMcpOperations}), or the
|
|
204
|
+
* caller passes `options.mcp`. Like GraphQL, MCP is one JSON-RPC call rather
|
|
205
|
+
* than a Postman-shaped request/response, so it gets its own adapter instead
|
|
206
|
+
* of routing through the HTTP one.
|
|
207
|
+
*/
|
|
208
|
+
declare class McpAdapter implements ProtocolAdapter<McpPlan> {
|
|
209
|
+
readonly name = "mcp";
|
|
210
|
+
supports(ctx: AdapterContext): number;
|
|
211
|
+
plan(ctx: AdapterContext): McpPlan;
|
|
212
|
+
execute(plan: McpPlan, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export { type DiscoverAndWriteMcpResult as D, type GeneratedMcpCall as G, MCP_PROTOCOL_VERSION as M, type WriteMcpOptions as W, McpAdapter as a, createMcpManualSession as b, createHttpMcpTransport as c, createMcpStdioSession as d, createStdioMcpTransport as e, discoverAndWriteMcpCapabilities as f, discoverMcpCapabilities as g, generateAllMcpCalls as h, generateMcpCall as i, initializeSession as j, runMcpManualSession as k, type McpPlan as l, type McpStdioConnection as m, type McpStdioOptions as n, type McpTransport as o, createMcpSessionCore as p, createMcpStdioConnection as q, resolveMcpConfig as r, runMcp as s, writeMcpOperations as w };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { L as LocatedOperation, E as ExecuteContext, P as ProtocolAdapter, A as AdapterContext } from './protocol-D7sEx8IP.js';
|
|
2
|
+
import { a as SendOptions, ak as ResolvedMcpConfig, E as ExecResult, W as InitializeSessionInit, a2 as McpDiscoveryResult, a1 as McpCapability, Z as JsonRpcOutcome, ad as McpTerminateOutcome, a5 as McpManualSessionOptions, a4 as McpManualSession, ac as McpStdioSessionOptions } from './types-C9ifzKqk.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the effective MCP call.
|
|
6
|
+
*
|
|
7
|
+
* Precedence: `options.mcp.*` (per-call override) > `operation['x-mcp'].*`
|
|
8
|
+
* (the document's declared capability, normally produced by
|
|
9
|
+
* {@link writeMcpOperations}).
|
|
10
|
+
*/
|
|
11
|
+
declare function resolveMcpConfig(located: LocatedOperation, spec: any, options: SendOptions): ResolvedMcpConfig;
|
|
12
|
+
|
|
13
|
+
declare function runMcp(config: ResolvedMcpConfig, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
14
|
+
|
|
15
|
+
declare const MCP_PROTOCOL_VERSION = "2025-06-18";
|
|
16
|
+
/**
|
|
17
|
+
* Handshake with an MCP server and establish a session.
|
|
18
|
+
* Every MCP interaction begins here: `initialize` negotiates the protocol
|
|
19
|
+
* version and capabilities, and the client must follow up with the
|
|
20
|
+
* `notifications/initialized` notification before issuing any other call.
|
|
21
|
+
*/
|
|
22
|
+
declare function initializeSession(endpoint: string, init?: InitializeSessionInit): Promise<{
|
|
23
|
+
sessionId?: string;
|
|
24
|
+
serverInfo?: {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
};
|
|
28
|
+
protocolVersion?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Auto-fetch everything an MCP server exposes: tools, resources, resource
|
|
32
|
+
* templates and prompts. This is the MCP analogue of gRPC's reflection
|
|
33
|
+
* `discover()` and GraphQL's schema introspection — one call that hands back
|
|
34
|
+
* every operation the endpoint can perform.
|
|
35
|
+
*/
|
|
36
|
+
declare function discoverMcpCapabilities(endpoint: string, options?: InitializeSessionInit): Promise<McpDiscoveryResult>;
|
|
37
|
+
|
|
38
|
+
interface GeneratedMcpCall {
|
|
39
|
+
capability: McpCapability;
|
|
40
|
+
/** JSON-RPC method for this capability. */
|
|
41
|
+
method: "tools/call" | "resources/read" | "prompts/get";
|
|
42
|
+
/** Sampled params, ready to send as-is or edit. */
|
|
43
|
+
params: Record<string, unknown>;
|
|
44
|
+
/** JSON Schema describing the editable portion of `params`. */
|
|
45
|
+
argumentsSchema: any;
|
|
46
|
+
notes: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Turn one discovered capability into a runnable call, sampling its
|
|
50
|
+
* argument schema the same way the HTTP adapter samples request bodies.
|
|
51
|
+
* This is the MCP counterpart of the gRPC adapter's `buildMessageTemplate`.
|
|
52
|
+
*/
|
|
53
|
+
declare function generateMcpCall(capability: McpCapability): GeneratedMcpCall;
|
|
54
|
+
declare function generateAllMcpCalls(capabilities: McpCapability[]): GeneratedMcpCall[];
|
|
55
|
+
|
|
56
|
+
interface WriteMcpOptions {
|
|
57
|
+
/** Overwrite an existing path for the same capability. Defaults to true. */
|
|
58
|
+
overwrite?: boolean;
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
clientInfo?: {
|
|
62
|
+
name: string;
|
|
63
|
+
version: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* "Upload" step: merge generated MCP calls into `spec.paths` as synthetic
|
|
68
|
+
* POST operations carrying an `x-mcp` extension, each independently
|
|
69
|
+
* addressable via `locateOperation({ operationId })` — the MCP counterpart of
|
|
70
|
+
* {@link writeGraphQLOperations}.
|
|
71
|
+
*/
|
|
72
|
+
declare function writeMcpOperations(spec: any, endpoint: string, calls: GeneratedMcpCall[], options?: WriteMcpOptions): any;
|
|
73
|
+
interface DiscoverAndWriteMcpResult {
|
|
74
|
+
spec: any;
|
|
75
|
+
capabilities: McpCapability[];
|
|
76
|
+
warnings: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* One-shot "auto-fetch + upload" for MCP: handshake, list every tool,
|
|
80
|
+
* resource and prompt the server exposes, sample arguments for each, and
|
|
81
|
+
* merge the results into the document.
|
|
82
|
+
*/
|
|
83
|
+
declare function discoverAndWriteMcpCapabilities(spec: any, endpoint: string, options?: WriteMcpOptions): Promise<DiscoverAndWriteMcpResult>;
|
|
84
|
+
|
|
85
|
+
interface McpStdioOptions {
|
|
86
|
+
command: string;
|
|
87
|
+
args?: string[];
|
|
88
|
+
cwd?: string;
|
|
89
|
+
/** Undefined values explicitly remove inherited environment variables. */
|
|
90
|
+
env?: Record<string, string | undefined>;
|
|
91
|
+
timeoutMs?: number;
|
|
92
|
+
maxBufferBytes?: number;
|
|
93
|
+
}
|
|
94
|
+
interface McpStdioConnection {
|
|
95
|
+
readonly pid: number | undefined;
|
|
96
|
+
request<T = unknown>(method: string, params?: unknown, signal?: AbortSignal): Promise<T>;
|
|
97
|
+
notify(method: string, params?: unknown, signal?: AbortSignal): Promise<void>;
|
|
98
|
+
close(): Promise<void>;
|
|
99
|
+
}
|
|
100
|
+
declare function createMcpStdioConnection(options: McpStdioOptions): McpStdioConnection;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* MCP transport abstraction.
|
|
104
|
+
*
|
|
105
|
+
* A manual MCP session is transport-agnostic: it drives initialize, JSON-RPC
|
|
106
|
+
* calls, notifications and termination through a small adapter, so the same
|
|
107
|
+
* session logic serves both Streamable HTTP and stdio. New transports plug in
|
|
108
|
+
* by implementing this interface; the session core never branches on the wire.
|
|
109
|
+
*/
|
|
110
|
+
|
|
111
|
+
interface McpTransportOpenInit {
|
|
112
|
+
clientInfo?: {
|
|
113
|
+
name: string;
|
|
114
|
+
version: string;
|
|
115
|
+
};
|
|
116
|
+
/** Client capabilities advertised at initialize. Default: {}. */
|
|
117
|
+
capabilities?: Record<string, unknown>;
|
|
118
|
+
/** Client protocol version to negotiate. Default: latest supported. */
|
|
119
|
+
protocolVersion?: string;
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}
|
|
122
|
+
interface McpTransportCallInit {
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
timeoutMs?: number;
|
|
125
|
+
/** Started timestamp used for first-byte timings. */
|
|
126
|
+
startedAt: number;
|
|
127
|
+
/** Negotiated protocol version, when the transport needs it. */
|
|
128
|
+
protocolVersion?: string;
|
|
129
|
+
/** Session id from the handshake, when the transport needs it. */
|
|
130
|
+
sessionId?: string;
|
|
131
|
+
headers?: Record<string, string>;
|
|
132
|
+
}
|
|
133
|
+
interface McpTransport {
|
|
134
|
+
readonly transport: "streamable-http" | "stdio";
|
|
135
|
+
/** Perform the MCP handshake (initialize + notifications/initialized). */
|
|
136
|
+
open(init: McpTransportOpenInit): Promise<{
|
|
137
|
+
sessionId?: string;
|
|
138
|
+
serverInfo?: {
|
|
139
|
+
name: string;
|
|
140
|
+
version: string;
|
|
141
|
+
};
|
|
142
|
+
protocolVersion?: string;
|
|
143
|
+
}>;
|
|
144
|
+
/** One JSON-RPC request/response exchange. Never throws on JSON-RPC errors. */
|
|
145
|
+
call(body: Record<string, unknown>, init: McpTransportCallInit): Promise<JsonRpcOutcome>;
|
|
146
|
+
/** One JSON-RPC notification. No response is expected. */
|
|
147
|
+
notify(body: Record<string, unknown>, init: McpTransportCallInit): Promise<JsonRpcOutcome>;
|
|
148
|
+
/** Best-effort session termination (HTTP DELETE / stdio no-op). */
|
|
149
|
+
terminate(init: {
|
|
150
|
+
sessionId?: string;
|
|
151
|
+
protocolVersion?: string;
|
|
152
|
+
signal?: AbortSignal;
|
|
153
|
+
headers?: Record<string, string>;
|
|
154
|
+
}): Promise<{
|
|
155
|
+
status?: number;
|
|
156
|
+
outcome: McpTerminateOutcome;
|
|
157
|
+
reason?: string;
|
|
158
|
+
}>;
|
|
159
|
+
/** Release transport resources (e.g. kill the stdio child). Idempotent. */
|
|
160
|
+
dispose(): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
declare function createHttpMcpTransport(options: {
|
|
163
|
+
endpoint: string;
|
|
164
|
+
headers?: Record<string, string>;
|
|
165
|
+
}): McpTransport;
|
|
166
|
+
declare function createStdioMcpTransport(options: McpStdioOptions): McpTransport;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Long-lived, stateful MCP manual sessions.
|
|
170
|
+
*
|
|
171
|
+
* One session core drives both supported transports (Streamable HTTP and
|
|
172
|
+
* stdio) through the `McpTransport` adapter in "./transport". The session
|
|
173
|
+
* mirrors `createWsManualSession` / `createGrpcManualSession`: open, drive
|
|
174
|
+
* list/call methods by hand, then close.
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Build a manual session over any transport. All state, event recording,
|
|
179
|
+
* pagination and close orchestration live here; only the wire differs.
|
|
180
|
+
*/
|
|
181
|
+
declare function createMcpSessionCore(transport: McpTransport, options: McpManualSessionOptions): McpManualSession;
|
|
182
|
+
/**
|
|
183
|
+
* Create a manual MCP session over either transport.
|
|
184
|
+
*
|
|
185
|
+
* - `{ transport: "streamable-http", endpoint }` (default)
|
|
186
|
+
* - `{ transport: "stdio", command, args?, cwd?, env? }`
|
|
187
|
+
*/
|
|
188
|
+
declare function createMcpManualSession(options: McpManualSessionOptions): McpManualSession;
|
|
189
|
+
/** stdio-only convenience factory. */
|
|
190
|
+
declare function createMcpStdioSession(options: McpStdioSessionOptions): McpManualSession;
|
|
191
|
+
/** @deprecated Use {@link createMcpManualSession}. */
|
|
192
|
+
declare const runMcpManualSession: typeof createMcpManualSession;
|
|
193
|
+
|
|
194
|
+
interface McpPlan {
|
|
195
|
+
config: ResolvedMcpConfig;
|
|
196
|
+
environment: Record<string, any>;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* MCP (Model Context Protocol) adapter, covering the Streamable HTTP and
|
|
200
|
+
* stdio transports.
|
|
201
|
+
*
|
|
202
|
+
* An operation is claimed when it declares `x-protocol: mcp`, carries an
|
|
203
|
+
* `x-mcp` extension (normally produced by {@link writeMcpOperations}), or the
|
|
204
|
+
* caller passes `options.mcp`. Like GraphQL, MCP is one JSON-RPC call rather
|
|
205
|
+
* than a Postman-shaped request/response, so it gets its own adapter instead
|
|
206
|
+
* of routing through the HTTP one.
|
|
207
|
+
*/
|
|
208
|
+
declare class McpAdapter implements ProtocolAdapter<McpPlan> {
|
|
209
|
+
readonly name = "mcp";
|
|
210
|
+
supports(ctx: AdapterContext): number;
|
|
211
|
+
plan(ctx: AdapterContext): McpPlan;
|
|
212
|
+
execute(plan: McpPlan, options: SendOptions, ctx?: ExecuteContext): Promise<ExecResult>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export { type DiscoverAndWriteMcpResult as D, type GeneratedMcpCall as G, MCP_PROTOCOL_VERSION as M, type WriteMcpOptions as W, McpAdapter as a, createMcpManualSession as b, createHttpMcpTransport as c, createMcpStdioSession as d, createStdioMcpTransport as e, discoverAndWriteMcpCapabilities as f, discoverMcpCapabilities as g, generateAllMcpCalls as h, generateMcpCall as i, initializeSession as j, runMcpManualSession as k, type McpPlan as l, type McpStdioConnection as m, type McpStdioOptions as n, type McpTransport as o, createMcpSessionCore as p, createMcpStdioConnection as q, resolveMcpConfig as r, runMcp as s, writeMcpOperations as w };
|