@oribos/mcp-client 0.5.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 +201 -0
- package/README.md +127 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +183 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# `@oribos/mcp-client`
|
|
2
|
+
|
|
3
|
+
Bridge a remote [MCP](https://modelcontextprotocol.io) server's tools into a
|
|
4
|
+
[Oribos](https://github.com/0xnicholas/oribos-framework) tool container: one `createMcpClient()`
|
|
5
|
+
object with a `tools` snapshot you spread straight into an agent, a `refresh()`, and a `close()`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createAgent } from '@oribos/core/agent';
|
|
9
|
+
import { createMcpClient } from '@oribos/mcp-client';
|
|
10
|
+
|
|
11
|
+
const client = await createMcpClient({
|
|
12
|
+
transport: { type: 'http', url: 'https://example.com/mcp' },
|
|
13
|
+
// or: { type: 'stdio', command: 'npx', args: ['my-mcp-server'] }
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const agent = createAgent({
|
|
17
|
+
name: 'assistant',
|
|
18
|
+
instructions: 'You have remote tools.',
|
|
19
|
+
model, // any AI SDK provider instance
|
|
20
|
+
tools: () => client.tools, // dynamic: every request resolves the latest snapshot
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
await client.refresh(); // re-list remotely, swap the snapshot
|
|
24
|
+
await client.close(); // tear down (idempotent)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- Spec: [`docs/architecture/tools.md`](https://github.com/0xnicholas/oribos-framework/blob/main/docs/architecture/tools.md)
|
|
28
|
+
- SDK facts this package builds on: [`docs/research/mcp-v2-sdk-surface.md`](https://github.com/0xnicholas/oribos-framework/blob/main/docs/research/mcp-v2-sdk-surface.md)
|
|
29
|
+
- Decisions: [ADR-0008](https://github.com/0xnicholas/oribos-framework/blob/main/docs/adr/0008-tools-mcp-abstraction.md) (tools/MCP), [ADR-0002](https://github.com/0xnicholas/oribos-framework/blob/main/docs/adr/0002-package-structure.md) (packaging)
|
|
30
|
+
- Paired example (server + client in one script): [`examples/mcp-tools`](https://github.com/0xnicholas/oribos-framework/blob/main/examples/mcp-tools)
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install @oribos/mcp-client @oribos/core
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`@oribos/core` is a peer dependency (one core instance by design). The only direct runtime
|
|
39
|
+
dependency is `@modelcontextprotocol/client`.
|
|
40
|
+
|
|
41
|
+
## Transports and options
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
const client = await createMcpClient({
|
|
45
|
+
transport:
|
|
46
|
+
| { type: 'stdio', command: string, args?: string[], env?: Record<string, string> }
|
|
47
|
+
| { type: 'http', url: string | URL, headers?: Record<string, string> },
|
|
48
|
+
protocol?: 'auto' | 'legacy' | { pin: '2026-07-28' }, // omitted = 'auto'
|
|
49
|
+
timeoutMs?: number, // omitted = the SDK's 60s per request
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- **stdio** spawns the server subprocess (the SDK owns it: shutdown is stdin → SIGTERM → SIGKILL).
|
|
54
|
+
`env`, when given, is the child's **whole** environment; omitted, the SDK applies its own safe
|
|
55
|
+
whitelist — never your full `process.env`. The child's stderr is inherited, so its logs reach
|
|
56
|
+
yours. `stderr` / `cwd` / `maxBufferSize` are not exposed — wire the official SDK yourself for
|
|
57
|
+
those (the escape hatch for everything v1 doesn't expose).
|
|
58
|
+
- **http** speaks Streamable HTTP; `headers` go on every request (bearer tokens and the like).
|
|
59
|
+
OAuth flows, custom `fetch`, `sessionId` reattach: not exposed in v1.
|
|
60
|
+
- **protocol**: `'auto'` (the default — raised here; the SDK's own default is `'legacy'`) probes
|
|
61
|
+
with `server/discover` first and falls back to the 2025 handshake. `'legacy'` skips the probe.
|
|
62
|
+
`{ pin: '2026-07-28' }` demands the modern era and fails loudly. Note the probe's cost: on
|
|
63
|
+
stdio it spawns a short-lived sibling process once per connect; on HTTP a probe timeout is
|
|
64
|
+
treated as an outage and rejects.
|
|
65
|
+
- **timeoutMs** is passed to the connect handshake and every request (the SDK has no client-level
|
|
66
|
+
default setting). There is no per-call override — a long-running tool call is what this option
|
|
67
|
+
is for.
|
|
68
|
+
- The client identity advertised to servers is this package's own name and version, not
|
|
69
|
+
overridable.
|
|
70
|
+
|
|
71
|
+
## The snapshot and its lifecycle
|
|
72
|
+
|
|
73
|
+
`client.tools` is a getter over a frozen `Record<string, Tool>` — keys are the remote tool names.
|
|
74
|
+
The identity is stable until the next `refresh()`; old references never break. There is no
|
|
75
|
+
`listChanged` subscription and **no auto-reconnect**: a dropped connection surfaces as SDK errors
|
|
76
|
+
on the calls in flight and after it; recovery is a new client. `close()` is idempotent — HTTP
|
|
77
|
+
sends `terminateSession` first (failures there are silent), then tears down; in-flight requests
|
|
78
|
+
reject with `CONNECTION_CLOSED`. Not calling `close()` on a stdio client keeps the subprocess
|
|
79
|
+
alive — the host owns the lifetime.
|
|
80
|
+
|
|
81
|
+
`prefixTools(tools, prefix, separator = '_')` renames bridged tools into a new frozen record
|
|
82
|
+
(`prefix + separator + name`). The prefix never reaches the wire — execute still calls the remote
|
|
83
|
+
name. No collision detection runs (a fixed prefix is an isomorphic mapping), and whether a
|
|
84
|
+
prefixed name is legal for your model provider is your concern.
|
|
85
|
+
|
|
86
|
+
## What crosses the bridge
|
|
87
|
+
|
|
88
|
+
**Schemas** arrive as JSON Schema documents and are wrapped in a pass-through Standard Schema:
|
|
89
|
+
`validate` always succeeds locally (validation is the remote's business — failures come back
|
|
90
|
+
through the execute path), and `jsonSchema.input` returns the remote document verbatim — same
|
|
91
|
+
reference, no rewriting between draft versions. `jsonSchema.output` throws: a bridged tool
|
|
92
|
+
carries no `outputSchema`, and the SDK client already validates `structuredContent` against the
|
|
93
|
+
remote's schema. A consequence: MCP→MCP re-exporting loses `structuredContent` (text only) —
|
|
94
|
+
explicit opt-in fidelity is a future minor.
|
|
95
|
+
|
|
96
|
+
**Context**: of the six `ToolContext` pieces only `signal` crosses — `callTool({ signal })`
|
|
97
|
+
passthrough, no pre-checks. `toolCallId` / `runId` / `traceId` / `spanId` stay local (the protocol
|
|
98
|
+
has no slot for them), and `requestContext` is not transmitted.
|
|
99
|
+
|
|
100
|
+
**Results**: `structuredContent` returns verbatim when present (any JSON value); otherwise text
|
|
101
|
+
blocks join on newlines; image / audio / resource-link blocks degrade to placeholder text — the
|
|
102
|
+
tool-result channel carries no multimodal parts, an honest v1 boundary. An empty result is `''`.
|
|
103
|
+
An `isError` result **throws**, so the framework turns it into a `Tool 'x' failed: …` error result
|
|
104
|
+
fed back to the model — the same road the server-side failure lines take.
|
|
105
|
+
|
|
106
|
+
**Errors** propagate as-is: no layer added, no message rewritten. Connect-time: era negotiation
|
|
107
|
+
failures, 401/403, probe timeouts. Runtime: request timeouts, `CONNECTION_CLOSED`, protocol
|
|
108
|
+
errors, output-validation failures. A remote `input_required` answer (multi-round-trip) surfaces
|
|
109
|
+
as a deterministic `SdkError` — this package pins `inputRequired.autoFulfill: false` and registers
|
|
110
|
+
no elicitation/sampling handlers.
|
|
111
|
+
|
|
112
|
+
On modern HTTP connections the SDK must drop tools whose `x-mcp-header` declarations are illegal
|
|
113
|
+
(SPEC MUST, warned in console) — the snapshot can be smaller than what the server advertises.
|
|
114
|
+
|
|
115
|
+
## Lightweight
|
|
116
|
+
|
|
117
|
+
Same axis as the rest of Oribos — install only what you use:
|
|
118
|
+
|
|
119
|
+
- dependency closure: everything `@modelcontextprotocol/client` pulls in — its OAuth / SSE / stdio
|
|
120
|
+
closure — recorded in `deps-budget.json`, where count and unpacked size are watched in CI
|
|
121
|
+
- first-party code: the minified baseline is recorded in `byte-budget.json` and checked on every
|
|
122
|
+
PR — a warning, not a merge gate or a public budget
|
|
123
|
+
- `@oribos/core` stays a peer, so there is exactly one core instance
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
[Apache-2.0](https://github.com/0xnicholas/oribos-framework/blob/main/LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oribos/mcp-client` — the MCP client capability package: bridge a remote MCP server's tools
|
|
3
|
+
* into the framework's `Record<string, Tool>` container, ready to spread straight into an agent.
|
|
4
|
+
*
|
|
5
|
+
* One connection, one object with three members: `tools` (a getter over the current snapshot),
|
|
6
|
+
* `refresh()` (re-list and swap the snapshot), and `close()` (terminate the session and tear the
|
|
7
|
+
* connection down, idempotently). No auto-reconnect — a dropped connection surfaces as SDK
|
|
8
|
+
* errors on the calls in flight and after; recovery is a new client. No `listChanged`
|
|
9
|
+
* subscription either — a long-lived agent reads the latest snapshot through
|
|
10
|
+
* `tools: () => client.tools` (a dynamic argument resolves it per request).
|
|
11
|
+
*
|
|
12
|
+
* The bridge is deliberately thin. Schemas go over as a JSON Schema pass-through Standard
|
|
13
|
+
* Schema wrapper (validation is the remote's business; failures come back through the execute
|
|
14
|
+
* path); results project as `structuredContent` verbatim or joined text; `isError` results
|
|
15
|
+
* throw so the agent loop turns them into `Tool 'x' failed: …` error results. Everything else —
|
|
16
|
+
* era negotiation (default raised to `'auto'`: probe `server/discover`, fall back to the 2025
|
|
17
|
+
* handshake), the 60s per-request timeout, `inputRequired.autoFulfill: false` — is the SDK's
|
|
18
|
+
* own semantics, configured once here and never re-wrapped.
|
|
19
|
+
*/
|
|
20
|
+
import type { Tool } from '@oribos/core/tools';
|
|
21
|
+
/** How to reach the server: a stdio subprocess the SDK owns, or a Streamable HTTP endpoint. */
|
|
22
|
+
export type McpClientTransport = {
|
|
23
|
+
readonly type: 'stdio';
|
|
24
|
+
/** The executable to run (the SDK owns the subprocess and its shutdown: stdin → SIGTERM → SIGKILL). */
|
|
25
|
+
readonly command: string;
|
|
26
|
+
readonly args?: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* The child's whole environment. Given, it replaces everything; omitted, the SDK applies
|
|
29
|
+
* its own safe-default whitelist (not the full `process.env`).
|
|
30
|
+
*/
|
|
31
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: 'http';
|
|
34
|
+
/** The Streamable HTTP endpoint. */
|
|
35
|
+
readonly url: string | URL;
|
|
36
|
+
/** Request headers applied to every request (bearer tokens and the like). */
|
|
37
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Which protocol generation to speak. `'auto'` (the default — raised here, the SDK's own default
|
|
41
|
+
* is `'legacy'`) probes with `server/discover` first and falls back to the 2025 handshake;
|
|
42
|
+
* `'legacy'` skips the probe; `{ pin: '2026-07-28' }` demands the modern era and fails loudly.
|
|
43
|
+
*/
|
|
44
|
+
export type McpClientProtocol = 'auto' | 'legacy' | {
|
|
45
|
+
readonly pin: '2026-07-28';
|
|
46
|
+
};
|
|
47
|
+
/** Creation-time options. */
|
|
48
|
+
export interface McpClientConfig {
|
|
49
|
+
readonly transport: McpClientTransport;
|
|
50
|
+
/** Protocol generation posture; omitted = `'auto'`.
|
|
51
|
+
*/
|
|
52
|
+
readonly protocol?: McpClientProtocol;
|
|
53
|
+
/**
|
|
54
|
+
* Per-request timeout in milliseconds, passed through to the connect handshake and every
|
|
55
|
+
* request the client makes. The SDK has no client-level default setting — without this the
|
|
56
|
+
* SDK's own 60s applies (`DEFAULT_REQUEST_TIMEOUT_MSEC`). No per-call override.
|
|
57
|
+
*/
|
|
58
|
+
readonly timeoutMs?: number;
|
|
59
|
+
}
|
|
60
|
+
/** A connected MCP client: the tool snapshot, a refresh, and a close. */
|
|
61
|
+
export interface McpClient {
|
|
62
|
+
/**
|
|
63
|
+
* The current snapshot as a `Record<string, Tool>` — spread it into an agent's tool container.
|
|
64
|
+
* The object identity is stable until the next `refresh()`; old references never break.
|
|
65
|
+
*/
|
|
66
|
+
readonly tools: Record<string, Tool>;
|
|
67
|
+
/** Re-lists the remote tools and swaps the snapshot; on failure keeps the old one and rejects. */
|
|
68
|
+
refresh(): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Tears the connection down, idempotently: HTTP sends `terminateSession` first (a failure
|
|
71
|
+
* there is silent), then the client closes — in-flight requests reject with
|
|
72
|
+
* `CONNECTION_CLOSED`, a stdio subprocess shuts down in the SDK's order.
|
|
73
|
+
*/
|
|
74
|
+
close(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Connects to an MCP server and bridges its tools into the framework's `Tool` container.
|
|
78
|
+
*
|
|
79
|
+
* The connection happens up front: a failed handshake (era negotiation, 401/403, probe timeout)
|
|
80
|
+
* rejects here, never later. On success `tools` already holds the first snapshot.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createMcpClient(config: McpClientConfig): Promise<McpClient>;
|
|
83
|
+
/**
|
|
84
|
+
* Renames bridged tools with a fixed prefix: returns a new frozen `Record<string, Tool>` keyed
|
|
85
|
+
* `prefix + separator + name` (separator defaults to `'_'`). The prefix never reaches the wire —
|
|
86
|
+
* the tool objects are untouched, and the remote name in each execute closure is unchanged. A
|
|
87
|
+
* fixed prefix is an isomorphic mapping, so no collision detection runs; whether a prefixed name
|
|
88
|
+
* is legal for a given provider is the caller's concern. Not part of the client config surface.
|
|
89
|
+
*/
|
|
90
|
+
export declare function prefixTools(tools: Record<string, Tool>, prefix: string, separator?: string): Record<string, Tool>;
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAWH,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,oBAAoB,CAAC;AAO5D,+FAA+F;AAC/F,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,uGAAuG;IACvG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oCAAoC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAC3B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD,CAAC;AAEN;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAA;CAAE,CAAC;AAEnF,6BAA6B;AAC7B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC;OACG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,yEAAyE;AACzE,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,kGAAkG;IAClG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAuEjF;AAmFD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAC3B,MAAM,EAAE,MAAM,EACd,SAAS,SAAM,GACd,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAItB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oribos/mcp-client` — the MCP client capability package: bridge a remote MCP server's tools
|
|
3
|
+
* into the framework's `Record<string, Tool>` container, ready to spread straight into an agent.
|
|
4
|
+
*
|
|
5
|
+
* One connection, one object with three members: `tools` (a getter over the current snapshot),
|
|
6
|
+
* `refresh()` (re-list and swap the snapshot), and `close()` (terminate the session and tear the
|
|
7
|
+
* connection down, idempotently). No auto-reconnect — a dropped connection surfaces as SDK
|
|
8
|
+
* errors on the calls in flight and after; recovery is a new client. No `listChanged`
|
|
9
|
+
* subscription either — a long-lived agent reads the latest snapshot through
|
|
10
|
+
* `tools: () => client.tools` (a dynamic argument resolves it per request).
|
|
11
|
+
*
|
|
12
|
+
* The bridge is deliberately thin. Schemas go over as a JSON Schema pass-through Standard
|
|
13
|
+
* Schema wrapper (validation is the remote's business; failures come back through the execute
|
|
14
|
+
* path); results project as `structuredContent` verbatim or joined text; `isError` results
|
|
15
|
+
* throw so the agent loop turns them into `Tool 'x' failed: …` error results. Everything else —
|
|
16
|
+
* era negotiation (default raised to `'auto'`: probe `server/discover`, fall back to the 2025
|
|
17
|
+
* handshake), the 60s per-request timeout, `inputRequired.autoFulfill: false` — is the SDK's
|
|
18
|
+
* own semantics, configured once here and never re-wrapped.
|
|
19
|
+
*/
|
|
20
|
+
import { createRequire } from 'node:module';
|
|
21
|
+
import { Client, StreamableHTTPClientTransport } from '@modelcontextprotocol/client';
|
|
22
|
+
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
|
|
23
|
+
/** The identity this package advertises to servers — its own name and version, not overridable. */
|
|
24
|
+
const CLIENT_NAME = '@oribos/mcp-client';
|
|
25
|
+
const { version: CLIENT_VERSION } = createRequire(import.meta.url)('../package.json');
|
|
26
|
+
/**
|
|
27
|
+
* Connects to an MCP server and bridges its tools into the framework's `Tool` container.
|
|
28
|
+
*
|
|
29
|
+
* The connection happens up front: a failed handshake (era negotiation, 401/403, probe timeout)
|
|
30
|
+
* rejects here, never later. On success `tools` already holds the first snapshot.
|
|
31
|
+
*/
|
|
32
|
+
export async function createMcpClient(config) {
|
|
33
|
+
const timeout = config.timeoutMs;
|
|
34
|
+
const requestOptions = timeout === undefined ? undefined : { timeout };
|
|
35
|
+
let terminate;
|
|
36
|
+
let transport;
|
|
37
|
+
if (config.transport.type === 'stdio') {
|
|
38
|
+
transport = new StdioClientTransport({
|
|
39
|
+
command: config.transport.command,
|
|
40
|
+
...(config.transport.args === undefined ? {} : { args: [...config.transport.args] }),
|
|
41
|
+
...(config.transport.env === undefined ? {} : { env: { ...config.transport.env } }),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const http = new StreamableHTTPClientTransport(new URL(config.transport.url), {
|
|
46
|
+
...(config.transport.headers === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { requestInit: { headers: { ...config.transport.headers } } }),
|
|
49
|
+
});
|
|
50
|
+
transport = http;
|
|
51
|
+
terminate = () => http.terminateSession();
|
|
52
|
+
}
|
|
53
|
+
const client = new Client({ name: CLIENT_NAME, version: CLIENT_VERSION }, {
|
|
54
|
+
// The default is raised to 'auto' here: probe with server/discover, fall back to legacy.
|
|
55
|
+
versionNegotiation: { mode: protocolMode(config.protocol) },
|
|
56
|
+
// No elicitation/sampling handlers exist to fulfil with — an `input_required` result must
|
|
57
|
+
// surface as a deterministic error, not a silent auto-flow.
|
|
58
|
+
inputRequired: { autoFulfill: false },
|
|
59
|
+
});
|
|
60
|
+
await client.connect(transport, requestOptions);
|
|
61
|
+
const call = (name, input, ctx) => client
|
|
62
|
+
.callTool({ name, ...(input === undefined ? {} : { arguments: input }) }, { signal: ctx.signal, ...(timeout === undefined ? {} : { timeout }) })
|
|
63
|
+
.then((result) => projectResult(name, result));
|
|
64
|
+
let snapshot = buildSnapshot((await listTools(client, requestOptions)).tools, call);
|
|
65
|
+
let closed = false;
|
|
66
|
+
return {
|
|
67
|
+
get tools() {
|
|
68
|
+
return snapshot;
|
|
69
|
+
},
|
|
70
|
+
async refresh() {
|
|
71
|
+
// cacheMode 'refresh' forces a real fetch past the SDK's response cache; the snapshot is
|
|
72
|
+
// only swapped on success, so a failure leaves the old one fully in place.
|
|
73
|
+
const listed = await client.listTools(undefined, {
|
|
74
|
+
cacheMode: 'refresh',
|
|
75
|
+
...(timeout === undefined ? {} : { timeout }),
|
|
76
|
+
});
|
|
77
|
+
snapshot = buildSnapshot(listed.tools, call);
|
|
78
|
+
},
|
|
79
|
+
async close() {
|
|
80
|
+
if (closed)
|
|
81
|
+
return;
|
|
82
|
+
closed = true;
|
|
83
|
+
if (terminate !== undefined) {
|
|
84
|
+
try {
|
|
85
|
+
await terminate();
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Silent by spec: the server may not support session teardown, or is already gone.
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
await client.close();
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** Maps the package's protocol posture onto the SDK's negotiation mode one-to-one. */
|
|
96
|
+
function protocolMode(protocol) {
|
|
97
|
+
return protocol ?? 'auto';
|
|
98
|
+
}
|
|
99
|
+
/** One list call shared by connect and refresh; the plain form at connect (empty cache → real fetch). */
|
|
100
|
+
function listTools(client, requestOptions) {
|
|
101
|
+
return client.listTools(undefined, requestOptions);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Builds a frozen snapshot: one bridged `Tool` per remote entry. The remote name is the key and
|
|
105
|
+
* the name used on the wire; remote tool names are neither validated nor mangled here (the MCP
|
|
106
|
+
* charset is wider than most providers' — renaming, if wanted, is `prefixTools`' caller's call).
|
|
107
|
+
*/
|
|
108
|
+
function buildSnapshot(remoteTools, call) {
|
|
109
|
+
const snapshot = {};
|
|
110
|
+
for (const remote of remoteTools) {
|
|
111
|
+
const { name } = remote;
|
|
112
|
+
snapshot[name] = Object.freeze({
|
|
113
|
+
description: remote.description ?? '',
|
|
114
|
+
inputSchema: jsonSchemaPassthrough(remote.inputSchema),
|
|
115
|
+
execute: (input, ctx) => call(name, input, ctx),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return Object.freeze(snapshot);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The result projection: `structuredContent !== undefined` returns that
|
|
122
|
+
* value verbatim (any JSON flows — `ToolResultChunk.output` is `unknown`); otherwise the text
|
|
123
|
+
* blocks join on newlines with non-text blocks degrading to placeholder text — the tool-result
|
|
124
|
+
* channel carries no multimodal parts, an honest v1 boundary; an empty result is `''`. An
|
|
125
|
+
* `isError` result throws, so the framework turns it into a `Tool 'x' failed: …` error result
|
|
126
|
+
* fed back to the model — the same road the three server-side failure lines take.
|
|
127
|
+
*/
|
|
128
|
+
function projectResult(name, result) {
|
|
129
|
+
const text = contentText(result.content);
|
|
130
|
+
if (result.isError === true)
|
|
131
|
+
throw new Error(text === '' ? `Tool '${name}' failed` : text);
|
|
132
|
+
if (result.structuredContent !== undefined)
|
|
133
|
+
return result.structuredContent;
|
|
134
|
+
return text;
|
|
135
|
+
}
|
|
136
|
+
/** Text blocks verbatim, other blocks as placeholders, joined on newlines; empty content is ''. */
|
|
137
|
+
function contentText(content) {
|
|
138
|
+
if (content === undefined || content.length === 0)
|
|
139
|
+
return '';
|
|
140
|
+
return content
|
|
141
|
+
.map((block) => (block.type === 'text' ? block.text : `[unsupported content block: ${block.type}]`))
|
|
142
|
+
.join('\n');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The JSON Schema pass-through wrapper — an internal factory, not
|
|
146
|
+
* exported. `validate` always succeeds synchronously (validation is the remote's business; a
|
|
147
|
+
* failure comes back through the execute error path), `jsonSchema.input` returns the remote
|
|
148
|
+
* document verbatim — same reference, target ignored: remote schemas are commonly 2020-12 while
|
|
149
|
+
* the core asks providers for draft-07, and this bridge rewrites nothing. `jsonSchema.output`
|
|
150
|
+
* throws: a bridged tool carries no output schema, and a fake would only validate vacuously.
|
|
151
|
+
* The wrapper and its `~standard` bag are frozen.
|
|
152
|
+
*/
|
|
153
|
+
function jsonSchemaPassthrough(remote) {
|
|
154
|
+
const wrapper = {
|
|
155
|
+
'~standard': Object.freeze({
|
|
156
|
+
version: 1,
|
|
157
|
+
vendor: 'oribos',
|
|
158
|
+
types: Object.freeze({ input: undefined, output: undefined }),
|
|
159
|
+
validate: Object.freeze((value) => ({ value })),
|
|
160
|
+
jsonSchema: Object.freeze({
|
|
161
|
+
input: Object.freeze(() => remote),
|
|
162
|
+
output: Object.freeze(() => {
|
|
163
|
+
throw new Error('A bridged MCP tool has no output schema: the remote schema stays on the server.');
|
|
164
|
+
}),
|
|
165
|
+
}),
|
|
166
|
+
}),
|
|
167
|
+
};
|
|
168
|
+
return Object.freeze(wrapper);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Renames bridged tools with a fixed prefix: returns a new frozen `Record<string, Tool>` keyed
|
|
172
|
+
* `prefix + separator + name` (separator defaults to `'_'`). The prefix never reaches the wire —
|
|
173
|
+
* the tool objects are untouched, and the remote name in each execute closure is unchanged. A
|
|
174
|
+
* fixed prefix is an isomorphic mapping, so no collision detection runs; whether a prefixed name
|
|
175
|
+
* is legal for a given provider is the caller's concern. Not part of the client config surface.
|
|
176
|
+
*/
|
|
177
|
+
export function prefixTools(tools, prefix, separator = '_') {
|
|
178
|
+
const prefixed = {};
|
|
179
|
+
for (const [name, tool] of Object.entries(tools))
|
|
180
|
+
prefixed[prefix + separator + name] = tool;
|
|
181
|
+
return Object.freeze(prefixed);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAOrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAI1E,mGAAmG;AACnG,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CAAwB,CAAC;AA6D7G;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAuB;IAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC;IACjC,MAAM,cAAc,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;IAEvE,IAAI,SAA4C,CAAC;IACjD,IAAI,SAAoB,CAAC;IACzB,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACtC,SAAS,GAAG,IAAI,oBAAoB,CAAC;YACnC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO;YACjC,GAAG,CA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,WAAW,CACzB,KAA2B,EAC3B,MAAc,EACd,SAAS,GAAG,GAAG;IAEf,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7F,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oribos/mcp-client",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Oribos MCP client — bridge remote MCP tools into the Tool container (Streamable HTTP + stdio).",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.13.0"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/0xnicholas/oribos-framework.git",
|
|
23
|
+
"directory": "packages/mcp-client"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@oribos/core": "^0.5.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@modelcontextprotocol/server": "^2.2.0",
|
|
33
|
+
"@oribos/core": "0.5.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@modelcontextprotocol/client": "^2.2.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
41
|
+
"check:dist": "node ../../scripts/check-dist.mjs",
|
|
42
|
+
"check:export-surface": "node ../../scripts/check-export-surface.mjs",
|
|
43
|
+
"check:runtime-deps": "node ../../scripts/check-runtime-deps.mjs",
|
|
44
|
+
"check:byte-budget": "node ../../scripts/check-byte-budget.mjs",
|
|
45
|
+
"byte-budget:update": "node ../../scripts/check-byte-budget.mjs --update",
|
|
46
|
+
"check:deps-budget": "node ../../scripts/check-deps-budget.mjs",
|
|
47
|
+
"deps-budget:update": "node ../../scripts/check-deps-budget.mjs --update"
|
|
48
|
+
}
|
|
49
|
+
}
|