@mcp-ts/sdk 2.3.4 → 2.4.1
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/README.md +161 -39
- package/dist/adapters/agui-adapter.d.mts +4 -4
- package/dist/adapters/agui-adapter.d.ts +4 -4
- package/dist/adapters/agui-middleware.d.mts +4 -4
- package/dist/adapters/agui-middleware.d.ts +4 -4
- package/dist/adapters/ai-adapter.d.mts +4 -4
- package/dist/adapters/ai-adapter.d.ts +4 -4
- package/dist/adapters/langchain-adapter.d.mts +4 -4
- package/dist/adapters/langchain-adapter.d.ts +4 -4
- package/dist/adapters/mastra-adapter.d.mts +2 -2
- package/dist/adapters/mastra-adapter.d.ts +2 -2
- package/dist/client/index.d.mts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs +2 -2
- package/dist/client/index.mjs.map +1 -1
- package/dist/client/react.d.mts +11 -10
- package/dist/client/react.d.ts +11 -10
- package/dist/client/react.js +66 -26
- package/dist/client/react.js.map +1 -1
- package/dist/client/react.mjs +67 -27
- package/dist/client/react.mjs.map +1 -1
- package/dist/client/vue.d.mts +8 -7
- package/dist/client/vue.d.ts +8 -7
- package/dist/client/vue.js +27 -17
- package/dist/client/vue.js.map +1 -1
- package/dist/client/vue.mjs +27 -17
- package/dist/client/vue.mjs.map +1 -1
- package/dist/{events-CK3N--3g.d.mts → events-C4m7tK1U.d.mts} +0 -1
- package/dist/{events-CK3N--3g.d.ts → events-C4m7tK1U.d.ts} +0 -1
- package/dist/{index-CmjMd2ac.d.ts → index-Ch7ouNSa.d.ts} +3 -3
- package/dist/{index-Cfjsme-a.d.mts → index-L5XoXgsb.d.mts} +3 -3
- package/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +799 -326
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +793 -324
- package/dist/index.mjs.map +1 -1
- package/dist/{multi-session-client-C_kPHpD5.d.ts → multi-session-client-Bwm-efqg.d.ts} +43 -38
- package/dist/{multi-session-client-C7hGqzgM.d.mts → multi-session-client-k-9RvWvi.d.mts} +43 -38
- package/dist/server/index.d.mts +48 -20
- package/dist/server/index.d.ts +48 -20
- package/dist/server/index.js +791 -320
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +787 -319
- package/dist/server/index.mjs.map +1 -1
- package/dist/shared/index.d.mts +10 -9
- package/dist/shared/index.d.ts +10 -9
- package/dist/shared/index.js +7 -5
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +5 -4
- package/dist/shared/index.mjs.map +1 -1
- package/dist/{tool-router-BMzhoNYt.d.ts → tool-router-CZMrOG8J.d.ts} +1 -1
- package/dist/{tool-router-BhHsvBfP.d.mts → tool-router-CuApsDiV.d.mts} +1 -1
- package/dist/{types-CxFaaZrM.d.mts → types-DCk_IF4L.d.mts} +5 -3
- package/dist/{types-CxFaaZrM.d.ts → types-DCk_IF4L.d.ts} +5 -3
- package/migrations/neon/20260513010000_install_mcp_sessions.sql +40 -3
- package/migrations/neon/20260513020000_add_session_cleanup_cron.sql +4 -4
- package/migrations/supabase/20260330195700_install_mcp_sessions.sql +67 -3
- package/migrations/supabase/20260421010000_add_session_cleanup_cron.sql +6 -6
- package/migrations/v2.3.4/neon/20260513010000_install_mcp_sessions.sql +69 -0
- package/migrations/v2.3.4/neon/20260513020000_add_session_cleanup_cron.sql +35 -0
- package/migrations/v2.3.4/supabase/20260330195700_install_mcp_sessions.sql +82 -0
- package/migrations/v2.3.4/supabase/20260421010000_add_session_cleanup_cron.sql +32 -0
- package/package.json +13 -3
- package/src/client/core/sse-client.ts +2 -2
- package/src/client/react/index.ts +1 -1
- package/src/client/react/oauth-popup.tsx +34 -13
- package/src/client/react/use-mcp.ts +19 -45
- package/src/client/utils/session-state.ts +43 -0
- package/src/client/vue/use-mcp.ts +18 -47
- package/src/server/handlers/sse-handler.ts +16 -9
- package/src/server/mcp/multi-session-client.ts +48 -11
- package/src/server/mcp/oauth-client.ts +133 -111
- package/src/server/mcp/storage-oauth-provider.ts +79 -50
- package/src/server/storage/file-backend.ts +74 -18
- package/src/server/storage/index.ts +2 -4
- package/src/server/storage/memory-backend.ts +49 -13
- package/src/server/storage/neon-backend.ts +201 -68
- package/src/server/storage/redis-backend.ts +81 -23
- package/src/server/storage/session-lifecycle.ts +78 -0
- package/src/server/storage/sqlite-backend.ts +89 -15
- package/src/server/storage/supabase-backend.ts +188 -63
- package/src/server/storage/types.ts +49 -16
- package/src/shared/constants.ts +5 -6
- package/src/shared/events.ts +0 -1
- package/src/shared/types.ts +5 -3
- package/src/shared/utils.ts +26 -0
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<a href="https://docs.mcp-assistant.in/">📚 Documentation</a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
|
+
|
|
19
20
|
<p>
|
|
20
21
|
<a href="https://www.npmjs.com/package/@mcp-ts/sdk">
|
|
21
22
|
<img src="https://img.shields.io/npm/v/@mcp-ts/sdk?color=dc2626&label=npm&logo=npm&style=flat-square" alt="npm version" />
|
|
@@ -31,45 +32,85 @@
|
|
|
31
32
|
|
|
32
33
|
<br />
|
|
33
34
|
|
|
34
|
-
##
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
- [
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
35
|
+
## Why does `mcp-ts or toolkit` even exist?
|
|
36
|
+
|
|
37
|
+
MCP makes it possible for AI applications to talk to tools, prompts, and resources, but building applications on top of MCP quickly becomes more than calling `listTools()` and `callTool()`.
|
|
38
|
+
|
|
39
|
+
You need to manage user sessions, OAuth flows, reconnects, storage, browser updates, framework adapters, and on-demand tool discovery so agents can load and call only what they need instead of flooding the model context, similar to Claude Code's [advanced tool use](https://www.anthropic.com/engineering/advanced-tool-use).
|
|
40
|
+
|
|
41
|
+
`mcp-ts` exists to handle that application layer while keeping your MCP data in infrastructure you own or choose. See [storage backends](https://docs.mcp-assistant.in/storage-backends/overview) and [framework adapters](https://docs.mcp-assistant.in/ai-adapters/overview).
|
|
42
|
+
|
|
43
|
+
It gives you a practical foundation for building MCP-native apps:
|
|
44
|
+
|
|
45
|
+
- Have multiple users using your application
|
|
46
|
+
- Already using AI SDK, LangChain, Mastra, and AG-UI Protocol where handling oauth, tokens management for mcp clients seems overhead
|
|
47
|
+
- Reduce large model context with on-demand tool discovery through `ToolRouter`
|
|
48
|
+
- Render interactive MCP Apps in your application.
|
|
49
|
+
- Run programmatic tool calling inside a secure sandbox with `CodeMode`
|
|
50
|
+
|
|
51
|
+
In short: the official MCP SDK gives you the protocol building blocks. `mcp-ts` gives you the application layer for building MCP applications around them.
|
|
52
|
+
|
|
53
|
+
## When you may not need it ?
|
|
54
|
+
|
|
55
|
+
If you already use a managed service/platform such as Smithery, Klavis Strata, Composio, nango or a similar SDK, you may not need `mcp-ts`.
|
|
49
56
|
|
|
50
57
|
---
|
|
51
58
|
|
|
59
|
+
## 📑 Table of Contents
|
|
60
|
+
|
|
61
|
+
- [Features](#features)
|
|
62
|
+
- [Packages](#packages)
|
|
63
|
+
- [Examples](#examples)
|
|
64
|
+
- [Inspiration](#inspiration)
|
|
65
|
+
- [SDK Setup (@mcp-ts/sdk)](#sdk-setup-mcp-tssdk)
|
|
66
|
+
- [Installation](#installation)
|
|
67
|
+
- [Quick Start](#quick-start)
|
|
68
|
+
- [MCP Endpoint (Hosted)](#-mcp-endpoint-hosted)
|
|
69
|
+
- [Adapters](#-adapters)
|
|
70
|
+
- [AG-UI Middleware](#-ag-ui-middleware)
|
|
71
|
+
- [MCP Apps (SEP-1865)](#️-mcp-apps-sep-1865)
|
|
72
|
+
- [Documentation](#documentation)
|
|
73
|
+
- [Topics Covered](#️-topics-covered)
|
|
74
|
+
- [Environment Setup](#environment-setup)
|
|
75
|
+
- [Configuration Examples](#-configuration-examples)
|
|
76
|
+
- [Gateway Setup (mcpassistant-gateway)](#gateway-setup-mcpassistant-gateway)
|
|
77
|
+
- [Installation](#installation-1)
|
|
78
|
+
- [Usage](#usage)
|
|
79
|
+
- [Architecture](#architecture)
|
|
80
|
+
- [Contributing](#contributing)
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
<a id="packages"></a>
|
|
85
|
+
|
|
52
86
|
## 📦 Packages
|
|
53
87
|
|
|
54
88
|
| Package | Description | Install |
|
|
55
89
|
| :--- | :--- | :--- |
|
|
56
|
-
| **[@mcp-ts/sdk](src)** | TypeScript/JavaScript SDK for
|
|
57
|
-
| **[
|
|
90
|
+
| **[@mcp-ts/sdk](src)** | Core TypeScript/JavaScript SDK for client applications. | `npm i @mcp-ts/sdk` |
|
|
91
|
+
| **[@mcp-ts/tool-router](packages/tool-router)** | ToolRouter for dynamic tool discovery across many MCP servers. | `npm i @mcp-ts/tool-router` |
|
|
92
|
+
| **[@mcp-ts/codemode](packages/code-mode)** | CodeMode: sandboxed program execution for tool calling. | `npm i @mcp-ts/codemode` |
|
|
93
|
+
| **[mcpassistant-gateway](packages/local-gateway)** | Python bridge for local MCP support in remote apps. | `pip install mcpassistant-gateway` |
|
|
58
94
|
|
|
59
95
|
---
|
|
60
96
|
|
|
97
|
+
<a id="features"></a>
|
|
98
|
+
|
|
61
99
|
## ✨ Features
|
|
62
100
|
|
|
63
101
|
Most features are available out-of-the-box in the **TypeScript SDK**:
|
|
64
102
|
|
|
65
|
-
- **
|
|
66
|
-
- **Flexible Storage** - Redis, SQLite, File System, or In-Memory backends
|
|
103
|
+
- **Storage Backends** - Redis, SQLite, File System, or In-Memory backends
|
|
67
104
|
- **Serverless** - Works in serverless environments (Vercel, AWS Lambda, etc.)
|
|
68
105
|
- **React Hook** - `useMcp` hook for easy React integration
|
|
69
106
|
- **Vue Composable** - `useMcp` composable for Vue applications
|
|
107
|
+
- **SSE** - Server-Sent Events for connection state and observability updates
|
|
70
108
|
- **MCP Protocol** - Support for tools, prompts, and resources
|
|
71
109
|
- **Agent Adapters** - Built-in adapters for AI SDK, LangChain, Mastra, and AG-UI
|
|
72
110
|
- **MCP Apps Extension (SEP-1865)** - Interactive UI-driven tool interfaces
|
|
111
|
+
- **ToolRouter** - Discover tools on-demand across multiple MCP servers (reduces context bloat)
|
|
112
|
+
|
|
113
|
+
<a id="examples"></a>
|
|
73
114
|
|
|
74
115
|
## 🧪 Examples
|
|
75
116
|
|
|
@@ -91,9 +132,11 @@ Check out working examples demonstrating the MCP Apps extension and agent integr
|
|
|
91
132
|
<p><em>Interactive UIs for MCP tools</em></p>
|
|
92
133
|
</div>
|
|
93
134
|
|
|
135
|
+
<a id="inspiration"></a>
|
|
136
|
+
|
|
94
137
|
## 💡 Inspiration
|
|
95
138
|
|
|
96
|
-
> I got the idea for `@mcp-ts` while working on
|
|
139
|
+
> I got the idea for `@mcp-ts` while working on **[MCP Assistant](https://mcp-assistant.in)**.
|
|
97
140
|
As the project grew, I had a few problems: storage, using different AI frameworks like LangGraph and ADK for different use cases, and figuring out how to get progressive SSE updates at each step so I could see what was happening.
|
|
98
141
|
So with that idea in mind, I built this SDK to make setup easier and keep the user experience smooth.
|
|
99
142
|
That’s how `@mcp-ts` started.
|
|
@@ -106,10 +149,14 @@ That’s how `@mcp-ts` started.
|
|
|
106
149
|
|
|
107
150
|
<br/>
|
|
108
151
|
|
|
152
|
+
<a id="sdk-setup-mcp-tssdk"></a>
|
|
153
|
+
|
|
109
154
|
## 🛠️ SDK Setup (@mcp-ts/sdk)
|
|
110
155
|
|
|
111
156
|
### 📦 Installation
|
|
112
157
|
|
|
158
|
+
<a id="installation"></a>
|
|
159
|
+
|
|
113
160
|
```bash
|
|
114
161
|
npm install @mcp-ts/sdk
|
|
115
162
|
```
|
|
@@ -122,7 +169,12 @@ The SDK supports multiple storage backends out of the box:
|
|
|
122
169
|
|
|
123
170
|
### 🚀 Quick Start
|
|
124
171
|
|
|
125
|
-
|
|
172
|
+
<a id="quick-start"></a>
|
|
173
|
+
|
|
174
|
+
Working reference: [examples/next](examples/next)
|
|
175
|
+
|
|
176
|
+
<details>
|
|
177
|
+
<summary><strong>Server-Side (Next.js)</strong></summary>
|
|
126
178
|
|
|
127
179
|
```typescript
|
|
128
180
|
// app/api/mcp/route.ts
|
|
@@ -138,7 +190,10 @@ export const { GET, POST } = createNextMcpHandler({
|
|
|
138
190
|
});
|
|
139
191
|
```
|
|
140
192
|
|
|
141
|
-
|
|
193
|
+
</details>
|
|
194
|
+
|
|
195
|
+
<details>
|
|
196
|
+
<summary><strong>Client-Side (React)</strong></summary>
|
|
142
197
|
|
|
143
198
|
```typescript
|
|
144
199
|
'use client';
|
|
@@ -177,8 +232,52 @@ function App() {
|
|
|
177
232
|
}
|
|
178
233
|
```
|
|
179
234
|
|
|
235
|
+
</details>
|
|
236
|
+
|
|
237
|
+
### 🌐 MCP Endpoint (Hosted)
|
|
238
|
+
|
|
239
|
+
<a id="-mcp-endpoint-hosted"></a>
|
|
240
|
+
|
|
241
|
+
#### Documentation MCP
|
|
242
|
+
|
|
243
|
+
- **Endpoint**: `https://docs.mcp-assistant.in/mcp`
|
|
244
|
+
- Use this endpoint to access `mcp-ts` / toolkit documentation over MCP.
|
|
245
|
+
|
|
246
|
+
#### MCP Assistant
|
|
247
|
+
|
|
248
|
+
- **Endpoint**: `https://api.mcp-assistant.in/mcp`
|
|
249
|
+
- `api.mcp-assistant.in/mcp` is the MCP Assistant server endpoint. It provides access to 100+ MCP servers such as GitHub, Notion, Zapier, and Supabase.
|
|
250
|
+
- The MCP Assistant server also exposes meta-tools for dynamic MCP discovery and a `CodeMode` tool that executes programs inside a secure sandbox for programmatic tool calling, workflow execution, and result processing, avoiding expensive LLM tool-calling loops.
|
|
251
|
+
|
|
252
|
+
#### Antigravity
|
|
253
|
+
|
|
254
|
+
```json
|
|
255
|
+
{
|
|
256
|
+
"mcpServers": {
|
|
257
|
+
"mcp-assistant": {
|
|
258
|
+
"serverUrl": "https://api.mcp-assistant.in/mcp"
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### VS Code
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"servers": {
|
|
269
|
+
"mcp-assistant": {
|
|
270
|
+
"type": "http",
|
|
271
|
+
"url": "https://api.mcp-assistant.in/mcp"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
180
277
|
### 🔌 Adapters
|
|
181
278
|
|
|
279
|
+
<a id="-adapters"></a>
|
|
280
|
+
|
|
182
281
|
Integrating with agent frameworks is simple using built-in adapters.
|
|
183
282
|
|
|
184
283
|
<details>
|
|
@@ -249,6 +348,8 @@ const tools = await MastraAdapter.getTools(client);
|
|
|
249
348
|
|
|
250
349
|
### 🧩 AG-UI Middleware
|
|
251
350
|
|
|
351
|
+
<a id="-ag-ui-middleware"></a>
|
|
352
|
+
|
|
252
353
|
Execute MCP tools server-side when using remote agents (LangGraph, AutoGen, etc.):
|
|
253
354
|
|
|
254
355
|
<details>
|
|
@@ -282,24 +383,27 @@ The middleware intercepts tool calls from remote agents, executes MCP tools serv
|
|
|
282
383
|
|
|
283
384
|
### 🛠️ MCP Apps (SEP-1865)
|
|
284
385
|
|
|
285
|
-
|
|
386
|
+
<a id="mcp-apps-sep-1865"></a>
|
|
387
|
+
<a id="-mcp-apps-sep-1865"></a>
|
|
388
|
+
|
|
389
|
+
Render interactive UIs for your tools using `McpAppRenderer`.
|
|
286
390
|
|
|
287
391
|
<details>
|
|
288
392
|
<summary>View MCP Apps</summary>
|
|
289
393
|
|
|
290
394
|
```typescript
|
|
291
395
|
import { useRenderToolCall } from "@copilotkit/react-core";
|
|
292
|
-
import {
|
|
396
|
+
import { McpAppRenderer } from "@mcp-ts/sdk/client/react";
|
|
293
397
|
import { useMcpContext } from "./mcp";
|
|
294
398
|
|
|
295
399
|
export function ToolRenderer() {
|
|
296
400
|
const { mcpClient } = useMcpContext();
|
|
297
|
-
const { McpAppRenderer } = useMcpApps(mcpClient);
|
|
298
401
|
|
|
299
402
|
useRenderToolCall({
|
|
300
403
|
name: "*",
|
|
301
404
|
render: ({ name, args, result, status }) => (
|
|
302
405
|
<McpAppRenderer
|
|
406
|
+
client={mcpClient}
|
|
303
407
|
name={name}
|
|
304
408
|
input={args}
|
|
305
409
|
result={result}
|
|
@@ -314,18 +418,25 @@ export function ToolRenderer() {
|
|
|
314
418
|
|
|
315
419
|
</details>
|
|
316
420
|
|
|
421
|
+
<a id="documentation"></a>
|
|
422
|
+
|
|
317
423
|
## 📚 Documentation
|
|
318
424
|
|
|
319
425
|
Full documentation is available at: **[Docs](https://docs.mcp-assistant.in/)**
|
|
320
426
|
|
|
321
|
-
|
|
427
|
+
<a id="topics-covered"></a>
|
|
428
|
+
<a id="️-topics-covered"></a>
|
|
429
|
+
|
|
430
|
+
### 🗂️ Topics Covered
|
|
322
431
|
|
|
323
432
|
- **[Getting Started](https://docs.mcp-assistant.in/get-started)** - Quick setup and overview
|
|
324
433
|
- **[Installation](https://docs.mcp-assistant.in/install)** - Detailed installation guide
|
|
325
|
-
- **[Storage Backends](https://docs.mcp-assistant.in/storage/overview)** - Redis, File, Memory options
|
|
434
|
+
- **[Storage Backends](https://docs.mcp-assistant.in/storage-backends/overview)** - Redis, File, SQLite, Supabase, Neon, and Memory options
|
|
326
435
|
- **[Next.js Integration](https://docs.mcp-assistant.in/nextjs)** - Complete Next.js examples
|
|
327
436
|
- **[React Hook Guide](https://docs.mcp-assistant.in/react)** - Using the useMcp hook
|
|
328
|
-
- **[API Reference](https://docs.mcp-assistant.in/
|
|
437
|
+
- **[API Reference](https://docs.mcp-assistant.in/reference/server)** - Complete API documentation
|
|
438
|
+
|
|
439
|
+
<a id="environment-setup"></a>
|
|
329
440
|
|
|
330
441
|
## ⚙️ Environment Setup
|
|
331
442
|
|
|
@@ -333,15 +444,17 @@ The library supports multiple storage backends. You can explicitly select one us
|
|
|
333
444
|
|
|
334
445
|
**Supported Types:** `redis`, `supabase`, `neon`, `sqlite`, `file`, `memory`.
|
|
335
446
|
|
|
447
|
+
<a id="-configuration-examples"></a>
|
|
448
|
+
|
|
336
449
|
### 🧷 Configuration Examples
|
|
337
450
|
|
|
338
|
-
1.
|
|
451
|
+
1. **Redis** (Recommended for production)
|
|
339
452
|
```bash
|
|
340
453
|
MCP_TS_STORAGE_TYPE=redis
|
|
341
454
|
REDIS_URL=redis://localhost:6379
|
|
342
455
|
```
|
|
343
456
|
|
|
344
|
-
2.
|
|
457
|
+
2. **SQLite** (Fast & Persistent)
|
|
345
458
|
```bash
|
|
346
459
|
MCP_TS_STORAGE_TYPE=sqlite
|
|
347
460
|
# Optional path
|
|
@@ -354,23 +467,27 @@ The library supports multiple storage backends. You can explicitly select one us
|
|
|
354
467
|
NEON_DATABASE_URL=postgresql://user:password@host.neon.tech/dbname?sslmode=verify-full&channel_binding=require
|
|
355
468
|
```
|
|
356
469
|
|
|
357
|
-
4.
|
|
470
|
+
4. **File System** (Great for local dev)
|
|
358
471
|
```bash
|
|
359
472
|
MCP_TS_STORAGE_TYPE=file
|
|
360
473
|
MCP_TS_STORAGE_FILE=./sessions.json
|
|
361
474
|
```
|
|
362
475
|
|
|
363
|
-
5.
|
|
476
|
+
5. **In-Memory** (Default for testing)
|
|
364
477
|
```bash
|
|
365
478
|
MCP_TS_STORAGE_TYPE=memory
|
|
366
479
|
```
|
|
367
480
|
|
|
368
481
|
---
|
|
369
482
|
|
|
483
|
+
<a id="gateway-setup-mcpassistant-gateway"></a>
|
|
484
|
+
|
|
370
485
|
## 🐍 Gateway Setup (mcpassistant-gateway)
|
|
371
486
|
|
|
372
487
|
The **MCP Gateway** is a Python-based bridge that allows local MCP servers to be accessed by remote applications via an outbound connection. This is useful for providing local context (like your filesystem) to a hosted AI agent.
|
|
373
488
|
|
|
489
|
+
<a id="installation-1"></a>
|
|
490
|
+
|
|
374
491
|
### 📦 Installation
|
|
375
492
|
|
|
376
493
|
```bash
|
|
@@ -379,6 +496,8 @@ pip install mcpassistant-gateway
|
|
|
379
496
|
|
|
380
497
|
### 🚀 Usage
|
|
381
498
|
|
|
499
|
+
<a id="usage"></a>
|
|
500
|
+
|
|
382
501
|
You can run the gateway using `uvx` or `pip`:
|
|
383
502
|
|
|
384
503
|
```bash
|
|
@@ -391,6 +510,8 @@ uvx mcpassistant-gateway run --name "local-files"
|
|
|
391
510
|
|
|
392
511
|
---
|
|
393
512
|
|
|
513
|
+
<a id="architecture"></a>
|
|
514
|
+
|
|
394
515
|
## 🏗️ Architecture
|
|
395
516
|
|
|
396
517
|
The MCP Toolkit supports two common runtime topologies:
|
|
@@ -434,15 +555,17 @@ graph LR
|
|
|
434
555
|
> [!NOTE]
|
|
435
556
|
> This package (`@mcp-ts/sdk`) provides a unified MCP client with support for adapters and storage backends such as AI SDK, Mastra, LangChain, and Redis.
|
|
436
557
|
> Adapters and storage backends are loaded via **optional peer dependencies** and must be installed independently. This ensures your application only includes the integrations you explicitly choose, keeping bundle size small and avoiding unnecessary dependencies.
|
|
437
|
-
> The SDK includes built-in support for **Memory** and **File** storage, while additional backends (such as Redis) and adapters can be added without impacting users who don
|
|
558
|
+
> The SDK includes built-in support for **Memory** and **File** storage, while additional backends (such as Redis) and adapters can be added without impacting users who don't need them.
|
|
438
559
|
|
|
439
560
|
For more details, refer to the documentation and follow the **installation guide for each adapter or storage backend**.
|
|
440
561
|
|
|
441
|
-
- [AI SDK Installation Guide](https://docs.mcp-assistant.in/adapters/ai-sdk)
|
|
442
|
-
- [Mastra Installation Guide](https://docs.mcp-assistant.in/adapters/mastra)
|
|
443
|
-
- [LangChain Installation Guide](https://docs.mcp-assistant.in/adapters/langchain)
|
|
444
|
-
- [Redis Storage Installation Guide](https://docs.mcp-assistant.in/storage/redis)
|
|
562
|
+
- [AI SDK Installation Guide](https://docs.mcp-assistant.in/ai-adapters/ai-sdk)
|
|
563
|
+
- [Mastra Installation Guide](https://docs.mcp-assistant.in/ai-adapters/mastra)
|
|
564
|
+
- [LangChain Installation Guide](https://docs.mcp-assistant.in/ai-adapters/langchain)
|
|
565
|
+
- [Redis Storage Installation Guide](https://docs.mcp-assistant.in/storage-backends/redis)
|
|
566
|
+
|
|
445
567
|
|
|
568
|
+
<a id="contributing"></a>
|
|
446
569
|
|
|
447
570
|
## 🤝 Contributing
|
|
448
571
|
|
|
@@ -452,7 +575,6 @@ Contributions are welcome! Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for
|
|
|
452
575
|
<br />
|
|
453
576
|
|
|
454
577
|
<p align="center">
|
|
455
|
-
<em>
|
|
456
|
-
<img src="https://visitor-badge.laobi.icu/badge?page_id=zonlabs.mcp-ts&style=for-the-badge&color=00d4ff" alt="Views">
|
|
578
|
+
<em>Thanks for visiting @mcp-ts!</em>
|
|
457
579
|
</p>
|
|
458
580
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
2
|
-
import { d as ToolRouter } from '../tool-router-
|
|
3
|
-
import '../events-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-k-9RvWvi.mjs';
|
|
2
|
+
import { d as ToolRouter } from '../tool-router-CuApsDiV.mjs';
|
|
3
|
+
import '../events-C4m7tK1U.mjs';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
7
|
-
import '../types-
|
|
7
|
+
import '../types-DCk_IF4L.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* MCP Adapter for AG-UI Integration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
2
|
-
import { d as ToolRouter } from '../tool-router-
|
|
3
|
-
import '../events-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-Bwm-efqg.js';
|
|
2
|
+
import { d as ToolRouter } from '../tool-router-CZMrOG8J.js';
|
|
3
|
+
import '../events-C4m7tK1U.js';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
7
|
-
import '../types-
|
|
7
|
+
import '../types-DCk_IF4L.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* MCP Adapter for AG-UI Integration
|
|
@@ -2,13 +2,13 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { Middleware, RunAgentInput, AbstractAgent, BaseEvent } from '@ag-ui/client';
|
|
3
3
|
export { AbstractAgent, BaseEvent, EventType, Middleware, RunAgentInput, Tool, ToolCallEndEvent } from '@ag-ui/client';
|
|
4
4
|
import { AguiTool } from './agui-adapter.mjs';
|
|
5
|
-
import '../multi-session-client-
|
|
6
|
-
import '../events-
|
|
5
|
+
import '../multi-session-client-k-9RvWvi.mjs';
|
|
6
|
+
import '../events-C4m7tK1U.mjs';
|
|
7
7
|
import '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
9
9
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
10
|
-
import '../tool-router-
|
|
11
|
-
import '../types-
|
|
10
|
+
import '../tool-router-CuApsDiV.mjs';
|
|
11
|
+
import '../types-DCk_IF4L.mjs';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* AG-UI Middleware for MCP Tool Execution
|
|
@@ -2,13 +2,13 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { Middleware, RunAgentInput, AbstractAgent, BaseEvent } from '@ag-ui/client';
|
|
3
3
|
export { AbstractAgent, BaseEvent, EventType, Middleware, RunAgentInput, Tool, ToolCallEndEvent } from '@ag-ui/client';
|
|
4
4
|
import { AguiTool } from './agui-adapter.js';
|
|
5
|
-
import '../multi-session-client-
|
|
6
|
-
import '../events-
|
|
5
|
+
import '../multi-session-client-Bwm-efqg.js';
|
|
6
|
+
import '../events-C4m7tK1U.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/types.js';
|
|
8
8
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
9
9
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
10
|
-
import '../tool-router-
|
|
11
|
-
import '../types-
|
|
10
|
+
import '../tool-router-CZMrOG8J.js';
|
|
11
|
+
import '../types-DCk_IF4L.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* AG-UI Middleware for MCP Tool Execution
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-k-9RvWvi.mjs';
|
|
2
2
|
import { ToolSet } from 'ai';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
4
|
-
import '../events-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-CuApsDiV.mjs';
|
|
4
|
+
import '../events-C4m7tK1U.mjs';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
8
|
-
import '../types-
|
|
8
|
+
import '../types-DCk_IF4L.mjs';
|
|
9
9
|
|
|
10
10
|
interface AIAdapterOptions {
|
|
11
11
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-Bwm-efqg.js';
|
|
2
2
|
import { ToolSet } from 'ai';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
4
|
-
import '../events-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-CZMrOG8J.js';
|
|
4
|
+
import '../events-C4m7tK1U.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
8
|
-
import '../types-
|
|
8
|
+
import '../types-DCk_IF4L.js';
|
|
9
9
|
|
|
10
10
|
interface AIAdapterOptions {
|
|
11
11
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-k-9RvWvi.mjs';
|
|
2
2
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
4
|
-
import '../events-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-CuApsDiV.mjs';
|
|
4
|
+
import '../events-C4m7tK1U.mjs';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
8
|
-
import '../types-
|
|
8
|
+
import '../types-DCk_IF4L.mjs';
|
|
9
9
|
|
|
10
10
|
interface LangChainAdapterOptions {
|
|
11
11
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-Bwm-efqg.js';
|
|
2
2
|
import { StructuredTool } from '@langchain/core/tools';
|
|
3
|
-
import { d as ToolRouter } from '../tool-router-
|
|
4
|
-
import '../events-
|
|
3
|
+
import { d as ToolRouter } from '../tool-router-CZMrOG8J.js';
|
|
4
|
+
import '../events-C4m7tK1U.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
7
7
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
8
|
-
import '../types-
|
|
8
|
+
import '../types-DCk_IF4L.js';
|
|
9
9
|
|
|
10
10
|
interface LangChainAdapterOptions {
|
|
11
11
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-k-9RvWvi.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import '../events-
|
|
3
|
+
import '../events-C4m7tK1U.mjs';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-
|
|
1
|
+
import { M as MCPClient, a as MultiSessionClient } from '../multi-session-client-Bwm-efqg.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import '../events-
|
|
3
|
+
import '../events-C4m7tK1U.js';
|
|
4
4
|
import '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import '@modelcontextprotocol/sdk/client/auth.js';
|
|
6
6
|
import '@modelcontextprotocol/sdk/shared/auth.js';
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from '../index-
|
|
2
|
-
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from '../events-
|
|
3
|
-
export { q as McpRpcRequest, r as McpRpcResponse, v as ToolInfo } from '../types-
|
|
1
|
+
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from '../index-L5XoXgsb.mjs';
|
|
2
|
+
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from '../events-C4m7tK1U.mjs';
|
|
3
|
+
export { q as McpRpcRequest, r as McpRpcResponse, v as ToolInfo } from '../types-DCk_IF4L.mjs';
|
|
4
4
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from '../index-
|
|
2
|
-
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from '../events-
|
|
3
|
-
export { q as McpRpcRequest, r as McpRpcResponse, v as ToolInfo } from '../types-
|
|
1
|
+
export { A as APP_HOST_DEFAULTS, a as AppHost, D as DEFAULT_MCP_APP_CSP, S as SANDBOX_PROXY_READY_METHOD, b as SANDBOX_RESOURCE_READY_METHOD, c as SSEClient, d as SSEClientOptions } from '../index-Ch7ouNSa.js';
|
|
2
|
+
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, M as McpConnectionEvent, c as McpConnectionState, d as McpObservabilityEvent } from '../events-C4m7tK1U.js';
|
|
3
|
+
export { q as McpRpcRequest, r as McpRpcResponse, v as ToolInfo } from '../types-DCk_IF4L.js';
|
|
4
4
|
import '@modelcontextprotocol/ext-apps/app-bridge';
|
|
5
5
|
import '@modelcontextprotocol/sdk/types.js';
|
package/dist/client/index.js
CHANGED
|
@@ -48,8 +48,8 @@ var SSEClient = class {
|
|
|
48
48
|
async getSession(sessionId) {
|
|
49
49
|
return this.sendRequest("getSession", { sessionId });
|
|
50
50
|
}
|
|
51
|
-
async finishAuth(
|
|
52
|
-
return this.sendRequest("finishAuth", {
|
|
51
|
+
async finishAuth(state, code) {
|
|
52
|
+
return this.sendRequest("finishAuth", { state, code });
|
|
53
53
|
}
|
|
54
54
|
async listPrompts(sessionId) {
|
|
55
55
|
return this.sendRequest("listPrompts", { sessionId });
|