Skip to content

Commit b3471e4

Browse files
committed
remove dead code
1 parent 2a10c2e commit b3471e4

File tree

3 files changed

+3
-176
lines changed

3 files changed

+3
-176
lines changed

fastapi_mcp/openapi/utils.py

Lines changed: 1 addition & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -4,96 +4,7 @@
44
This module provides utility functions for working with OpenAPI schemas.
55
"""
66

7-
from typing import Any, Dict, List, Optional, Union
8-
from datetime import date, datetime
9-
from decimal import Decimal
10-
from uuid import UUID
11-
12-
PYTHON_TYPE_IMPORTS = {
13-
"List": List,
14-
"Dict": Dict,
15-
"Any": Any,
16-
"Optional": Optional,
17-
"Union": Union,
18-
"date": date,
19-
"datetime": datetime,
20-
"Decimal": Decimal,
21-
"UUID": UUID,
22-
}
23-
# Type mapping from OpenAPI types to Python types
24-
OPENAPI_PYTHON_TYPES_MAP = {
25-
# Core data types (OpenAPI 3.x)
26-
"string": "str",
27-
"number": "Union[float, Decimal]", # Could be float or Decimal for precision
28-
"integer": "int",
29-
"boolean": "bool",
30-
"null": "None",
31-
# Complex types
32-
"object": "Dict[str, Any]", # More specific than Dict[Any, Any]
33-
"array": "List[Any]",
34-
# Numeric formats
35-
"int32": "int",
36-
"int64": "int",
37-
"float": "float",
38-
"double": "float",
39-
"decimal": "Decimal",
40-
# String formats - Common
41-
"date": "date", # datetime.date
42-
"date-time": "datetime", # datetime.datetime
43-
"time": "str", # Could use datetime.time
44-
"duration": "str", # Could use datetime.timedelta
45-
"password": "str",
46-
"byte": "bytes", # base64 encoded
47-
"binary": "bytes", # raw binary
48-
# String formats - Extended
49-
"email": "str",
50-
"uuid": "UUID", # uuid.UUID
51-
"uri": "str",
52-
"uri-reference": "str",
53-
"uri-template": "str",
54-
"url": "str",
55-
"hostname": "str",
56-
"ipv4": "str",
57-
"ipv6": "str",
58-
"regex": "str",
59-
"json-pointer": "str",
60-
"relative-json-pointer": "str",
61-
# Rich text formats
62-
"markdown": "str",
63-
"html": "str",
64-
# Media types
65-
"image/*": "bytes",
66-
"audio/*": "bytes",
67-
"video/*": "bytes",
68-
"application/*": "bytes",
69-
# Special formats
70-
"format": "str", # Custom format string
71-
"pattern": "str", # Regular expression pattern
72-
"contentEncoding": "str", # e.g., base64, quoted-printable
73-
"contentMediaType": "str", # MIME type
74-
# Additional numeric formats
75-
"currency": "Decimal", # For precise decimal calculations
76-
"percentage": "float",
77-
# Geographic coordinates
78-
"latitude": "float",
79-
"longitude": "float",
80-
# Time-related
81-
"timezone": "str", # Could use zoneinfo.ZoneInfo in Python 3.9+
82-
"unix-time": "int", # Unix timestamp
83-
"iso-week-date": "str", # ISO 8601 week date
84-
# Specialized string formats
85-
"isbn": "str",
86-
"issn": "str",
87-
"iban": "str",
88-
"credit-card": "str",
89-
"phone": "str",
90-
"postal-code": "str",
91-
"language-code": "str", # ISO 639 language codes
92-
"country-code": "str", # ISO 3166 country codes
93-
"currency-code": "str", # ISO 4217 currency codes
94-
# Default fallback
95-
"unknown": "Any",
96-
}
7+
from typing import Any, Dict, List, Optional
978

989

9910
def get_single_param_type_from_schema(param_schema: Dict[str, Any]) -> str:
@@ -111,21 +22,6 @@ def get_single_param_type_from_schema(param_schema: Dict[str, Any]) -> str:
11122
return param_schema.get("type", "string")
11223

11324

114-
def get_python_type_and_default(parsed_param_schema: Dict[str, Any]) -> tuple[str, bool]:
115-
"""
116-
Parse parameters into a python type and default value string.
117-
Returns:
118-
A tuple containing:
119-
- A string representing the Python type annotation (e.g. "str", "int = 0", etc.)
120-
- A boolean indicating whether a default value is present
121-
"""
122-
# Handle direct type specification
123-
python_type = OPENAPI_PYTHON_TYPES_MAP.get(parsed_param_schema.get("type", ""), "Any")
124-
if "default" in parsed_param_schema:
125-
return f"{python_type} = {parsed_param_schema.get('default')}", True
126-
return python_type, False
127-
128-
12925
def resolve_schema_references(schema_part: Dict[str, Any], reference_schema: Dict[str, Any]) -> Dict[str, Any]:
13026
"""
13127
Resolve schema references in OpenAPI schemas.

fastapi_mcp/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from mcp.server.sse import SseServerTransport
1414
import mcp.types as types
1515

16-
from .openapi.convert import convert_openapi_to_mcp_tools
17-
from .execute import execute_api_tool
16+
from fastapi_mcp.openapi.convert import convert_openapi_to_mcp_tools
17+
from fastapi_mcp.execute import execute_api_tool
1818

1919

2020
def create_mcp_server(

tests/test_server.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)