@smithery/api 0.23.0 → 0.25.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/CHANGELOG.md +21 -0
- package/client.d.mts +6 -6
- package/client.d.mts.map +1 -1
- package/client.d.ts +6 -6
- package/client.d.ts.map +1 -1
- package/client.js.map +1 -1
- package/client.mjs +1 -1
- package/client.mjs.map +1 -1
- package/lib/mcp-transport.d.mts +102 -0
- package/lib/mcp-transport.d.mts.map +1 -0
- package/lib/mcp-transport.d.ts +102 -0
- package/lib/mcp-transport.d.ts.map +1 -0
- package/lib/mcp-transport.js +233 -0
- package/lib/mcp-transport.js.map +1 -0
- package/lib/mcp-transport.mjs +229 -0
- package/lib/mcp-transport.mjs.map +1 -0
- package/package.json +34 -2
- package/resources/beta/connect/connect.d.mts +2 -2
- package/resources/beta/connect/connect.d.mts.map +1 -1
- package/resources/beta/connect/connect.d.ts +2 -2
- package/resources/beta/connect/connect.d.ts.map +1 -1
- package/resources/beta/connect/connect.js.map +1 -1
- package/resources/beta/connect/connect.mjs.map +1 -1
- package/resources/beta/connect/connections.d.mts +38 -24
- package/resources/beta/connect/connections.d.mts.map +1 -1
- package/resources/beta/connect/connections.d.ts +38 -24
- package/resources/beta/connect/connections.d.ts.map +1 -1
- package/resources/beta/connect/connections.js +21 -21
- package/resources/beta/connect/connections.js.map +1 -1
- package/resources/beta/connect/connections.mjs +21 -21
- package/resources/beta/connect/connections.mjs.map +1 -1
- package/resources/beta/connect/index.d.mts +1 -1
- package/resources/beta/connect/index.d.mts.map +1 -1
- package/resources/beta/connect/index.d.ts +1 -1
- package/resources/beta/connect/index.d.ts.map +1 -1
- package/resources/beta/connect/index.js.map +1 -1
- package/resources/beta/connect/index.mjs.map +1 -1
- package/resources/index.d.mts +3 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/namespaces.d.mts +11 -16
- package/resources/namespaces.d.mts.map +1 -1
- package/resources/namespaces.d.ts +11 -16
- package/resources/namespaces.d.ts.map +1 -1
- package/resources/namespaces.js +12 -15
- package/resources/namespaces.js.map +1 -1
- package/resources/namespaces.mjs +12 -15
- package/resources/namespaces.mjs.map +1 -1
- package/resources/servers/deployments.d.mts +30 -27
- package/resources/servers/deployments.d.mts.map +1 -1
- package/resources/servers/deployments.d.ts +30 -27
- package/resources/servers/deployments.d.ts.map +1 -1
- package/resources/servers/deployments.js +7 -7
- package/resources/servers/deployments.js.map +1 -1
- package/resources/servers/deployments.mjs +7 -7
- package/resources/servers/deployments.mjs.map +1 -1
- package/resources/servers/index.d.mts +2 -2
- package/resources/servers/index.d.mts.map +1 -1
- package/resources/servers/index.d.ts +2 -2
- package/resources/servers/index.d.ts.map +1 -1
- package/resources/servers/servers.d.mts +30 -30
- package/resources/servers/servers.d.mts.map +1 -1
- package/resources/servers/servers.d.ts +30 -30
- package/resources/servers/servers.d.ts.map +1 -1
- package/resources/servers/servers.js +6 -6
- package/resources/servers/servers.js.map +1 -1
- package/resources/servers/servers.mjs +6 -6
- package/resources/servers/servers.mjs.map +1 -1
- package/resources/tokens.d.mts +96 -63
- package/resources/tokens.d.mts.map +1 -1
- package/resources/tokens.d.ts +96 -63
- package/resources/tokens.d.ts.map +1 -1
- package/resources/tokens.js +1 -4
- package/resources/tokens.js.map +1 -1
- package/resources/tokens.mjs +1 -4
- package/resources/tokens.mjs.map +1 -1
- package/src/client.ts +20 -5
- package/src/lib/mcp-transport.ts +300 -0
- package/src/resources/beta/connect/connect.ts +4 -2
- package/src/resources/beta/connect/connections.ts +53 -35
- package/src/resources/beta/connect/index.ts +2 -1
- package/src/resources/index.ts +13 -3
- package/src/resources/namespaces.ts +17 -17
- package/src/resources/servers/deployments.ts +45 -47
- package/src/resources/servers/index.ts +3 -3
- package/src/resources/servers/servers.ts +49 -49
- package/src/resources/tokens.ts +103 -58
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SmitheryTransport - An MCP Transport that routes JSON-RPC messages through Smithery Connect.
|
|
4
|
+
*
|
|
5
|
+
* This allows you to use the official MCP SDK's Client class with Smithery Connect as the transport layer.
|
|
6
|
+
*
|
|
7
|
+
* **Important:** Smithery Connect handles MCP initialization server-side when a connection is created.
|
|
8
|
+
* This transport lazily fetches/creates the connection on first message and uses its server info
|
|
9
|
+
* to satisfy the MCP SDK's initialization flow without re-initializing the already-established connection.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
14
|
+
* import Smithery from '@smithery/api';
|
|
15
|
+
* import { SmitheryTransport } from '@smithery/api/mcp';
|
|
16
|
+
*
|
|
17
|
+
* const smithery = new Smithery({ apiKey: process.env.SMITHERY_API_KEY });
|
|
18
|
+
* // Option 1: Let Smithery generate a connection ID and use default namespace
|
|
19
|
+
* const transport = new SmitheryTransport({
|
|
20
|
+
* client: smithery,
|
|
21
|
+
* mcpUrl: 'https://mcp.example.com/sse',
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Option 2: Use a specific namespace and connection ID
|
|
25
|
+
* const transport2 = new SmitheryTransport({
|
|
26
|
+
* client: smithery,
|
|
27
|
+
* namespace: 'my-namespace',
|
|
28
|
+
* connectionId: 'my-connection',
|
|
29
|
+
* mcpUrl: 'https://mcp.example.com/sse',
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* const mcpClient = new Client({ name: 'my-app', version: '1.0.0' }, { capabilities: {} });
|
|
33
|
+
* await mcpClient.connect(transport);
|
|
34
|
+
*
|
|
35
|
+
* // Now use the MCP SDK's ergonomic API
|
|
36
|
+
* const { tools } = await mcpClient.listTools();
|
|
37
|
+
* const result = await mcpClient.callTool({ name: 'my-tool', arguments: {} });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.SmitheryTransport = void 0;
|
|
42
|
+
// MCP protocol version
|
|
43
|
+
const LATEST_PROTOCOL_VERSION = '2024-11-05';
|
|
44
|
+
class SmitheryTransport {
|
|
45
|
+
/**
|
|
46
|
+
* Returns the connection ID. If no connectionId was provided in options,
|
|
47
|
+
* this returns the auto-generated ID after the first message is sent.
|
|
48
|
+
*/
|
|
49
|
+
get connectionId() {
|
|
50
|
+
return this._connectionId;
|
|
51
|
+
}
|
|
52
|
+
constructor(options) {
|
|
53
|
+
this._started = false;
|
|
54
|
+
this._closed = false;
|
|
55
|
+
this._connection = null;
|
|
56
|
+
this._client = options.client;
|
|
57
|
+
this._namespace = options.namespace;
|
|
58
|
+
this._connectionId = options.connectionId;
|
|
59
|
+
this._mcpUrl = options.mcpUrl;
|
|
60
|
+
// Validate: mcpUrl is required if connectionId is not provided
|
|
61
|
+
if (!this._connectionId && !this._mcpUrl) {
|
|
62
|
+
throw new Error('mcpUrl is required when connectionId is not provided');
|
|
63
|
+
}
|
|
64
|
+
this._capabilities = options.capabilities ?? {
|
|
65
|
+
// Default to advertising common capabilities
|
|
66
|
+
// The actual MCP server behind Smithery Connect will handle the real capabilities
|
|
67
|
+
tools: {},
|
|
68
|
+
resources: {},
|
|
69
|
+
prompts: {},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
async start() {
|
|
73
|
+
if (this._started) {
|
|
74
|
+
throw new Error('SmitheryTransport already started! If using Client class, note that connect() calls start() automatically.');
|
|
75
|
+
}
|
|
76
|
+
if (this._closed) {
|
|
77
|
+
throw new Error('Transport has been closed');
|
|
78
|
+
}
|
|
79
|
+
this._started = true;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Lazily ensures a namespace is available.
|
|
83
|
+
* If no namespace was provided, uses the first existing namespace or creates a new one.
|
|
84
|
+
*/
|
|
85
|
+
async _ensureNamespace() {
|
|
86
|
+
if (this._namespace) {
|
|
87
|
+
return this._namespace;
|
|
88
|
+
}
|
|
89
|
+
const { namespaces } = await this._client.namespaces.list();
|
|
90
|
+
if (namespaces.length > 0) {
|
|
91
|
+
this._namespace = namespaces[0].name;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// Create a new namespace with server-generated name
|
|
95
|
+
const { name } = await this._client.namespaces.create();
|
|
96
|
+
this._namespace = name;
|
|
97
|
+
}
|
|
98
|
+
return this._namespace;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Lazily ensures the Smithery Connect connection exists.
|
|
102
|
+
* Called on first message to defer network IO until actually needed.
|
|
103
|
+
*/
|
|
104
|
+
async _ensureConnection() {
|
|
105
|
+
if (this._connection) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const namespace = await this._ensureNamespace();
|
|
109
|
+
if (this._connectionId) {
|
|
110
|
+
// Connection ID provided: try to get, or create if mcpUrl is provided
|
|
111
|
+
try {
|
|
112
|
+
this._connection = await this._client.beta.connect.connections.get(this._connectionId, {
|
|
113
|
+
namespace,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
// If connection doesn't exist and we have mcpUrl, create it with the specified ID
|
|
118
|
+
if (this._mcpUrl) {
|
|
119
|
+
this._connection = await this._client.beta.connect.connections.set(this._connectionId, {
|
|
120
|
+
namespace,
|
|
121
|
+
mcpUrl: this._mcpUrl,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// No connection ID: create a new connection with auto-generated ID
|
|
131
|
+
// mcpUrl is guaranteed to be present (validated in constructor)
|
|
132
|
+
this._connection = await this._client.beta.connect.connections.create(namespace, {
|
|
133
|
+
mcpUrl: this._mcpUrl,
|
|
134
|
+
});
|
|
135
|
+
// Store the generated connection ID for subsequent RPC calls
|
|
136
|
+
this._connectionId = this._connection.connectionId;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async send(message, _options) {
|
|
140
|
+
if (!this._started) {
|
|
141
|
+
throw new Error('Transport not started');
|
|
142
|
+
}
|
|
143
|
+
if (this._closed) {
|
|
144
|
+
throw new Error('Transport has been closed');
|
|
145
|
+
}
|
|
146
|
+
// Only handle outgoing requests and notifications (messages with a method)
|
|
147
|
+
if (!('method' in message)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
// Lazily ensure connection exists before processing any message
|
|
151
|
+
await this._ensureConnection();
|
|
152
|
+
// Intercept 'initialize' request - Smithery Connect handles initialization server-side
|
|
153
|
+
// Return the real serverInfo from the connection
|
|
154
|
+
if (message.method === 'initialize' && 'id' in message && message.id !== undefined) {
|
|
155
|
+
if (this.onmessage) {
|
|
156
|
+
const serverInfo = this._connection?.serverInfo ?? {
|
|
157
|
+
name: 'smithery-connect',
|
|
158
|
+
version: '1.0.0',
|
|
159
|
+
};
|
|
160
|
+
const initializeResponse = {
|
|
161
|
+
jsonrpc: '2.0',
|
|
162
|
+
id: message.id,
|
|
163
|
+
result: {
|
|
164
|
+
protocolVersion: LATEST_PROTOCOL_VERSION,
|
|
165
|
+
serverInfo: {
|
|
166
|
+
name: serverInfo.name,
|
|
167
|
+
version: serverInfo.version,
|
|
168
|
+
},
|
|
169
|
+
capabilities: this._capabilities,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
// Use setTimeout to make this async and match real transport behavior
|
|
173
|
+
setTimeout(() => this.onmessage(initializeResponse), 0);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// Intercept 'notifications/initialized' - no response needed, just acknowledge
|
|
178
|
+
if (message.method === 'notifications/initialized') {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
// Build the RPC call params, only including id if it's defined
|
|
183
|
+
// _namespace is guaranteed to be set after _ensureConnection
|
|
184
|
+
const rpcParams = {
|
|
185
|
+
namespace: this._namespace,
|
|
186
|
+
jsonrpc: '2.0',
|
|
187
|
+
method: message.method,
|
|
188
|
+
};
|
|
189
|
+
// Only add id if present (for requests, not notifications)
|
|
190
|
+
if ('id' in message && message.id !== undefined) {
|
|
191
|
+
rpcParams.id = message.id;
|
|
192
|
+
}
|
|
193
|
+
// Only add params if present
|
|
194
|
+
if ('params' in message && message.params !== undefined) {
|
|
195
|
+
rpcParams.params = message.params;
|
|
196
|
+
}
|
|
197
|
+
const response = await this._client.beta.connect.rpc.call(this._connectionId, rpcParams);
|
|
198
|
+
// Route the response back via onmessage callback for requests (messages with an id)
|
|
199
|
+
if ('id' in message && message.id !== undefined && this.onmessage) {
|
|
200
|
+
const jsonRpcResponse = {
|
|
201
|
+
jsonrpc: '2.0',
|
|
202
|
+
id: response.id,
|
|
203
|
+
result: response.result,
|
|
204
|
+
};
|
|
205
|
+
this.onmessage(jsonRpcResponse);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
210
|
+
// For requests, send an error response via onmessage
|
|
211
|
+
if ('id' in message && message.id !== undefined && this.onmessage) {
|
|
212
|
+
const errorResponse = {
|
|
213
|
+
jsonrpc: '2.0',
|
|
214
|
+
id: message.id,
|
|
215
|
+
error: {
|
|
216
|
+
code: -32603, // Internal error
|
|
217
|
+
message: normalizedError.message,
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
this.onmessage(errorResponse);
|
|
221
|
+
}
|
|
222
|
+
// Also report via onerror callback
|
|
223
|
+
this.onerror?.(normalizedError);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
async close() {
|
|
227
|
+
this._closed = true;
|
|
228
|
+
this._started = false;
|
|
229
|
+
this.onclose?.();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
exports.SmitheryTransport = SmitheryTransport;
|
|
233
|
+
//# sourceMappingURL=mcp-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-transport.js","sourceRoot":"","sources":["../src/lib/mcp-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;;AAuCH,uBAAuB;AACvB,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAE7C,MAAa,iBAAiB;IAgB5B;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,YAAY,OAAiC;QAnBrC,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAAG,KAAK,CAAC;QAEhB,gBAAW,GAAsB,IAAI,CAAC;QAiB5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;QACpC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAE9B,+DAA+D;QAC/D,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,IAAI;YAC3C,6CAA6C;YAC7C,kFAAkF;YAClF,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;SACZ,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,4GAA4G,CAC7G,CAAC;Q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CAAC;CACF;AA5ND,8CA4NC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmitheryTransport - An MCP Transport that routes JSON-RPC messages through Smithery Connect.
|
|
3
|
+
*
|
|
4
|
+
* This allows you to use the official MCP SDK's Client class with Smithery Connect as the transport layer.
|
|
5
|
+
*
|
|
6
|
+
* **Important:** Smithery Connect handles MCP initialization server-side when a connection is created.
|
|
7
|
+
* This transport lazily fetches/creates the connection on first message and uses its server info
|
|
8
|
+
* to satisfy the MCP SDK's initialization flow without re-initializing the already-established connection.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
13
|
+
* import Smithery from '@smithery/api';
|
|
14
|
+
* import { SmitheryTransport } from '@smithery/api/mcp';
|
|
15
|
+
*
|
|
16
|
+
* const smithery = new Smithery({ apiKey: process.env.SMITHERY_API_KEY });
|
|
17
|
+
* // Option 1: Let Smithery generate a connection ID and use default namespace
|
|
18
|
+
* const transport = new SmitheryTransport({
|
|
19
|
+
* client: smithery,
|
|
20
|
+
* mcpUrl: 'https://mcp.example.com/sse',
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Option 2: Use a specific namespace and connection ID
|
|
24
|
+
* const transport2 = new SmitheryTransport({
|
|
25
|
+
* client: smithery,
|
|
26
|
+
* namespace: 'my-namespace',
|
|
27
|
+
* connectionId: 'my-connection',
|
|
28
|
+
* mcpUrl: 'https://mcp.example.com/sse',
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* const mcpClient = new Client({ name: 'my-app', version: '1.0.0' }, { capabilities: {} });
|
|
32
|
+
* await mcpClient.connect(transport);
|
|
33
|
+
*
|
|
34
|
+
* // Now use the MCP SDK's ergonomic API
|
|
35
|
+
* const { tools } = await mcpClient.listTools();
|
|
36
|
+
* const result = await mcpClient.callTool({ name: 'my-tool', arguments: {} });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
// MCP protocol version
|
|
40
|
+
const LATEST_PROTOCOL_VERSION = '2024-11-05';
|
|
41
|
+
export class SmitheryTransport {
|
|
42
|
+
/**
|
|
43
|
+
* Returns the connection ID. If no connectionId was provided in options,
|
|
44
|
+
* this returns the auto-generated ID after the first message is sent.
|
|
45
|
+
*/
|
|
46
|
+
get connectionId() {
|
|
47
|
+
return this._connectionId;
|
|
48
|
+
}
|
|
49
|
+
constructor(options) {
|
|
50
|
+
this._started = false;
|
|
51
|
+
this._closed = false;
|
|
52
|
+
this._connection = null;
|
|
53
|
+
this._client = options.client;
|
|
54
|
+
this._namespace = options.namespace;
|
|
55
|
+
this._connectionId = options.connectionId;
|
|
56
|
+
this._mcpUrl = options.mcpUrl;
|
|
57
|
+
// Validate: mcpUrl is required if connectionId is not provided
|
|
58
|
+
if (!this._connectionId && !this._mcpUrl) {
|
|
59
|
+
throw new Error('mcpUrl is required when connectionId is not provided');
|
|
60
|
+
}
|
|
61
|
+
this._capabilities = options.capabilities ?? {
|
|
62
|
+
// Default to advertising common capabilities
|
|
63
|
+
// The actual MCP server behind Smithery Connect will handle the real capabilities
|
|
64
|
+
tools: {},
|
|
65
|
+
resources: {},
|
|
66
|
+
prompts: {},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async start() {
|
|
70
|
+
if (this._started) {
|
|
71
|
+
throw new Error('SmitheryTransport already started! If using Client class, note that connect() calls start() automatically.');
|
|
72
|
+
}
|
|
73
|
+
if (this._closed) {
|
|
74
|
+
throw new Error('Transport has been closed');
|
|
75
|
+
}
|
|
76
|
+
this._started = true;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Lazily ensures a namespace is available.
|
|
80
|
+
* If no namespace was provided, uses the first existing namespace or creates a new one.
|
|
81
|
+
*/
|
|
82
|
+
async _ensureNamespace() {
|
|
83
|
+
if (this._namespace) {
|
|
84
|
+
return this._namespace;
|
|
85
|
+
}
|
|
86
|
+
const { namespaces } = await this._client.namespaces.list();
|
|
87
|
+
if (namespaces.length > 0) {
|
|
88
|
+
this._namespace = namespaces[0].name;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Create a new namespace with server-generated name
|
|
92
|
+
const { name } = await this._client.namespaces.create();
|
|
93
|
+
this._namespace = name;
|
|
94
|
+
}
|
|
95
|
+
return this._namespace;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Lazily ensures the Smithery Connect connection exists.
|
|
99
|
+
* Called on first message to defer network IO until actually needed.
|
|
100
|
+
*/
|
|
101
|
+
async _ensureConnection() {
|
|
102
|
+
if (this._connection) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const namespace = await this._ensureNamespace();
|
|
106
|
+
if (this._connectionId) {
|
|
107
|
+
// Connection ID provided: try to get, or create if mcpUrl is provided
|
|
108
|
+
try {
|
|
109
|
+
this._connection = await this._client.beta.connect.connections.get(this._connectionId, {
|
|
110
|
+
namespace,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
// If connection doesn't exist and we have mcpUrl, create it with the specified ID
|
|
115
|
+
if (this._mcpUrl) {
|
|
116
|
+
this._connection = await this._client.beta.connect.connections.set(this._connectionId, {
|
|
117
|
+
namespace,
|
|
118
|
+
mcpUrl: this._mcpUrl,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// No connection ID: create a new connection with auto-generated ID
|
|
128
|
+
// mcpUrl is guaranteed to be present (validated in constructor)
|
|
129
|
+
this._connection = await this._client.beta.connect.connections.create(namespace, {
|
|
130
|
+
mcpUrl: this._mcpUrl,
|
|
131
|
+
});
|
|
132
|
+
// Store the generated connection ID for subsequent RPC calls
|
|
133
|
+
this._connectionId = this._connection.connectionId;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async send(message, _options) {
|
|
137
|
+
if (!this._started) {
|
|
138
|
+
throw new Error('Transport not started');
|
|
139
|
+
}
|
|
140
|
+
if (this._closed) {
|
|
141
|
+
throw new Error('Transport has been closed');
|
|
142
|
+
}
|
|
143
|
+
// Only handle outgoing requests and notifications (messages with a method)
|
|
144
|
+
if (!('method' in message)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Lazily ensure connection exists before processing any message
|
|
148
|
+
await this._ensureConnection();
|
|
149
|
+
// Intercept 'initialize' request - Smithery Connect handles initialization server-side
|
|
150
|
+
// Return the real serverInfo from the connection
|
|
151
|
+
if (message.method === 'initialize' && 'id' in message && message.id !== undefined) {
|
|
152
|
+
if (this.onmessage) {
|
|
153
|
+
const serverInfo = this._connection?.serverInfo ?? {
|
|
154
|
+
name: 'smithery-connect',
|
|
155
|
+
version: '1.0.0',
|
|
156
|
+
};
|
|
157
|
+
const initializeResponse = {
|
|
158
|
+
jsonrpc: '2.0',
|
|
159
|
+
id: message.id,
|
|
160
|
+
result: {
|
|
161
|
+
protocolVersion: LATEST_PROTOCOL_VERSION,
|
|
162
|
+
serverInfo: {
|
|
163
|
+
name: serverInfo.name,
|
|
164
|
+
version: serverInfo.version,
|
|
165
|
+
},
|
|
166
|
+
capabilities: this._capabilities,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
// Use setTimeout to make this async and match real transport behavior
|
|
170
|
+
setTimeout(() => this.onmessage(initializeResponse), 0);
|
|
171
|
+
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
// Intercept 'notifications/initialized' - no response needed, just acknowledge
|
|
175
|
+
if (message.method === 'notifications/initialized') {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
// Build the RPC call params, only including id if it's defined
|
|
180
|
+
// _namespace is guaranteed to be set after _ensureConnection
|
|
181
|
+
const rpcParams = {
|
|
182
|
+
namespace: this._namespace,
|
|
183
|
+
jsonrpc: '2.0',
|
|
184
|
+
method: message.method,
|
|
185
|
+
};
|
|
186
|
+
// Only add id if present (for requests, not notifications)
|
|
187
|
+
if ('id' in message && message.id !== undefined) {
|
|
188
|
+
rpcParams.id = message.id;
|
|
189
|
+
}
|
|
190
|
+
// Only add params if present
|
|
191
|
+
if ('params' in message && message.params !== undefined) {
|
|
192
|
+
rpcParams.params = message.params;
|
|
193
|
+
}
|
|
194
|
+
const response = await this._client.beta.connect.rpc.call(this._connectionId, rpcParams);
|
|
195
|
+
// Route the response back via onmessage callback for requests (messages with an id)
|
|
196
|
+
if ('id' in message && message.id !== undefined && this.onmessage) {
|
|
197
|
+
const jsonRpcResponse = {
|
|
198
|
+
jsonrpc: '2.0',
|
|
199
|
+
id: response.id,
|
|
200
|
+
result: response.result,
|
|
201
|
+
};
|
|
202
|
+
this.onmessage(jsonRpcResponse);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
207
|
+
// For requests, send an error response via onmessage
|
|
208
|
+
if ('id' in message && message.id !== undefined && this.onmessage) {
|
|
209
|
+
const errorResponse = {
|
|
210
|
+
jsonrpc: '2.0',
|
|
211
|
+
id: message.id,
|
|
212
|
+
error: {
|
|
213
|
+
code: -32603, // Internal error
|
|
214
|
+
message: normalizedError.message,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
this.onmessage(errorResponse);
|
|
218
|
+
}
|
|
219
|
+
// Also report via onerror callback
|
|
220
|
+
this.onerror?.(normalizedError);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
async close() {
|
|
224
|
+
this._closed = true;
|
|
225
|
+
this._started = false;
|
|
226
|
+
this.onclose?.();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=mcp-transport.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-transport.mjs","sourceRoot":"","sources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IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBAClE,MAAM,eAAe,GAAoB;oBACvC,OAAO,EAAE,KAAK;oBACd,EAAE,EAAE,QAAQ,CAAC,EAAG;oBAChB,MAAM,EAAE,QAAQ,CAAC,MAAiC;iBACnD,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,eAAe,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAElF,qDAAqD;YACrD,IAAI,IAAI,IAAI,OAAO,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBAClE,MAAM,aAAa,GAAoB;oBACrC,OAAO,EAAE,KAAK;oBACd,EAAE,EAAE,OAAO,CAAC,EAAE;oBACd,KAAK,EAAE;wBACL,IAAI,EAAE,CAAC,KAAK,EAAE,iBAAiB;wBAC/B,OAAO,EAAE,eAAe,CAAC,OAAO;qBACjC;iBACF,CAAC;gBACF,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAChC,CAAC;YAED,mCAAmC;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;IACnB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithery/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "The official TypeScript library for the Smithery API",
|
|
5
5
|
"author": "Smithery <contact@smithery.ai>",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
-
"dependencies": {},
|
|
19
18
|
"exports": {
|
|
20
19
|
".": {
|
|
21
20
|
"require": {
|
|
@@ -75,6 +74,16 @@
|
|
|
75
74
|
"./index.mjs": {
|
|
76
75
|
"default": "./index.mjs"
|
|
77
76
|
},
|
|
77
|
+
"./lib/*.mjs": {
|
|
78
|
+
"default": "./lib/*.mjs"
|
|
79
|
+
},
|
|
80
|
+
"./lib/*.js": {
|
|
81
|
+
"default": "./lib/*.js"
|
|
82
|
+
},
|
|
83
|
+
"./lib/*": {
|
|
84
|
+
"import": "./lib/*.mjs",
|
|
85
|
+
"require": "./lib/*.js"
|
|
86
|
+
},
|
|
78
87
|
"./pagination": {
|
|
79
88
|
"import": "./pagination.mjs",
|
|
80
89
|
"require": "./pagination.js"
|
|
@@ -134,6 +143,29 @@
|
|
|
134
143
|
},
|
|
135
144
|
"./version.mjs": {
|
|
136
145
|
"default": "./version.mjs"
|
|
146
|
+
},
|
|
147
|
+
"./mcp": {
|
|
148
|
+
"require": {
|
|
149
|
+
"types": "./lib/mcp-transport.d.ts",
|
|
150
|
+
"default": "./lib/mcp-transport.js"
|
|
151
|
+
},
|
|
152
|
+
"types": "./lib/mcp-transport.d.mts",
|
|
153
|
+
"default": "./lib/mcp-transport.mjs"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"peerDependencies": {
|
|
157
|
+
"@modelcontextprotocol/sdk": ">=1.0.0"
|
|
158
|
+
},
|
|
159
|
+
"peerDependenciesMeta": {
|
|
160
|
+
"@modelcontextprotocol/sdk": {
|
|
161
|
+
"optional": true
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"typesVersions": {
|
|
165
|
+
"*": {
|
|
166
|
+
"mcp": [
|
|
167
|
+
"./lib/mcp-transport.d.ts"
|
|
168
|
+
]
|
|
137
169
|
}
|
|
138
170
|
},
|
|
139
171
|
"scripts": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIResource } from "../../../core/resource.mjs";
|
|
2
2
|
import * as ConnectionsAPI from "./connections.mjs";
|
|
3
|
-
import { Connection, ConnectionCreateParams, ConnectionDeleteParams, ConnectionDeleteResponse,
|
|
3
|
+
import { Connection, ConnectionCreateParams, ConnectionDeleteParams, ConnectionDeleteResponse, ConnectionGetParams, ConnectionListParams, ConnectionSetParams, Connections, ConnectionsListResponse, CreateConnectionRequest } from "./connections.mjs";
|
|
4
4
|
import * as RpcAPI from "./rpc.mjs";
|
|
5
5
|
import { JsonRpcRequest, JsonRpcResponse, Rpc, RpcCallParams } from "./rpc.mjs";
|
|
6
6
|
export declare class Connect extends APIResource {
|
|
@@ -8,7 +8,7 @@ export declare class Connect extends APIResource {
|
|
|
8
8
|
rpc: RpcAPI.Rpc;
|
|
9
9
|
}
|
|
10
10
|
export declare namespace Connect {
|
|
11
|
-
export { Connections as Connections, type Connection as Connection, type ConnectionsListResponse as ConnectionsListResponse, type CreateConnectionRequest as CreateConnectionRequest, type ConnectionDeleteResponse as ConnectionDeleteResponse, type ConnectionCreateParams as ConnectionCreateParams, type
|
|
11
|
+
export { Connections as Connections, type Connection as Connection, type ConnectionsListResponse as ConnectionsListResponse, type CreateConnectionRequest as CreateConnectionRequest, type ConnectionDeleteResponse as ConnectionDeleteResponse, type ConnectionCreateParams as ConnectionCreateParams, type ConnectionListParams as ConnectionListParams, type ConnectionDeleteParams as ConnectionDeleteParams, type ConnectionGetParams as ConnectionGetParams, type ConnectionSetParams as ConnectionSetParams, };
|
|
12
12
|
export { Rpc as Rpc, type JsonRpcRequest as JsonRpcRequest, type JsonRpcResponse as JsonRpcResponse, type RpcCallParams as RpcCallParams, };
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=connect.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,cAAc;OACnB,EACL,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"connect.d.mts","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,cAAc;OACnB,EACL,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACxB;OACM,KAAK,MAAM;OACX,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,EAAE;AAE9D,qBAAa,OAAQ,SAAQ,WAAW;IACtC,WAAW,EAAE,cAAc,CAAC,WAAW,CAAgD;IACvF,GAAG,EAAE,MAAM,CAAC,GAAG,CAAgC;CAChD;AAKD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EACL,WAAW,IAAI,WAAW,EAC1B,KAAK,UAAU,IAAI,UAAU,EAC7B,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,GAChD,CAAC;IAEF,OAAO,EACL,GAAG,IAAI,GAAG,EACV,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,aAAa,IAAI,aAAa,GACpC,CAAC;CACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APIResource } from "../../../core/resource.js";
|
|
2
2
|
import * as ConnectionsAPI from "./connections.js";
|
|
3
|
-
import { Connection, ConnectionCreateParams, ConnectionDeleteParams, ConnectionDeleteResponse,
|
|
3
|
+
import { Connection, ConnectionCreateParams, ConnectionDeleteParams, ConnectionDeleteResponse, ConnectionGetParams, ConnectionListParams, ConnectionSetParams, Connections, ConnectionsListResponse, CreateConnectionRequest } from "./connections.js";
|
|
4
4
|
import * as RpcAPI from "./rpc.js";
|
|
5
5
|
import { JsonRpcRequest, JsonRpcResponse, Rpc, RpcCallParams } from "./rpc.js";
|
|
6
6
|
export declare class Connect extends APIResource {
|
|
@@ -8,7 +8,7 @@ export declare class Connect extends APIResource {
|
|
|
8
8
|
rpc: RpcAPI.Rpc;
|
|
9
9
|
}
|
|
10
10
|
export declare namespace Connect {
|
|
11
|
-
export { Connections as Connections, type Connection as Connection, type ConnectionsListResponse as ConnectionsListResponse, type CreateConnectionRequest as CreateConnectionRequest, type ConnectionDeleteResponse as ConnectionDeleteResponse, type ConnectionCreateParams as ConnectionCreateParams, type
|
|
11
|
+
export { Connections as Connections, type Connection as Connection, type ConnectionsListResponse as ConnectionsListResponse, type CreateConnectionRequest as CreateConnectionRequest, type ConnectionDeleteResponse as ConnectionDeleteResponse, type ConnectionCreateParams as ConnectionCreateParams, type ConnectionListParams as ConnectionListParams, type ConnectionDeleteParams as ConnectionDeleteParams, type ConnectionGetParams as ConnectionGetParams, type ConnectionSetParams as ConnectionSetParams, };
|
|
12
12
|
export { Rpc as Rpc, type JsonRpcRequest as JsonRpcRequest, type JsonRpcResponse as JsonRpcResponse, type RpcCallParams as RpcCallParams, };
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,cAAc;OACnB,EACL,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,cAAc;OACnB,EACL,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACxB;OACM,KAAK,MAAM;OACX,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,EAAE,aAAa,EAAE;AAE9D,qBAAa,OAAQ,SAAQ,WAAW;IACtC,WAAW,EAAE,cAAc,CAAC,WAAW,CAAgD;IACvF,GAAG,EAAE,MAAM,CAAC,GAAG,CAAgC;CAChD;AAKD,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EACL,WAAW,IAAI,WAAW,EAC1B,KAAK,UAAU,IAAI,UAAU,EAC7B,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,wBAAwB,IAAI,wBAAwB,EACzD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,oBAAoB,IAAI,oBAAoB,EACjD,KAAK,sBAAsB,IAAI,sBAAsB,EACrD,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,mBAAmB,IAAI,mBAAmB,GAChD,CAAC;IAEF,OAAO,EACL,GAAG,IAAI,GAAG,EACV,KAAK,cAAc,IAAI,cAAc,EACrC,KAAK,eAAe,IAAI,eAAe,EACvC,KAAK,aAAa,IAAI,aAAa,GACpC,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AACrD,yEAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,wDAAqD;AACrD,yEAAgD;AAChD,kDAWuB;AACvB,yDAAgC;AAChC,kCAA4E;AAE5E,MAAa,OAAQ,SAAQ,sBAAW;IAAxC;;QACE,gBAAW,GAA+B,IAAI,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvF,QAAG,GAAe,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CAAA;AAHD,0BAGC;AAED,OAAO,CAAC,WAAW,GAAG,yBAAW,CAAC;AAClC,OAAO,CAAC,GAAG,GAAG,SAAG,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.mjs","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,KAAK,cAAc;OACnB,
|
|
1
|
+
{"version":3,"file":"connect.mjs","sourceRoot":"","sources":["../../../src/resources/beta/connect/connect.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,KAAK,cAAc;OACnB,EAQL,WAAW,GAGZ;OACM,KAAK,MAAM;OACX,EAAmC,GAAG,EAAiB;AAE9D,MAAM,OAAO,OAAQ,SAAQ,WAAW;IAAxC;;QACE,gBAAW,GAA+B,IAAI,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvF,QAAG,GAAe,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CAAA;AAED,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;AAClC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC"}
|