@yolk-sdk/mcp 0.0.1-canary.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 +82 -0
- package/dist/client/client.d.mts +40 -0
- package/dist/client/client.d.mts.map +1 -0
- package/dist/client/client.mjs +225 -0
- package/dist/client/client.mjs.map +1 -0
- package/dist/client/config.d.mts +29 -0
- package/dist/client/config.d.mts.map +1 -0
- package/dist/client/config.mjs +13 -0
- package/dist/client/config.mjs.map +1 -0
- package/dist/client/errors.d.mts +14 -0
- package/dist/client/errors.d.mts.map +1 -0
- package/dist/client/errors.mjs +22 -0
- package/dist/client/errors.mjs.map +1 -0
- package/dist/client/index.d.mts +5 -0
- package/dist/client/index.mjs +5 -0
- package/dist/client/node.d.mts +16 -0
- package/dist/client/node.d.mts.map +1 -0
- package/dist/client/node.mjs +13 -0
- package/dist/client/node.mjs.map +1 -0
- package/dist/client/protocol.d.mts +175 -0
- package/dist/client/protocol.d.mts.map +1 -0
- package/dist/client/protocol.mjs +225 -0
- package/dist/client/protocol.mjs.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/server/errors.d.mts +11 -0
- package/dist/server/errors.d.mts.map +1 -0
- package/dist/server/errors.mjs +16 -0
- package/dist/server/errors.mjs.map +1 -0
- package/dist/server/index.d.mts +4 -0
- package/dist/server/index.mjs +4 -0
- package/dist/server/server.d.mts +22 -0
- package/dist/server/server.d.mts.map +1 -0
- package/dist/server/server.mjs +180 -0
- package/dist/server/server.mjs.map +1 -0
- package/dist/server/stdio.d.mts +8 -0
- package/dist/server/stdio.d.mts.map +1 -0
- package/dist/server/stdio.mjs +18 -0
- package/dist/server/stdio.mjs.map +1 -0
- package/package.json +77 -0
- package/src/client/README.md +24 -0
- package/src/client/client.ts +494 -0
- package/src/client/config.ts +37 -0
- package/src/client/errors.ts +20 -0
- package/src/client/index.ts +48 -0
- package/src/client/node.ts +32 -0
- package/src/client/protocol.ts +364 -0
- package/src/index.ts +2 -0
- package/src/server/README.md +22 -0
- package/src/server/errors.ts +6 -0
- package/src/server/index.ts +4 -0
- package/src/server/server.ts +331 -0
- package/src/server/stdio.ts +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yolk SDK contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @yolk-sdk/mcp
|
|
2
|
+
|
|
3
|
+
Domain-free Model Context Protocol client/server package.
|
|
4
|
+
|
|
5
|
+
Root export is intentionally tiny. Import client, protocol, and server APIs from explicit subpaths.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @yolk-sdk/mcp@canary @yolk-sdk/agent@canary effect
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Canary APIs are unstable. Keep all `@yolk-sdk/*` packages on the same version.
|
|
14
|
+
|
|
15
|
+
## Subpaths
|
|
16
|
+
|
|
17
|
+
| Subpath | Purpose |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `@yolk-sdk/mcp/client` | Remote/local MCP config, tool listing/calling, protocol adapters |
|
|
20
|
+
| `@yolk-sdk/mcp/client/node` | Node-only local stdio convenience helpers |
|
|
21
|
+
| `@yolk-sdk/mcp/protocol` | JSON-RPC/MCP wire helpers |
|
|
22
|
+
| `@yolk-sdk/mcp/server` | Tool-only MCP server primitives |
|
|
23
|
+
|
|
24
|
+
## Imports
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { listMcpTools } from '@yolk-sdk/mcp/client'
|
|
28
|
+
import { listMcpToolsNode } from '@yolk-sdk/mcp/client/node'
|
|
29
|
+
import { makeJsonRpcRequest } from '@yolk-sdk/mcp/protocol'
|
|
30
|
+
import { makeMcpToolServer } from '@yolk-sdk/mcp/server'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Remote client
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { Effect } from 'effect'
|
|
37
|
+
import { listRemoteMcpServerTools } from '@yolk-sdk/mcp/client'
|
|
38
|
+
|
|
39
|
+
const tools = listRemoteMcpServerTools({
|
|
40
|
+
id: 'docs',
|
|
41
|
+
transport: { kind: 'http', url: 'https://example.com/mcp' },
|
|
42
|
+
allowHttpLocalhost: false
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// Host provides HttpClient layer and auth policy.
|
|
46
|
+
Effect.runPromise(tools)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Local stdio client
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { listMcpToolsNode } from '@yolk-sdk/mcp/client/node'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`@yolk-sdk/mcp/client/node` may use Node process APIs. Keep Worker/browser imports on `@yolk-sdk/mcp/client`.
|
|
56
|
+
|
|
57
|
+
## Server
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { makeMcpToolServer } from '@yolk-sdk/mcp/server'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The server is tool-only. Hosts own HTTP routes, auth, deployment, and tool policy.
|
|
64
|
+
|
|
65
|
+
## Host responsibilities
|
|
66
|
+
|
|
67
|
+
- Own persisted MCP server config, auth, and product tool policy.
|
|
68
|
+
- Provide HTTP runtime layers and credentials for remote MCP.
|
|
69
|
+
- Keep Node stdio usage behind Node-only hosts.
|
|
70
|
+
|
|
71
|
+
## Boundaries
|
|
72
|
+
|
|
73
|
+
- App auth, persisted config, policy, and product tools stay outside this package.
|
|
74
|
+
- Node convenience wrappers stay behind `@yolk-sdk/mcp/client/node`.
|
|
75
|
+
- MCP may adapt to `@yolk-sdk/agent/protocol` tool types; agent loop/providers stay MCP-agnostic.
|
|
76
|
+
- Remote MCP requires `https:` by default; localhost HTTP is explicit dev policy.
|
|
77
|
+
|
|
78
|
+
## Tree-shaking
|
|
79
|
+
|
|
80
|
+
- ESM package with `sideEffects: false`.
|
|
81
|
+
- Explicit subpath exports only.
|
|
82
|
+
- No wildcard exports or root feature barrel.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { McpClientInfo, McpLocalServerConfig, McpRemoteServerConfig, McpSecurityPolicy, McpServerConfig } from "./config.mjs";
|
|
2
|
+
import { McpError } from "./errors.mjs";
|
|
3
|
+
import { mcpToolToToolDef } from "./protocol.mjs";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
import { HttpClient } from "effect/unstable/http";
|
|
6
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
7
|
+
import { ToolResult } from "@yolk-sdk/agent/protocol";
|
|
8
|
+
|
|
9
|
+
//#region src/client/client.d.ts
|
|
10
|
+
type McpClientOptions = {
|
|
11
|
+
readonly clientInfo?: McpClientInfo;
|
|
12
|
+
readonly securityPolicy?: McpSecurityPolicy;
|
|
13
|
+
readonly timeoutMs?: number;
|
|
14
|
+
};
|
|
15
|
+
type McpResolvedTool = {
|
|
16
|
+
readonly serverName: string;
|
|
17
|
+
readonly mcpToolName: string;
|
|
18
|
+
readonly def: ReturnType<typeof mcpToolToToolDef>;
|
|
19
|
+
};
|
|
20
|
+
declare const listRemoteMcpServerTools: (config: McpRemoteServerConfig, options?: McpClientOptions) => Effect.Effect<ReadonlyArray<McpResolvedTool>, McpError, HttpClient.HttpClient>;
|
|
21
|
+
declare const listLocalMcpServerTools: (config: McpLocalServerConfig, options?: McpClientOptions) => Effect.Effect<ReadonlyArray<McpResolvedTool>, McpError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
22
|
+
declare const listMcpServerTools: (config: McpServerConfig, options?: McpClientOptions) => Effect.Effect<readonly McpResolvedTool[], McpError, ChildProcessSpawner.ChildProcessSpawner | HttpClient.HttpClient>;
|
|
23
|
+
type CallMcpServerToolInput = {
|
|
24
|
+
readonly config: McpServerConfig;
|
|
25
|
+
readonly mcpToolName: string;
|
|
26
|
+
readonly toolCallId: string;
|
|
27
|
+
readonly params: unknown;
|
|
28
|
+
readonly options?: McpClientOptions;
|
|
29
|
+
};
|
|
30
|
+
declare const callRemoteMcpServerTool: (input: Omit<CallMcpServerToolInput, "config"> & {
|
|
31
|
+
readonly config: McpRemoteServerConfig;
|
|
32
|
+
}) => Effect.Effect<ToolResult, McpError, HttpClient.HttpClient>;
|
|
33
|
+
declare const callLocalMcpServerTool: (input: Omit<CallMcpServerToolInput, "config"> & {
|
|
34
|
+
readonly config: McpLocalServerConfig;
|
|
35
|
+
}) => Effect.Effect<ToolResult, McpError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
36
|
+
declare const callMcpServerTool: (input: CallMcpServerToolInput) => Effect.Effect<ToolResult, McpError, ChildProcessSpawner.ChildProcessSpawner | HttpClient.HttpClient>;
|
|
37
|
+
declare const listMcpTools: (configs: ReadonlyArray<McpServerConfig>, options?: McpClientOptions) => Effect.Effect<McpResolvedTool[], McpError, ChildProcessSpawner.ChildProcessSpawner | HttpClient.HttpClient>;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { CallMcpServerToolInput, McpClientOptions, McpResolvedTool, callLocalMcpServerTool, callMcpServerTool, callRemoteMcpServerTool, listLocalMcpServerTools, listMcpServerTools, listMcpTools, listRemoteMcpServerTools };
|
|
40
|
+
//# sourceMappingURL=client.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.mts","names":[],"sources":["../../src/client/client.ts"],"mappings":";;;;;;;;;KAgCY,gBAAA;EAAA,SACD,UAAA,GAAa,aAAA;EAAA,SACb,cAAA,GAAiB,iBAAiB;EAAA,SAClC,SAAA;AAAA;AAAA,KAGC,eAAA;EAAA,SACD,UAAA;EAAA,SACA,WAAA;EAAA,SACA,GAAA,EAAK,UAAU,QAAQ,gBAAA;AAAA;AAAA,cAqUrB,wBAAA,GACX,MAAA,EAAQ,qBAAA,EACR,OAAA,GAAU,gBAAA,KACT,MAAA,CAAO,MAAA,CAAO,aAAA,CAAc,eAAA,GAAkB,QAAA,EAAU,UAAA,CAAW,UAAA;AAAA,cAUzD,uBAAA,GACX,MAAA,EAAQ,oBAAA,EACR,OAAA,GAAU,gBAAA,KACT,MAAA,CAAO,MAAA,CACR,aAAA,CAAc,eAAA,GACd,QAAA,EACA,mBAAA,CAAoB,mBAAA;AAAA,cAYT,kBAAA,GAAsB,MAAA,EAAQ,eAAA,EAAiB,OAAA,GAAU,gBAAA,KAAgB,MAAA,CAAA,MAAA,UAAA,eAAA,IAAA,QAAA,EAAA,mBAAA,CAAA,mBAAA,GAAA,UAAA,CAAA,UAAA;AAAA,KAa1E,sBAAA;EAAA,SACD,MAAA,EAAQ,eAAA;EAAA,SACR,WAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA;EAAA,SACA,OAAA,GAAU,gBAAgB;AAAA;AAAA,cAmBxB,uBAAA,GACX,KAAA,EAAO,IAAA,CAAK,sBAAA;EAAA,SAA+C,MAAA,EAAQ,qBAAA;AAAA,MAClE,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY,QAAA,EAAU,UAAA,CAAW,UAAA;AAAA,cAUrC,sBAAA,GACX,KAAA,EAAO,IAAA,CAAK,sBAAA;EAAA,SAA+C,MAAA,EAAQ,oBAAA;AAAA,MAClE,MAAA,CAAO,MAAA,CAAO,UAAA,EAAY,QAAA,EAAU,mBAAA,CAAoB,mBAAA;AAAA,cAU9C,iBAAA,GACX,KAAA,EAAO,sBAAA,KACN,MAAA,CAAO,MAAA,CACR,UAAA,EACA,QAAA,EACA,mBAAA,CAAoB,mBAAA,GAAsB,UAAA,CAAW,UAAA;AAAA,cAkB1C,YAAA,GAAgB,OAAA,EAAS,aAAA,CAAc,eAAA,GAAkB,OAAA,GAAU,gBAAA,KAAgB,MAAA,CAAA,MAAA,CAAA,eAAA,IAAA,QAAA,EAAA,mBAAA,CAAA,mBAAA,GAAA,UAAA,CAAA,UAAA"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { defaultMcpClientInfo, defaultMcpSecurityPolicy } from "./config.mjs";
|
|
2
|
+
import { McpError } from "./errors.mjs";
|
|
3
|
+
import { decodeJsonRpcResponseFromJson, decodeToolCallResult, decodeToolsListResult, encodeJsonRpcMessage, jsonRpcErrorToMcpError, makeInitializeParams, makeInitializedNotification, makeJsonRpcRequest, mcpToolToToolDef, toolCallResultToToolResult } from "./protocol.mjs";
|
|
4
|
+
import { Duration, Effect, Option, Stream } from "effect";
|
|
5
|
+
import { HttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
6
|
+
import { ChildProcess } from "effect/unstable/process";
|
|
7
|
+
//#region src/client/client.ts
|
|
8
|
+
const defaultRequestTimeoutMs = 3e4;
|
|
9
|
+
const unknownToMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
10
|
+
const timeoutMs = (options) => options?.timeoutMs ?? defaultRequestTimeoutMs;
|
|
11
|
+
const clientInfo = (options) => options?.clientInfo ?? defaultMcpClientInfo;
|
|
12
|
+
const securityPolicy = (options) => options?.securityPolicy ?? defaultMcpSecurityPolicy;
|
|
13
|
+
const fail = (server, message, cause) => Effect.fail(new McpError({
|
|
14
|
+
server,
|
|
15
|
+
message,
|
|
16
|
+
cause
|
|
17
|
+
}));
|
|
18
|
+
const validateRemoteUrl = (config, policy) => Effect.gen(function* () {
|
|
19
|
+
const url = yield* Effect.try({
|
|
20
|
+
try: () => new URL(config.url),
|
|
21
|
+
catch: (error) => new McpError({
|
|
22
|
+
server: config.name,
|
|
23
|
+
message: `Invalid MCP server URL: ${unknownToMessage(error)}`,
|
|
24
|
+
cause: "validation"
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
if (url.protocol === "https:") return url.toString();
|
|
28
|
+
if (policy.allowDevHttpLocalhost && url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1" || url.hostname === "[::1]")) return url.toString();
|
|
29
|
+
return yield* fail(config.name, "Remote MCP requires https: URL", "security");
|
|
30
|
+
});
|
|
31
|
+
const validateLocal = (config, policy) => Effect.gen(function* () {
|
|
32
|
+
if (!policy.allowLocalServers) return yield* fail(config.name, "Local MCP servers are disabled by policy", "security");
|
|
33
|
+
if (config.command.length === 0) return yield* fail(config.name, "Local MCP command must not be empty", "validation");
|
|
34
|
+
});
|
|
35
|
+
const parseSseJsonRpcResponse = (server, body) => Effect.gen(function* () {
|
|
36
|
+
const candidates = [body, ...body.split("\n").filter((line) => line.startsWith("data: ")).map((line) => line.substring(6))];
|
|
37
|
+
const parsed = yield* Effect.forEach(candidates, (candidate) => decodeJsonRpcResponseFromJson(server, candidate).pipe(Effect.option)).pipe(Effect.map(Option.firstSomeOf));
|
|
38
|
+
if (Option.isSome(parsed)) return parsed.value;
|
|
39
|
+
return yield* fail(server, "MCP response did not contain a JSON-RPC message", "protocol");
|
|
40
|
+
});
|
|
41
|
+
const unwrapResponse = (server, response) => "error" in response ? Effect.fail(jsonRpcErrorToMcpError(server, response.error)) : Effect.succeed(response.result);
|
|
42
|
+
const mapUnknownToMcpError = (server, message, cause) => (error) => error instanceof McpError ? error : new McpError({
|
|
43
|
+
server,
|
|
44
|
+
message: `${message}: ${unknownToMessage(error)}`,
|
|
45
|
+
cause
|
|
46
|
+
});
|
|
47
|
+
const findDuplicateToolName = (tools) => {
|
|
48
|
+
const names = tools.map((tool) => tool.def.name);
|
|
49
|
+
return Option.fromNullishOr(names.find((name, index) => names.indexOf(name) !== index));
|
|
50
|
+
};
|
|
51
|
+
const requestRemote = (config, request, options) => Effect.gen(function* () {
|
|
52
|
+
const url = yield* validateRemoteUrl(config, securityPolicy(options));
|
|
53
|
+
const http = yield* HttpClient.HttpClient;
|
|
54
|
+
const body = yield* encodeJsonRpcMessage(config.name, request);
|
|
55
|
+
const encoded = HttpClientRequest.post(url).pipe(HttpClientRequest.accept("application/json, text/event-stream"), HttpClientRequest.setHeaders(config.headers ?? {}), HttpClientRequest.bodyText(body, "application/json"));
|
|
56
|
+
const text = yield* (yield* HttpClient.filterStatusOk(http).execute(encoded).pipe(Effect.mapError((error) => new McpError({
|
|
57
|
+
server: config.name,
|
|
58
|
+
message: `MCP request failed: ${unknownToMessage(error)}`,
|
|
59
|
+
cause: "transport"
|
|
60
|
+
})), Effect.timeoutOrElse({
|
|
61
|
+
duration: Duration.millis(timeoutMs(options)),
|
|
62
|
+
orElse: () => fail(config.name, "MCP request timed out", "timeout")
|
|
63
|
+
}))).text.pipe(Effect.mapError((error) => new McpError({
|
|
64
|
+
server: config.name,
|
|
65
|
+
message: `Could not read MCP response: ${unknownToMessage(error)}`,
|
|
66
|
+
cause: "transport"
|
|
67
|
+
})));
|
|
68
|
+
const decoded = yield* parseSseJsonRpcResponse(config.name, text);
|
|
69
|
+
return yield* unwrapResponse(config.name, decoded);
|
|
70
|
+
});
|
|
71
|
+
const notifyRemote = (config, notification, options) => Effect.gen(function* () {
|
|
72
|
+
const url = yield* validateRemoteUrl(config, securityPolicy(options));
|
|
73
|
+
const http = yield* HttpClient.HttpClient;
|
|
74
|
+
const body = yield* encodeJsonRpcMessage(config.name, notification);
|
|
75
|
+
const encoded = HttpClientRequest.post(url).pipe(HttpClientRequest.accept("application/json, text/event-stream"), HttpClientRequest.setHeaders(config.headers ?? {}), HttpClientRequest.bodyText(body, "application/json"));
|
|
76
|
+
yield* HttpClient.filterStatusOk(http).execute(encoded).pipe(Effect.mapError((error) => new McpError({
|
|
77
|
+
server: config.name,
|
|
78
|
+
message: `MCP notification failed: ${unknownToMessage(error)}`,
|
|
79
|
+
cause: "transport"
|
|
80
|
+
})), Effect.timeoutOrElse({
|
|
81
|
+
duration: Duration.millis(timeoutMs(options)),
|
|
82
|
+
orElse: () => fail(config.name, "MCP notification timed out", "timeout")
|
|
83
|
+
}));
|
|
84
|
+
});
|
|
85
|
+
const requestRemoteSession = (config, request, options) => Effect.gen(function* () {
|
|
86
|
+
yield* requestRemote(config, initializeRequest(options), options);
|
|
87
|
+
yield* notifyRemote(config, makeInitializedNotification(), options);
|
|
88
|
+
return yield* requestRemote(config, request, options);
|
|
89
|
+
});
|
|
90
|
+
const requestLocalEncoded = (config, messages, expectedResponses, options) => {
|
|
91
|
+
if (!securityPolicy(options).allowLocalServers) return fail(config.name, "Local MCP servers are disabled by policy", "security");
|
|
92
|
+
const command = config.command[0];
|
|
93
|
+
if (command === void 0) return fail(config.name, "Local MCP command must not be empty", "validation");
|
|
94
|
+
return Effect.gen(function* () {
|
|
95
|
+
const stdin = Stream.fromIterable(messages.map((message) => `${message.line}\n`)).pipe(Stream.encodeText);
|
|
96
|
+
const lines = yield* (yield* ChildProcess.make(command, config.command.slice(1), {
|
|
97
|
+
env: config.environment ?? {},
|
|
98
|
+
extendEnv: false,
|
|
99
|
+
stdin: {
|
|
100
|
+
stream: stdin,
|
|
101
|
+
endOnDone: true
|
|
102
|
+
},
|
|
103
|
+
stderr: "ignore"
|
|
104
|
+
})).stdout.pipe(Stream.decodeText, Stream.splitLines, Stream.filter((line) => line.length > 0), Stream.take(expectedResponses), Stream.runCollect);
|
|
105
|
+
const responses = yield* Effect.forEach(lines, (line) => decodeJsonRpcResponseFromJson(config.name, line));
|
|
106
|
+
if (responses.length < expectedResponses) return yield* fail(config.name, "Local MCP did not return expected response", "protocol");
|
|
107
|
+
return responses;
|
|
108
|
+
}).pipe(Effect.scoped, Effect.timeoutOrElse({
|
|
109
|
+
duration: Duration.millis(timeoutMs(options)),
|
|
110
|
+
orElse: () => fail(config.name, "Local MCP request timed out", "timeout")
|
|
111
|
+
}), Effect.mapError(mapUnknownToMcpError(config.name, "Local MCP request failed", "transport")));
|
|
112
|
+
};
|
|
113
|
+
const requestLocal = (config, requests, expectedResponses, options) => Effect.gen(function* () {
|
|
114
|
+
return yield* requestLocalEncoded(config, yield* Effect.forEach(requests, (request) => encodeJsonRpcMessage(config.name, request).pipe(Effect.map((line) => ({
|
|
115
|
+
message: request,
|
|
116
|
+
line
|
|
117
|
+
})))), expectedResponses, options);
|
|
118
|
+
});
|
|
119
|
+
const initializeRequest = (options) => makeJsonRpcRequest({
|
|
120
|
+
id: 1,
|
|
121
|
+
method: "initialize",
|
|
122
|
+
params: makeInitializeParams(clientInfo(options))
|
|
123
|
+
});
|
|
124
|
+
const listToolsRequest = () => makeJsonRpcRequest({
|
|
125
|
+
id: 2,
|
|
126
|
+
method: "tools/list"
|
|
127
|
+
});
|
|
128
|
+
const callToolRequest = (input) => makeJsonRpcRequest({
|
|
129
|
+
id: 3,
|
|
130
|
+
method: "tools/call",
|
|
131
|
+
params: {
|
|
132
|
+
name: input.toolName,
|
|
133
|
+
arguments: input.params
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
const responseById = (responses, id) => Option.fromNullishOr(responses.find((response) => response.id === id));
|
|
137
|
+
const requestLocalSession = (config, request, options) => Effect.gen(function* () {
|
|
138
|
+
const initialize = initializeRequest(options);
|
|
139
|
+
const responses = yield* requestLocal(config, [
|
|
140
|
+
initialize,
|
|
141
|
+
makeInitializedNotification(),
|
|
142
|
+
request
|
|
143
|
+
], 2, options);
|
|
144
|
+
const initializeResponse = responseById(responses, initialize.id);
|
|
145
|
+
if (Option.isNone(initializeResponse)) return yield* fail(config.name, "Local MCP did not return initialize response", "protocol");
|
|
146
|
+
yield* unwrapResponse(config.name, initializeResponse.value);
|
|
147
|
+
return responses;
|
|
148
|
+
}).pipe(Effect.flatMap((responses) => {
|
|
149
|
+
const response = responseById(responses, request.id);
|
|
150
|
+
return Option.isNone(response) ? fail(config.name, "Local MCP did not return expected response", "protocol") : unwrapResponse(config.name, response.value);
|
|
151
|
+
}));
|
|
152
|
+
const resolveMcpTools = (config, result) => Effect.gen(function* () {
|
|
153
|
+
return (yield* decodeToolsListResult(result).pipe(Effect.mapError((error) => new McpError({
|
|
154
|
+
server: config.name,
|
|
155
|
+
message: `Invalid tools/list result: ${unknownToMessage(error)}`,
|
|
156
|
+
cause: "validation"
|
|
157
|
+
})))).tools.map((tool) => ({
|
|
158
|
+
serverName: config.name,
|
|
159
|
+
mcpToolName: tool.name,
|
|
160
|
+
def: mcpToolToToolDef({
|
|
161
|
+
serverName: config.name,
|
|
162
|
+
tool
|
|
163
|
+
})
|
|
164
|
+
}));
|
|
165
|
+
});
|
|
166
|
+
const listRemoteMcpServerTools = (config, options) => Effect.gen(function* () {
|
|
167
|
+
if (config.enabled === false) return [];
|
|
168
|
+
return yield* resolveMcpTools(config, yield* requestRemoteSession(config, listToolsRequest(), options));
|
|
169
|
+
});
|
|
170
|
+
const listLocalMcpServerTools = (config, options) => Effect.gen(function* () {
|
|
171
|
+
if (config.enabled === false) return [];
|
|
172
|
+
yield* validateLocal(config, securityPolicy(options));
|
|
173
|
+
return yield* resolveMcpTools(config, yield* requestLocalSession(config, listToolsRequest(), options));
|
|
174
|
+
});
|
|
175
|
+
const listMcpServerTools = (config, options) => Effect.gen(function* () {
|
|
176
|
+
if (config.enabled === false) return [];
|
|
177
|
+
if (config.type === "local") return yield* listLocalMcpServerTools(config, options);
|
|
178
|
+
return yield* listRemoteMcpServerTools(config, options);
|
|
179
|
+
});
|
|
180
|
+
const resolveMcpToolResult = (input, result) => Effect.gen(function* () {
|
|
181
|
+
const toolCallResult = yield* decodeToolCallResult(result).pipe(Effect.mapError((error) => new McpError({
|
|
182
|
+
server: input.config.name,
|
|
183
|
+
message: `Invalid tools/call result: ${unknownToMessage(error)}`,
|
|
184
|
+
cause: "validation"
|
|
185
|
+
})));
|
|
186
|
+
return toolCallResultToToolResult({
|
|
187
|
+
toolCallId: input.toolCallId,
|
|
188
|
+
result: toolCallResult
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
const callRemoteMcpServerTool = (input) => Effect.gen(function* () {
|
|
192
|
+
return yield* resolveMcpToolResult(input, yield* requestRemoteSession(input.config, callToolRequest({
|
|
193
|
+
toolName: input.mcpToolName,
|
|
194
|
+
params: input.params
|
|
195
|
+
}), input.options));
|
|
196
|
+
});
|
|
197
|
+
const callLocalMcpServerTool = (input) => Effect.gen(function* () {
|
|
198
|
+
return yield* resolveMcpToolResult(input, yield* requestLocalSession(input.config, callToolRequest({
|
|
199
|
+
toolName: input.mcpToolName,
|
|
200
|
+
params: input.params
|
|
201
|
+
}), input.options));
|
|
202
|
+
});
|
|
203
|
+
const callMcpServerTool = (input) => input.config.type === "local" ? callLocalMcpServerTool({
|
|
204
|
+
config: input.config,
|
|
205
|
+
mcpToolName: input.mcpToolName,
|
|
206
|
+
toolCallId: input.toolCallId,
|
|
207
|
+
params: input.params,
|
|
208
|
+
options: input.options
|
|
209
|
+
}) : callRemoteMcpServerTool({
|
|
210
|
+
config: input.config,
|
|
211
|
+
mcpToolName: input.mcpToolName,
|
|
212
|
+
toolCallId: input.toolCallId,
|
|
213
|
+
params: input.params,
|
|
214
|
+
options: input.options
|
|
215
|
+
});
|
|
216
|
+
const listMcpTools = (configs, options) => Effect.flatMap(Effect.forEach(configs, (config) => listMcpServerTools(config, options)), (tools) => {
|
|
217
|
+
const resolved = tools.flat();
|
|
218
|
+
const duplicate = findDuplicateToolName(resolved);
|
|
219
|
+
if (Option.isSome(duplicate)) return fail("mcp", `Duplicate MCP tool name: ${duplicate.value}`, "validation");
|
|
220
|
+
return Effect.succeed(resolved);
|
|
221
|
+
});
|
|
222
|
+
//#endregion
|
|
223
|
+
export { callLocalMcpServerTool, callMcpServerTool, callRemoteMcpServerTool, listLocalMcpServerTools, listMcpServerTools, listMcpTools, listRemoteMcpServerTools };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=client.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../../src/client/client.ts"],"sourcesContent":["import { Duration, Effect, Option, Stream } from 'effect'\nimport { HttpClient, HttpClientRequest } from 'effect/unstable/http'\nimport { ChildProcess } from 'effect/unstable/process'\nimport type { ChildProcessSpawner } from 'effect/unstable/process'\nimport type { ToolResult } from '@yolk-sdk/agent/protocol'\nimport type {\n McpClientInfo,\n McpLocalServerConfig,\n McpRemoteServerConfig,\n McpSecurityPolicy,\n McpServerConfig\n} from './config.ts'\nimport { defaultMcpClientInfo, defaultMcpSecurityPolicy } from './config.ts'\nimport { McpError } from './errors.ts'\nimport {\n decodeJsonRpcResponseFromJson,\n decodeToolCallResult,\n decodeToolsListResult,\n encodeJsonRpcMessage,\n jsonRpcErrorToMcpError,\n makeInitializedNotification,\n makeInitializeParams,\n makeJsonRpcRequest,\n mcpToolToToolDef,\n toolCallResultToToolResult,\n type JsonRpcNotification,\n type JsonRpcRequest,\n type JsonRpcResponse\n} from './protocol.ts'\n\nconst defaultRequestTimeoutMs = 30_000\n\nexport type McpClientOptions = {\n readonly clientInfo?: McpClientInfo\n readonly securityPolicy?: McpSecurityPolicy\n readonly timeoutMs?: number\n}\n\nexport type McpResolvedTool = {\n readonly serverName: string\n readonly mcpToolName: string\n readonly def: ReturnType<typeof mcpToolToToolDef>\n}\n\nconst unknownToMessage = (error: unknown) =>\n error instanceof Error ? error.message : String(error)\n\nconst timeoutMs = (options?: McpClientOptions) => options?.timeoutMs ?? defaultRequestTimeoutMs\n\nconst clientInfo = (options?: McpClientOptions) => options?.clientInfo ?? defaultMcpClientInfo\n\nconst securityPolicy = (options?: McpClientOptions) =>\n options?.securityPolicy ?? defaultMcpSecurityPolicy\n\nconst fail = (server: string, message: string, cause: McpError['cause']) =>\n Effect.fail(new McpError({ server, message, cause }))\n\nconst validateRemoteUrl = (config: McpRemoteServerConfig, policy: McpSecurityPolicy) =>\n Effect.gen(function* () {\n const url = yield* Effect.try({\n try: () => new URL(config.url),\n catch: error =>\n new McpError({\n server: config.name,\n message: `Invalid MCP server URL: ${unknownToMessage(error)}`,\n cause: 'validation'\n })\n })\n\n if (url.protocol === 'https:') {\n return url.toString()\n }\n\n if (\n policy.allowDevHttpLocalhost &&\n url.protocol === 'http:' &&\n (url.hostname === 'localhost' || url.hostname === '127.0.0.1' || url.hostname === '[::1]')\n ) {\n return url.toString()\n }\n\n return yield* fail(config.name, 'Remote MCP requires https: URL', 'security')\n })\n\nconst validateLocal = (config: McpLocalServerConfig, policy: McpSecurityPolicy) =>\n Effect.gen(function* () {\n if (!policy.allowLocalServers) {\n return yield* fail(config.name, 'Local MCP servers are disabled by policy', 'security')\n }\n\n if (config.command.length === 0) {\n return yield* fail(config.name, 'Local MCP command must not be empty', 'validation')\n }\n })\n\nconst parseSseJsonRpcResponse = (server: string, body: string) =>\n Effect.gen(function* () {\n const candidates = [\n body,\n ...body\n .split('\\n')\n .filter(line => line.startsWith('data: '))\n .map(line => line.substring('data: '.length))\n ]\n const parsed = yield* Effect.forEach(candidates, candidate =>\n decodeJsonRpcResponseFromJson(server, candidate).pipe(Effect.option)\n ).pipe(Effect.map(Option.firstSomeOf))\n\n if (Option.isSome(parsed)) {\n return parsed.value\n }\n\n return yield* fail(server, 'MCP response did not contain a JSON-RPC message', 'protocol')\n })\n\nconst unwrapResponse = (server: string, response: JsonRpcResponse) =>\n 'error' in response\n ? Effect.fail(jsonRpcErrorToMcpError(server, response.error))\n : Effect.succeed(response.result)\n\nconst mapUnknownToMcpError =\n (server: string, message: string, cause: McpError['cause']) => (error: unknown) =>\n error instanceof McpError\n ? error\n : new McpError({\n server,\n message: `${message}: ${unknownToMessage(error)}`,\n cause\n })\n\nconst findDuplicateToolName = (tools: ReadonlyArray<McpResolvedTool>) => {\n const names = tools.map(tool => tool.def.name)\n return Option.fromNullishOr(names.find((name, index) => names.indexOf(name) !== index))\n}\n\nconst requestRemote = (\n config: McpRemoteServerConfig,\n request: JsonRpcRequest,\n options?: McpClientOptions\n) =>\n Effect.gen(function* () {\n const policy = securityPolicy(options)\n const url = yield* validateRemoteUrl(config, policy)\n const http = yield* HttpClient.HttpClient\n const body = yield* encodeJsonRpcMessage(config.name, request)\n const encoded = HttpClientRequest.post(url).pipe(\n HttpClientRequest.accept('application/json, text/event-stream'),\n HttpClientRequest.setHeaders(config.headers ?? {}),\n HttpClientRequest.bodyText(body, 'application/json')\n )\n const response = yield* HttpClient.filterStatusOk(http)\n .execute(encoded)\n .pipe(\n Effect.mapError(\n error =>\n new McpError({\n server: config.name,\n message: `MCP request failed: ${unknownToMessage(error)}`,\n cause: 'transport'\n })\n ),\n Effect.timeoutOrElse({\n duration: Duration.millis(timeoutMs(options)),\n orElse: () => fail(config.name, 'MCP request timed out', 'timeout')\n })\n )\n const text = yield* response.text.pipe(\n Effect.mapError(\n error =>\n new McpError({\n server: config.name,\n message: `Could not read MCP response: ${unknownToMessage(error)}`,\n cause: 'transport'\n })\n )\n )\n const decoded = yield* parseSseJsonRpcResponse(config.name, text)\n\n return yield* unwrapResponse(config.name, decoded)\n })\n\nconst notifyRemote = (\n config: McpRemoteServerConfig,\n notification: JsonRpcNotification,\n options?: McpClientOptions\n) =>\n Effect.gen(function* () {\n const policy = securityPolicy(options)\n const url = yield* validateRemoteUrl(config, policy)\n const http = yield* HttpClient.HttpClient\n const body = yield* encodeJsonRpcMessage(config.name, notification)\n const encoded = HttpClientRequest.post(url).pipe(\n HttpClientRequest.accept('application/json, text/event-stream'),\n HttpClientRequest.setHeaders(config.headers ?? {}),\n HttpClientRequest.bodyText(body, 'application/json')\n )\n yield* HttpClient.filterStatusOk(http)\n .execute(encoded)\n .pipe(\n Effect.mapError(\n error =>\n new McpError({\n server: config.name,\n message: `MCP notification failed: ${unknownToMessage(error)}`,\n cause: 'transport'\n })\n ),\n Effect.timeoutOrElse({\n duration: Duration.millis(timeoutMs(options)),\n orElse: () => fail(config.name, 'MCP notification timed out', 'timeout')\n })\n )\n })\n\nconst requestRemoteSession = (\n config: McpRemoteServerConfig,\n request: JsonRpcRequest,\n options?: McpClientOptions\n) =>\n Effect.gen(function* () {\n yield* requestRemote(config, initializeRequest(options), options)\n yield* notifyRemote(config, makeInitializedNotification(), options)\n return yield* requestRemote(config, request, options)\n })\n\ntype EncodedLocalMessage = {\n readonly message: JsonRpcRequest | JsonRpcNotification\n readonly line: string\n}\n\nconst requestLocalEncoded = (\n config: McpLocalServerConfig,\n messages: ReadonlyArray<EncodedLocalMessage>,\n expectedResponses: number,\n options?: McpClientOptions\n) => {\n const policy = securityPolicy(options)\n if (!policy.allowLocalServers) {\n return fail(config.name, 'Local MCP servers are disabled by policy', 'security')\n }\n\n const command = config.command[0]\n if (command === undefined) {\n return fail(config.name, 'Local MCP command must not be empty', 'validation')\n }\n\n return Effect.gen(function* () {\n const stdin = Stream.fromIterable(messages.map(message => `${message.line}\\n`)).pipe(\n Stream.encodeText\n )\n const child = yield* ChildProcess.make(command, config.command.slice(1), {\n env: config.environment ?? {},\n extendEnv: false,\n stdin: { stream: stdin, endOnDone: true },\n stderr: 'ignore'\n })\n const lines = yield* child.stdout.pipe(\n Stream.decodeText,\n Stream.splitLines,\n Stream.filter(line => line.length > 0),\n Stream.take(expectedResponses),\n Stream.runCollect\n )\n const responses = yield* Effect.forEach(lines, line =>\n decodeJsonRpcResponseFromJson(config.name, line)\n )\n\n if (responses.length < expectedResponses) {\n return yield* fail(config.name, 'Local MCP did not return expected response', 'protocol')\n }\n\n return responses\n }).pipe(\n Effect.scoped,\n Effect.timeoutOrElse({\n duration: Duration.millis(timeoutMs(options)),\n orElse: () => fail(config.name, 'Local MCP request timed out', 'timeout')\n }),\n Effect.mapError(mapUnknownToMcpError(config.name, 'Local MCP request failed', 'transport'))\n )\n}\n\nconst requestLocal = (\n config: McpLocalServerConfig,\n requests: ReadonlyArray<JsonRpcRequest | JsonRpcNotification>,\n expectedResponses: number,\n options?: McpClientOptions\n) =>\n Effect.gen(function* () {\n const messages = yield* Effect.forEach(requests, request =>\n encodeJsonRpcMessage(config.name, request).pipe(\n Effect.map(line => ({ message: request, line }))\n )\n )\n\n return yield* requestLocalEncoded(config, messages, expectedResponses, options)\n })\n\nconst initializeRequest = (options?: McpClientOptions) =>\n makeJsonRpcRequest({\n id: 1,\n method: 'initialize',\n params: makeInitializeParams(clientInfo(options))\n })\n\nconst listToolsRequest = () => makeJsonRpcRequest({ id: 2, method: 'tools/list' })\n\nconst callToolRequest = (input: { readonly toolName: string; readonly params: unknown }) =>\n makeJsonRpcRequest({\n id: 3,\n method: 'tools/call',\n params: { name: input.toolName, arguments: input.params }\n })\n\nconst responseById = (responses: ReadonlyArray<JsonRpcResponse>, id: string | number) =>\n Option.fromNullishOr(responses.find(response => response.id === id))\n\nconst requestLocalSession = (\n config: McpLocalServerConfig,\n request: JsonRpcRequest,\n options?: McpClientOptions\n) =>\n Effect.gen(function* () {\n const initialize = initializeRequest(options)\n const responses = yield* requestLocal(\n config,\n [initialize, makeInitializedNotification(), request],\n 2,\n options\n )\n const initializeResponse = responseById(responses, initialize.id)\n if (Option.isNone(initializeResponse)) {\n return yield* fail(config.name, 'Local MCP did not return initialize response', 'protocol')\n }\n yield* unwrapResponse(config.name, initializeResponse.value)\n\n return responses\n }).pipe(\n Effect.flatMap(responses => {\n const response = responseById(responses, request.id)\n return Option.isNone(response)\n ? fail(config.name, 'Local MCP did not return expected response', 'protocol')\n : unwrapResponse(config.name, response.value)\n })\n )\n\nconst resolveMcpTools = (config: McpServerConfig, result: unknown) =>\n Effect.gen(function* () {\n const tools = yield* decodeToolsListResult(result).pipe(\n Effect.mapError(\n error =>\n new McpError({\n server: config.name,\n message: `Invalid tools/list result: ${unknownToMessage(error)}`,\n cause: 'validation'\n })\n )\n )\n\n return tools.tools.map(tool => ({\n serverName: config.name,\n mcpToolName: tool.name,\n def: mcpToolToToolDef({ serverName: config.name, tool })\n }))\n })\n\nexport const listRemoteMcpServerTools = (\n config: McpRemoteServerConfig,\n options?: McpClientOptions\n): Effect.Effect<ReadonlyArray<McpResolvedTool>, McpError, HttpClient.HttpClient> =>\n Effect.gen(function* () {\n if (config.enabled === false) {\n return []\n }\n\n const result = yield* requestRemoteSession(config, listToolsRequest(), options)\n return yield* resolveMcpTools(config, result)\n })\n\nexport const listLocalMcpServerTools = (\n config: McpLocalServerConfig,\n options?: McpClientOptions\n): Effect.Effect<\n ReadonlyArray<McpResolvedTool>,\n McpError,\n ChildProcessSpawner.ChildProcessSpawner\n> =>\n Effect.gen(function* () {\n if (config.enabled === false) {\n return []\n }\n\n yield* validateLocal(config, securityPolicy(options))\n const result = yield* requestLocalSession(config, listToolsRequest(), options)\n return yield* resolveMcpTools(config, result)\n })\n\nexport const listMcpServerTools = (config: McpServerConfig, options?: McpClientOptions) =>\n Effect.gen(function* () {\n if (config.enabled === false) {\n return []\n }\n\n if (config.type === 'local') {\n return yield* listLocalMcpServerTools(config, options)\n }\n\n return yield* listRemoteMcpServerTools(config, options)\n })\n\nexport type CallMcpServerToolInput = {\n readonly config: McpServerConfig\n readonly mcpToolName: string\n readonly toolCallId: string\n readonly params: unknown\n readonly options?: McpClientOptions\n}\n\nconst resolveMcpToolResult = (input: CallMcpServerToolInput, result: unknown) =>\n Effect.gen(function* () {\n const toolCallResult = yield* decodeToolCallResult(result).pipe(\n Effect.mapError(\n error =>\n new McpError({\n server: input.config.name,\n message: `Invalid tools/call result: ${unknownToMessage(error)}`,\n cause: 'validation'\n })\n )\n )\n\n return toolCallResultToToolResult({ toolCallId: input.toolCallId, result: toolCallResult })\n })\n\nexport const callRemoteMcpServerTool = (\n input: Omit<CallMcpServerToolInput, 'config'> & { readonly config: McpRemoteServerConfig }\n): Effect.Effect<ToolResult, McpError, HttpClient.HttpClient> =>\n Effect.gen(function* () {\n const result = yield* requestRemoteSession(\n input.config,\n callToolRequest({ toolName: input.mcpToolName, params: input.params }),\n input.options\n )\n return yield* resolveMcpToolResult(input, result)\n })\n\nexport const callLocalMcpServerTool = (\n input: Omit<CallMcpServerToolInput, 'config'> & { readonly config: McpLocalServerConfig }\n): Effect.Effect<ToolResult, McpError, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function* () {\n const result = yield* requestLocalSession(\n input.config,\n callToolRequest({ toolName: input.mcpToolName, params: input.params }),\n input.options\n )\n return yield* resolveMcpToolResult(input, result)\n })\n\nexport const callMcpServerTool = (\n input: CallMcpServerToolInput\n): Effect.Effect<\n ToolResult,\n McpError,\n ChildProcessSpawner.ChildProcessSpawner | HttpClient.HttpClient\n> =>\n input.config.type === 'local'\n ? callLocalMcpServerTool({\n config: input.config,\n mcpToolName: input.mcpToolName,\n toolCallId: input.toolCallId,\n params: input.params,\n options: input.options\n })\n : callRemoteMcpServerTool({\n config: input.config,\n mcpToolName: input.mcpToolName,\n toolCallId: input.toolCallId,\n params: input.params,\n options: input.options\n })\n\nexport const listMcpTools = (configs: ReadonlyArray<McpServerConfig>, options?: McpClientOptions) =>\n Effect.flatMap(\n Effect.forEach(configs, config => listMcpServerTools(config, options)),\n tools => {\n const resolved = tools.flat()\n const duplicate = findDuplicateToolName(resolved)\n if (Option.isSome(duplicate)) {\n return fail('mcp', `Duplicate MCP tool name: ${duplicate.value}`, 'validation')\n }\n\n return Effect.succeed(resolved)\n }\n )\n"],"m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CACgD;AAClD,CAAC;AAEH,MAAa,0BACX,UAEA,OAAO,IAAI,aAAa;CAMtB,OAAO,OAAO,qBAAqB,OAAO,OALpB,oBACpB,MAAM,QACN,gBAAgB;EAAE,UAAU,MAAM;EAAa,QAAQ,MAAM;CAAO,CAAC,GACrE,MAAM,OACR,CACgD;AAClD,CAAC;AAEH,MAAa,qBACX,UAMA,MAAM,OAAO,SAAS,UAClB,uBAAuB;CACrB,QAAQ,MAAM;CACd,aAAa,MAAM;CACnB,YAAY,MAAM;CAClB,QAAQ,MAAM;CACd,SAAS,MAAM;AACjB,CAAC,IACD,wBAAwB;CACtB,QAAQ,MAAM;CACd,aAAa,MAAM;CACnB,YAAY,MAAM;CAClB,QAAQ,MAAM;CACd,SAAS,MAAM;AACjB,CAAC;AAEP,MAAa,gBAAgB,SAAyC,YACpE,OAAO,QACL,OAAO,QAAQ,UAAS,WAAU,mBAAmB,QAAQ,OAAO,CAAC,IACrE,UAAS;CACP,MAAM,WAAW,MAAM,KAAK;CAC5B,MAAM,YAAY,sBAAsB,QAAQ;CAChD,IAAI,OAAO,OAAO,SAAS,GACzB,OAAO,KAAK,OAAO,4BAA4B,UAAU,SAAS,YAAY;CAGhF,OAAO,OAAO,QAAQ,QAAQ;AAChC,CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/client/config.d.ts
|
|
2
|
+
type McpRemoteServerConfig = {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly type: 'remote';
|
|
5
|
+
readonly url: string;
|
|
6
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
7
|
+
readonly enabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type McpLocalServerConfig = {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly type: 'local';
|
|
12
|
+
readonly command: ReadonlyArray<string>;
|
|
13
|
+
readonly environment?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly enabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type McpServerConfig = McpRemoteServerConfig | McpLocalServerConfig;
|
|
17
|
+
type McpClientInfo = {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
};
|
|
21
|
+
type McpSecurityPolicy = {
|
|
22
|
+
readonly allowLocalServers: boolean;
|
|
23
|
+
readonly allowDevHttpLocalhost: boolean;
|
|
24
|
+
};
|
|
25
|
+
declare const defaultMcpClientInfo: McpClientInfo;
|
|
26
|
+
declare const defaultMcpSecurityPolicy: McpSecurityPolicy;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { McpClientInfo, McpLocalServerConfig, McpRemoteServerConfig, McpSecurityPolicy, McpServerConfig, defaultMcpClientInfo, defaultMcpSecurityPolicy };
|
|
29
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/client/config.ts"],"mappings":";KAAY,qBAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAA;EAAA,SACA,GAAA;EAAA,SACA,OAAA,GAAU,QAAQ,CAAC,MAAA;EAAA,SACnB,OAAA;AAAA;AAAA,KAGC,oBAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA,EAAS,aAAA;EAAA,SACT,WAAA,GAAc,QAAA,CAAS,MAAA;EAAA,SACvB,OAAA;AAAA;AAAA,KAGC,eAAA,GAAkB,qBAAA,GAAwB,oBAAoB;AAAA,KAE9D,aAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAO;AAAA;AAAA,KAGN,iBAAA;EAAA,SACD,iBAAA;EAAA,SACA,qBAAqB;AAAA;AAAA,cAGnB,oBAAA,EAAsB,aAGlC;AAAA,cAEY,wBAAA,EAA0B,iBAGtC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/client/config.ts
|
|
2
|
+
const defaultMcpClientInfo = {
|
|
3
|
+
name: "yolk",
|
|
4
|
+
version: "0.1.0"
|
|
5
|
+
};
|
|
6
|
+
const defaultMcpSecurityPolicy = {
|
|
7
|
+
allowLocalServers: false,
|
|
8
|
+
allowDevHttpLocalhost: false
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { defaultMcpClientInfo, defaultMcpSecurityPolicy };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/client/config.ts"],"sourcesContent":["export type McpRemoteServerConfig = {\n readonly name: string\n readonly type: 'remote'\n readonly url: string\n readonly headers?: Readonly<Record<string, string>>\n readonly enabled?: boolean\n}\n\nexport type McpLocalServerConfig = {\n readonly name: string\n readonly type: 'local'\n readonly command: ReadonlyArray<string>\n readonly environment?: Readonly<Record<string, string>>\n readonly enabled?: boolean\n}\n\nexport type McpServerConfig = McpRemoteServerConfig | McpLocalServerConfig\n\nexport type McpClientInfo = {\n readonly name: string\n readonly version: string\n}\n\nexport type McpSecurityPolicy = {\n readonly allowLocalServers: boolean\n readonly allowDevHttpLocalhost: boolean\n}\n\nexport const defaultMcpClientInfo: McpClientInfo = {\n name: 'yolk',\n version: '0.1.0'\n}\n\nexport const defaultMcpSecurityPolicy: McpSecurityPolicy = {\n allowLocalServers: false,\n allowDevHttpLocalhost: false\n}\n"],"mappings":";AA4BA,MAAa,uBAAsC;CACjD,MAAM;CACN,SAAS;AACX;AAEA,MAAa,2BAA8C;CACzD,mBAAmB;CACnB,uBAAuB;AACzB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
|
|
3
|
+
//#region src/client/errors.d.ts
|
|
4
|
+
declare const McpErrorCause: Schema.Literals<readonly ["disabled", "security", "transport", "protocol", "parse", "encoding", "timeout", "validation", "tool_error"]>;
|
|
5
|
+
type McpErrorCause = typeof McpErrorCause.Type;
|
|
6
|
+
declare const McpError_base: Schema.Class<McpError, Schema.TaggedStruct<"McpError", {
|
|
7
|
+
readonly server: Schema.String;
|
|
8
|
+
readonly message: Schema.String;
|
|
9
|
+
readonly cause: Schema.Literals<readonly ["disabled", "security", "transport", "protocol", "parse", "encoding", "timeout", "validation", "tool_error"]>;
|
|
10
|
+
}>, import("effect/Cause").YieldableError>;
|
|
11
|
+
declare class McpError extends McpError_base {}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { McpError, McpErrorCause };
|
|
14
|
+
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../../src/client/errors.ts"],"mappings":";;;cAEa,aAAA,EAAa,MAAA,CAAA,QAAA;AAAA,KAWd,aAAA,UAAuB,aAAA,CAAc,IAAI;AAAA,cAAA,aAAA;;;;;cAExC,QAAA,SAAiB,aAI5B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
//#region src/client/errors.ts
|
|
3
|
+
const McpErrorCause = Schema.Literals([
|
|
4
|
+
"disabled",
|
|
5
|
+
"security",
|
|
6
|
+
"transport",
|
|
7
|
+
"protocol",
|
|
8
|
+
"parse",
|
|
9
|
+
"encoding",
|
|
10
|
+
"timeout",
|
|
11
|
+
"validation",
|
|
12
|
+
"tool_error"
|
|
13
|
+
]);
|
|
14
|
+
var McpError = class extends Schema.TaggedErrorClass()("McpError", {
|
|
15
|
+
server: Schema.String,
|
|
16
|
+
message: Schema.String,
|
|
17
|
+
cause: McpErrorCause
|
|
18
|
+
}) {};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { McpError, McpErrorCause };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../../src/client/errors.ts"],"sourcesContent":["import * as Schema from 'effect/Schema'\n\nexport const McpErrorCause = Schema.Literals([\n 'disabled',\n 'security',\n 'transport',\n 'protocol',\n 'parse',\n 'encoding',\n 'timeout',\n 'validation',\n 'tool_error'\n])\nexport type McpErrorCause = typeof McpErrorCause.Type\n\nexport class McpError extends Schema.TaggedErrorClass<McpError>()('McpError', {\n server: Schema.String,\n message: Schema.String,\n cause: McpErrorCause\n}) {}\n"],"mappings":";;AAEA,MAAa,gBAAgB,OAAO,SAAS;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,IAAa,WAAb,cAA8B,OAAO,iBAA2B,EAAE,YAAY;CAC5E,QAAQ,OAAO;CACf,SAAS,OAAO;CAChB,OAAO;AACT,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { McpClientInfo, McpLocalServerConfig, McpRemoteServerConfig, McpSecurityPolicy, McpServerConfig, defaultMcpClientInfo, defaultMcpSecurityPolicy } from "./config.mjs";
|
|
2
|
+
import { McpError, McpErrorCause } from "./errors.mjs";
|
|
3
|
+
import { GenericContentBlock, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, McpTool, TextContentBlock, ToolCallResult, ToolsListResult, decodeJsonRpcMessageFromJson, decodeJsonRpcResponse, decodeJsonRpcResponseFromJson, decodeToolCallResult, decodeToolsListResult, encodeJsonRpcMessage, jsonRpcErrorToMcpError, latestMcpProtocolVersion, makeInitializeParams, makeInitializedNotification, makeJsonRpcRequest, mcpToolToToolDef, sanitizeMcpName, toolCallResultToToolResult } from "./protocol.mjs";
|
|
4
|
+
import { CallMcpServerToolInput, McpClientOptions, McpResolvedTool, callLocalMcpServerTool, callMcpServerTool, callRemoteMcpServerTool, listLocalMcpServerTools, listMcpServerTools, listMcpTools, listRemoteMcpServerTools } from "./client.mjs";
|
|
5
|
+
export { type CallMcpServerToolInput, GenericContentBlock, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, type JsonRpcMessage as JsonRpcMessageType, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, type McpClientInfo, type McpClientOptions, McpError, McpErrorCause, type McpLocalServerConfig, type McpRemoteServerConfig, type McpResolvedTool, type McpSecurityPolicy, type McpServerConfig, McpTool, TextContentBlock, ToolCallResult, ToolsListResult, callLocalMcpServerTool, callMcpServerTool, callRemoteMcpServerTool, decodeJsonRpcMessageFromJson, decodeJsonRpcResponse, decodeJsonRpcResponseFromJson, decodeToolCallResult, decodeToolsListResult, defaultMcpClientInfo, defaultMcpSecurityPolicy, encodeJsonRpcMessage, jsonRpcErrorToMcpError, latestMcpProtocolVersion, listLocalMcpServerTools, listMcpServerTools, listMcpTools, listRemoteMcpServerTools, makeInitializeParams, makeInitializedNotification, makeJsonRpcRequest, mcpToolToToolDef, sanitizeMcpName, toolCallResultToToolResult };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { defaultMcpClientInfo, defaultMcpSecurityPolicy } from "./config.mjs";
|
|
2
|
+
import { McpError, McpErrorCause } from "./errors.mjs";
|
|
3
|
+
import { GenericContentBlock, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, McpTool, TextContentBlock, ToolCallResult, ToolsListResult, decodeJsonRpcMessageFromJson, decodeJsonRpcResponse, decodeJsonRpcResponseFromJson, decodeToolCallResult, decodeToolsListResult, encodeJsonRpcMessage, jsonRpcErrorToMcpError, latestMcpProtocolVersion, makeInitializeParams, makeInitializedNotification, makeJsonRpcRequest, mcpToolToToolDef, sanitizeMcpName, toolCallResultToToolResult } from "./protocol.mjs";
|
|
4
|
+
import { callLocalMcpServerTool, callMcpServerTool, callRemoteMcpServerTool, listLocalMcpServerTools, listMcpServerTools, listMcpTools, listRemoteMcpServerTools } from "./client.mjs";
|
|
5
|
+
export { GenericContentBlock, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse, McpError, McpErrorCause, McpTool, TextContentBlock, ToolCallResult, ToolsListResult, callLocalMcpServerTool, callMcpServerTool, callRemoteMcpServerTool, decodeJsonRpcMessageFromJson, decodeJsonRpcResponse, decodeJsonRpcResponseFromJson, decodeToolCallResult, decodeToolsListResult, defaultMcpClientInfo, defaultMcpSecurityPolicy, encodeJsonRpcMessage, jsonRpcErrorToMcpError, latestMcpProtocolVersion, listLocalMcpServerTools, listMcpServerTools, listMcpTools, listRemoteMcpServerTools, makeInitializeParams, makeInitializedNotification, makeJsonRpcRequest, mcpToolToToolDef, sanitizeMcpName, toolCallResultToToolResult };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { McpLocalServerConfig, McpServerConfig } from "./config.mjs";
|
|
2
|
+
import { McpError } from "./errors.mjs";
|
|
3
|
+
import { CallMcpServerToolInput, McpClientOptions, McpResolvedTool } from "./client.mjs";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
|
|
6
|
+
//#region src/client/node.d.ts
|
|
7
|
+
declare const listLocalMcpServerToolsNode: (config: McpLocalServerConfig, options?: McpClientOptions) => Effect.Effect<readonly McpResolvedTool[], McpError, never>;
|
|
8
|
+
declare const listMcpServerToolsNode: (config: McpServerConfig, options?: McpClientOptions) => Effect.Effect<readonly McpResolvedTool[], McpError, import("effect/unstable/http/HttpClient").HttpClient>;
|
|
9
|
+
declare const listMcpToolsNode: (configs: ReadonlyArray<McpServerConfig>, options?: McpClientOptions) => Effect.Effect<McpResolvedTool[], McpError, import("effect/unstable/http/HttpClient").HttpClient>;
|
|
10
|
+
declare const callLocalMcpServerToolNode: (input: Omit<CallMcpServerToolInput, "config"> & {
|
|
11
|
+
readonly config: McpLocalServerConfig;
|
|
12
|
+
}) => Effect.Effect<import("@yolk-sdk/agent/protocol").ToolResult, McpError, never>;
|
|
13
|
+
declare const callMcpServerToolNode: (input: CallMcpServerToolInput) => Effect.Effect<import("@yolk-sdk/agent/protocol").ToolResult, McpError, import("effect/unstable/http/HttpClient").HttpClient>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { callLocalMcpServerToolNode, callMcpServerToolNode, listLocalMcpServerToolsNode, listMcpServerToolsNode, listMcpToolsNode };
|
|
16
|
+
//# sourceMappingURL=node.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.mts","names":[],"sources":["../../src/client/node.ts"],"mappings":";;;;;;cAaa,2BAAA,GACX,MAAA,EAAQ,oBAAA,EACR,OAAA,GAAU,gBAAA,KAAgB,MAAA,CAAA,MAAA,UAAA,eAAA,IAAA,QAAA;AAAA,cAGf,sBAAA,GAA0B,MAAA,EAAQ,eAAA,EAAiB,OAAA,GAAU,gBAAA,KAAgB,MAAA,CAAA,MAAA,UAAA,eAAA,IAAA,QAAA,4CAAA,UAAA;AAAA,cAG7E,gBAAA,GACX,OAAA,EAAS,aAAA,CAAc,eAAA,GACvB,OAAA,GAAU,gBAAA,KAAgB,MAAA,CAAA,MAAA,CAAA,eAAA,IAAA,QAAA,4CAAA,UAAA;AAAA,cAGf,0BAAA,GACX,KAAA,EAAO,IAAA,CAAK,sBAAA;EAAA,SAA+C,MAAA,EAAQ,oBAAA;AAAA,MAAsB,MAAA,CAAA,MAAA,oCAAA,UAAA,EAAF,QAAA;AAAA,cAG5E,qBAAA,GAAyB,KAAA,EAAO,sBAAA,KAAsB,MAAA,CAAA,MAAA,oCAAA,UAAA,EAAA,QAAA,4CAAA,UAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { callLocalMcpServerTool, callMcpServerTool, listLocalMcpServerTools, listMcpServerTools, listMcpTools } from "./client.mjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { NodeServices } from "@effect/platform-node";
|
|
4
|
+
//#region src/client/node.ts
|
|
5
|
+
const listLocalMcpServerToolsNode = (config, options) => listLocalMcpServerTools(config, options).pipe(Effect.provide(NodeServices.layer));
|
|
6
|
+
const listMcpServerToolsNode = (config, options) => listMcpServerTools(config, options).pipe(Effect.provide(NodeServices.layer));
|
|
7
|
+
const listMcpToolsNode = (configs, options) => listMcpTools(configs, options).pipe(Effect.provide(NodeServices.layer));
|
|
8
|
+
const callLocalMcpServerToolNode = (input) => callLocalMcpServerTool(input).pipe(Effect.provide(NodeServices.layer));
|
|
9
|
+
const callMcpServerToolNode = (input) => callMcpServerTool(input).pipe(Effect.provide(NodeServices.layer));
|
|
10
|
+
//#endregion
|
|
11
|
+
export { callLocalMcpServerToolNode, callMcpServerToolNode, listLocalMcpServerToolsNode, listMcpServerToolsNode, listMcpToolsNode };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.mjs","names":[],"sources":["../../src/client/node.ts"],"sourcesContent":["import { Effect } from 'effect'\nimport { NodeServices } from '@effect/platform-node'\nimport type { McpLocalServerConfig, McpServerConfig } from './config.ts'\nimport {\n callLocalMcpServerTool,\n callMcpServerTool,\n listLocalMcpServerTools,\n listMcpServerTools,\n listMcpTools,\n type CallMcpServerToolInput,\n type McpClientOptions\n} from './client.ts'\n\nexport const listLocalMcpServerToolsNode = (\n config: McpLocalServerConfig,\n options?: McpClientOptions\n) => listLocalMcpServerTools(config, options).pipe(Effect.provide(NodeServices.layer))\n\nexport const listMcpServerToolsNode = (config: McpServerConfig, options?: McpClientOptions) =>\n listMcpServerTools(config, options).pipe(Effect.provide(NodeServices.layer))\n\nexport const listMcpToolsNode = (\n configs: ReadonlyArray<McpServerConfig>,\n options?: McpClientOptions\n) => listMcpTools(configs, options).pipe(Effect.provide(NodeServices.layer))\n\nexport const callLocalMcpServerToolNode = (\n input: Omit<CallMcpServerToolInput, 'config'> & { readonly config: McpLocalServerConfig }\n) => callLocalMcpServerTool(input).pipe(Effect.provide(NodeServices.layer))\n\nexport const callMcpServerToolNode = (input: CallMcpServerToolInput) =>\n callMcpServerTool(input).pipe(Effect.provide(NodeServices.layer))\n"],"mappings":";;;;AAaA,MAAa,+BACX,QACA,YACG,wBAAwB,QAAQ,OAAO,EAAE,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAErF,MAAa,0BAA0B,QAAyB,YAC9D,mBAAmB,QAAQ,OAAO,EAAE,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE7E,MAAa,oBACX,SACA,YACG,aAAa,SAAS,OAAO,EAAE,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE3E,MAAa,8BACX,UACG,uBAAuB,KAAK,EAAE,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC;AAE1E,MAAa,yBAAyB,UACpC,kBAAkB,KAAK,EAAE,KAAK,OAAO,QAAQ,aAAa,KAAK,CAAC"}
|