Skip to content

Commit 3cf2bf4

Browse files
committed
Redact userinfo from URL before logging
1 parent c78e98a commit 3cf2bf4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/mcp_grafana/transports/http.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,16 @@ async def http_rw():
179179
logger.debug("Waiting for request body")
180180
body = await write_stream_reader.receive()
181181

182-
logger.debug(f"Connecting to HTTP endpoint: {url}")
182+
u = httpx.URL(url)
183+
u_cleaned = (
184+
u
185+
if u.userinfo == b""
186+
else u.copy_with(username="<redacted>", password="<redacted>")
187+
)
188+
logger.debug(f"Connecting to HTTP endpoint: {u_cleaned}")
183189
async with httpx.AsyncClient(headers=headers) as client:
184190
response = await client.post(
185-
url, content=body.model_dump_json(by_alias=True)
191+
u, content=body.model_dump_json(by_alias=True)
186192
)
187193
logger.debug(f"Received response: {response.status_code}")
188194
message = types.JSONRPCMessage.model_validate_json(response.content)

0 commit comments

Comments
 (0)