Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/openharness/mcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ async def call_tool(self, server_name: str, tool_name: str, arguments: dict[str,
parts.append(getattr(item, "text", ""))
else:
parts.append(item.model_dump_json())
if result.structuredContent and not parts:
parts.append(str(result.structuredContent))
if result.structured_content and not parts:
parts.append(str(result.structured_content))
if not parts:
parts.append("(no output)")
return "\n".join(parts).strip()
Expand Down Expand Up @@ -221,7 +221,7 @@ async def _connect_http(self, name: str, config: McpHttpServerConfig) -> None:
http_client = await stack.enter_async_context(
httpx.AsyncClient(headers=config.headers or None)
)
read_stream, write_stream, _get_session_id = await stack.enter_async_context(
read_stream, write_stream = await stack.enter_async_context(
streamable_http_client(config.url, http_client=http_client)
)
await self._register_connected_session(
Expand Down Expand Up @@ -273,7 +273,7 @@ async def _register_connected_session(
server_name=name,
name=tool.name,
description=tool.description or "",
input_schema=dict(tool.inputSchema or {"type": "object", "properties": {}}),
input_schema=dict(tool.input_schema or {"type": "object", "properties": {}}),
)
for tool in tool_result.tools
]
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/fake_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from __future__ import annotations

from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer

server = FastMCP("fixture-demo")
server = MCPServer("fixture-demo")


@server.tool()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mcp/test_client_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def test_connect_all_marks_http_server_failed_when_initialize_is_cancelled
monkeypatch.setattr(
client_module,
"streamable_http_client",
lambda *args, **kwargs: _AsyncContextManager((object(), object(), AsyncMock())),
lambda *args, **kwargs: _AsyncContextManager((object(), object())),
)
manager._register_connected_session = AsyncMock(
side_effect=asyncio.CancelledError("simulated cancellation")
Expand Down
11 changes: 5 additions & 6 deletions tests/test_mcp/test_http_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import httpx
import pytest
from mcp.server.fastmcp import FastMCP
from mcp.server.mcpserver import MCPServer
from mcp.server.transport_security import TransportSecuritySettings

import openharness.mcp.client as client_module
Expand All @@ -18,10 +18,7 @@

@pytest.mark.asyncio
async def test_http_mcp_manager_connects_and_executes_in_process_server(monkeypatch):
server = FastMCP(
"demo-http",
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
)
server = MCPServer("demo-http")

@server.tool()
def hello(name: str) -> str:
Expand All @@ -31,7 +28,9 @@ def hello(name: str) -> str:
def readme() -> str:
return "http fixture resource contents"

app = server.streamable_http_app()
app = server.streamable_http_app(
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False)
)
transport = httpx.ASGITransport(app=app)
original_async_client = client_module.httpx.AsyncClient
seen_headers: list[dict[str, str] | None] = []
Expand Down