@smthrs/mcp 0.0.0-stage → 1.0.0-rc.3
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/CHANGELOG.md +121 -0
- package/LICENSE +21 -0
- package/README.md +111 -2
- package/dist/cjs/Diagnostics.d.ts +46 -0
- package/dist/cjs/Diagnostics.d.ts.map +1 -0
- package/dist/cjs/Diagnostics.js +29 -0
- package/dist/cjs/Diagnostics.js.map +7 -0
- package/dist/cjs/McpClient.d.ts +304 -0
- package/dist/cjs/McpClient.d.ts.map +1 -0
- package/dist/cjs/McpClient.js +622 -0
- package/dist/cjs/McpClient.js.map +7 -0
- package/dist/cjs/McpError.d.ts +44 -0
- package/dist/cjs/McpError.d.ts.map +1 -0
- package/dist/cjs/McpError.js +41 -0
- package/dist/cjs/McpError.js.map +7 -0
- package/dist/cjs/McpFlows.d.ts +112 -0
- package/dist/cjs/McpFlows.d.ts.map +1 -0
- package/dist/cjs/McpFlows.js +127 -0
- package/dist/cjs/McpFlows.js.map +7 -0
- package/dist/cjs/index.d.ts +39 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/DiagnosticReporter.d.ts +17 -0
- package/dist/cjs/internal/DiagnosticReporter.d.ts.map +1 -0
- package/dist/cjs/internal/DiagnosticReporter.js +56 -0
- package/dist/cjs/internal/DiagnosticReporter.js.map +7 -0
- package/dist/cjs/internal/HttpTransport.d.ts +67 -0
- package/dist/cjs/internal/HttpTransport.d.ts.map +1 -0
- package/dist/cjs/internal/HttpTransport.js +298 -0
- package/dist/cjs/internal/HttpTransport.js.map +7 -0
- package/dist/cjs/internal/JsonLimits.d.ts +29 -0
- package/dist/cjs/internal/JsonLimits.d.ts.map +1 -0
- package/dist/cjs/internal/JsonLimits.js +51 -0
- package/dist/cjs/internal/JsonLimits.js.map +7 -0
- package/dist/cjs/internal/Limits.d.ts +36 -0
- package/dist/cjs/internal/Limits.d.ts.map +1 -0
- package/dist/cjs/internal/Limits.js +34 -0
- package/dist/cjs/internal/Limits.js.map +7 -0
- package/dist/cjs/internal/Rpc.d.ts +141 -0
- package/dist/cjs/internal/Rpc.d.ts.map +1 -0
- package/dist/cjs/internal/Rpc.js +92 -0
- package/dist/cjs/internal/Rpc.js.map +7 -0
- package/dist/cjs/internal/StdioTransport.d.ts +78 -0
- package/dist/cjs/internal/StdioTransport.d.ts.map +1 -0
- package/dist/cjs/internal/StdioTransport.js +310 -0
- package/dist/cjs/internal/StdioTransport.js.map +7 -0
- package/dist/cjs/internal/Transport.d.ts +87 -0
- package/dist/cjs/internal/Transport.d.ts.map +1 -0
- package/dist/cjs/internal/Transport.js +116 -0
- package/dist/cjs/internal/Transport.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Diagnostics.d.ts +46 -0
- package/dist/esm/Diagnostics.d.ts.map +1 -0
- package/dist/esm/Diagnostics.js +26 -0
- package/dist/esm/Diagnostics.js.map +1 -0
- package/dist/esm/McpClient.d.ts +304 -0
- package/dist/esm/McpClient.d.ts.map +1 -0
- package/dist/esm/McpClient.js +671 -0
- package/dist/esm/McpClient.js.map +1 -0
- package/dist/esm/McpError.d.ts +44 -0
- package/dist/esm/McpError.d.ts.map +1 -0
- package/dist/esm/McpError.js +43 -0
- package/dist/esm/McpError.js.map +1 -0
- package/dist/esm/McpFlows.d.ts +112 -0
- package/dist/esm/McpFlows.d.ts.map +1 -0
- package/dist/esm/McpFlows.js +167 -0
- package/dist/esm/McpFlows.js.map +1 -0
- package/dist/esm/index.d.ts +39 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +39 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/DiagnosticReporter.d.ts +17 -0
- package/dist/esm/internal/DiagnosticReporter.d.ts.map +1 -0
- package/dist/esm/internal/DiagnosticReporter.js +44 -0
- package/dist/esm/internal/DiagnosticReporter.js.map +1 -0
- package/dist/esm/internal/HttpTransport.d.ts +67 -0
- package/dist/esm/internal/HttpTransport.d.ts.map +1 -0
- package/dist/esm/internal/HttpTransport.js +266 -0
- package/dist/esm/internal/HttpTransport.js.map +1 -0
- package/dist/esm/internal/JsonLimits.d.ts +29 -0
- package/dist/esm/internal/JsonLimits.d.ts.map +1 -0
- package/dist/esm/internal/JsonLimits.js +55 -0
- package/dist/esm/internal/JsonLimits.js.map +1 -0
- package/dist/esm/internal/Limits.d.ts +36 -0
- package/dist/esm/internal/Limits.d.ts.map +1 -0
- package/dist/esm/internal/Limits.js +41 -0
- package/dist/esm/internal/Limits.js.map +1 -0
- package/dist/esm/internal/Rpc.d.ts +141 -0
- package/dist/esm/internal/Rpc.d.ts.map +1 -0
- package/dist/esm/internal/Rpc.js +129 -0
- package/dist/esm/internal/Rpc.js.map +1 -0
- package/dist/esm/internal/StdioTransport.d.ts +78 -0
- package/dist/esm/internal/StdioTransport.d.ts.map +1 -0
- package/dist/esm/internal/StdioTransport.js +332 -0
- package/dist/esm/internal/StdioTransport.js.map +1 -0
- package/dist/esm/internal/Transport.d.ts +87 -0
- package/dist/esm/internal/Transport.d.ts.map +1 -0
- package/dist/esm/internal/Transport.js +146 -0
- package/dist/esm/internal/Transport.js.map +1 -0
- package/docs/README.md +139 -0
- package/docs/api.md +469 -0
- package/docs/concepts/the-session.md +135 -0
- package/docs/concepts/tools-as-flows.md +116 -0
- package/docs/guides/bound-an-untrusted-server.md +158 -0
- package/docs/guides/configure-servers-for-the-cli.md +167 -0
- package/docs/guides/connect-a-server.md +161 -0
- package/docs/guides/grant-authority-to-mcp-tools.md +130 -0
- package/docs/guides/handle-a-failed-tool-call.md +125 -0
- package/docs/guides/select-the-tools-a-run-sees.md +92 -0
- package/docs/guides/testing.md +132 -0
- package/docs/guides/validate-structured-output.md +103 -0
- package/docs/installation.md +117 -0
- package/docs/quickstart.md +200 -0
- package/docs/troubleshooting.md +316 -0
- package/package.json +157 -3
- package/src/Diagnostics.ts +47 -0
- package/src/McpClient.ts +985 -0
- package/src/McpError.ts +52 -0
- package/src/McpFlows.ts +210 -0
- package/src/index.ts +42 -0
- package/src/internal/DiagnosticReporter.ts +47 -0
- package/src/internal/HttpTransport.ts +400 -0
- package/src/internal/JsonLimits.ts +53 -0
- package/src/internal/Limits.ts +48 -0
- package/src/internal/Rpc.ts +219 -0
- package/src/internal/StdioTransport.ts +491 -0
- package/src/internal/Transport.ts +178 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# @smthrs/mcp
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Enforce a fixed 128-container JSON nesting limit, including the wire envelope,
|
|
8
|
+
before recursive consumers; reject incoming numeric overflow. Bound argument
|
|
9
|
+
expansion before copying shared-reference trees, require an object argument
|
|
10
|
+
root, and reject unsafe-integer limit options. Violations are typed failures.
|
|
11
|
+
- Deep-freeze the public catalog and schemas so caller edits cannot change
|
|
12
|
+
subsequent tool dispatch or validation. Copy them before making local edits.
|
|
13
|
+
- **Breaking error prose:** session errors no longer echo child stderr, spawn
|
|
14
|
+
details, remote error text/data, invalid protocol versions, duplicate tool
|
|
15
|
+
names, cursors, or argument/result property paths. Stable `McpError` codes and
|
|
16
|
+
remote numeric error codes remain available. Successful tool output is unchanged.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Optional `Diagnostics.layer(report)` for trusted local host inspection.
|
|
21
|
+
Details are bounded to 16 KiB UTF-8 and wrapped in `Redacted`; JSON/log
|
|
22
|
+
inspection does not expose them. No implicit raw logging, and callback
|
|
23
|
+
failures cannot fail the connection. Hosts own access, retention, and any
|
|
24
|
+
explicit unwrapping.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Stderr diagnostics are redacted one complete line at a time before the
|
|
29
|
+
`maxStderrBytes` cap. Capping raw bytes first could cut a credential's
|
|
30
|
+
recognizable prefix and hand its remainder to the private diagnostic observer
|
|
31
|
+
unredacted. A stderr line longer than 64 KiB is withheld whole.
|
|
32
|
+
|
|
33
|
+
- Distinguish inbound server requests from notifications. Reply to `ping` with
|
|
34
|
+
an empty result and unsupported methods with `-32601`, preserving exact ids
|
|
35
|
+
independently of active client requests. Server responses obey the outbound
|
|
36
|
+
frame, queue, and admission-deadline bounds.
|
|
37
|
+
- Keep a timed-out request's cancellation notification best-effort, dropping
|
|
38
|
+
it when the bounded outbound queue is full instead of blocking past the
|
|
39
|
+
deadline it reports.
|
|
40
|
+
- Snapshot tool arguments through guarded property descriptors. Accessors are
|
|
41
|
+
never invoked, proxy reflection failures remain typed `McpError` failures,
|
|
42
|
+
and non-enumerable properties are omitted like `JSON.stringify`.
|
|
43
|
+
- Point the package README at mcp.smithers.sh. The Markdown files under
|
|
44
|
+
`docs/` stay out of the published tarball.
|
|
45
|
+
- Require every tool `inputSchema` to declare `type: "object"`, and reject C1
|
|
46
|
+
control characters in tool names alongside C0 controls and U+007F.
|
|
47
|
+
- Drop stdout that does not claim JSON-RPC as server log noise, while closing
|
|
48
|
+
the connection when a tagged envelope has the wrong version or is missing a
|
|
49
|
+
reply id.
|
|
50
|
+
- Map a server's explicit `-32601` or `-32602` unknown-tool rejection to
|
|
51
|
+
`tool_not_found` while retaining `tool_failed` for ordinary tool failures.
|
|
52
|
+
- Validate `structuredContent` against the tool's declared `outputSchema` for
|
|
53
|
+
the supported `type`, `required`, `properties`, `items`, and `enum` subset,
|
|
54
|
+
and accept structured-only results with an empty `content` array.
|
|
55
|
+
- Freeze the exported client identity and supported protocol revision list so
|
|
56
|
+
consumers cannot mutate later initialization frames.
|
|
57
|
+
|
|
58
|
+
## [1.0.0-rc.0] - 2026-09-01
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- Added `@smthrs/mcp`: a stdio MCP client (`McpClient`) and a
|
|
63
|
+
`FlowBinding.Source` projector (`McpFlows`) that turns a connected server's
|
|
64
|
+
tool catalog into one flow per tool, so an MCP tool call is an ordinary flow
|
|
65
|
+
call with no second registration path alongside `@smthrs/std`'s filesystem and
|
|
66
|
+
shell flows.
|
|
67
|
+
- Added negotiation of the `initialize` result: the server's `protocolVersion`
|
|
68
|
+
must be one this client decodes and its `capabilities.tools` must be present
|
|
69
|
+
before the handshake completes.
|
|
70
|
+
- Added `tools/list` pagination, following `nextCursor` across pages under a
|
|
71
|
+
page cap, with duplicate names rejected across the whole catalog.
|
|
72
|
+
- Added bounds on what an untrusted server can size: `maxTools`,
|
|
73
|
+
`maxToolNameBytes`, `maxCatalogPages`, `maxOutboundFrameBytes`, and
|
|
74
|
+
`maxStderrBytes`, each with an exported default constant.
|
|
75
|
+
- Added `include`, `exclude`, and `namePrefix` projection options so a host
|
|
76
|
+
chooses which of a server's tools reach the model and under what names.
|
|
77
|
+
- Added `notifications/cancelled` for a timed-out or interrupted `tools/call`,
|
|
78
|
+
so remote work declared `irreversible` is not abandoned mid-flight.
|
|
79
|
+
- Added pass-through of MCP 2025-06-18 structured tool output: a tool's
|
|
80
|
+
`outputSchema` on `ToolDescription` and `structuredContent` on `ToolResult`
|
|
81
|
+
and on the flow's own `Result` schema.
|
|
82
|
+
- Added package-owned documentation under `docs/`, generated into
|
|
83
|
+
`docs/reference.md` by `scripts/docs.mjs`.
|
|
84
|
+
|
|
85
|
+
### Changed
|
|
86
|
+
|
|
87
|
+
- Declare authority as one exact `namespace:operation:resource` string per
|
|
88
|
+
`Capability.Action`, derived from `Capability.Action.literals` and frozen. The
|
|
89
|
+
bare `"*"` this module used to declare parsed as nothing, and an unparseable
|
|
90
|
+
declaration is treated as unauthorized, so every MCP tool was refused with
|
|
91
|
+
`capability_refused` before it ran even under an unrestricted envelope.
|
|
92
|
+
- Close the stdio transport without racing a separate terminal signal.
|
|
93
|
+
- Identify to remote servers as `smithers` at this package's version rather than
|
|
94
|
+
as `flows` at `0.1.0`.
|
|
95
|
+
- Drain the child's stderr into a bounded tail and append it to `spawn_failed`,
|
|
96
|
+
`timeout`, and `connection_closed` messages, so a startup failure explains
|
|
97
|
+
itself instead of surfacing as an unexplained handshake deadline.
|
|
98
|
+
|
|
99
|
+
### Fixed
|
|
100
|
+
|
|
101
|
+
- Merge `env` into the inherited child environment instead of replacing it. A
|
|
102
|
+
server spawned with a credential received no `PATH`, so the canonical
|
|
103
|
+
`{ command: "npx", env: { TOKEN } }` entry failed to spawn at all.
|
|
104
|
+
- Validate every JSON-RPC envelope before correlating it: a reply must carry a
|
|
105
|
+
valid id and exactly one of `result` or `error`, and an error must carry an
|
|
106
|
+
integer code and a string message. An `error: null` reply used to kill the
|
|
107
|
+
reader fiber and hang every pending request until its deadline.
|
|
108
|
+
- Map a JSON-RPC error by the method that failed, keeping the numeric code in
|
|
109
|
+
the message, instead of reporting every failure as `tool_failed`.
|
|
110
|
+
- Decode `tools/list` and `tools/call` payloads instead of casting them. A
|
|
111
|
+
`null` catalog entry used to throw a `TypeError` out of the declared error
|
|
112
|
+
channel, a non-object content block used to surface as a flow-authored schema
|
|
113
|
+
failure that named no server, and a missing `inputSchema` used to be
|
|
114
|
+
fabricated rather than rejected.
|
|
115
|
+
- Reject duplicate tool names at the adapter. A server that repeated a name used
|
|
116
|
+
to fail the host's entire flow catalog, including flows unrelated to MCP.
|
|
117
|
+
- Snapshot tool arguments to plain JSON before a request id is registered, so a
|
|
118
|
+
getter, a proxy, a cycle, or a non-finite number fails with a typed error and
|
|
119
|
+
a bounded path instead of a defect.
|
|
120
|
+
- Bound the `notifications/initialized` step by `handshakeTimeoutMs` rather than
|
|
121
|
+
by the 120 second tool-call deadline.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 William Cory and the Smithers Flows 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
CHANGED
|
@@ -1,3 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @smthrs/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Release candidate scope, host requirements and compatibility review are defined in the [library support policy](https://github.com/smithersai/smithers/blob/main/RELEASE_SUPPORT.md).
|
|
4
|
+
|
|
5
|
+
This package declares `effect` as an exact
|
|
6
|
+
`4.0.0-rc.115` peer dependency. Keep the application on that version so
|
|
7
|
+
all Smithers packages share one Effect runtime.
|
|
8
|
+
|
|
9
|
+
**Documentation:** https://mcp.smithers.sh
|
|
10
|
+
|
|
11
|
+
Model Context Protocol client and flow adapter for Smithers.
|
|
12
|
+
|
|
13
|
+
`@smthrs/mcp` connects to an MCP server over stdio or Streamable HTTP and projects the tools that
|
|
14
|
+
server offers as flows a Smithers agent can call. `McpClient` speaks the
|
|
15
|
+
protocol: the `initialize` handshake, `tools/list`, and `tools/call`.
|
|
16
|
+
`McpFlows` turns the resulting catalog into one `FlowBinding.Binding` per tool,
|
|
17
|
+
so a cell calls a remote tool with the same two lines it uses for a filesystem
|
|
18
|
+
flow, and nothing downstream needs to know the difference.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
`@smthrs/mcp` is not published to npm yet. Its source is on
|
|
23
|
+
[GitHub](https://github.com/smithersai/smithers).
|
|
24
|
+
|
|
25
|
+
It needs Node.js 26.4.0 or later, [`effect`](https://effect.website), and a
|
|
26
|
+
`ChildProcessSpawner`, which `@effect/platform-node` provides on Node. Not on npm yet; see [Installation](https://github.com/smithersai/smithers/blob/main/packages/smithers/flows/flow/docs/installation.md#use-the-libraries).
|
|
27
|
+
|
|
28
|
+
## Connect a server and read its flows
|
|
29
|
+
|
|
30
|
+
Install a reviewed server version and its dependencies before supplying any
|
|
31
|
+
credentials. This example pins the deprecated GitHub server to `2025.4.8`;
|
|
32
|
+
review it for your use before running it. Use a dedicated directory, review and
|
|
33
|
+
retain `package.json` and `package-lock.json`, then install from that lockfile:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
mkdir -p /path/to/mcp-servers
|
|
37
|
+
env -u GITHUB_TOKEN -u GITHUB_PERSONAL_ACCESS_TOKEN npm install --prefix /path/to/mcp-servers --package-lock-only --ignore-scripts --save-exact @modelcontextprotocol/server-github@2025.4.8
|
|
38
|
+
# Review the pinned package and lockfile before installing.
|
|
39
|
+
env -u GITHUB_TOKEN -u GITHUB_PERSONAL_ACCESS_TOKEN npm ci --prefix /path/to/mcp-servers --ignore-scripts
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Both npm commands remove the GitHub credential variables from their environment.
|
|
43
|
+
Launch the installed executable directly and supply the token only in the
|
|
44
|
+
server's `env`. This server reads `GITHUB_PERSONAL_ACCESS_TOKEN`.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { NodeServices } from "@effect/platform-node"
|
|
48
|
+
import * as McpFlows from "@smthrs/mcp/McpFlows"
|
|
49
|
+
import { Effect } from "effect"
|
|
50
|
+
|
|
51
|
+
const program = Effect.scoped(Effect.gen(function*() {
|
|
52
|
+
const source = yield* McpFlows.connected({
|
|
53
|
+
server: "github",
|
|
54
|
+
command: "/path/to/mcp-servers/node_modules/.bin/mcp-server-github",
|
|
55
|
+
args: [],
|
|
56
|
+
env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_TOKEN },
|
|
57
|
+
include: ["create_issue", "get_issue", "list_issues"]
|
|
58
|
+
})
|
|
59
|
+
const bindings = yield* source.bindings()
|
|
60
|
+
return bindings.map((binding) => binding.descriptor.name)
|
|
61
|
+
}))
|
|
62
|
+
|
|
63
|
+
// [ "mcp/github/create_issue", "mcp/github/get_issue", "mcp/github/list_issues" ]
|
|
64
|
+
console.log(await Effect.runPromise(Effect.provide(program, NodeServices.layer)))
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Each tool becomes a flow named `mcp/<server>/<tool>`. The connection's lifetime
|
|
68
|
+
is the scope's lifetime. The child inherits `PATH`, `HOME`, `USER`, `LANG`,
|
|
69
|
+
`LC_*`, `TERM`, `TMPDIR`, and `SHELL`; `env` explicitly adds or replaces names.
|
|
70
|
+
Other ambient variables, including provider credentials, are withheld.
|
|
71
|
+
|
|
72
|
+
Catalog tools must declare `inputSchema.type: "object"`. Structured-only tool
|
|
73
|
+
results are accepted with `content: []`, and declared `outputSchema` documents
|
|
74
|
+
are enforced for the supported keyword subset.
|
|
75
|
+
|
|
76
|
+
Session errors withhold raw child stderr, remote error text/data, and property
|
|
77
|
+
paths. An optional host-only [Diagnostics observer](https://mcp.smithers.sh/reference/api/#diagnostics)
|
|
78
|
+
provides credential-redacted `Redacted` details for explicit local inspection,
|
|
79
|
+
with child stderr bounded by `maxStderrBytes` (2048 by default). Successful tool
|
|
80
|
+
outputs, including `isError: true`, are returned unchanged.
|
|
81
|
+
|
|
82
|
+
Every projected flow declares the widest authority the capability vocabulary
|
|
83
|
+
can express, because an MCP tool is opaque code this package does not control.
|
|
84
|
+
Narrowing that declaration to what you actually grant a server is the host's
|
|
85
|
+
step, and the one thing standing between a projected source and a cell that can
|
|
86
|
+
call it.
|
|
87
|
+
|
|
88
|
+
This is the client half of Smithers and MCP: a Smithers run calling somebody
|
|
89
|
+
else's tools. The other half, an agent such as Claude Code driving Smithers, is
|
|
90
|
+
the Smithers MCP server behind `smthrs mcp`.
|
|
91
|
+
|
|
92
|
+
## Documentation
|
|
93
|
+
|
|
94
|
+
Full documentation is at [mcp.smithers.sh](https://mcp.smithers.sh):
|
|
95
|
+
|
|
96
|
+
- [Quickstart](https://mcp.smithers.sh/quickstart/): a real server in its own
|
|
97
|
+
process, two tool calls, and the flows they project.
|
|
98
|
+
- [A remote tool as a flow](https://mcp.smithers.sh/concepts/tools-as-flows/):
|
|
99
|
+
what the projection produces, and why nothing downstream knows the flow is
|
|
100
|
+
remote.
|
|
101
|
+
- [Grant authority to MCP tools](https://mcp.smithers.sh/guides/grant-authority-to-mcp-tools/):
|
|
102
|
+
the step between a projected source and a cell that can call it.
|
|
103
|
+
- [Configure servers for the CLI](https://mcp.smithers.sh/guides/configure-servers-for-the-cli/):
|
|
104
|
+
the `--mcp-config` file the `smthrs` command line reads.
|
|
105
|
+
- [API reference](https://mcp.smithers.sh/reference/api/): every public export
|
|
106
|
+
of `Diagnostics`, `McpClient`, `McpError`, and `McpFlows`.
|
|
107
|
+
- [Troubleshooting](https://mcp.smithers.sh/troubleshooting/): every failure
|
|
108
|
+
this package reports, with its cause and fix.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
MIT. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only access to untrusted MCP diagnostics, separate from model-facing
|
|
3
|
+
* errors. Merely logging or JSON-encoding an event cannot expose its detail.
|
|
4
|
+
*
|
|
5
|
+
* @since 1.0.0-rc.0
|
|
6
|
+
*/
|
|
7
|
+
import { Context, Layer } from "effect";
|
|
8
|
+
import type { Redacted } from "effect";
|
|
9
|
+
/**
|
|
10
|
+
* One bounded diagnostic from a connection. Detail can contain credentials,
|
|
11
|
+
* private tool arguments, or arbitrary server text. Only an explicitly trusted
|
|
12
|
+
* local host should unwrap it; never forward it to agents, journals, or logs.
|
|
13
|
+
*
|
|
14
|
+
* @category models
|
|
15
|
+
* @since 1.0.0-rc.0
|
|
16
|
+
*/
|
|
17
|
+
export interface Event {
|
|
18
|
+
readonly server: string;
|
|
19
|
+
readonly source: "spawn" | "stderr" | "transport" | "remote-error" | "invalid-response" | "invalid-arguments";
|
|
20
|
+
/** At most 16 KiB of UTF-8 text; never the original unbounded value. */
|
|
21
|
+
readonly detail: Redacted.Redacted<string>;
|
|
22
|
+
readonly truncated: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare const Diagnostics_base: Context.ServiceClass<Diagnostics, "@smthrs/mcp/Diagnostics", {
|
|
25
|
+
readonly report: (event: Event) => void;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Optional diagnostic observer, captured when a connection is opened. The
|
|
29
|
+
* synchronous callback must not block; throws are isolated from the protocol.
|
|
30
|
+
* Absent this service, raw diagnostics are discarded, not logged implicitly.
|
|
31
|
+
*
|
|
32
|
+
* @category services
|
|
33
|
+
* @since 1.0.0-rc.0
|
|
34
|
+
*/
|
|
35
|
+
export declare class Diagnostics extends Diagnostics_base {
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Installs a trusted host observer. Inspecting detail requires an explicit
|
|
39
|
+
* `Redacted.value` call and responsibility for its destination and retention.
|
|
40
|
+
*
|
|
41
|
+
* @category layers
|
|
42
|
+
* @since 1.0.0-rc.0
|
|
43
|
+
*/
|
|
44
|
+
export declare const layer: (report: (event: Event) => void) => Layer.Layer<Diagnostics>;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=Diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Diagnostics.d.ts","sourceRoot":"","sources":["../../src/Diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;IAC7G,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC1C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAC5B;;qBAWkB,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;AATzC;;;;;;;GAOG;AACH,qBAAa,WAAY,SAAQ,gBAEF;CAAG;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CACtC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Diagnostics_exports = {};
|
|
20
|
+
__export(Diagnostics_exports, {
|
|
21
|
+
Diagnostics: () => Diagnostics,
|
|
22
|
+
layer: () => layer
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Diagnostics_exports);
|
|
25
|
+
var import_effect = require("effect");
|
|
26
|
+
class Diagnostics extends import_effect.Context.Service()("@smthrs/mcp/Diagnostics") {
|
|
27
|
+
}
|
|
28
|
+
const layer = (report) => import_effect.Layer.succeed(Diagnostics)({ report });
|
|
29
|
+
//# sourceMappingURL=Diagnostics.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/Diagnostics.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Host-only access to untrusted MCP diagnostics, separate from model-facing\n * errors. Merely logging or JSON-encoding an event cannot expose its detail.\n *\n * @since 1.0.0-rc.0\n */\n\nimport { Context, Layer } from \"effect\"\nimport type { Redacted } from \"effect\"\n\n/**\n * One bounded diagnostic from a connection. Detail can contain credentials,\n * private tool arguments, or arbitrary server text. Only an explicitly trusted\n * local host should unwrap it; never forward it to agents, journals, or logs.\n *\n * @category models\n * @since 1.0.0-rc.0\n */\nexport interface Event {\n readonly server: string\n readonly source: \"spawn\" | \"stderr\" | \"transport\" | \"remote-error\" | \"invalid-response\" | \"invalid-arguments\"\n /** At most 16 KiB of UTF-8 text; never the original unbounded value. */\n readonly detail: Redacted.Redacted<string>\n readonly truncated: boolean\n}\n\n/**\n * Optional diagnostic observer, captured when a connection is opened. The\n * synchronous callback must not block; throws are isolated from the protocol.\n * Absent this service, raw diagnostics are discarded, not logged implicitly.\n *\n * @category services\n * @since 1.0.0-rc.0\n */\nexport class Diagnostics extends Context.Service<Diagnostics, {\n readonly report: (event: Event) => void\n}>()(\"@smthrs/mcp/Diagnostics\") {}\n\n/**\n * Installs a trusted host observer. Inspecting detail requires an explicit\n * `Redacted.value` call and responsibility for its destination and retention.\n *\n * @category layers\n * @since 1.0.0-rc.0\n */\nexport const layer = (report: (event: Event) => void): Layer.Layer<Diagnostics> =>\n Layer.succeed(Diagnostics)({ report })\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAA+B;AA2BxB,MAAM,oBAAoB,sBAAQ,QAEtC,EAAE,yBAAyB,EAAE;AAAC;AAS1B,MAAM,QAAQ,CAAC,WACpB,oBAAM,QAAQ,WAAW,EAAE,EAAE,OAAO,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal MCP client covering the `initialize` handshake, `tools/list`, and
|
|
3
|
+
* `tools/call`, over stdio or Streamable HTTP.
|
|
4
|
+
*
|
|
5
|
+
* This is deliberately not a general MCP SDK. Smithers has exactly one
|
|
6
|
+
* consumer of an MCP session: {@link McpFlows}, which needs a tool catalog
|
|
7
|
+
* and a way to invoke one entry from it, so the client exposes only that.
|
|
8
|
+
* Resources, prompts, sampling, and roots are not wired up; add them here
|
|
9
|
+
* when a flow adapter needs them, not speculatively.
|
|
10
|
+
*
|
|
11
|
+
* @since 1.0.0-rc.0
|
|
12
|
+
*/
|
|
13
|
+
import { Effect, Schema, Scope } from "effect";
|
|
14
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
15
|
+
import type { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
16
|
+
import * as HttpTransport from "./internal/HttpTransport.ts";
|
|
17
|
+
import * as StdioTransport from "./internal/StdioTransport.ts";
|
|
18
|
+
import { McpError } from "./McpError.ts";
|
|
19
|
+
/**
|
|
20
|
+
* One remote tool as the server describes it.
|
|
21
|
+
*
|
|
22
|
+
* @category models
|
|
23
|
+
* @since 1.0.0-rc.0
|
|
24
|
+
*/
|
|
25
|
+
export interface ToolDescription {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly description: string | undefined;
|
|
28
|
+
/** The tool's parameter shape, as a JSON Schema document with `type: "object"`. */
|
|
29
|
+
readonly inputSchema: Record<string, unknown>;
|
|
30
|
+
/** The tool's structured result shape, when the server disclosed one. */
|
|
31
|
+
readonly outputSchema: Record<string, unknown> | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The result of one `tools/call`.
|
|
35
|
+
*
|
|
36
|
+
* MCP tool content is a small union (text, image, embedded resource, …); this
|
|
37
|
+
* client passes every block through by shape rather than modeling the union,
|
|
38
|
+
* since {@link McpFlows} only needs to hand the blocks back to the caller.
|
|
39
|
+
*
|
|
40
|
+
* @category models
|
|
41
|
+
* @since 1.0.0-rc.0
|
|
42
|
+
*/
|
|
43
|
+
export interface ToolResult {
|
|
44
|
+
readonly content: ReadonlyArray<Record<string, unknown>>;
|
|
45
|
+
readonly isError: boolean;
|
|
46
|
+
readonly structuredContent: Record<string, unknown> | undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A live MCP session, holding the tool catalog fetched at connect time and a
|
|
50
|
+
* way to call one of its entries.
|
|
51
|
+
*
|
|
52
|
+
* @category models
|
|
53
|
+
* @since 1.0.0-rc.0
|
|
54
|
+
*/
|
|
55
|
+
export interface McpClient {
|
|
56
|
+
readonly server: string;
|
|
57
|
+
readonly tools: ReadonlyArray<ToolDescription>;
|
|
58
|
+
/**
|
|
59
|
+
* Calls one catalogued tool. An unknown name fails with `tool_not_found`
|
|
60
|
+
* before a JSON-RPC frame is written. Declared structured output is checked
|
|
61
|
+
* against the supported output-schema subset before it is returned.
|
|
62
|
+
*/
|
|
63
|
+
readonly callTool: (name: string, args: Record<string, unknown>) => Effect.Effect<ToolResult, McpError>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Session and catalog limits shared by every transport.
|
|
67
|
+
*
|
|
68
|
+
* @category models
|
|
69
|
+
* @since 1.0.0-rc.1
|
|
70
|
+
*/
|
|
71
|
+
export interface ClientOptions {
|
|
72
|
+
/** The name this server is known by, for flow naming and error messages. */
|
|
73
|
+
readonly server: string;
|
|
74
|
+
/** Deadline for each initialize/catalog request. See {@link defaultHandshakeTimeoutMs}. */
|
|
75
|
+
readonly handshakeTimeoutMs?: number | undefined;
|
|
76
|
+
/** Maximum tools accepted across every catalog page. See {@link defaultMaxTools}. */
|
|
77
|
+
readonly maxTools?: number | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Maximum UTF-8 bytes in a tool name. Names also cannot be `.` or `..`, or
|
|
80
|
+
* contain `/`, a control or format character (Unicode categories Cc and Cf,
|
|
81
|
+
* which include bidi and zero-width marks), U+2028, U+2029, or a lone
|
|
82
|
+
* surrogate. See {@link defaultMaxToolNameBytes}.
|
|
83
|
+
*/
|
|
84
|
+
readonly maxToolNameBytes?: number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Maximum UTF-8 bytes of one tool's model-facing text: its description plus
|
|
87
|
+
* its JSON-encoded `inputSchema`. See {@link defaultMaxToolDocumentBytes}.
|
|
88
|
+
*/
|
|
89
|
+
readonly maxToolDocumentBytes?: number | undefined;
|
|
90
|
+
/** Maximum pages walked while fetching the catalog. See {@link defaultMaxCatalogPages}. */
|
|
91
|
+
readonly maxCatalogPages?: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* A server spawned as a child process and spoken to over its stdio.
|
|
95
|
+
*
|
|
96
|
+
* @category models
|
|
97
|
+
* @since 1.0.0-rc.1
|
|
98
|
+
*/
|
|
99
|
+
export interface StdioConnectOptions extends StdioTransport.ConnectOptions, ClientOptions {
|
|
100
|
+
readonly url?: never;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Supplies the bearer credential for a Streamable HTTP server. `token` runs
|
|
104
|
+
* once per HTTP message, so a provider can rotate the credential; its failure
|
|
105
|
+
* fails that message unchanged.
|
|
106
|
+
*
|
|
107
|
+
* @category models
|
|
108
|
+
* @since 1.0.0-rc.1
|
|
109
|
+
*/
|
|
110
|
+
export type AuthProvider = HttpTransport.AuthProvider;
|
|
111
|
+
/**
|
|
112
|
+
* A remote server reached over MCP Streamable HTTP through the `HttpClient`
|
|
113
|
+
* in context.
|
|
114
|
+
*
|
|
115
|
+
* @category models
|
|
116
|
+
* @since 1.0.0-rc.1
|
|
117
|
+
*/
|
|
118
|
+
export interface HttpConnectOptions extends HttpTransport.ConnectOptions, ClientOptions {
|
|
119
|
+
readonly command?: never;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Options accepted by {@link connect}: a stdio command or an HTTP `url`.
|
|
123
|
+
*
|
|
124
|
+
* @category models
|
|
125
|
+
* @since 1.0.0-rc.0
|
|
126
|
+
*/
|
|
127
|
+
export type ConnectOptions = StdioConnectOptions | HttpConnectOptions;
|
|
128
|
+
/**
|
|
129
|
+
* The services {@link connect} needs for the given options: a process spawner
|
|
130
|
+
* for stdio, an `HttpClient` for a `url`.
|
|
131
|
+
*
|
|
132
|
+
* @category models
|
|
133
|
+
* @since 1.0.0-rc.1
|
|
134
|
+
*/
|
|
135
|
+
export type Requirements<O extends ConnectOptions> = O extends {
|
|
136
|
+
readonly url: string;
|
|
137
|
+
} ? HttpClient.HttpClient : ChildProcessSpawner;
|
|
138
|
+
/**
|
|
139
|
+
* Authoritative decoder for a persisted stdio MCP server entry.
|
|
140
|
+
*
|
|
141
|
+
* The schema requires non-empty server and command names, string arguments,
|
|
142
|
+
* a plain string-valued environment record, and positive-integer limits.
|
|
143
|
+
*
|
|
144
|
+
* @category schemas
|
|
145
|
+
* @since 1.0.0-rc.0
|
|
146
|
+
*/
|
|
147
|
+
export declare const ConnectOptionsSchema: Schema.Struct<{
|
|
148
|
+
readonly server: Schema.NonEmptyString;
|
|
149
|
+
readonly command: Schema.NonEmptyString;
|
|
150
|
+
readonly args: Schema.$Array<Schema.String>;
|
|
151
|
+
readonly cwd: Schema.optional<Schema.NonEmptyString>;
|
|
152
|
+
readonly env: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
153
|
+
readonly handshakeTimeoutMs: Schema.optional<Schema.Int>;
|
|
154
|
+
readonly requestTimeoutMs: Schema.optional<Schema.Int>;
|
|
155
|
+
readonly queueCapacity: Schema.optional<Schema.Int>;
|
|
156
|
+
readonly maxFrameBytes: Schema.optional<Schema.Int>;
|
|
157
|
+
readonly maxOutboundFrameBytes: Schema.optional<Schema.Int>;
|
|
158
|
+
readonly maxStderrBytes: Schema.optional<Schema.Int>;
|
|
159
|
+
readonly maxTools: Schema.optional<Schema.Int>;
|
|
160
|
+
readonly maxToolNameBytes: Schema.optional<Schema.Int>;
|
|
161
|
+
readonly maxToolDocumentBytes: Schema.optional<Schema.Int>;
|
|
162
|
+
readonly maxCatalogPages: Schema.optional<Schema.Int>;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Authoritative decoder for a persisted Streamable HTTP MCP server entry.
|
|
166
|
+
*
|
|
167
|
+
* The schema requires a non-empty server name, an absolute `http:` or
|
|
168
|
+
* `https:` `url` without userinfo, and positive-integer limits. A bearer
|
|
169
|
+
* credential is never stored in the entry: `bearerTokenEnv` names the
|
|
170
|
+
* environment variable the host reads it from and turns into an
|
|
171
|
+
* {@link AuthProvider}.
|
|
172
|
+
*
|
|
173
|
+
* @category schemas
|
|
174
|
+
* @since 1.0.0-rc.1
|
|
175
|
+
*/
|
|
176
|
+
export declare const HttpConnectOptionsSchema: Schema.Struct<{
|
|
177
|
+
readonly server: Schema.NonEmptyString;
|
|
178
|
+
readonly url: Schema.String;
|
|
179
|
+
readonly bearerTokenEnv: Schema.optionalKey<Schema.String>;
|
|
180
|
+
readonly handshakeTimeoutMs: Schema.optional<Schema.Int>;
|
|
181
|
+
readonly requestTimeoutMs: Schema.optional<Schema.Int>;
|
|
182
|
+
readonly maxFrameBytes: Schema.optional<Schema.Int>;
|
|
183
|
+
readonly maxOutboundFrameBytes: Schema.optional<Schema.Int>;
|
|
184
|
+
readonly maxTools: Schema.optional<Schema.Int>;
|
|
185
|
+
readonly maxToolNameBytes: Schema.optional<Schema.Int>;
|
|
186
|
+
readonly maxToolDocumentBytes: Schema.optional<Schema.Int>;
|
|
187
|
+
readonly maxCatalogPages: Schema.optional<Schema.Int>;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Frozen identity disclosed to every MCP server during initialization.
|
|
191
|
+
*
|
|
192
|
+
* @category constants
|
|
193
|
+
* @since 1.0.0-rc.0
|
|
194
|
+
*/
|
|
195
|
+
export declare const clientInfo: {
|
|
196
|
+
readonly name: string;
|
|
197
|
+
readonly version: string;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* MCP revisions whose `tools/list` and `tools/call` shapes this client
|
|
201
|
+
* decodes. The frozen list always proposes `2025-06-18` first.
|
|
202
|
+
*
|
|
203
|
+
* @category constants
|
|
204
|
+
* @since 1.0.0-rc.0
|
|
205
|
+
*/
|
|
206
|
+
export declare const supportedProtocolVersions: ReadonlyArray<string>;
|
|
207
|
+
/**
|
|
208
|
+
* Default deadline for each MCP handshake request.
|
|
209
|
+
*
|
|
210
|
+
* @category constants
|
|
211
|
+
* @since 1.0.0-rc.0
|
|
212
|
+
*/
|
|
213
|
+
export declare const defaultHandshakeTimeoutMs = 10000;
|
|
214
|
+
/**
|
|
215
|
+
* Default deadline for each tool request.
|
|
216
|
+
*
|
|
217
|
+
* @category constants
|
|
218
|
+
* @since 1.0.0-rc.0
|
|
219
|
+
*/
|
|
220
|
+
export declare const defaultRequestTimeoutMs = 120000;
|
|
221
|
+
/**
|
|
222
|
+
* Default number of outbound frames allowed to wait in memory.
|
|
223
|
+
*
|
|
224
|
+
* @category constants
|
|
225
|
+
* @since 1.0.0-rc.0
|
|
226
|
+
*/
|
|
227
|
+
export declare const defaultQueueCapacity = 64;
|
|
228
|
+
/**
|
|
229
|
+
* Default maximum inbound JSON-RPC frame size.
|
|
230
|
+
*
|
|
231
|
+
* @category constants
|
|
232
|
+
* @since 1.0.0-rc.0
|
|
233
|
+
*/
|
|
234
|
+
export declare const defaultMaxFrameBytes: number;
|
|
235
|
+
/**
|
|
236
|
+
* Default maximum outbound JSON-RPC frame size.
|
|
237
|
+
*
|
|
238
|
+
* @category constants
|
|
239
|
+
* @since 1.0.0-rc.0
|
|
240
|
+
*/
|
|
241
|
+
export declare const defaultMaxOutboundFrameBytes: number;
|
|
242
|
+
/**
|
|
243
|
+
* Default maximum child-stderr tail retained for connection diagnostics.
|
|
244
|
+
*
|
|
245
|
+
* @category constants
|
|
246
|
+
* @since 1.0.0-rc.0
|
|
247
|
+
*/
|
|
248
|
+
export declare const defaultMaxStderrBytes = 2048;
|
|
249
|
+
/**
|
|
250
|
+
* Default maximum number of tools in a remote catalog.
|
|
251
|
+
*
|
|
252
|
+
* @category constants
|
|
253
|
+
* @since 1.0.0-rc.0
|
|
254
|
+
*/
|
|
255
|
+
export declare const defaultMaxTools = 256;
|
|
256
|
+
/**
|
|
257
|
+
* Default maximum UTF-8 byte length of one remote tool name.
|
|
258
|
+
*
|
|
259
|
+
* @category constants
|
|
260
|
+
* @since 1.0.0-rc.0
|
|
261
|
+
*/
|
|
262
|
+
export declare const defaultMaxToolNameBytes = 128;
|
|
263
|
+
/**
|
|
264
|
+
* Default maximum UTF-8 bytes of one tool's description plus its JSON-encoded
|
|
265
|
+
* `inputSchema`, the server-authored text a model reads for that tool.
|
|
266
|
+
*
|
|
267
|
+
* @category constants
|
|
268
|
+
* @since 1.0.0-rc.1
|
|
269
|
+
*/
|
|
270
|
+
export declare const defaultMaxToolDocumentBytes = 65536;
|
|
271
|
+
/**
|
|
272
|
+
* Default maximum number of remote catalog pages.
|
|
273
|
+
*
|
|
274
|
+
* @category constants
|
|
275
|
+
* @since 1.0.0-rc.0
|
|
276
|
+
*/
|
|
277
|
+
export declare const defaultMaxCatalogPages = 32;
|
|
278
|
+
/**
|
|
279
|
+
* Maximum nested JSON containers, including the JSON-RPC envelope. Fixed so
|
|
280
|
+
* accepted server schemas and values remain safe for recursive consumers.
|
|
281
|
+
*
|
|
282
|
+
* @category constants
|
|
283
|
+
* @since 1.0.0-rc.0
|
|
284
|
+
*/
|
|
285
|
+
export declare const maxJsonDepth = 128;
|
|
286
|
+
/**
|
|
287
|
+
* Connects to an MCP server over stdio (`command`) or Streamable HTTP (`url`),
|
|
288
|
+
* completes the `initialize` handshake, and fetches its tool catalog once, up
|
|
289
|
+
* front. Failed or interrupted setup closes its subprocess, I/O fibers, or
|
|
290
|
+
* HTTP session before returning to the caller; a successful session stays
|
|
291
|
+
* open until the caller scope closes.
|
|
292
|
+
*
|
|
293
|
+
* The tool catalog is a snapshot: a server that changes its tools after
|
|
294
|
+
* connecting (a `notifications/tools/list_changed` push) is not re-polled.
|
|
295
|
+
* {@link McpFlows} rebuilds by reconnecting to refresh.
|
|
296
|
+
* Catalog input schemas must declare `type: "object"`. A later tool result may
|
|
297
|
+
* omit `content` when it carries `structuredContent`; a declared output schema
|
|
298
|
+
* is enforced for the documented keyword subset.
|
|
299
|
+
*
|
|
300
|
+
* @category constructors
|
|
301
|
+
* @since 1.0.0-rc.0
|
|
302
|
+
*/
|
|
303
|
+
export declare const connect: <O extends ConnectOptions>(options: O) => Effect.Effect<McpClient, McpError, Requirements<O> | Scope.Scope>;
|
|
304
|
+
//# sourceMappingURL=McpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpClient.d.ts","sourceRoot":"","sources":["../../src/McpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,MAAM,EA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