Skip to content

Commit 4c8afef

Browse files
committed
refactor(mcp): support dynamic hostname
1 parent 29f62cb commit 4c8afef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/api/core/mcps.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99

1010
@asynccontextmanager
11-
async def mcp_sse_client() -> AsyncGenerator[ClientSession]:
11+
async def mcp_sse_client(
12+
mcp_host: str = "mcp",
13+
) -> AsyncGenerator[ClientSession]:
1214
"""
1315
Creates and initializes an MCP client session over SSE.
1416
@@ -18,7 +20,9 @@ async def mcp_sse_client() -> AsyncGenerator[ClientSession]:
1820
Yields:
1921
ClientSession: An initialized MCP client session.
2022
"""
21-
async with sse_client(f"http://mcp:{settings.mcp_server_port}/sse") as (
23+
async with sse_client(
24+
f"http://{mcp_host}:{settings.mcp_server_port}/sse"
25+
) as (
2226
read_stream,
2327
write_stream,
2428
):

0 commit comments

Comments
 (0)