Skip to content

Commit 0ff39c7

Browse files
authored
Merge pull request #131 from modelcontextprotocol/jadamson/fetch-use-readabilityjs-fix
fix(fetch): fix type checking issue from previous change
2 parents e0234c7 + bee382c commit 0ff39c7

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

src/fetch/src/mcp_server_fetch/server.py

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Tuple
1+
from typing import Annotated, Tuple
22
from urllib.parse import urlparse, urlunparse
33

44
import markdownify
@@ -17,7 +17,7 @@
1717
INTERNAL_ERROR,
1818
)
1919
from protego import Protego
20-
from pydantic import BaseModel, Field, AnyUrl, conint
20+
from pydantic import BaseModel, Field, AnyUrl
2121

2222
DEFAULT_USER_AGENT_AUTONOMOUS = "ModelContextProtocol/1.0 (Autonomous; +https://github.com/modelcontextprotocol/servers)"
2323
DEFAULT_USER_AGENT_MANUAL = "ModelContextProtocol/1.0 (User-Specified; +https://github.com/modelcontextprotocol/servers)"
@@ -148,22 +148,35 @@ async def fetch_url(
148148
class Fetch(BaseModel):
149149
"""Parameters for fetching a URL."""
150150

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

164177

165178
async def serve(
166-
custom_user_agent: Optional[str] = None, ignore_robots_txt: bool = False
179+
custom_user_agent: str | None = None, ignore_robots_txt: bool = False
167180
) -> None:
168181
"""Run the fetch MCP server.
169182

0 commit comments

Comments
 (0)