Skip to content
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
2 changes: 2 additions & 0 deletions services/chatbot/src/mcpserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import httpx
from fastmcp import FastMCP

from .tool_helpers import fix_array_responses_in_spec
from .config import Config

# Configure logging
Expand Down Expand Up @@ -77,6 +78,7 @@ def get_http_client():
# Load your OpenAPI spec
with open(Config.OPENAPI_SPEC, "r") as f:
openapi_spec = json.load(f)
openapi_spec = fix_array_responses_in_spec(openapi_spec)

# Create the MCP server
mcp = FastMCP.from_openapi(
Expand Down
15 changes: 15 additions & 0 deletions services/chatbot/src/mcpserver/tool_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@ async def get_any_api_key():
if doc and "openai_api_key" in doc:
return doc["openai_api_key"]
return None

def fix_array_responses_in_spec(spec):
for path_item in spec.get("paths", {}).values():
for method, operation in path_item.items():
if method not in ["get", "post", "put", "patch", "delete"]:
continue

for response in operation.get("responses", {}).values():
for media in response.get("content", {}).values():
schema = media.get("schema", {})

if schema.get("type") == "array":
del media["schema"]

return spec
Loading