@smithery/sdk 0.0.21 → 0.0.23

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 CHANGED
@@ -34,18 +34,14 @@ The following code sets up the client and connects to an Exa MCP server:
34
34
  import { MultiClient } from "@smithery/sdk"
35
35
  import { OpenAIChatAdapter } from "@smithery/sdk/integrations/llm/openai"
36
36
  import { AnthropicChatAdapter } from "@smithery/sdk/integrations/llm/anthropic"
37
- import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"
37
+ import { createTransport } from "@smithery/sdk/transport.js"
38
38
  import { OpenAI } from "openai"
39
39
  import Anthropic from "@anthropic-ai/sdk"
40
- import EventSource from "eventsource"
41
-
42
- // Patch event source for Node.js environment
43
- global.EventSource = EventSource as any
44
40
 
45
41
  // Create a new connection
46
- const exaTransport = new SSEClientTransport(
42
+ const exaTransport = createTransport(
47
43
  // Replace with your deployed MCP server URL
48
- new URL("https://your-mcp-server.example.com/sse")
44
+ "https://your-mcp-server.example.com"
49
45
  )
50
46
 
51
47
  // Initialize a multi-client connection
@@ -109,23 +105,4 @@ while (!isDone) {
109
105
  }
110
106
  ```
111
107
 
112
- See a full example in the [examples](./src/examples) directory.
113
-
114
- # Troubleshooting
115
-
116
- ```
117
- Error: ReferenceError: EventSource is not defined
118
- ```
119
-
120
- This error means you're trying to use EventSource API (which is typically used in the browser) from Node. Install the following packages:
121
-
122
- ```bash
123
- npm install eventsource
124
- npm install -D @types/eventsource
125
- ```
126
-
127
- Then patch the global EventSource object:
128
-
129
- ```typescript
130
- import EventSource from "eventsource"
131
- global.EventSource = EventSource as any
108
+ See a full example in the [examples](./src/examples) directory.
package/dist/config.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function createSmitheryUrl(baseUrl: string, config: object): URL;
1
+ export declare function createSmitheryUrl(baseUrl: string, config?: object): URL;
package/dist/config.js CHANGED
@@ -1,8 +1,10 @@
1
1
  export function createSmitheryUrl(baseUrl, config) {
2
2
  const url = new URL(baseUrl);
3
- const param = typeof window !== "undefined"
4
- ? btoa(JSON.stringify(config))
5
- : Buffer.from(JSON.stringify(config)).toString("base64");
6
- url.searchParams.set("config", param);
3
+ if (config) {
4
+ const param = typeof window !== "undefined"
5
+ ? btoa(JSON.stringify(config))
6
+ : Buffer.from(JSON.stringify(config)).toString("base64");
7
+ url.searchParams.set("config", param);
8
+ }
7
9
  return url;
8
10
  }
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { wrapErrorAdapter } from "./integrations/error-adapter.js";
2
2
  export { AnthropicChatAdapter } from "./integrations/llm/anthropic.js";
3
3
  export { OpenAIChatAdapter } from "./integrations/llm/openai.js";
4
4
  export { MultiClient } from "./multi-client.js";
5
+ export { createSmitheryUrl } from "./config.js";
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@ export { wrapErrorAdapter } from "./integrations/error-adapter.js";
2
2
  export { AnthropicChatAdapter } from "./integrations/llm/anthropic.js";
3
3
  export { OpenAIChatAdapter } from "./integrations/llm/openai.js";
4
4
  export { MultiClient } from "./multi-client.js";
5
+ export { createSmitheryUrl } from "./config.js";
@@ -0,0 +1,8 @@
1
+ import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
2
+ /**
3
+ * Creates a transport to connect to the Smithery server
4
+ * @param smitheryServerUrl The URL of the Smithery server (without trailing slash or protocol)
5
+ * @param config Config to pass to the server
6
+ * @returns Transport
7
+ */
8
+ export declare function createTransport(smitheryServerUrl: string, config?: object): WebSocketClientTransport;
@@ -0,0 +1,11 @@
1
+ import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";
2
+ import { createSmitheryUrl } from "./config.js";
3
+ /**
4
+ * Creates a transport to connect to the Smithery server
5
+ * @param smitheryServerUrl The URL of the Smithery server (without trailing slash or protocol)
6
+ * @param config Config to pass to the server
7
+ * @returns Transport
8
+ */
9
+ export function createTransport(smitheryServerUrl, config) {
10
+ return new WebSocketClientTransport(createSmitheryUrl(`${smitheryServerUrl}/ws`, config));
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithery/sdk",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Connect language models to Model Context Protocols",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,11 +30,9 @@
30
30
  "devDependencies": {
31
31
  "@smithery/mcp-e2b": "*",
32
32
  "@smithery/mcp-exa": "*",
33
- "@types/eventsource": "^1.1.15",
34
33
  "@types/node": "^20.0.0",
35
34
  "@types/uuid": "^9.0.7",
36
35
  "dotenv": "^16.4.7",
37
- "eventsource": "^2.0.2",
38
36
  "tsx": "^4.19.2",
39
37
  "typescript": "^5.0.0"
40
38
  }