Update article query logic and improve response structure
Removed the unused `smd_detail_article` decorator and expanded the response structure to include detailed article data in nested JSON. Adjusted the pagination default `pageSize` from 10 to 25 to handle larger datasets effectively.
This commit is contained in:
parent
d779b5bd98
commit
1554d5e4ab
1 changed files with 20 additions and 3 deletions
|
@ -24,7 +24,6 @@ logger = logging.getLogger(__name__)
|
|||
# Initialize FastMCP server
|
||||
mcp = FastMCP("SMD Researcher", host="0.0.0.0", port=8000, timeout_keep_alive=720)
|
||||
|
||||
@mcp.tool()
|
||||
async def smd_detail_article(article_id: str) -> dict:
|
||||
"""
|
||||
Get the Details of an article found by the tool smd_research based on the article_id.
|
||||
|
@ -85,7 +84,7 @@ async def smd_research(search_query: str = "Bundesrat", date_from: str = "2024-0
|
|||
],
|
||||
"exact": False,
|
||||
"pagination": {
|
||||
"pageSize": 10,
|
||||
"pageSize": 25,
|
||||
"currentPage": 1
|
||||
},
|
||||
"onlyResults": False
|
||||
|
@ -98,12 +97,30 @@ async def smd_research(search_query: str = "Bundesrat", date_from: str = "2024-0
|
|||
}
|
||||
response = requests.post(url, headers=headers, json=query)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
result = response.json()
|
||||
|
||||
# Artikel-Liste aus der `data`-Struktur der Antwort
|
||||
articles = result.get("data", [])
|
||||
|
||||
# Verschachtelte JSON-Resultate von `smd_detail_article` sammeln
|
||||
detailed_articles = []
|
||||
for article in articles:
|
||||
article_id = article.get("id")
|
||||
if article_id:
|
||||
detailed_result = smd_detail_article(article_id)
|
||||
detailed_articles.append(detailed_result)
|
||||
|
||||
# Gesamtantwort mit kombinierter JSON-Struktur
|
||||
return {
|
||||
"search_result": result,
|
||||
"detailed_articles": detailed_articles
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"message": response.text
|
||||
}
|
||||
|
||||
|
||||
def run_server():
|
||||
"""Run the MCP server using FastMCP's built-in event loop handling."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue