Skip to content
This repository was archived by the owner on May 26, 2026. It is now read-only.
Merged
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
37 changes: 37 additions & 0 deletions kora_cli/listeners/mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@

TOOLS: list = [DAEMON_STATUS_TOOL]

# KR-MCP-RUNTIME-SURFACE ST1 — extend with the 5 read-only tools.
# Imported lazily inside this list-extension so the import side-effect
# happens at module-load time but doesn't ripple to test fixtures that
# need to patch the dispatch table.
from kora_cli.listeners.mcp_tools import ( # noqa: E402
TOOL_DESCRIPTORS as _ST1_DESCRIPTORS,
TOOL_DISPATCH as _ST1_DISPATCH,
)

TOOLS.extend(_ST1_DESCRIPTORS)


def _execute_daemon_status() -> Dict[str, Any]:
"""Body for ``kora__daemon_status``. Returns the JSON dict."""
Expand Down Expand Up @@ -178,6 +189,7 @@ async def post_jsonrpc(request: Request) -> Dict[str, Any]:

if method == "tools/call":
tool_name = params.get("name")
tool_args = params.get("arguments") or {}
if tool_name == "kora__daemon_status":
return _jsonrpc_result(
req_id,
Expand All @@ -190,6 +202,31 @@ async def post_jsonrpc(request: Request) -> Dict[str, Any]:
]
},
)
# KR-MCP-RUNTIME-SURFACE ST1 — route into the mcp_tools dispatch
# table for the read-only tools. Each dispatcher returns a
# Pydantic model; we serialize via model_dump_json for the
# content[].text field.
if tool_name in _ST1_DISPATCH:
try:
model = await _ST1_DISPATCH[tool_name](tool_args)
except Exception as exc:
logger.exception(
"[mcp] tool %s raised %r", tool_name, exc
)
return _jsonrpc_error(
req_id, -32603, f"tool error: {type(exc).__name__}"
)
return _jsonrpc_result(
req_id,
{
"content": [
{
"type": "text",
"text": model.model_dump_json(),
}
]
},
)
return _jsonrpc_error(
req_id, -32602, f"unknown tool: {tool_name!r}"
)
Expand Down
Loading