Skip to content

Commit a9e37d2

Browse files
committed
switch pydantic type annotations to satisfy pyright
1 parent e0234c7 commit a9e37d2

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

src/fetch/src/mcp_server_fetch/server.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from typing import Optional, Tuple
2+
from typing_extensions import Annotated
23
from urllib.parse import urlparse, urlunparse
34

45
import markdownify
@@ -17,7 +18,7 @@
1718
INTERNAL_ERROR,
1819
)
1920
from protego import Protego
20-
from pydantic import BaseModel, Field, AnyUrl, conint
21+
from pydantic import BaseModel, Field, AnyUrl
2122

2223
DEFAULT_USER_AGENT_AUTONOMOUS = "ModelContextProtocol/1.0 (Autonomous; +https://github.com/modelcontextprotocol/servers)"
2324
DEFAULT_USER_AGENT_MANUAL = "ModelContextProtocol/1.0 (User-Specified; +https://github.com/modelcontextprotocol/servers)"
@@ -148,18 +149,31 @@ async def fetch_url(
148149
class Fetch(BaseModel):
149150
"""Parameters for fetching a URL."""
150151

151-
url: AnyUrl = Field(..., description="URL to fetch")
152-
max_length: conint(gt=0, lt=1000000) = Field(
153-
5000, description="Maximum number of characters to return."
154-
)
155-
start_index: conint(ge=0) = Field(
156-
0,
157-
description="On return output starting at this character index, useful if a previous fetch was truncated and more context is required.",
158-
)
159-
raw: bool = Field(
160-
False,
161-
description="Get the actual HTML content if the requested page, without simplification.",
162-
)
152+
url: Annotated[AnyUrl, Field(description="URL to fetch")]
153+
max_length: Annotated[
154+
int,
155+
Field(
156+
default=5000,
157+
description="Maximum number of characters to return.",
158+
gt=0,
159+
lt=1000000,
160+
),
161+
]
162+
start_index: Annotated[
163+
int,
164+
Field(
165+
default=0,
166+
description="On return output starting at this character index, useful if a previous fetch was truncated and more context is required.",
167+
ge=0,
168+
),
169+
]
170+
raw: Annotated[
171+
bool,
172+
Field(
173+
default=False,
174+
description="Get the actual HTML content if the requested page, without simplification.",
175+
),
176+
]
163177

164178

165179
async def serve(

0 commit comments

Comments
 (0)