@mcp-ts/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +297 -0
- package/dist/adapters/agui-adapter.d.mts +119 -0
- package/dist/adapters/agui-adapter.d.ts +119 -0
- package/dist/adapters/agui-adapter.js +109 -0
- package/dist/adapters/agui-adapter.js.map +1 -0
- package/dist/adapters/agui-adapter.mjs +107 -0
- package/dist/adapters/agui-adapter.mjs.map +1 -0
- package/dist/adapters/agui-middleware.d.mts +171 -0
- package/dist/adapters/agui-middleware.d.ts +171 -0
- package/dist/adapters/agui-middleware.js +429 -0
- package/dist/adapters/agui-middleware.js.map +1 -0
- package/dist/adapters/agui-middleware.mjs +417 -0
- package/dist/adapters/agui-middleware.mjs.map +1 -0
- package/dist/adapters/ai-adapter.d.mts +38 -0
- package/dist/adapters/ai-adapter.d.ts +38 -0
- package/dist/adapters/ai-adapter.js +82 -0
- package/dist/adapters/ai-adapter.js.map +1 -0
- package/dist/adapters/ai-adapter.mjs +80 -0
- package/dist/adapters/ai-adapter.mjs.map +1 -0
- package/dist/adapters/langchain-adapter.d.mts +46 -0
- package/dist/adapters/langchain-adapter.d.ts +46 -0
- package/dist/adapters/langchain-adapter.js +102 -0
- package/dist/adapters/langchain-adapter.js.map +1 -0
- package/dist/adapters/langchain-adapter.mjs +100 -0
- package/dist/adapters/langchain-adapter.mjs.map +1 -0
- package/dist/adapters/mastra-adapter.d.mts +49 -0
- package/dist/adapters/mastra-adapter.d.ts +49 -0
- package/dist/adapters/mastra-adapter.js +95 -0
- package/dist/adapters/mastra-adapter.js.map +1 -0
- package/dist/adapters/mastra-adapter.mjs +93 -0
- package/dist/adapters/mastra-adapter.mjs.map +1 -0
- package/dist/client/index.d.mts +119 -0
- package/dist/client/index.d.ts +119 -0
- package/dist/client/index.js +225 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +223 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/client/react.d.mts +151 -0
- package/dist/client/react.d.ts +151 -0
- package/dist/client/react.js +492 -0
- package/dist/client/react.js.map +1 -0
- package/dist/client/react.mjs +489 -0
- package/dist/client/react.mjs.map +1 -0
- package/dist/client/vue.d.mts +157 -0
- package/dist/client/vue.d.ts +157 -0
- package/dist/client/vue.js +474 -0
- package/dist/client/vue.js.map +1 -0
- package/dist/client/vue.mjs +471 -0
- package/dist/client/vue.mjs.map +1 -0
- package/dist/events-BP6WyRNh.d.mts +110 -0
- package/dist/events-BP6WyRNh.d.ts +110 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2784 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2723 -0
- package/dist/index.mjs.map +1 -0
- package/dist/multi-session-client-BOFgPypS.d.ts +389 -0
- package/dist/multi-session-client-DMF3ED2O.d.mts +389 -0
- package/dist/server/index.d.mts +269 -0
- package/dist/server/index.d.ts +269 -0
- package/dist/server/index.js +2444 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/index.mjs +2414 -0
- package/dist/server/index.mjs.map +1 -0
- package/dist/shared/index.d.mts +24 -0
- package/dist/shared/index.d.ts +24 -0
- package/dist/shared/index.js +223 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/index.mjs +190 -0
- package/dist/shared/index.mjs.map +1 -0
- package/dist/types-SbDlA2VX.d.mts +153 -0
- package/dist/types-SbDlA2VX.d.ts +153 -0
- package/dist/utils-0qmYrqoa.d.mts +92 -0
- package/dist/utils-0qmYrqoa.d.ts +92 -0
- package/package.json +165 -0
- package/src/adapters/agui-adapter.ts +210 -0
- package/src/adapters/agui-middleware.ts +512 -0
- package/src/adapters/ai-adapter.ts +115 -0
- package/src/adapters/langchain-adapter.ts +127 -0
- package/src/adapters/mastra-adapter.ts +126 -0
- package/src/client/core/sse-client.ts +340 -0
- package/src/client/index.ts +26 -0
- package/src/client/react/index.ts +10 -0
- package/src/client/react/useMcp.ts +558 -0
- package/src/client/vue/index.ts +10 -0
- package/src/client/vue/useMcp.ts +542 -0
- package/src/index.ts +11 -0
- package/src/server/handlers/nextjs-handler.ts +216 -0
- package/src/server/handlers/sse-handler.ts +699 -0
- package/src/server/index.ts +57 -0
- package/src/server/mcp/multi-session-client.ts +132 -0
- package/src/server/mcp/oauth-client.ts +1168 -0
- package/src/server/mcp/storage-oauth-provider.ts +239 -0
- package/src/server/storage/file-backend.ts +169 -0
- package/src/server/storage/index.ts +115 -0
- package/src/server/storage/memory-backend.ts +132 -0
- package/src/server/storage/redis-backend.ts +210 -0
- package/src/server/storage/redis.ts +160 -0
- package/src/server/storage/types.ts +109 -0
- package/src/shared/constants.ts +29 -0
- package/src/shared/errors.ts +133 -0
- package/src/shared/events.ts +166 -0
- package/src/shared/index.ts +70 -0
- package/src/shared/types.ts +274 -0
- package/src/shared/utils.ts +16 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { c as McpConnectionState, M as McpConnectionEvent } from '../events-BP6WyRNh.mjs';
|
|
2
|
+
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, d as McpObservabilityEvent } from '../events-BP6WyRNh.mjs';
|
|
3
|
+
import { T as ToolInfo, k as FinishAuthResult, n as ListToolsRpcResult, L as ListPromptsResult, l as ListResourcesResult } from '../types-SbDlA2VX.mjs';
|
|
4
|
+
export { p as McpRpcRequest, q as McpRpcResponse } from '../types-SbDlA2VX.mjs';
|
|
5
|
+
export { SSEClient, SSEClientOptions } from './index.mjs';
|
|
6
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* useMcp Vue Composable
|
|
10
|
+
* Manages MCP connections with SSE-based real-time updates
|
|
11
|
+
* Based on Cloudflare's agents pattern
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface UseMcpOptions {
|
|
15
|
+
/**
|
|
16
|
+
* SSE endpoint URL
|
|
17
|
+
*/
|
|
18
|
+
url: string;
|
|
19
|
+
/**
|
|
20
|
+
* User/Client identifier
|
|
21
|
+
*/
|
|
22
|
+
identity: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional auth token
|
|
25
|
+
*/
|
|
26
|
+
authToken?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Auto-connect on mount
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
autoConnect?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Auto-initialize sessions on mount
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
autoInitialize?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Connection event callback
|
|
39
|
+
*/
|
|
40
|
+
onConnectionEvent?: (event: McpConnectionEvent) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Debug logging callback
|
|
43
|
+
*/
|
|
44
|
+
onLog?: (level: string, message: string, metadata?: Record<string, unknown>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Optional callback to handle OAuth redirects (e.g. for popup flow)
|
|
47
|
+
* If provided, this will be called instead of window.location.href assignment
|
|
48
|
+
*/
|
|
49
|
+
onRedirect?: (url: string) => void;
|
|
50
|
+
}
|
|
51
|
+
interface McpConnection {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
serverId: string;
|
|
54
|
+
serverName: string;
|
|
55
|
+
serverUrl?: string;
|
|
56
|
+
transport?: string;
|
|
57
|
+
state: McpConnectionState;
|
|
58
|
+
tools: ToolInfo[];
|
|
59
|
+
error?: string;
|
|
60
|
+
connectedAt?: Date;
|
|
61
|
+
}
|
|
62
|
+
interface McpClient {
|
|
63
|
+
/**
|
|
64
|
+
* All connections (Represents a Reactive Ref)
|
|
65
|
+
*/
|
|
66
|
+
connections: {
|
|
67
|
+
value: McpConnection[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* SSE connection status (Represents a Reactive Ref)
|
|
71
|
+
*/
|
|
72
|
+
status: {
|
|
73
|
+
value: 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Whether initializing (Represents a Reactive Ref)
|
|
77
|
+
*/
|
|
78
|
+
isInitializing: {
|
|
79
|
+
value: boolean;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Connect to an MCP server
|
|
83
|
+
*/
|
|
84
|
+
connect: (params: {
|
|
85
|
+
serverId: string;
|
|
86
|
+
serverName: string;
|
|
87
|
+
serverUrl: string;
|
|
88
|
+
callbackUrl: string;
|
|
89
|
+
transportType?: 'sse' | 'streamable_http';
|
|
90
|
+
}) => Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Disconnect from an MCP server
|
|
93
|
+
*/
|
|
94
|
+
disconnect: (sessionId: string) => Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get connection by session ID
|
|
97
|
+
*/
|
|
98
|
+
getConnection: (sessionId: string) => McpConnection | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get connection by server ID
|
|
101
|
+
*/
|
|
102
|
+
getConnectionByServerId: (serverId: string) => McpConnection | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Check if server is connected
|
|
105
|
+
*/
|
|
106
|
+
isServerConnected: (serverId: string) => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Get tools for a session
|
|
109
|
+
*/
|
|
110
|
+
getTools: (sessionId: string) => ToolInfo[];
|
|
111
|
+
/**
|
|
112
|
+
* Refresh all connections
|
|
113
|
+
*/
|
|
114
|
+
refresh: () => Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Manually connect SSE
|
|
117
|
+
*/
|
|
118
|
+
connectSSE: () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Manually disconnect SSE
|
|
121
|
+
*/
|
|
122
|
+
disconnectSSE: () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Complete OAuth authorization
|
|
125
|
+
*/
|
|
126
|
+
finishAuth: (sessionId: string, code: string) => Promise<FinishAuthResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Call a tool from a session
|
|
129
|
+
*/
|
|
130
|
+
callTool: (sessionId: string, toolName: string, toolArgs: Record<string, unknown>) => Promise<unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* List available tools for a session
|
|
133
|
+
*/
|
|
134
|
+
listTools: (sessionId: string) => Promise<ListToolsRpcResult>;
|
|
135
|
+
/**
|
|
136
|
+
* List available prompts for a session
|
|
137
|
+
*/
|
|
138
|
+
listPrompts: (sessionId: string) => Promise<ListPromptsResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Get a specific prompt with arguments
|
|
141
|
+
*/
|
|
142
|
+
getPrompt: (sessionId: string, name: string, args?: Record<string, string>) => Promise<unknown>;
|
|
143
|
+
/**
|
|
144
|
+
* List available resources for a session
|
|
145
|
+
*/
|
|
146
|
+
listResources: (sessionId: string) => Promise<ListResourcesResult>;
|
|
147
|
+
/**
|
|
148
|
+
* Read a specific resource
|
|
149
|
+
*/
|
|
150
|
+
readResource: (sessionId: string, uri: string) => Promise<unknown>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Vue Composable for MCP connection management with SSE
|
|
154
|
+
*/
|
|
155
|
+
declare function useMcp(options: UseMcpOptions): McpClient;
|
|
156
|
+
|
|
157
|
+
export { type McpClient, type McpConnection, McpConnectionEvent, McpConnectionState, ToolInfo, type UseMcpOptions, useMcp };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { c as McpConnectionState, M as McpConnectionEvent } from '../events-BP6WyRNh.js';
|
|
2
|
+
export { D as Disposable, a as DisposableStore, E as Emitter, b as Event, d as McpObservabilityEvent } from '../events-BP6WyRNh.js';
|
|
3
|
+
import { T as ToolInfo, k as FinishAuthResult, n as ListToolsRpcResult, L as ListPromptsResult, l as ListResourcesResult } from '../types-SbDlA2VX.js';
|
|
4
|
+
export { p as McpRpcRequest, q as McpRpcResponse } from '../types-SbDlA2VX.js';
|
|
5
|
+
export { SSEClient, SSEClientOptions } from './index.js';
|
|
6
|
+
import '@modelcontextprotocol/sdk/types.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* useMcp Vue Composable
|
|
10
|
+
* Manages MCP connections with SSE-based real-time updates
|
|
11
|
+
* Based on Cloudflare's agents pattern
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface UseMcpOptions {
|
|
15
|
+
/**
|
|
16
|
+
* SSE endpoint URL
|
|
17
|
+
*/
|
|
18
|
+
url: string;
|
|
19
|
+
/**
|
|
20
|
+
* User/Client identifier
|
|
21
|
+
*/
|
|
22
|
+
identity: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional auth token
|
|
25
|
+
*/
|
|
26
|
+
authToken?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Auto-connect on mount
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
autoConnect?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Auto-initialize sessions on mount
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
autoInitialize?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Connection event callback
|
|
39
|
+
*/
|
|
40
|
+
onConnectionEvent?: (event: McpConnectionEvent) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Debug logging callback
|
|
43
|
+
*/
|
|
44
|
+
onLog?: (level: string, message: string, metadata?: Record<string, unknown>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Optional callback to handle OAuth redirects (e.g. for popup flow)
|
|
47
|
+
* If provided, this will be called instead of window.location.href assignment
|
|
48
|
+
*/
|
|
49
|
+
onRedirect?: (url: string) => void;
|
|
50
|
+
}
|
|
51
|
+
interface McpConnection {
|
|
52
|
+
sessionId: string;
|
|
53
|
+
serverId: string;
|
|
54
|
+
serverName: string;
|
|
55
|
+
serverUrl?: string;
|
|
56
|
+
transport?: string;
|
|
57
|
+
state: McpConnectionState;
|
|
58
|
+
tools: ToolInfo[];
|
|
59
|
+
error?: string;
|
|
60
|
+
connectedAt?: Date;
|
|
61
|
+
}
|
|
62
|
+
interface McpClient {
|
|
63
|
+
/**
|
|
64
|
+
* All connections (Represents a Reactive Ref)
|
|
65
|
+
*/
|
|
66
|
+
connections: {
|
|
67
|
+
value: McpConnection[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* SSE connection status (Represents a Reactive Ref)
|
|
71
|
+
*/
|
|
72
|
+
status: {
|
|
73
|
+
value: 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Whether initializing (Represents a Reactive Ref)
|
|
77
|
+
*/
|
|
78
|
+
isInitializing: {
|
|
79
|
+
value: boolean;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Connect to an MCP server
|
|
83
|
+
*/
|
|
84
|
+
connect: (params: {
|
|
85
|
+
serverId: string;
|
|
86
|
+
serverName: string;
|
|
87
|
+
serverUrl: string;
|
|
88
|
+
callbackUrl: string;
|
|
89
|
+
transportType?: 'sse' | 'streamable_http';
|
|
90
|
+
}) => Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Disconnect from an MCP server
|
|
93
|
+
*/
|
|
94
|
+
disconnect: (sessionId: string) => Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get connection by session ID
|
|
97
|
+
*/
|
|
98
|
+
getConnection: (sessionId: string) => McpConnection | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Get connection by server ID
|
|
101
|
+
*/
|
|
102
|
+
getConnectionByServerId: (serverId: string) => McpConnection | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Check if server is connected
|
|
105
|
+
*/
|
|
106
|
+
isServerConnected: (serverId: string) => boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Get tools for a session
|
|
109
|
+
*/
|
|
110
|
+
getTools: (sessionId: string) => ToolInfo[];
|
|
111
|
+
/**
|
|
112
|
+
* Refresh all connections
|
|
113
|
+
*/
|
|
114
|
+
refresh: () => Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Manually connect SSE
|
|
117
|
+
*/
|
|
118
|
+
connectSSE: () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Manually disconnect SSE
|
|
121
|
+
*/
|
|
122
|
+
disconnectSSE: () => void;
|
|
123
|
+
/**
|
|
124
|
+
* Complete OAuth authorization
|
|
125
|
+
*/
|
|
126
|
+
finishAuth: (sessionId: string, code: string) => Promise<FinishAuthResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Call a tool from a session
|
|
129
|
+
*/
|
|
130
|
+
callTool: (sessionId: string, toolName: string, toolArgs: Record<string, unknown>) => Promise<unknown>;
|
|
131
|
+
/**
|
|
132
|
+
* List available tools for a session
|
|
133
|
+
*/
|
|
134
|
+
listTools: (sessionId: string) => Promise<ListToolsRpcResult>;
|
|
135
|
+
/**
|
|
136
|
+
* List available prompts for a session
|
|
137
|
+
*/
|
|
138
|
+
listPrompts: (sessionId: string) => Promise<ListPromptsResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Get a specific prompt with arguments
|
|
141
|
+
*/
|
|
142
|
+
getPrompt: (sessionId: string, name: string, args?: Record<string, string>) => Promise<unknown>;
|
|
143
|
+
/**
|
|
144
|
+
* List available resources for a session
|
|
145
|
+
*/
|
|
146
|
+
listResources: (sessionId: string) => Promise<ListResourcesResult>;
|
|
147
|
+
/**
|
|
148
|
+
* Read a specific resource
|
|
149
|
+
*/
|
|
150
|
+
readResource: (sessionId: string, uri: string) => Promise<unknown>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Vue Composable for MCP connection management with SSE
|
|
154
|
+
*/
|
|
155
|
+
declare function useMcp(options: UseMcpOptions): McpClient;
|
|
156
|
+
|
|
157
|
+
export { type McpClient, type McpConnection, McpConnectionEvent, McpConnectionState, ToolInfo, type UseMcpOptions, useMcp };
|