feat(Session 452): Add 24/5 trading MCP tools
Added 4 new MCP tools for Session 452 - 24/5 Trading Enhancement:
1. market_closure_context
- Get current market closure context and crypto allocation adjustments
- Endpoint: /api/dashboard/market-closure-context
2. pi_consensus_query
- Get PI consensus data for a symbol (3+ PIs holding)
- Endpoint: /api/pi-intelligence/consensus/{symbol}
3. pi_consensus_top
- Get top PI consensus opportunities
- Endpoint: /api/pi-intelligence/consensus/top
4. pi_scan_trigger
- Trigger manual PI portfolio scan
- Endpoint: /api/pi-intelligence/scan/trigger
USAGE: Enables Claude to query market status and PI consensus during
trading sessions, supporting dynamic strategy adjustments.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -527,6 +527,45 @@ async def list_tools() -> list[Tool]:
|
|||||||
"required": ["container", "confirm"],
|
"required": ["container", "confirm"],
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
# === SESSION 452: 24/5 TRADING & CRYPTO FOCUS ===
|
||||||
|
Tool(
|
||||||
|
name="market_closure_context",
|
||||||
|
description="Get current market closure context and crypto allocation adjustments",
|
||||||
|
inputSchema={"type": "object", "properties": {}, "required": []},
|
||||||
|
),
|
||||||
|
Tool(
|
||||||
|
name="pi_consensus_query",
|
||||||
|
description="Get PI consensus data for a symbol (3+ PIs holding)",
|
||||||
|
inputSchema={
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"symbol": {"type": "string", "description": "Ticker symbol (e.g., BTC, NVDA, AAPL)"},
|
||||||
|
},
|
||||||
|
"required": ["symbol"],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Tool(
|
||||||
|
name="pi_consensus_top",
|
||||||
|
description="Get top PI consensus opportunities",
|
||||||
|
inputSchema={
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"limit": {"type": "number", "default": 10, "description": "Max results (1-100)"},
|
||||||
|
},
|
||||||
|
"required": [],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Tool(
|
||||||
|
name="pi_scan_trigger",
|
||||||
|
description="Trigger manual PI portfolio scan",
|
||||||
|
inputSchema={
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"usernames": {"type": "string", "description": "Comma-separated PI usernames (optional)"},
|
||||||
|
},
|
||||||
|
"required": [],
|
||||||
|
},
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -615,7 +654,12 @@ async def call_tool(name: str, arguments: dict[str, Any]) -> list[TextContent]:
|
|||||||
case "rate_limiter":
|
case "rate_limiter":
|
||||||
result = await api_get("/api/monitoring/rate_limiter/stats")
|
result = await api_get("/api/monitoring/rate_limiter/stats")
|
||||||
case "portfolio_allocation":
|
case "portfolio_allocation":
|
||||||
result = await api_get("/api/portfolio/status")
|
# Get positions and extract allocation breakdown
|
||||||
|
positions_data = await api_get("/api/trade/positions")
|
||||||
|
if positions_data and "summary" in positions_data and "by_asset_class" in positions_data["summary"]:
|
||||||
|
result = positions_data["summary"]["by_asset_class"]
|
||||||
|
else:
|
||||||
|
result = {"error": "Asset allocation data not available"}
|
||||||
case "create_order":
|
case "create_order":
|
||||||
payload = {
|
payload = {
|
||||||
"symbol": arguments["symbol"],
|
"symbol": arguments["symbol"],
|
||||||
@@ -754,6 +798,22 @@ async def call_tool(name: str, arguments: dict[str, Any]) -> list[TextContent]:
|
|||||||
result = await api_post(
|
result = await api_post(
|
||||||
f"/containers/restart?container={arguments['container']}&confirm={str(arguments.get('confirm', False)).lower()}"
|
f"/containers/restart?container={arguments['container']}&confirm={str(arguments.get('confirm', False)).lower()}"
|
||||||
)
|
)
|
||||||
|
# === SESSION 452: 24/5 TRADING & CRYPTO FOCUS ===
|
||||||
|
case "market_closure_context":
|
||||||
|
# Get market closure context from dashboard
|
||||||
|
result = await api_get("/api/dashboard/market-closure-context")
|
||||||
|
case "pi_consensus_query":
|
||||||
|
symbol = arguments["symbol"].upper()
|
||||||
|
result = await api_get(f"/api/pi-intelligence/consensus/{symbol}")
|
||||||
|
case "pi_consensus_top":
|
||||||
|
limit = arguments.get("limit", 10)
|
||||||
|
result = await api_get(f"/api/pi-intelligence/consensus/top?limit={limit}")
|
||||||
|
case "pi_scan_trigger":
|
||||||
|
usernames = arguments.get("usernames")
|
||||||
|
endpoint = "/api/pi-intelligence/scan/trigger"
|
||||||
|
if usernames:
|
||||||
|
endpoint += f"?usernames={usernames}"
|
||||||
|
result = await api_post(endpoint)
|
||||||
case _:
|
case _:
|
||||||
result = {"error": f"Unknown tool: {name}"}
|
result = {"error": f"Unknown tool: {name}"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user