Skip to content

Commit 79f6c04

Browse files
committed
chore: imports
1 parent 374a673 commit 79f6c04

File tree

8 files changed

+592
-638
lines changed

8 files changed

+592
-638
lines changed

src/examples/server/mcpServerOutputSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* This demonstrates how to easily create tools with structured output
55
*/
66

7-
import { McpServer } from "../../server/mcp.js";
8-
import { StdioServerTransport } from "../../server/stdio.js";
9-
import { z } from "zod/v4";
7+
import { McpServer } from '../../server/mcp.js';
8+
import { StdioServerTransport } from '../../server/stdio.js';
9+
import { z } from 'zod';
1010

1111
const server = new McpServer({
1212
name: 'mcp-output-schema-high-level-example',

src/examples/server/toolWithSampleServer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Run with: npx tsx src/examples/server/toolWithSampleServer.ts
22

3-
import { McpServer } from "../../server/mcp.js";
4-
import { StdioServerTransport } from "../../server/stdio.js";
5-
import { z } from "zod/v4";
3+
import { McpServer } from '../../server/mcp.js';
4+
import { StdioServerTransport } from '../../server/stdio.js';
5+
import { z } from 'zod';
66

77
const mcpServer = new McpServer({
88
name: 'tools-with-sample-server',

src/server/completable.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { z } from "zod/v4";
2-
import { completable } from "./completable.js";
1+
import { z } from 'zod';
2+
import { completable } from './completable.js';
33

44
describe('completable', () => {
55
it('preserves types and values of underlying schema', () => {

src/server/completable.ts

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,40 @@
1-
import { ZodTypeAny } from "zod/v4";
1+
import { ZodTypeAny } from 'zod';
22

33
export enum McpZodTypeKind {
44
Completable = 'McpCompletable'
55
}
66

77
export type CompleteCallback<T extends ZodTypeAny = ZodTypeAny> = (
8-
value: T["_input"],
9-
context?: {
10-
arguments?: Record<string, string>;
11-
}
12-
) => T["_input"][] | Promise<T["_input"][]>;
8+
value: T['_input'],
9+
context?: {
10+
arguments?: Record<string, string>;
11+
}
12+
) => T['_input'][] | Promise<T['_input'][]>;
1313

1414
export interface CompletableDef<T extends ZodTypeAny = ZodTypeAny> {
15-
type: T;
16-
complete: CompleteCallback<T>;
17-
typeName: McpZodTypeKind.Completable;
15+
type: T;
16+
complete: CompleteCallback<T>;
17+
typeName: McpZodTypeKind.Completable;
1818
}
1919

2020
/**
2121
* Wraps a Zod type to provide autocompletion capabilities. Useful for, e.g., prompt arguments in MCP.
2222
*/
2323
export function completable<T extends ZodTypeAny>(
24-
schema: T,
25-
complete: CompleteCallback<T>
24+
schema: T,
25+
complete: CompleteCallback<T>
2626
): T & {
27-
_def: (T extends { _def: infer D } ? D : unknown) & CompletableDef<T>;
28-
} {
29-
const target = schema as unknown as { _def?: Record<string, unknown> };
30-
const originalDef = (target._def ?? {}) as Record<string, unknown>;
31-
// Only mutate the existing _def object to respect read-only property semantics
32-
if (
33-
(originalDef as { typeName?: unknown }).typeName !==
34-
McpZodTypeKind.Completable
35-
) {
36-
(originalDef as { typeName?: McpZodTypeKind; type?: ZodTypeAny }).typeName =
37-
McpZodTypeKind.Completable;
38-
(originalDef as { typeName?: McpZodTypeKind; type?: ZodTypeAny }).type =
39-
schema;
40-
}
41-
(originalDef as { complete?: CompleteCallback<T> }).complete = complete;
42-
return schema as unknown as T & {
4327
_def: (T extends { _def: infer D } ? D : unknown) & CompletableDef<T>;
44-
};
28+
} {
29+
const target = schema as unknown as { _def?: Record<string, unknown> };
30+
const originalDef = (target._def ?? {}) as Record<string, unknown>;
31+
// Only mutate the existing _def object to respect read-only property semantics
32+
if ((originalDef as { typeName?: unknown }).typeName !== McpZodTypeKind.Completable) {
33+
(originalDef as { typeName?: McpZodTypeKind; type?: ZodTypeAny }).typeName = McpZodTypeKind.Completable;
34+
(originalDef as { typeName?: McpZodTypeKind; type?: ZodTypeAny }).type = schema;
35+
}
36+
(originalDef as { complete?: CompleteCallback<T> }).complete = complete;
37+
return schema as unknown as T & {
38+
_def: (T extends { _def: infer D } ? D : unknown) & CompletableDef<T>;
39+
};
4540
}

src/server/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
22
/* eslint-disable no-constant-binary-expression */
33
/* eslint-disable @typescript-eslint/no-unused-expressions */
4-
import { Server } from "./index.js";
5-
import { z } from "zod/v4";
4+
import { Server } from './index.js';
5+
import { z } from 'zod';
66
import {
77
RequestSchema,
88
NotificationSchema,

src/server/streamableHttp.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { createServer, type Server, IncomingMessage, ServerResponse } from "node:http";
2-
import { createServer as netCreateServer, AddressInfo } from "node:net";
3-
import { randomUUID } from "node:crypto";
4-
import { EventStore, StreamableHTTPServerTransport, EventId, StreamId } from "./streamableHttp.js";
5-
import { McpServer } from "./mcp.js";
6-
import { CallToolResult, JSONRPCMessage } from "../types.js";
7-
import { z } from "zod/v4";
8-
import { AuthInfo } from "./auth/types.js";
1+
import { createServer, type Server, IncomingMessage, ServerResponse } from 'node:http';
2+
import { createServer as netCreateServer, AddressInfo } from 'node:net';
3+
import { randomUUID } from 'node:crypto';
4+
import { EventStore, StreamableHTTPServerTransport, EventId, StreamId } from './streamableHttp.js';
5+
import { McpServer } from './mcp.js';
6+
import { CallToolResult, JSONRPCMessage } from '../types.js';
7+
import { z } from 'zod';
8+
import { AuthInfo } from './auth/types.js';
99

1010
async function getFreePort() {
1111
return new Promise(res => {

src/server/title.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Server } from "./index.js";
2-
import { Client } from "../client/index.js";
3-
import { InMemoryTransport } from "../inMemory.js";
4-
import { z } from "zod/v4";
5-
import { McpServer, ResourceTemplate } from "./mcp.js";
1+
import { Server } from './index.js';
2+
import { Client } from '../client/index.js';
3+
import { InMemoryTransport } from '../inMemory.js';
4+
import { z } from 'zod';
5+
import { McpServer, ResourceTemplate } from './mcp.js';
66

77
describe('Title field backwards compatibility', () => {
88
it('should work with tools that have title', async () => {

0 commit comments

Comments
 (0)