diff --git a/src/scrapegraph_mcp/server.py b/src/scrapegraph_mcp/server.py index e5e429f..4eb50ca 100644 --- a/src/scrapegraph_mcp/server.py +++ b/src/scrapegraph_mcp/server.py @@ -83,6 +83,7 @@ from smithery.decorators import smithery from starlette.requests import Request from starlette.responses import JSONResponse, RedirectResponse +from starlette.types import ASGIApp, Receive, Scope, Send # Configure logging logging.basicConfig( @@ -111,18 +112,18 @@ class BrowserRedirectMiddleware: ``/health`` endpoint are left untouched. """ - def __init__(self, app, docs_url: str = DOCS_URL) -> None: + def __init__(self, app: ASGIApp, docs_url: str = DOCS_URL) -> None: self.app = app self.docs_url = docs_url - async def __call__(self, scope, receive, send) -> None: + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: if scope["type"] == "http" and self._is_browser_navigation(scope): response = RedirectResponse(self.docs_url, status_code=302) await response(scope, receive, send) return await self.app(scope, receive, send) - def _is_browser_navigation(self, scope) -> bool: + def _is_browser_navigation(self, scope: Scope) -> bool: if scope["method"] not in ("GET", "HEAD"): return False if scope["path"].rstrip("/") != "": @@ -219,6 +220,7 @@ def __init__(self, api_key: str, base_url: Optional[str] = None) -> None: "SGAI-APIKEY": api_key, "Content-Type": "application/json", "accept": "application/json", + "User-Agent": f"scrapegraph-mcp/{MCP_SERVER_VERSION}", "X-SDK-Version": f"scrapegraph-mcp@{MCP_SERVER_VERSION}", } self.client = httpx.Client(timeout=httpx.Timeout(_api_timeout_s()))