@smithery/sdk 1.4.1 → 1.4.2
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
2
|
+
import express from "express";
|
|
2
3
|
import type { z } from "zod";
|
|
3
4
|
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
4
5
|
import { type SessionStore } from "./session.js";
|
|
@@ -22,14 +23,18 @@ export interface StatefulServerOptions<T = Record<string, unknown>> {
|
|
|
22
23
|
* Zod schema for config validation
|
|
23
24
|
*/
|
|
24
25
|
schema?: z.ZodSchema<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Express app instance to use (optional)
|
|
28
|
+
*/
|
|
29
|
+
app?: express.Application;
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
27
32
|
* Creates a stateful server for handling MCP requests.
|
|
28
33
|
* For every new session, we invoke createMcpServer to create a new instance of the server.
|
|
29
34
|
* @param createMcpServer Function to create an MCP server
|
|
30
|
-
* @param options Configuration options including optional schema validation
|
|
35
|
+
* @param options Configuration options including optional schema validation and Express app
|
|
31
36
|
* @returns Express app
|
|
32
37
|
*/
|
|
33
38
|
export declare function createStatefulServer<T = Record<string, unknown>>(createMcpServer: CreateServerFn<T>, options?: StatefulServerOptions<T>): {
|
|
34
|
-
app:
|
|
39
|
+
app: express.Application;
|
|
35
40
|
};
|
package/dist/server/stateful.js
CHANGED
|
@@ -8,11 +8,11 @@ import { createLRUStore } from "./session.js";
|
|
|
8
8
|
* Creates a stateful server for handling MCP requests.
|
|
9
9
|
* For every new session, we invoke createMcpServer to create a new instance of the server.
|
|
10
10
|
* @param createMcpServer Function to create an MCP server
|
|
11
|
-
* @param options Configuration options including optional schema validation
|
|
11
|
+
* @param options Configuration options including optional schema validation and Express app
|
|
12
12
|
* @returns Express app
|
|
13
13
|
*/
|
|
14
14
|
export function createStatefulServer(createMcpServer, options) {
|
|
15
|
-
const app = express();
|
|
15
|
+
const app = options?.app ?? express();
|
|
16
16
|
app.use(express.json());
|
|
17
17
|
const sessionStore = options?.sessionStore ?? createLRUStore();
|
|
18
18
|
// Handle POST requests for client-to-server communication
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import express from "express";
|
|
1
2
|
import type { z } from "zod";
|
|
2
3
|
import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
4
|
/**
|
|
@@ -9,6 +10,7 @@ export interface CreateServerArg<T = Record<string, unknown>> {
|
|
|
9
10
|
export type CreateServerFn<T = Record<string, unknown>> = (arg: CreateServerArg<T>) => Server;
|
|
10
11
|
export interface CreateStatelessServerOptions<T> {
|
|
11
12
|
schema?: z.ZodSchema<T>;
|
|
13
|
+
app?: express.Application;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
14
16
|
* Creates a stateless server for handling MCP requests
|
|
@@ -18,5 +20,5 @@ export interface CreateStatelessServerOptions<T> {
|
|
|
18
20
|
* @returns Express app
|
|
19
21
|
*/
|
|
20
22
|
export declare function createStatelessServer<T = Record<string, unknown>>(createMcpServer: CreateServerFn<T>, options?: CreateStatelessServerOptions<T>): {
|
|
21
|
-
app:
|
|
23
|
+
app: express.Application;
|
|
22
24
|
};
|
package/dist/server/stateless.js
CHANGED
|
@@ -9,7 +9,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
9
9
|
* @returns Express app
|
|
10
10
|
*/
|
|
11
11
|
export function createStatelessServer(createMcpServer, options) {
|
|
12
|
-
const app = express();
|
|
12
|
+
const app = options?.app ?? express();
|
|
13
13
|
app.use(express.json());
|
|
14
14
|
app.post("/mcp", async (req, res) => {
|
|
15
15
|
// In stateless mode, create a new instance of transport and server for each request
|