portfolio-optimiser/tests/test_okf_server_example.py
Kjell Tore Guttormsen 459b00f512
docs(readme): name the okf 1.1 server by full path -- a bare okf finds the 0.8.5 dependency
The example config now has the placeholder `/path/to/okf` for `command`, and the README explains
how to find the real path (`command -v okf` outside this project's environment). It also explains
why the bare name fails under `uv run`: it resolves to this framework's own okf 0.8.5, which has
no `mcp` command. A new pin asserts that the example's command is an absolute path; it was red at
daccdbe. The xfail smoke test stays as the measurement behind the rule.

Chose this over lifting the okf dependency to 1.1: it fixes the startup failure without a version
bump and without touching --prepass-payload.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 15:28:53 +02:00

31 lines
1.3 KiB
Python

"""The committed example that wires the ``okf`` MCP server into a run must load through the same
fail-fast loader a real run uses -- a config in the README that ``load_mcp_config`` refuses is a
broken instruction, not documentation."""
from __future__ import annotations
from pathlib import Path
from portfolio_optimiser.mcp_tools import load_mcp_config
EXAMPLE = Path(__file__).resolve().parent.parent / "examples" / "okf-server.mcp.json"
def test_okf_server_example_loads_through_the_run_loader() -> None:
(server,) = load_mcp_config(EXAMPLE)
assert server.name == "okf"
assert server.transport == "stdio"
assert set(server.allowed_tools) == {"okf_list", "okf_describe", "okf_ask", "okf_fetch"}
assert server.timeout_seconds > 0
def test_okf_server_example_carries_a_neutral_placeholder_path() -> None:
text = EXAMPLE.read_text(encoding="utf-8")
assert "/Users/" not in text and "/home/" not in text
def test_okf_server_example_names_the_server_by_full_path() -> None:
"""A bare ``okf`` resolves to this project's own okf 0.8.5 dependency (no ``mcp``) under
``uv run`` or an activated environment -- measured in ``test_okf_server_smoke.py``."""
(server,) = load_mcp_config(EXAMPLE)
assert server.command is not None and Path(server.command).is_absolute()