@haikit/mcp 0.0.0-stage → 0.32.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/LICENSE +21 -0
- package/README.md +63 -2
- package/dist/errors.d.ts +60 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +54 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +127 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +412 -0
- package/dist/index.js.map +1 -0
- package/dist/text.d.ts +16 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +51 -0
- package/dist/text.js.map +1 -0
- package/dist/transports.d.ts +20 -0
- package/dist/transports.d.ts.map +1 -0
- package/dist/transports.js +28 -0
- package/dist/transports.js.map +1 -0
- package/package.json +52 -4
- package/src/errors.ts +78 -0
- package/src/index.ts +535 -0
- package/src/text.ts +60 -0
- package/src/transports.ts +33 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StreamableHTTPClientTransport, type StreamableHTTPClientTransportOptions, type Transport } from "@modelcontextprotocol/client";
|
|
2
|
+
import { StdioClientTransport, type StdioServerParameters } from "@modelcontextprotocol/client/stdio";
|
|
3
|
+
|
|
4
|
+
export interface HttpOptions extends StreamableHTTPClientTransportOptions {
|
|
5
|
+
/** Sent on every request, over any of the same name in `requestInit.headers`. */
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A server at `url`, over Streamable HTTP. Everything but `headers` is the
|
|
11
|
+
* SDK's own `StreamableHTTPClientTransportOptions`, such as an `authProvider`.
|
|
12
|
+
* The URL is checked now, so a bad one fails at startup.
|
|
13
|
+
*/
|
|
14
|
+
export function http(url: string | URL, options: HttpOptions = {}): () => Transport {
|
|
15
|
+
const target = new URL(url);
|
|
16
|
+
const { headers, ...rest } = options;
|
|
17
|
+
if (headers) {
|
|
18
|
+
const merged = new Headers(rest.requestInit?.headers);
|
|
19
|
+
for (const [name, value] of Object.entries(headers)) merged.set(name, value);
|
|
20
|
+
rest.requestInit = { ...rest.requestInit, headers: merged };
|
|
21
|
+
}
|
|
22
|
+
return () => new StreamableHTTPClientTransport(target, rest);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A server this process starts, and talks to over its stdin and stdout. Each
|
|
27
|
+
* connection starts a new child; `close()` stops it. Unless `env` is given,
|
|
28
|
+
* the child gets only the SDK's short list of safe variables (such as `HOME`
|
|
29
|
+
* and `PATH`), not this process's environment and the secrets in it.
|
|
30
|
+
*/
|
|
31
|
+
export function stdio(params: StdioServerParameters): () => Transport {
|
|
32
|
+
return () => new StdioClientTransport(params);
|
|
33
|
+
}
|