@smithery/api 0.28.0 → 0.30.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.
Files changed (129) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/client.d.mts +2 -2
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +2 -2
  5. package/client.d.ts.map +1 -1
  6. package/lib/mcp-transport.d.mts +57 -69
  7. package/lib/mcp-transport.d.mts.map +1 -1
  8. package/lib/mcp-transport.d.ts +57 -69
  9. package/lib/mcp-transport.d.ts.map +1 -1
  10. package/lib/mcp-transport.js +106 -204
  11. package/lib/mcp-transport.js.map +1 -1
  12. package/lib/mcp-transport.mjs +103 -202
  13. package/lib/mcp-transport.mjs.map +1 -1
  14. package/package.json +1 -1
  15. package/resources/beta/beta.d.mts +2 -2
  16. package/resources/beta/beta.d.mts.map +1 -1
  17. package/resources/beta/beta.d.ts +2 -2
  18. package/resources/beta/beta.d.ts.map +1 -1
  19. package/resources/beta/beta.js.map +1 -1
  20. package/resources/beta/beta.mjs.map +1 -1
  21. package/resources/beta/connect/connect.d.mts +4 -8
  22. package/resources/beta/connect/connect.d.mts.map +1 -1
  23. package/resources/beta/connect/connect.d.ts +4 -8
  24. package/resources/beta/connect/connect.d.ts.map +1 -1
  25. package/resources/beta/connect/connect.js +4 -8
  26. package/resources/beta/connect/connect.js.map +1 -1
  27. package/resources/beta/connect/connect.mjs +4 -8
  28. package/resources/beta/connect/connect.mjs.map +1 -1
  29. package/resources/beta/connect/connections.d.mts +5 -1
  30. package/resources/beta/connect/connections.d.mts.map +1 -1
  31. package/resources/beta/connect/connections.d.ts +5 -1
  32. package/resources/beta/connect/connections.d.ts.map +1 -1
  33. package/resources/beta/connect/index.d.mts +1 -2
  34. package/resources/beta/connect/index.d.mts.map +1 -1
  35. package/resources/beta/connect/index.d.ts +1 -2
  36. package/resources/beta/connect/index.d.ts.map +1 -1
  37. package/resources/beta/connect/index.js +3 -5
  38. package/resources/beta/connect/index.js.map +1 -1
  39. package/resources/beta/connect/index.mjs +1 -2
  40. package/resources/beta/connect/index.mjs.map +1 -1
  41. package/resources/beta/connect/{rpc.d.mts → mcp.d.mts} +9 -9
  42. package/resources/beta/connect/{rpc.d.mts.map → mcp.d.mts.map} +1 -1
  43. package/resources/beta/connect/{rpc.d.ts → mcp.d.ts} +9 -9
  44. package/resources/beta/connect/{rpc.d.ts.map → mcp.d.ts.map} +1 -1
  45. package/resources/beta/connect/{rpc.js → mcp.js} +8 -8
  46. package/resources/beta/connect/{rpc.js.map → mcp.js.map} +1 -1
  47. package/resources/beta/connect/{rpc.mjs → mcp.mjs} +6 -6
  48. package/resources/beta/connect/{rpc.mjs.map → mcp.mjs.map} +1 -1
  49. package/resources/beta/index.d.mts +1 -1
  50. package/resources/beta/index.d.mts.map +1 -1
  51. package/resources/beta/index.d.ts +1 -1
  52. package/resources/beta/index.d.ts.map +1 -1
  53. package/resources/beta/index.js.map +1 -1
  54. package/resources/beta/index.mjs.map +1 -1
  55. package/resources/beta/tools.d.mts +43 -77
  56. package/resources/beta/tools.d.mts.map +1 -1
  57. package/resources/beta/tools.d.ts +43 -77
  58. package/resources/beta/tools.d.ts.map +1 -1
  59. package/resources/beta/tools.js +9 -11
  60. package/resources/beta/tools.js.map +1 -1
  61. package/resources/beta/tools.mjs +9 -11
  62. package/resources/beta/tools.mjs.map +1 -1
  63. package/resources/index.d.mts +1 -1
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +1 -1
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/namespaces/index.d.mts +1 -1
  68. package/resources/namespaces/index.d.mts.map +1 -1
  69. package/resources/namespaces/index.d.ts +1 -1
  70. package/resources/namespaces/index.d.ts.map +1 -1
  71. package/resources/namespaces/index.js.map +1 -1
  72. package/resources/namespaces/index.mjs +1 -1
  73. package/resources/namespaces/index.mjs.map +1 -1
  74. package/resources/namespaces/namespaces.d.mts +2 -2
  75. package/resources/namespaces/namespaces.d.mts.map +1 -1
  76. package/resources/namespaces/namespaces.d.ts +2 -2
  77. package/resources/namespaces/namespaces.d.ts.map +1 -1
  78. package/resources/namespaces/namespaces.js.map +1 -1
  79. package/resources/namespaces/namespaces.mjs.map +1 -1
  80. package/resources/namespaces/servers.d.mts +7 -11
  81. package/resources/namespaces/servers.d.mts.map +1 -1
  82. package/resources/namespaces/servers.d.ts +7 -11
  83. package/resources/namespaces/servers.d.ts.map +1 -1
  84. package/resources/namespaces/servers.js +4 -4
  85. package/resources/namespaces/servers.mjs +4 -4
  86. package/resources/servers/deployments.d.mts +3 -3
  87. package/resources/servers/deployments.d.mts.map +1 -1
  88. package/resources/servers/deployments.d.ts +3 -3
  89. package/resources/servers/deployments.d.ts.map +1 -1
  90. package/resources/servers/servers.d.mts +2 -0
  91. package/resources/servers/servers.d.mts.map +1 -1
  92. package/resources/servers/servers.d.ts +2 -0
  93. package/resources/servers/servers.d.ts.map +1 -1
  94. package/resources/servers/servers.js.map +1 -1
  95. package/resources/servers/servers.mjs.map +1 -1
  96. package/resources/tokens.d.mts +18 -18
  97. package/resources/tokens.d.mts.map +1 -1
  98. package/resources/tokens.d.ts +18 -18
  99. package/resources/tokens.d.ts.map +1 -1
  100. package/src/client.ts +2 -2
  101. package/src/lib/mcp-transport.ts +131 -236
  102. package/src/resources/beta/beta.ts +3 -4
  103. package/src/resources/beta/connect/connect.ts +6 -16
  104. package/src/resources/beta/connect/connections.ts +6 -1
  105. package/src/resources/beta/connect/index.ts +1 -2
  106. package/src/resources/beta/connect/{rpc.ts → mcp.ts} +9 -9
  107. package/src/resources/beta/index.ts +1 -1
  108. package/src/resources/beta/tools.ts +48 -109
  109. package/src/resources/index.ts +1 -1
  110. package/src/resources/namespaces/index.ts +1 -6
  111. package/src/resources/namespaces/namespaces.ts +2 -3
  112. package/src/resources/namespaces/servers.ts +7 -17
  113. package/src/resources/servers/deployments.ts +5 -5
  114. package/src/resources/servers/servers.ts +4 -0
  115. package/src/resources/tokens.ts +17 -17
  116. package/src/version.ts +1 -1
  117. package/version.d.mts +1 -1
  118. package/version.d.ts +1 -1
  119. package/version.js +1 -1
  120. package/version.mjs +1 -1
  121. package/resources/beta/connect/tools.d.mts +0 -47
  122. package/resources/beta/connect/tools.d.mts.map +0 -1
  123. package/resources/beta/connect/tools.d.ts +0 -47
  124. package/resources/beta/connect/tools.d.ts.map +0 -1
  125. package/resources/beta/connect/tools.js +0 -25
  126. package/resources/beta/connect/tools.js.map +0 -1
  127. package/resources/beta/connect/tools.mjs +0 -21
  128. package/resources/beta/connect/tools.mjs.map +0 -1
  129. package/src/resources/beta/connect/tools.ts +0 -70
@@ -1,233 +1,135 @@
1
1
  "use strict";
2
2
  /**
3
- * SmitheryTransport - An MCP Transport that routes JSON-RPC messages through Smithery Connect.
3
+ * Smithery Connect Create an MCP connection that routes through Smithery Connect.
4
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.
5
+ * Smithery Connect acts as a connection manager and credential vault, handling OAuth
6
+ * orchestration with upstream MCP servers. This module provides a factory function
7
+ * that creates a connection and returns a standard MCP SDK transport.
10
8
  *
11
9
  * @example
12
10
  * ```typescript
13
11
  * import { Client } from '@modelcontextprotocol/sdk/client/index.js';
14
- * import Smithery from '@smithery/api';
15
- * import { SmitheryTransport } from '@smithery/api/mcp';
16
- *
17
- * // Simple usage - client auto-created using SMITHERY_API_KEY env var
18
- * const transport = new SmitheryTransport({
19
- * mcpUrl: 'https://mcp.example.com/sse',
20
- * });
12
+ * import { createConnection, SmitheryAuthorizationError } from '@smithery/api/mcp';
21
13
  *
22
- * // Or with explicit client
23
- * const smithery = new Smithery({ apiKey: process.env.SMITHERY_API_KEY });
24
- * const transport2 = new SmitheryTransport({
25
- * client: smithery,
26
- * namespace: 'my-namespace',
27
- * connectionId: 'my-connection',
28
- * mcpUrl: 'https://mcp.example.com/sse',
29
- * });
14
+ * try {
15
+ * const { transport } = await createConnection({
16
+ * mcpUrl: 'https://server.smithery.ai/exa/mcp',
17
+ * });
30
18
  *
31
- * const mcpClient = new Client({ name: 'my-app', version: '1.0.0' }, { capabilities: {} });
32
- * await mcpClient.connect(transport);
19
+ * const client = new Client({ name: 'my-app', version: '1.0.0' }, { capabilities: {} });
20
+ * await client.connect(transport);
33
21
  *
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: {} });
22
+ * const { tools } = await client.listTools();
23
+ * const result = await client.callTool({ name: 'my-tool', arguments: {} });
24
+ * } catch (e) {
25
+ * if (e instanceof SmitheryAuthorizationError) {
26
+ * // The upstream MCP server requires OAuth — redirect the user
27
+ * console.log(`Please authorize: ${e.authorizationUrl}`);
28
+ * // After auth completes, retry with the same connectionId:
29
+ * // await createConnection({ connectionId: e.connectionId });
30
+ * }
31
+ * }
37
32
  * ```
38
33
  */
39
34
  Object.defineProperty(exports, "__esModule", { value: true });
40
- exports.SmitheryTransport = void 0;
35
+ exports.SmitheryAuthorizationError = void 0;
36
+ exports.createConnection = createConnection;
37
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
41
38
  const client_1 = require("../client.js");
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;
39
+ /**
40
+ * Thrown when the upstream MCP server requires OAuth authorization.
41
+ * Contains the authorization URL to redirect the user to, and the connection ID
42
+ * to reuse when retrying after authorization completes.
43
+ */
44
+ class SmitheryAuthorizationError extends Error {
45
+ constructor(message, authorizationUrl, connectionId) {
46
+ super(message);
47
+ this.authorizationUrl = authorizationUrl;
48
+ this.connectionId = connectionId;
49
+ this.name = 'SmitheryAuthorizationError';
51
50
  }
52
- constructor(options) {
53
- this._started = false;
54
- this._closed = false;
55
- this._connection = null;
56
- this._client = options.client ?? new client_1.Smithery();
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
- };
51
+ }
52
+ exports.SmitheryAuthorizationError = SmitheryAuthorizationError;
53
+ /**
54
+ * Creates a Smithery Connect connection and returns an MCP transport.
55
+ *
56
+ * This function handles connection creation/retrieval and returns a standard
57
+ * `StreamableHTTPClientTransport` that can be used with any MCP SDK client.
58
+ * Smithery Connect manages the upstream MCP server connection, including
59
+ * OAuth credential storage and refresh.
60
+ *
61
+ * @throws {SmitheryAuthorizationError} If the upstream MCP server requires OAuth.
62
+ * The error contains `authorizationUrl` (where to redirect the user) and
63
+ * `connectionId` (to reuse when retrying after auth completes).
64
+ */
65
+ async function createConnection(options) {
66
+ const client = options.client ?? new client_1.Smithery();
67
+ // Validate: mcpUrl is required if connectionId is not provided
68
+ if (!options.connectionId && !options.mcpUrl) {
69
+ throw new Error('mcpUrl is required when connectionId is not provided');
71
70
  }
72
- async start() {
73
- if (this._started) {
74
- throw new Error('SmitheryTransport already started! If using Client class, note that connect() calls start() automatically.');
71
+ // Resolve namespace
72
+ const namespace = await resolveNamespace(client, options.namespace);
73
+ // Create or fetch connection
74
+ const connection = await resolveConnection(client, namespace, options.connectionId, options.mcpUrl);
75
+ const connectionId = connection.connectionId;
76
+ // Check connection status (present on create/set responses)
77
+ if (connection.status) {
78
+ if (connection.status.state === 'auth_required') {
79
+ const { authorizationUrl } = connection.status;
80
+ if (authorizationUrl) {
81
+ throw new SmitheryAuthorizationError(`MCP server requires authorization. Please visit: ${authorizationUrl}`, authorizationUrl, connectionId);
82
+ }
83
+ throw new Error('MCP server requires authorization.');
75
84
  }
76
- if (this._closed) {
77
- throw new Error('Transport has been closed');
85
+ if (connection.status.state === 'error') {
86
+ throw new Error(`MCP connection failed: ${connection.status.message}`);
78
87
  }
79
- this._started = true;
80
88
  }
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;
89
+ else if (!connection.serverInfo) {
90
+ // No status field (e.g., fetched via get()) and no serverInfo means the
91
+ // connection never initialized successfully likely requires authorization.
92
+ // Surface this early rather than returning a broken transport.
93
+ throw new Error('Connection is not initialized. The upstream MCP server may require authorization. ' +
94
+ 'Try creating a new connection with mcpUrl to get authorization details.');
99
95
  }
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
- }
96
+ // Build the MCP endpoint URL
97
+ const url = new URL(`/connect/${namespace}/${connectionId}/mcp`, client.baseURL).href;
98
+ // Create transport with auth headers
99
+ const transport = new streamableHttp_js_1.StreamableHTTPClientTransport(new URL(url), {
100
+ requestInit: {
101
+ headers: {
102
+ Authorization: `Bearer ${client.apiKey}`,
103
+ },
104
+ },
105
+ });
106
+ return { transport, connectionId, url };
107
+ }
108
+ async function resolveNamespace(client, namespace) {
109
+ if (namespace) {
110
+ return namespace;
138
111
  }
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
- }
112
+ const { namespaces } = await client.namespaces.list();
113
+ if (namespaces.length > 0) {
114
+ return namespaces[0].name;
115
+ }
116
+ const { name } = await client.namespaces.create();
117
+ return name;
118
+ }
119
+ async function resolveConnection(client, namespace, connectionId, mcpUrl) {
120
+ if (connectionId) {
121
+ // Connection ID provided: try to get, or create if mcpUrl is provided
181
122
  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
- }
123
+ return await client.beta.connect.connections.get(connectionId, { namespace });
207
124
  }
208
125
  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);
126
+ if (mcpUrl) {
127
+ return await client.beta.connect.connections.set(connectionId, { namespace, mcpUrl });
221
128
  }
222
- // Also report via onerror callback
223
- this.onerror?.(normalizedError);
129
+ throw error;
224
130
  }
225
131
  }
226
- async close() {
227
- this._closed = true;
228
- this._started = false;
229
- this.onclose?.();
230
- }
132
+ // No connection ID: create a new connection with auto-generated ID
133
+ return await client.beta.connect.connections.create(namespace, { mcpUrl: mcpUrl });
231
134
  }
232
- exports.SmitheryTransport = SmitheryTransport;
233
135
  //# sourceMappingURL=mcp-transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-transport.js","sourceRoot":"","sources":["../src/lib/mcp-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;;;AAIH,yCAAqC;AAoCrC,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,IAAI,IAAI,iBAAQ,EAAE,CAAC;QAChD,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;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,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