Skip to content

Commit 044f109

Browse files
authored
Merge branch 'main' into fix-elicitation-example
2 parents b5bb7c0 + 9df0972 commit 044f109

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+9034
-7838
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ out
130130

131131
.DS_Store
132132
dist/
133+
134+
# IDE
135+
.idea/

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ The Model Context Protocol allows applications to provide context for LLMs in a
4747
## Installation
4848

4949
```bash
50-
npm install @modelcontextprotocol/sdk
50+
npm install @modelcontextprotocol/sdk zod
5151
```
5252

53+
This SDK has a **required peer dependency** on `zod` for schema validation. The SDK internally imports from `zod/v4`, but maintains backwards compatibility with projects using Zod v3.25 or later. You can use either API in your code by importing from `zod/v3` or `zod/v4`:
54+
5355
## Quick Start
5456

5557
Let's create a simple MCP server that exposes a calculator tool and some data. Save the following as `server.ts`:
@@ -58,7 +60,7 @@ Let's create a simple MCP server that exposes a calculator tool and some data. S
5860
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
5961
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
6062
import express from 'express';
61-
import { z } from 'zod';
63+
import * as z from 'zod/v4';
6264

6365
// Create an MCP server
6466
const server = new McpServer({
@@ -130,7 +132,7 @@ app.listen(port, () => {
130132
});
131133
```
132134

133-
Install the deps with `npm install @modelcontextprotocol/sdk express zod@3`, and run with `npx -y tsx server.ts`.
135+
Install the deps with `npm install @modelcontextprotocol/sdk express zod`, and run with `npx -y tsx server.ts`.
134136

135137
You can connect to it using any MCP client that supports streamable http, such as:
136138

@@ -477,7 +479,7 @@ MCP servers can request LLM completions from connected clients that support samp
477479
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
478480
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
479481
import express from 'express';
480-
import { z } from 'zod';
482+
import * as z from 'zod/v4';
481483

482484
const mcpServer = new McpServer({
483485
name: 'tools-with-sample-server',
@@ -561,7 +563,7 @@ For most use cases where session management isn't needed:
561563
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
562564
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
563565
import express from 'express';
564-
import { z } from 'zod';
566+
import * as z from 'zod/v4';
565567

566568
const app = express();
567569
app.use(express.json());
@@ -796,7 +798,7 @@ A simple server demonstrating resources, tools, and prompts:
796798

797799
```typescript
798800
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
799-
import { z } from 'zod';
801+
import * as z from 'zod/v4';
800802

801803
const server = new McpServer({
802804
name: 'echo-server',
@@ -866,7 +868,7 @@ A more complex example showing database integration:
866868
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
867869
import sqlite3 from 'sqlite3';
868870
import { promisify } from 'util';
869-
import { z } from 'zod';
871+
import * as z from 'zod/v4';
870872

871873
const server = new McpServer({
872874
name: 'sqlite-explorer',
@@ -961,7 +963,7 @@ If you want to offer an initial set of tools/prompts/resources, but later add ad
961963
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
962964
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
963965
import express from 'express';
964-
import { z } from 'zod';
966+
import * as z from 'zod/v4';
965967

966968
const server = new McpServer({
967969
name: 'Dynamic Example',

0 commit comments

Comments
 (0)