From d152162dbfb53e26299d73d3d22704ce85a9b375 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 30 Dec 2025 20:46:02 +0000 Subject: [PATCH] Fix params type: accept Any (string, dict, or None) for flexibility --- server.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/server.py b/server.py index c34b366..b2182b4 100644 --- a/server.py +++ b/server.py @@ -1,6 +1,7 @@ import os import json import logging +from typing import Any import httpx from fastmcp import FastMCP from starlette.applications import Starlette @@ -183,7 +184,7 @@ async def list_collection_documents( @mcp.tool() -async def outline_api_call(method: str, params: str = "") -> str: +async def outline_api_call(method: str, params: Any = None) -> str: """Execute a raw Outline API call for any endpoint. Use the 'outline://api-reference' resource to discover available methods @@ -191,20 +192,33 @@ async def outline_api_call(method: str, params: str = "") -> str: Args: method: API method name (e.g., 'documents.create', 'users.list') - params: JSON string of parameters to send in request body + params: Parameters as JSON string or dict (optional) Returns: JSON string with raw API response Examples: - method='documents.create', params='{"title": "New Doc", "collectionId": "uuid"}' - - method='users.list', params='{"limit": 10}' + - method='users.list', params={"limit": 10} - method='documents.delete', params='{"id": "document-uuid"}' """ - try: - parsed_params = json.loads(params) if params and params.strip() else {} - except json.JSONDecodeError as e: - return json.dumps({"ok": False, "error": f"Invalid JSON params: {str(e)}"}) + # Handle params being string, dict, or None/empty + if params is None or params == "" or params == {}: + parsed_params = {} + elif isinstance(params, dict): + parsed_params = params + elif isinstance(params, str): + try: + parsed_params = json.loads(params) if params.strip() else {} + except json.JSONDecodeError as e: + return json.dumps({"ok": False, "error": f"Invalid JSON params: {str(e)}"}) + else: + return json.dumps( + { + "ok": False, + "error": f"params must be string or dict, got {type(params).__name__}", + } + ) result = await outline_client.call(method, parsed_params) return json.dumps(result, indent=2)