|
25 | 25 | from pathlib import Path |
26 | 26 | from typing import Literal, Optional, cast |
27 | 27 |
|
28 | | -from mcp.server.fastmcp import FastMCP |
| 28 | +from mcp.server.mcpserver import MCPServer |
29 | 29 |
|
30 | 30 | # ═══════════════════════════════════════════════════════════════════ |
31 | 31 | # AUTO-UPDATE SYSTEM |
@@ -151,7 +151,7 @@ def _maybe_auto_update() -> Optional[dict]: |
151 | 151 | return update_result |
152 | 152 |
|
153 | 153 |
|
154 | | -mcp = FastMCP( |
| 154 | +mcp = MCPServer( |
155 | 155 | "scomp-link", |
156 | 156 | instructions="End-to-end ML toolkit: train models, tune hyperparameters, detect drift, " |
157 | 157 | "generate HTML reports with 39 chart types, detect anomalies, forecast time series, " |
@@ -1423,6 +1423,71 @@ def report_add_diff( |
1423 | 1423 | return json.dumps({"status": "diff_added", "language": language, "collapsed": collapsed}) |
1424 | 1424 |
|
1425 | 1425 |
|
| 1426 | +@mcp.tool() |
| 1427 | +def report_add_mermaid(report_id: str, diagram: str, title: str = "", collapsed: bool = False) -> str: |
| 1428 | + """Add a Mermaid.js diagram to the report. |
| 1429 | +
|
| 1430 | + Renders flowcharts, sequence diagrams, class diagrams, gantt charts, state diagrams, |
| 1431 | + ER diagrams, and more. Uses Mermaid.js syntax. |
| 1432 | +
|
| 1433 | + Parameters: |
| 1434 | + report_id: The report ID returned by report_create. |
| 1435 | + diagram: Mermaid diagram definition string. |
| 1436 | + Example: "graph TD; A[Start]-->B[Train]; B-->C[Validate]; C-->D[Deploy];" |
| 1437 | + title: Optional title above the diagram. |
| 1438 | + collapsed: Wrap in collapsible element (default: false). |
| 1439 | +
|
| 1440 | + Common diagram types: |
| 1441 | + - graph TD (top-down flowchart) |
| 1442 | + - graph LR (left-right flowchart) |
| 1443 | + - sequenceDiagram |
| 1444 | + - classDiagram |
| 1445 | + - gantt |
| 1446 | + - stateDiagram-v2 |
| 1447 | + - erDiagram |
| 1448 | + - pie |
| 1449 | + """ |
| 1450 | + report = _get_report(report_id) |
| 1451 | + if not report: |
| 1452 | + return json.dumps({"error": f"Report '{report_id}' not found. Use report_create first."}) |
| 1453 | + |
| 1454 | + report.add_mermaid(diagram, title, collapsed=collapsed) |
| 1455 | + return json.dumps({"status": "mermaid_added", "collapsed": collapsed}) |
| 1456 | + |
| 1457 | + |
| 1458 | +@mcp.tool() |
| 1459 | +def report_add_terminal( |
| 1460 | + report_id: str, |
| 1461 | + cast_data: str, |
| 1462 | + title: str = "", |
| 1463 | + cols: int = 80, |
| 1464 | + rows: int = 24, |
| 1465 | + theme: str = "dracula", |
| 1466 | + collapsed: bool = False, |
| 1467 | +) -> str: |
| 1468 | + """Add an embedded terminal replay (asciinema player) to the report. |
| 1469 | +
|
| 1470 | + Embeds an interactive terminal session that plays back recorded commands and output. |
| 1471 | + The user can play/pause/seek through the recording. |
| 1472 | +
|
| 1473 | + Parameters: |
| 1474 | + report_id: The report ID returned by report_create. |
| 1475 | + cast_data: Content of an asciinema .cast file (v2 format, JSON lines). |
| 1476 | + Generate with: asciinema rec demo.cast |
| 1477 | + title: Optional title above the terminal. |
| 1478 | + cols: Terminal width in columns (default: 80). |
| 1479 | + rows: Terminal height in rows (default: 24). |
| 1480 | + theme: Player theme — "dracula", "monokai", "solarized-dark", "tango" (default: "dracula"). |
| 1481 | + collapsed: Wrap in collapsible element (default: false). |
| 1482 | + """ |
| 1483 | + report = _get_report(report_id) |
| 1484 | + if not report: |
| 1485 | + return json.dumps({"error": f"Report '{report_id}' not found. Use report_create first."}) |
| 1486 | + |
| 1487 | + report.add_terminal(cast_data, title, cols=cols, rows=rows, theme=theme, collapsed=collapsed) |
| 1488 | + return json.dumps({"status": "terminal_added", "cols": cols, "rows": rows, "collapsed": collapsed}) |
| 1489 | + |
| 1490 | + |
1426 | 1491 | # ═══════════════════════════════════════════════════════════════════ |
1427 | 1492 | # RESOURCES |
1428 | 1493 | # ═══════════════════════════════════════════════════════════════════ |
|
0 commit comments