Add a streamable-HTTP MCP adapter (mcp_server.py, official FastMCP SDK) mounted at /mcp in the existing FastAPI app, with a combined lifespan so the MCP session manager starts/stops with the service. Ships one smoke tool (qonto_ping, no bank call) — real capability tools land in T02. Prove REST and MCP hit the identical policy path: PolicyEngine.decide() never branches on request.protocol, verified by a parametrized test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
25 lines
761 B
Python
25 lines
761 B
Python
import pytest
|
|
|
|
from qonto_assistant.config import Settings
|
|
from qonto_assistant.mcp_server import create_mcp_server
|
|
|
|
|
|
def _settings() -> Settings:
|
|
settings = Settings.from_env()
|
|
return settings
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_mcp_server_starts_and_lists_smoke_tool() -> None:
|
|
server = create_mcp_server(settings=_settings())
|
|
tools = await server.list_tools()
|
|
tool_names = {tool.name for tool in tools}
|
|
assert "qonto_ping" in tool_names
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_mcp_server_smoke_tool_returns_no_bank_call() -> None:
|
|
server = create_mcp_server(settings=_settings())
|
|
result = await server.call_tool("qonto_ping", {})
|
|
payload = result[1] if isinstance(result, tuple) else result
|
|
assert payload is not None
|