Skip to content

Commit a2d6680

Browse files
committed
Simplify imports
1 parent e5b8f59 commit a2d6680

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/zeromcp/mcp.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import sys
12
import time
23
import uuid
34
import json
5+
import inspect
46
import threading
57
import traceback
6-
import sys
78
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
8-
from typing import Any, Callable, get_type_hints, Annotated, BinaryIO
9+
from typing import Any, Callable, Union, Annotated, BinaryIO, NotRequired, get_origin, get_args, get_type_hints
910
from urllib.parse import urlparse, parse_qs
1011
from io import BufferedIOBase
1112

@@ -338,8 +339,6 @@ def _mcp_tools_call(self, name: str, arguments: dict | None = None, _meta: dict
338339

339340
def _type_to_json_schema(self, py_type: Any) -> dict:
340341
"""Convert Python type hint to JSON schema object"""
341-
from typing import get_origin, get_args, Union
342-
343342
# Handle Annotated[Type, "description"]
344343
if get_origin(py_type) is Annotated:
345344
args = get_args(py_type)
@@ -391,13 +390,6 @@ def _type_to_json_schema(self, py_type: Any) -> dict:
391390

392391
def _typed_dict_to_schema(self, typed_dict_class) -> dict:
393392
"""Convert TypedDict to JSON schema"""
394-
try:
395-
from typing_extensions import NotRequired
396-
except ImportError:
397-
from typing import NotRequired
398-
399-
from typing import get_origin, get_args
400-
401393
hints = get_type_hints(typed_dict_class, include_extras=True)
402394
properties = {}
403395
required = []
@@ -432,8 +424,6 @@ def _typed_dict_to_schema(self, typed_dict_class) -> dict:
432424

433425
def _generate_tool_schema(self, func_name: str, func: Callable) -> dict:
434426
"""Generate MCP tool schema from a function"""
435-
import inspect
436-
437427
hints = get_type_hints(func, include_extras=True)
438428
return_type = hints.pop("return", None)
439429
sig = inspect.signature(func)

0 commit comments

Comments
 (0)