@smithery/sdk 2.1.0 → 3.0.1

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/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from "./shared/config.js";
2
2
  export * from "./shared/patch.js";
3
- export { createStatefulServer, type StatefulServerOptions, } from "./server/stateful.js";
3
+ export { createStatefulServer, type CreateServerFn, type StatefulServerOptions, } from "./server/stateful.js";
4
+ export { createStatelessServer, type CreateStatelessServerFn, type StatelessServerOptions, } from "./server/stateless.js";
5
+ export * from "./server/logger.js";
4
6
  export * from "./server/session.js";
5
7
  export * from "./server/auth/identity.js";
6
8
  export * from "./server/auth/oauth.js";
package/dist/index.js CHANGED
@@ -6,6 +6,8 @@ export * from "./shared/patch.js";
6
6
  // === Server Primitives ===
7
7
  // Stateful/stateless server patterns, session management, auth
8
8
  export { createStatefulServer, } from "./server/stateful.js";
9
+ export { createStatelessServer, } from "./server/stateless.js";
10
+ export * from "./server/logger.js";
9
11
  export * from "./server/session.js";
10
12
  export * from "./server/auth/identity.js";
11
13
  export * from "./server/auth/oauth.js";
@@ -2,7 +2,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
2
2
  import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
3
3
  import express from "express";
4
4
  import type { z } from "zod";
5
- import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
6
6
  import { type SessionStore } from "./session.js";
7
7
  import type { Logger } from "./logger.js";
8
8
  /**
@@ -14,7 +14,7 @@ export interface CreateServerArg<T = Record<string, unknown>> {
14
14
  auth?: AuthInfo;
15
15
  logger: Logger;
16
16
  }
17
- export type CreateServerFn<T = Record<string, unknown>> = (arg: CreateServerArg<T>) => Server;
17
+ export type CreateServerFn<T = Record<string, unknown>> = (arg: CreateServerArg<T>) => McpServer["server"];
18
18
  /**
19
19
  * Configuration options for the stateful server
20
20
  */
@@ -3,7 +3,7 @@ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
3
3
  import express from "express";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { parseAndValidateConfig } from "../shared/config.js";
6
- import { zodToJsonSchema } from "zod-to-json-schema";
6
+ import * as zod from "zod";
7
7
  import { createLRUStore } from "./session.js";
8
8
  import { createLogger } from "./logger.js";
9
9
  /**
@@ -108,20 +108,16 @@ export function createStatefulServer(createMcpServer, options) {
108
108
  app.get("/.well-known/mcp-config", (req, res) => {
109
109
  // Set proper content type for JSON Schema
110
110
  res.set("Content-Type", "application/schema+json; charset=utf-8");
111
- const baseSchema = options?.schema
112
- ? zodToJsonSchema(options.schema)
113
- : {
114
- type: "object",
115
- properties: {},
116
- required: [],
117
- };
118
- const configSchema = {
119
- $schema: "https://json-schema.org/draft/2020-12/schema",
120
- $id: `${req.protocol}://${req.get("host")}/.well-known/mcp-config`,
111
+ // Create schema with metadata using Zod's native .meta()
112
+ const schema = (options?.schema ?? zod.object({})).meta({
121
113
  title: "MCP Session Configuration",
122
114
  description: "Schema for the /mcp endpoint configuration",
123
115
  "x-query-style": "dot+bracket",
124
- ...baseSchema,
116
+ });
117
+ const configSchema = {
118
+ ...zod.toJSONSchema(schema, { target: "draft-2020-12" }),
119
+ // $id is dynamic based on request, so we add it manually
120
+ $id: `${req.protocol}://${req.get("host")}/.well-known/mcp-config`,
125
121
  };
126
122
  res.json(configSchema);
127
123
  });
@@ -1,6 +1,6 @@
1
1
  import express from "express";
2
2
  import type { z } from "zod";
3
- import type { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
5
5
  import type { OAuthMountOptions } from "./auth/oauth.js";
6
6
  import { type Logger } from "./logger.js";
@@ -13,7 +13,7 @@ export interface CreateStatelessServerArg<T = Record<string, unknown>> {
13
13
  auth?: AuthInfo;
14
14
  logger: Logger;
15
15
  }
16
- export type CreateStatelessServerFn<T = Record<string, unknown>> = (arg: CreateStatelessServerArg<T>) => Server;
16
+ export type CreateStatelessServerFn<T = Record<string, unknown>> = (arg: CreateStatelessServerArg<T>) => McpServer["server"];
17
17
  /**
18
18
  * Configuration options for the stateless server
19
19
  */
@@ -1,7 +1,7 @@
1
1
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
2
2
  import express from "express";
3
+ import * as zod from "zod";
3
4
  import { parseAndValidateConfig } from "../shared/config.js";
4
- import { zodToJsonSchema } from "zod-to-json-schema";
5
5
  import { createLogger } from "./logger.js";
6
6
  /**
7
7
  * Creates a stateless server for handling MCP requests.
@@ -102,20 +102,16 @@ export function createStatelessServer(createMcpServer, options) {
102
102
  app.get("/.well-known/mcp-config", (req, res) => {
103
103
  // Set proper content type for JSON Schema
104
104
  res.set("Content-Type", "application/schema+json; charset=utf-8");
105
- const baseSchema = options?.schema
106
- ? zodToJsonSchema(options.schema)
107
- : {
108
- type: "object",
109
- properties: {},
110
- required: [],
111
- };
112
- const configSchema = {
113
- $schema: "https://json-schema.org/draft/2020-12/schema",
114
- $id: `${req.protocol}://${req.get("host")}/.well-known/mcp-config`,
105
+ // Create schema with metadata using Zod's native .meta()
106
+ const schema = (options?.schema ?? zod.object({})).meta({
115
107
  title: "MCP Session Configuration",
116
108
  description: "Schema for the /mcp endpoint configuration",
117
109
  "x-query-style": "dot+bracket",
118
- ...baseSchema,
110
+ });
111
+ const configSchema = {
112
+ ...zod.toJSONSchema(schema, { target: "draft-2020-12" }),
113
+ // $id is dynamic based on request, so we add it manually
114
+ $id: `${req.protocol}://${req.get("host")}/.well-known/mcp-config`,
119
115
  };
120
116
  res.json(configSchema);
121
117
  });
@@ -1,5 +1,5 @@
1
1
  import type { Request as ExpressRequest } from "express";
2
- import type { z } from "zod";
2
+ import * as z from "zod";
3
3
  export interface SmitheryUrlOptions {
4
4
  apiKey?: string;
5
5
  profile?: string;
@@ -25,12 +25,7 @@ export declare function parseAndValidateConfig<T = Record<string, unknown>>(req:
25
25
  readonly status: 422;
26
26
  readonly detail: "One or more config parameters are invalid.";
27
27
  readonly instance: string;
28
- readonly configSchema: import("zod-to-json-schema").JsonSchema7Type & {
29
- $schema?: string | undefined;
30
- definitions?: {
31
- [key: string]: import("zod-to-json-schema").JsonSchema7Type;
32
- } | undefined;
33
- };
28
+ readonly configSchema: z.core.ZodStandardJSONSchemaPayload<z.ZodType<T, unknown, z.core.$ZodTypeInternals<T, unknown>>>;
34
29
  readonly errors: {
35
30
  param: string;
36
31
  pointer: string;
@@ -1,6 +1,6 @@
1
1
  import _ from "lodash";
2
2
  import { err, ok } from "okay-error";
3
- import { zodToJsonSchema } from "zod-to-json-schema";
3
+ import * as z from "zod";
4
4
  function isPlainObject(value) {
5
5
  return value !== null && typeof value === "object" && !Array.isArray(value);
6
6
  }
@@ -71,13 +71,14 @@ export function parseAndValidateConfig(req, schema) {
71
71
  if (schema) {
72
72
  const result = schema.safeParse(config);
73
73
  if (!result.success) {
74
- const jsonSchema = zodToJsonSchema(schema);
74
+ const jsonSchema = z.toJSONSchema(schema);
75
75
  const errors = result.error.issues.map(issue => {
76
76
  // Safely traverse the config object to get the received value
77
77
  let received = config;
78
78
  for (const key of issue.path) {
79
- if (received && typeof received === "object" && key in received) {
80
- received = received[key];
79
+ const keyStr = String(key);
80
+ if (received && typeof received === "object" && keyStr in received) {
81
+ received = received[keyStr];
81
82
  }
82
83
  else {
83
84
  received = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithery/sdk",
3
- "version": "2.1.0",
3
+ "version": "3.0.1",
4
4
  "description": "SDK to develop with Smithery",
5
5
  "type": "module",
6
6
  "repository": {
@@ -10,44 +10,30 @@
10
10
  "main": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts",
12
12
  "exports": {
13
- ".": "./dist/index.js",
14
- "./server": "./dist/server/index.js",
15
- "./server/stateful.js": "./dist/server/stateful.js",
16
- "./server/stateless.js": "./dist/server/stateless.js",
17
- "./server/logger.js": "./dist/server/logger.js",
18
- "./server/session.js": "./dist/server/session.js",
19
- "./server/auth/oauth.js": "./dist/server/auth/oauth.js",
20
- "./server/auth/identity.js": "./dist/server/auth/identity.js",
21
- "./shared/config.js": "./dist/shared/config.js",
22
- "./shared/patch.js": "./dist/shared/patch.js",
23
- "./helpers": "./dist/helpers/index.js",
24
- "./helpers/tool.js": "./dist/helpers/tool.js"
13
+ ".": "./dist/index.js"
25
14
  },
26
15
  "files": [
27
16
  "dist"
28
17
  ],
29
18
  "scripts": {
30
19
  "build": "tsc",
31
- "build:all": "npm run build -ws --include-workspace-root",
20
+ "build:all": "pnpm -r --filter './*' build",
32
21
  "watch": "tsc --watch",
33
- "check": "npx @biomejs/biome check --write --unsafe",
34
- "prepare": "npm run build"
22
+ "check": "pnpm exec biome check --write --unsafe",
23
+ "prepare": "pnpm run build"
35
24
  },
36
- "packageManager": "npm@11.4.1",
25
+ "packageManager": "pnpm@9.0.0",
37
26
  "license": "MIT",
38
27
  "dependencies": {
39
- "@modelcontextprotocol/sdk": "^1.20.0",
28
+ "@modelcontextprotocol/sdk": "^1.25.1",
40
29
  "chalk": "^5.6.2",
41
30
  "express": "^5.1.0",
42
31
  "jose": "^6.1.0",
43
- "json-schema": "^0.4.0",
44
32
  "lodash": "^4.17.21",
45
- "okay-error": "^1.0.3",
46
- "uuid": "^11.0.3",
47
- "zod-to-json-schema": "^3.24.1"
33
+ "okay-error": "^1.0.3"
48
34
  },
49
35
  "peerDependencies": {
50
- "zod": ">=3.23.8 <4.0.0"
36
+ "zod": "^4"
51
37
  },
52
38
  "devDependencies": {
53
39
  "@biomejs/biome": "2.2.6",
@@ -59,6 +45,6 @@
59
45
  "dotenv": "^16.4.7",
60
46
  "tsx": "^4.19.2",
61
47
  "typescript": "^5.0.0",
62
- "zod": ">=3.23.8 <4.0.0"
48
+ "zod": "^4"
63
49
  }
64
50
  }