|
83 | 83 | from smithery.decorators import smithery |
84 | 84 | from starlette.requests import Request |
85 | 85 | from starlette.responses import JSONResponse, RedirectResponse |
| 86 | +from starlette.types import ASGIApp, Receive, Scope, Send |
86 | 87 |
|
87 | 88 | # Configure logging |
88 | 89 | logging.basicConfig( |
@@ -111,18 +112,18 @@ class BrowserRedirectMiddleware: |
111 | 112 | ``/health`` endpoint are left untouched. |
112 | 113 | """ |
113 | 114 |
|
114 | | - def __init__(self, app, docs_url: str = DOCS_URL) -> None: |
| 115 | + def __init__(self, app: ASGIApp, docs_url: str = DOCS_URL) -> None: |
115 | 116 | self.app = app |
116 | 117 | self.docs_url = docs_url |
117 | 118 |
|
118 | | - async def __call__(self, scope, receive, send) -> None: |
| 119 | + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: |
119 | 120 | if scope["type"] == "http" and self._is_browser_navigation(scope): |
120 | 121 | response = RedirectResponse(self.docs_url, status_code=302) |
121 | 122 | await response(scope, receive, send) |
122 | 123 | return |
123 | 124 | await self.app(scope, receive, send) |
124 | 125 |
|
125 | | - def _is_browser_navigation(self, scope) -> bool: |
| 126 | + def _is_browser_navigation(self, scope: Scope) -> bool: |
126 | 127 | if scope["method"] not in ("GET", "HEAD"): |
127 | 128 | return False |
128 | 129 | if scope["path"].rstrip("/") != "": |
@@ -219,6 +220,7 @@ def __init__(self, api_key: str, base_url: Optional[str] = None) -> None: |
219 | 220 | "SGAI-APIKEY": api_key, |
220 | 221 | "Content-Type": "application/json", |
221 | 222 | "accept": "application/json", |
| 223 | + "User-Agent": f"scrapegraph-mcp/{MCP_SERVER_VERSION}", |
222 | 224 | "X-SDK-Version": f"scrapegraph-mcp@{MCP_SERVER_VERSION}", |
223 | 225 | } |
224 | 226 | self.client = httpx.Client(timeout=httpx.Timeout(_api_timeout_s())) |
|
0 commit comments