@eum-agent/integration-mcp 1.1.0 → 1.2.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/connection-sdk-DYfRLV61.js +114 -0
- package/dist/index.js +841 -751
- package/dist/limits-CiNML2zk.js +72 -0
- package/package.json +4 -4
- package/ui/ui.js +5431 -303
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { i as responseLimit, n as boundedFetch, r as responseBudget, t as RESPONSE_BYTES } from "./limits-CiNML2zk.js";
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import { PromptListChangedNotificationSchema, ResourceListChangedNotificationSchema, ToolListChangedNotificationSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
5
|
+
import { ReadBuffer, serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
6
|
+
//#region src/transport/http.ts
|
|
7
|
+
function httpTransport(input) {
|
|
8
|
+
return new StreamableHTTPClientTransport(new URL(input.url), {
|
|
9
|
+
fetch: boundedFetch(input.fetch),
|
|
10
|
+
requestInit: { headers: { ...input.headers } },
|
|
11
|
+
...input.authProvider ? { authProvider: input.authProvider } : {}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/transport/stdio.ts
|
|
16
|
+
var ProcessTransport = class {
|
|
17
|
+
onclose;
|
|
18
|
+
onerror;
|
|
19
|
+
onmessage;
|
|
20
|
+
process;
|
|
21
|
+
buffer = new ReadBuffer();
|
|
22
|
+
responseBounds = /* @__PURE__ */ new Map();
|
|
23
|
+
bufferedBytes = 0;
|
|
24
|
+
closed = false;
|
|
25
|
+
stopping;
|
|
26
|
+
maxBytes;
|
|
27
|
+
constructor(process, maxBytes = RESPONSE_BYTES) {
|
|
28
|
+
this.process = process;
|
|
29
|
+
this.maxBytes = maxBytes;
|
|
30
|
+
}
|
|
31
|
+
async start() {
|
|
32
|
+
const { stdout, stdin } = this.process;
|
|
33
|
+
stdout.on("data", (chunk) => {
|
|
34
|
+
if (this.closed) return;
|
|
35
|
+
let offset = 0;
|
|
36
|
+
while (offset < chunk.length) {
|
|
37
|
+
const end = chunk.indexOf(10, offset);
|
|
38
|
+
const finish = end === -1 ? chunk.length : end + 1;
|
|
39
|
+
const fragment = chunk.subarray(offset, finish);
|
|
40
|
+
this.bufferedBytes += fragment.length;
|
|
41
|
+
const maximum = this.responseBounds.size ? Math.max(...this.responseBounds.values()) : this.maxBytes;
|
|
42
|
+
if (this.bufferedBytes > Math.min(this.maxBytes, maximum)) {
|
|
43
|
+
this.buffer.clear();
|
|
44
|
+
this.onerror?.(responseLimit());
|
|
45
|
+
this.close().catch((error) => this.onerror?.(error));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
this.buffer.append(fragment);
|
|
50
|
+
if (end !== -1) {
|
|
51
|
+
this.bufferedBytes = 0;
|
|
52
|
+
const message = this.buffer.readMessage();
|
|
53
|
+
if (message) {
|
|
54
|
+
if ("id" in message && message.id !== void 0) this.responseBounds.delete(message.id);
|
|
55
|
+
this.onmessage?.(message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
this.bufferedBytes = 0;
|
|
60
|
+
this.buffer.clear();
|
|
61
|
+
this.onerror?.(error);
|
|
62
|
+
}
|
|
63
|
+
offset = finish;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
stdout.on("error", (error) => this.onerror?.(error));
|
|
67
|
+
stdin.on("error", (error) => this.onerror?.(error));
|
|
68
|
+
this.process.exited.then(() => this.finish(), () => this.finish());
|
|
69
|
+
}
|
|
70
|
+
send(message) {
|
|
71
|
+
if (this.closed) return Promise.reject(/* @__PURE__ */ new Error("server process is not running"));
|
|
72
|
+
if ("method" in message && message.method === "notifications/cancelled" && "params" in message) {
|
|
73
|
+
const id = message.params?.requestId;
|
|
74
|
+
if (typeof id === "string" || typeof id === "number") this.responseBounds.delete(id);
|
|
75
|
+
}
|
|
76
|
+
if ("id" in message && message.id !== void 0 && "method" in message) {
|
|
77
|
+
if (this.responseBounds.size >= 1024) return Promise.reject(Object.assign(/* @__PURE__ */ new Error("too many pending MCP requests"), { code: "read-limit" }));
|
|
78
|
+
this.responseBounds.set(message.id, responseBudget());
|
|
79
|
+
}
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
const { stdin } = this.process;
|
|
82
|
+
const done = (error) => error ? reject(error) : void 0;
|
|
83
|
+
if (stdin.write(serializeMessage(message), done)) resolve();
|
|
84
|
+
else stdin.once("drain", () => resolve());
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
close() {
|
|
88
|
+
this.stopping ??= Promise.resolve().then(() => this.process.stop()).then(() => this.finish()).catch((error) => {
|
|
89
|
+
this.stopping = void 0;
|
|
90
|
+
try {
|
|
91
|
+
this.finish();
|
|
92
|
+
} catch (notification) {
|
|
93
|
+
throw new AggregateError([error, notification], "transport stop and close notification failed", { cause: error });
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
});
|
|
97
|
+
return this.stopping;
|
|
98
|
+
}
|
|
99
|
+
get stopRequested() {
|
|
100
|
+
return this.stopping !== void 0;
|
|
101
|
+
}
|
|
102
|
+
get stopped() {
|
|
103
|
+
return this.stopping;
|
|
104
|
+
}
|
|
105
|
+
finish() {
|
|
106
|
+
if (this.closed) return;
|
|
107
|
+
this.closed = true;
|
|
108
|
+
this.buffer.clear();
|
|
109
|
+
this.responseBounds.clear();
|
|
110
|
+
this.onclose?.();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { Client, ProcessTransport, PromptListChangedNotificationSchema, ResourceListChangedNotificationSchema, ToolListChangedNotificationSchema, httpTransport };
|