Skip to content

Commit 8e20862

Browse files
Fix section_titles input validation for string arguments (#5)
* Improve description * Fix section_titles input validation for string arguments Accept both List[str] and str for section_titles in fetch_openbb_content. Some LLMs send comma-separated strings instead of JSON arrays, which caused schema validation to reject the input before the function body ran. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f132ba5 commit 8e20862

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

server.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import re
1212
import logging
1313
import traceback
14-
from typing import List, Dict, Any, Optional
14+
from typing import List, Dict, Any, Optional, Union
1515
import httpx
1616
import uvicorn
1717
from fastmcp import FastMCP
@@ -121,7 +121,7 @@ async def identify_openbb_docs_sections(user_query: str) -> Dict[str, Any]:
121121

122122

123123
@mcp.tool()
124-
async def fetch_openbb_content(section_titles: List[str], user_query: str) -> Dict[str, Any]:
124+
async def fetch_openbb_content(section_titles: Union[List[str], str], user_query: str) -> Dict[str, Any]:
125125
"""
126126
127127
Fetch specific documentation content from OpenBB docs based on section titles.
@@ -198,6 +198,8 @@ async def fetch_openbb_content(section_titles: List[str], user_query: str) -> Di
198198
Returns:
199199
Dict with 'success', 'user\_query', 'extracted\_content', and 'sections\_found' fields
200200
"""
201+
if isinstance(section_titles, str):
202+
section_titles = [s.strip() for s in section_titles.split(",") if s.strip()]
201203
try:
202204
result = await _fetch_content_async(section_titles, user_query)
203205
return result

0 commit comments

Comments
 (0)