|
29 | 29 | import zlib |
30 | 30 | from collections.abc import AsyncIterator, Awaitable, Callable, Mapping, Sequence |
31 | 31 | from contextlib import asynccontextmanager |
32 | | -from typing import Annotated, Any, Tuple |
33 | 32 | from importlib.metadata import version |
| 33 | +from typing import Annotated, Any |
34 | 34 | from urllib.parse import urlparse, urlunparse |
35 | 35 |
|
36 | 36 | import httpx |
37 | | -from pydantic import TypeAdapter, ValidationError |
38 | 37 | import markdownify |
39 | 38 | import readabilipy.simple_json |
40 | | -from .readability_js import extract_article |
41 | 39 | from bs4 import BeautifulSoup, Tag |
42 | | -from .allowlist import normalize_allowed_hosts, refuse_unlisted_destination |
43 | 40 | from mcp.server import MCPServer, ServerRequestContext |
44 | 41 | from mcp.server.context import CallNext, HandlerResult, ServerMiddleware |
45 | 42 | from mcp.server.mcpserver.exceptions import ToolError |
46 | 43 | from mcp.shared.exceptions import MCPError |
| 44 | +from mcp.types import INVALID_PARAMS, ToolAnnotations |
| 45 | +from protego import Protego |
| 46 | +from pydantic import AnyUrl, Field, TypeAdapter, ValidationError |
| 47 | + |
| 48 | +from .allowlist import normalize_allowed_hosts, refuse_unlisted_destination |
| 49 | +from .readability_js import extract_article |
47 | 50 | from .timeout import ( |
48 | 51 | DEFAULT_TIMEOUT_MS, |
49 | 52 | MAX_TIMEOUT_MS, |
50 | 53 | MIN_TIMEOUT_MS, |
51 | 54 | timeout_ms_from_env, |
52 | 55 | ) |
53 | | -from mcp.types import INVALID_PARAMS, ToolAnnotations |
54 | | -from protego import Protego |
55 | | -from pydantic import AnyUrl, Field |
56 | | - |
57 | 56 | from .title import with_page_title |
58 | 57 |
|
59 | 58 | # The version this server reports in serverInfo, read from the installed |
@@ -751,7 +750,7 @@ async def fetch_url( |
751 | 750 | allowed_hosts: tuple[str, ...] = (), |
752 | 751 | check_robots_txt: bool = False, |
753 | 752 | use_readability_js: bool = True, |
754 | | -) -> Tuple[str, str]: |
| 753 | +) -> tuple[str, str]: |
755 | 754 | """ |
756 | 755 | Fetch the URL and return the content in a form ready for the LLM, as well as a prefix string with status information. |
757 | 756 |
|
|
0 commit comments