generated from coulomb/repo-seed
Fix MCP server httpx redirect handling
Add follow_redirects=True to httpx Client so 307 redirects (FastAPI trailing-slash redirects) are followed transparently. Also add trailing slash normalisation to _get and _patch to match existing _post behaviour, so all three helpers hit the correct URLs on first attempt. Requires Claude Code restart to take effect (MCP server is a subprocess launched at startup). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,10 +32,12 @@ mcp = FastMCP(
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _client() -> httpx.Client:
|
||||
return httpx.Client(base_url=API_BASE, timeout=30.0)
|
||||
return httpx.Client(base_url=API_BASE, timeout=30.0, follow_redirects=True)
|
||||
|
||||
|
||||
def _get(path: str, params: dict | None = None) -> Any:
|
||||
if not path.endswith("/"):
|
||||
path = path + "/"
|
||||
with _client() as c:
|
||||
r = c.get(path, params={k: v for k, v in (params or {}).items() if v is not None})
|
||||
r.raise_for_status()
|
||||
@@ -52,6 +54,8 @@ def _post(path: str, body: dict) -> Any:
|
||||
|
||||
|
||||
def _patch(path: str, body: dict) -> Any:
|
||||
if not path.endswith("/"):
|
||||
path = path + "/"
|
||||
with _client() as c:
|
||||
r = c.patch(path, json={k: v for k, v in body.items() if v is not None})
|
||||
r.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user