INNER CODE UNIT · Python

_handle_tools_call

stevesolun/ctx · src/ctx/mcp_server/server.py:178

def _handle_tools_call(state: _ServerState, params: dict[str, Any]) -> dict[str, Any]:
    """Execute one tool call.

    MCP's tools/call response is:
      {"content": [<content block>, ...], "isError": <bool>}

    Our dispatch returns a JSON-encoded string from CtxCoreToolbox
    (shape: {"results": [...]} or {"error": "..."}). We wrap it as a
    single text content block. Tool-level errors (e.g. missing wiki
    dir) are returned as isError=True so the model sees the diagnostic.
    """
    toolbox = state.ensure_toolbox()
    name = params.get("name")
    if not isinstance(name, str) or not name:
        raise _JsonRpcError(_ErrorCode.INVALID_PARAMS, "params.name is required")

    arguments = params.get("arguments") or {}
    if not isinstance(arguments, dict):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…