@smithery/sdk 0.0.22 → 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 +4 -27
- package/dist/transport.d.ts +8 -0
- package/dist/transport.js +11 -0
- package/package.json +1 -3
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 {
|
|
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 =
|
|
42
|
+
const exaTransport = createTransport(
|
|
47
43
|
// Replace with your deployed MCP server URL
|
|
48
|
-
|
|
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.
|
|
@@ -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.
|
|
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
|
}
|