feat: zod v4 with backwards compatibility for v3.25+ (#1040)
This commit is contained in:
parent
7fca1f2b15
commit
418b7f9b85
1 changed files with 14723 additions and 1002 deletions
12
README.md
12
README.md
|
|
@ -58,7 +58,7 @@ Let's create a simple MCP server that exposes a calculator tool and some data. S
|
|||
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
import express from 'express';
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
// Create an MCP server
|
||||
const server = new McpServer({
|
||||
|
|
@ -477,7 +477,7 @@ MCP servers can request LLM completions from connected clients that support samp
|
|||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
import express from 'express';
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
const mcpServer = new McpServer({
|
||||
name: 'tools-with-sample-server',
|
||||
|
|
@ -561,7 +561,7 @@ For most use cases where session management isn't needed:
|
|||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
import express from 'express';
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
|
|
@ -796,7 +796,7 @@ A simple server demonstrating resources, tools, and prompts:
|
|||
|
||||
```typescript
|
||||
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
const server = new McpServer({
|
||||
name: 'echo-server',
|
||||
|
|
@ -866,7 +866,7 @@ A more complex example showing database integration:
|
|||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import sqlite3 from 'sqlite3';
|
||||
import { promisify } from 'util';
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
const server = new McpServer({
|
||||
name: 'sqlite-explorer',
|
||||
|
|
@ -961,7 +961,7 @@ If you want to offer an initial set of tools/prompts/resources, but later add ad
|
|||
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
||||
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
||||
import express from 'express';
|
||||
import { z } from 'zod';
|
||||
import * as z from 'zod/v4';
|
||||
|
||||
const server = new McpServer({
|
||||
name: 'Dynamic Example',
|
||||
|
|
|
|||
Loading…
Reference in a new issue