build: complete upgrade to fastapi 0.141, mcp sdk v2, fastmcp 4 and httpx2
This commit is contained in:
@@ -79,7 +79,7 @@ async def test_mcp_binder_refreshes_oauth_for_http() -> None:
|
||||
assert len(refresher.calls) == 1
|
||||
|
||||
|
||||
async def test_httpx_oauth_refresher_posts_refresh_token_grant(
|
||||
async def test_httpx2_oauth_refresher_posts_refresh_token_grant(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
from pydantic import AnyUrl
|
||||
@@ -110,7 +110,7 @@ async def test_httpx_oauth_refresher_posts_refresh_token_grant(
|
||||
captured_posts.append((url, data))
|
||||
return _Response()
|
||||
|
||||
monkeypatch.setattr(mod.httpx, "AsyncClient", _Client)
|
||||
monkeypatch.setattr(mod.httpx2, "AsyncClient", _Client)
|
||||
|
||||
token = await HttpxOAuthTokenRefresher().refresh(
|
||||
OAuthRefreshTokenAuth(
|
||||
|
||||
@@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import httpx2
|
||||
import pytest
|
||||
from mcp import McpError
|
||||
from mcp import MCPError
|
||||
from mcp.types import ErrorData
|
||||
|
||||
from wf_authoring import build_async_registry
|
||||
@@ -134,7 +134,9 @@ class _ToolsOnlyAdapter(_Adapter):
|
||||
connection: McpSourceConnection,
|
||||
auth: AuthRecord | None,
|
||||
) -> list[DiscoveredResource]:
|
||||
raise McpError(ErrorData(code=-32601, message="Method not found"))
|
||||
raise MCPError.from_error_data(
|
||||
ErrorData(code=-32601, message="Method not found")
|
||||
)
|
||||
|
||||
async def list_prompts(
|
||||
self,
|
||||
@@ -143,7 +145,11 @@ class _ToolsOnlyAdapter(_Adapter):
|
||||
) -> list[DiscoveredPrompt]:
|
||||
raise ExceptionGroup(
|
||||
"unhandled errors in a TaskGroup",
|
||||
[McpError(ErrorData(code=-32601, message="Method not found"))],
|
||||
[
|
||||
MCPError.from_error_data(
|
||||
ErrorData(code=-32601, message="Method not found")
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -162,11 +168,11 @@ class _HttpOptionalUnsupportedAdapter(_Adapter):
|
||||
connection: McpSourceConnection,
|
||||
auth: AuthRecord | None,
|
||||
) -> list[DiscoveredResource]:
|
||||
request = httpx.Request("POST", "https://example.test/mcp")
|
||||
response = httpx.Response(400, request=request)
|
||||
request = httpx2.Request("POST", "https://example.test/mcp")
|
||||
response = httpx2.Response(400, request=request)
|
||||
raise ExceptionGroup(
|
||||
"unhandled errors in a TaskGroup",
|
||||
[httpx.HTTPStatusError("bad request", request=request, response=response)],
|
||||
[httpx2.HTTPStatusError("bad request", request=request, response=response)],
|
||||
)
|
||||
|
||||
async def list_prompts(
|
||||
@@ -174,9 +180,9 @@ class _HttpOptionalUnsupportedAdapter(_Adapter):
|
||||
connection: McpSourceConnection,
|
||||
auth: AuthRecord | None,
|
||||
) -> list[DiscoveredPrompt]:
|
||||
request = httpx.Request("POST", "https://example.test/mcp")
|
||||
response = httpx.Response(404, request=request)
|
||||
raise httpx.HTTPStatusError("not found", request=request, response=response)
|
||||
request = httpx2.Request("POST", "https://example.test/mcp")
|
||||
response = httpx2.Response(404, request=request)
|
||||
raise httpx2.HTTPStatusError("not found", request=request, response=response)
|
||||
|
||||
|
||||
async def test_discover_connection_capabilities_collects_all_capability_families() -> (
|
||||
|
||||
@@ -8,7 +8,7 @@ from wf_sources_mcp.sdk.converters import tool_result_to_call_result, tool_to_di
|
||||
def test_tool_without_output_schema_exposes_raw_content_schema() -> None:
|
||||
tool = Tool(
|
||||
name="echo",
|
||||
inputSchema={"type": "object", "properties": {}},
|
||||
input_schema={"type": "object", "properties": {}},
|
||||
)
|
||||
|
||||
discovered = tool_to_discovered(tool)
|
||||
@@ -21,8 +21,8 @@ def test_tool_without_output_schema_exposes_raw_content_schema() -> None:
|
||||
def test_tool_with_content_only_output_schema_stays_raw() -> None:
|
||||
tool = Tool(
|
||||
name="echo",
|
||||
inputSchema={"type": "object", "properties": {}},
|
||||
outputSchema={
|
||||
input_schema={"type": "object", "properties": {}},
|
||||
output_schema={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
@@ -58,7 +58,7 @@ def test_tool_result_single_text_content_block_stays_in_content() -> None:
|
||||
def test_tool_result_structured_content_is_not_rewritten() -> None:
|
||||
result = CallToolResult(
|
||||
content=[TextContent(type="text", text="ignored")],
|
||||
structuredContent={"value": "structured"},
|
||||
structured_content={"value": "structured"},
|
||||
)
|
||||
|
||||
converted = tool_result_to_call_result(result)
|
||||
|
||||
Reference in New Issue
Block a user