Spaces:
Running
Running
Update app/mcp.py
Browse files- app/mcp.py +35 -0
app/mcp.py
CHANGED
|
@@ -26,6 +26,7 @@ import os
|
|
| 26 |
from typing import Dict, Any
|
| 27 |
|
| 28 |
from . import config as app_config # reads app/.pyfun — only config source for app/*
|
|
|
|
| 29 |
|
| 30 |
logger = logging.getLogger('mcp')
|
| 31 |
|
|
@@ -64,6 +65,7 @@ async def initialize() -> None:
|
|
| 64 |
_register_search_tools(_mcp)
|
| 65 |
# _register_db_tools(_mcp) # uncomment when db_sync is ready
|
| 66 |
_register_system_tools(_mcp)
|
|
|
|
| 67 |
|
| 68 |
logger.info("MCP Hub initialized.")
|
| 69 |
|
|
@@ -337,6 +339,39 @@ def _register_system_tools(mcp) -> None:
|
|
| 337 |
logger.info("Tool registered: health_check")
|
| 338 |
|
| 339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
# =============================================================================
|
| 341 |
# Direct execution guard
|
| 342 |
# =============================================================================
|
|
|
|
| 26 |
from typing import Dict, Any
|
| 27 |
|
| 28 |
from . import config as app_config # reads app/.pyfun — only config source for app/*
|
| 29 |
+
# from . import polymarket
|
| 30 |
|
| 31 |
logger = logging.getLogger('mcp')
|
| 32 |
|
|
|
|
| 65 |
_register_search_tools(_mcp)
|
| 66 |
# _register_db_tools(_mcp) # uncomment when db_sync is ready
|
| 67 |
_register_system_tools(_mcp)
|
| 68 |
+
_register_polymarket_tools(_mcp)
|
| 69 |
|
| 70 |
logger.info("MCP Hub initialized.")
|
| 71 |
|
|
|
|
| 339 |
logger.info("Tool registered: health_check")
|
| 340 |
|
| 341 |
|
| 342 |
+
|
| 343 |
+
# 3. Neue Funktion — analog zu _register_search_tools():
|
| 344 |
+
def _register_polymarket_tools(mcp) -> None:
|
| 345 |
+
"""Polymarket tools — no ENV key needed, Gamma API is public."""
|
| 346 |
+
|
| 347 |
+
@mcp.tool()
|
| 348 |
+
async def get_markets(category: str = None, limit: int = 20) -> list:
|
| 349 |
+
"""Get active prediction markets, optional category filter."""
|
| 350 |
+
return await polymarket.get_markets(category=category, limit=limit)
|
| 351 |
+
|
| 352 |
+
@mcp.tool()
|
| 353 |
+
async def trending_markets(limit: int = 10) -> list:
|
| 354 |
+
"""Get top trending markets by trading volume."""
|
| 355 |
+
return await polymarket.trending_markets(limit=limit)
|
| 356 |
+
|
| 357 |
+
@mcp.tool()
|
| 358 |
+
async def analyze_market(market_id: str) -> dict:
|
| 359 |
+
"""LLM analysis of a single market. Fallback if no LLM key set."""
|
| 360 |
+
return await polymarket.analyze_market(market_id)
|
| 361 |
+
|
| 362 |
+
@mcp.tool()
|
| 363 |
+
async def summary_report(category: str = None) -> dict:
|
| 364 |
+
"""Summary report for a category or all markets."""
|
| 365 |
+
return await polymarket.summary_report(category=category)
|
| 366 |
+
|
| 367 |
+
@mcp.tool()
|
| 368 |
+
async def polymarket_cache_info() -> dict:
|
| 369 |
+
"""Cache status, available categories, LLM availability."""
|
| 370 |
+
return await polymarket.get_cache_info()
|
| 371 |
+
|
| 372 |
+
logger.info("Tools registered: polymarket (5 tools)")
|
| 373 |
+
|
| 374 |
+
|
| 375 |
# =============================================================================
|
| 376 |
# Direct execution guard
|
| 377 |
# =============================================================================
|