Skip to content

Commit 2189b22

Browse files
author
Giacomo Saccaggi
committed
feat: MCP v2 + Mermaid diagrams + Terminal replay (v2.2.0)
BREAKING: mcp>=2.0.0 (FastMCP → MCPServer) - Migrate mcp_server.py from FastMCP to MCPServer (mcp SDK v2) - add_mermaid(): Mermaid.js 11.4.0 diagrams (flowchart, sequence, gantt, class, state, ER, pie) with collapsible option - add_terminal(): asciinema-player 3.8.0 embedded terminal replay with custom theme, dimensions, collapsible - MCP tools: report_add_mermaid, report_add_terminal (31 tools total) - Pipeline DSL: MermaidStep, TerminalStep for >> operator - 15 new tests (135 total passing)
1 parent 69741a7 commit 2189b22

11 files changed

Lines changed: 489 additions & 67 deletions

File tree

‎AGENTS.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ report.save_html('output.html')
134134

135135
## MCP Server
136136

137-
For structured tool calls (29 tools), start the MCP server:
137+
For structured tool calls (31 tools), start the MCP server:
138138
```bash
139139
scomp-link mcp
140140
```
@@ -156,7 +156,9 @@ For building custom branded HTML reports step-by-step:
156156
10. report_add_dark_mode_toggle(report_id) → floating dark/light toggle
157157
11. report_add_code(report_id, code, language, title, output, line_numbers, collapsed) → syntax-highlighted code block with copy button
158158
12. report_add_diff(report_id, old_code, new_code, language, title, old_label, new_label, collapsed) → side-by-side diff view
159-
13. report_save(report_id, output) → saves HTML, frees memory
159+
13. report_add_mermaid(report_id, diagram, title, collapsed) → Mermaid.js diagram (flowchart, sequence, gantt, etc.)
160+
14. report_add_terminal(report_id, cast_data, title, cols, rows, theme, collapsed) → embedded terminal replay (asciinema)
161+
15. report_save(report_id, output) → saves HTML, frees memory
160162
```
161163

162164
**Engines:** plotly (interactive), rawgraphs (SVG static), highcharts (time series)

‎README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[![Security: CodeQL](https://img.shields.io/badge/security-CodeQL-green?logo=github)](https://github.com/GiacomoSaccaggi/scomp_link/security)
1515
[![Docker](https://img.shields.io/docker/v/jack15121/scomp-link?label=docker&logo=docker)](https://hub.docker.com/r/jack15121/scomp-link)
1616
[![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue?logo=github)](https://giacomosaccaggi.github.io/scomp_link/)
17-
[![MCP](https://img.shields.io/badge/MCP-29_tools-blue?logo=anthropic)](https://modelcontextprotocol.io)
17+
[![MCP](https://img.shields.io/badge/MCP-31_tools-blue?logo=anthropic)](https://modelcontextprotocol.io)
1818
[![Smithery](https://img.shields.io/badge/Smithery-scomp--link-purple)](https://smithery.ai/servers/giacomosaccaggi/scomp-link)
1919
[![HuggingFace](https://img.shields.io/badge/%F0%9F%A4%97-MCP%20Space-yellow)](https://huggingface.co/spaces/Euribor512/scomp-link)
2020
[![Claude](https://img.shields.io/badge/Works_with-Claude-blueviolet?logo=anthropic)](AGENT_INTEGRATION.md)
@@ -389,7 +389,7 @@ scomp_link/
389389

390390
scomp-link works natively with AI agents via **MCP (Model Context Protocol)** and **Agent Skills**.
391391

392-
### MCP Server (29 tools for structured agent calls)
392+
### MCP Server (31 tools for structured agent calls)
393393

394394
```bash
395395
pip install scomp-link[mcp]
@@ -421,13 +421,13 @@ docker pull jack15121/scomp-link:latest
421421
docker run -i jack15121/scomp-link mcp
422422
```
423423

424-
**Available tools:** `describe_data`, `train_model`, `predict`, `validate_model`, `detect_drift`, `detect_anomalies`, `check_fairness`, `forecast_series`, `engineer_features`, `cluster_data`, `generate_report`, `create_visualization`, `compare_models`, `export_model`, `embed_text`, `select_backbone`, `report_create`, `report_add_section`, `report_add_text`, `report_add_table`, `report_add_chart`, `report_add_kpi_cards`, `report_add_tabs`, `report_add_comparison_table`, `report_add_summary_stats`, `report_add_dark_mode_toggle`, `report_add_code`, `report_add_diff`, `report_save`
424+
**Available tools:** `describe_data`, `train_model`, `predict`, `validate_model`, `detect_drift`, `detect_anomalies`, `check_fairness`, `forecast_series`, `engineer_features`, `cluster_data`, `generate_report`, `create_visualization`, `compare_models`, `export_model`, `embed_text`, `select_backbone`, `report_create`, `report_add_section`, `report_add_text`, `report_add_table`, `report_add_chart`, `report_add_kpi_cards`, `report_add_tabs`, `report_add_comparison_table`, `report_add_summary_stats`, `report_add_dark_mode_toggle`, `report_add_code`, `report_add_diff`, `report_add_mermaid`, `report_add_terminal`, `report_save`
425425

426426
### Quick Setup Prompt for AI Agents
427427

428428
Copy-paste this prompt into your AI agent (Claude, ChatGPT, Cursor, etc.) to enable scomp-link capabilities:
429429

430-
> You have access to scomp-link, an ML toolkit with 29 MCP tools. Use them for:
430+
> You have access to scomp-link, an ML toolkit with 31 MCP tools. Use them for:
431431
> - **Data profiling**: `describe_data(path)` — always start here
432432
> - **Training**: `train_model(data, target, task)` with optional `tune=true` for Optuna
433433
> - **Validation**: `validate_model(artifact, data, target)` for test evaluation

‎docs/agent-integration.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cp -r /path/to/scomp_link/skills/scomp-link .github/copilot/skills/
4444

4545
## 2. MCP Server — Model Context Protocol (Structured Tools)
4646

47-
The MCP server exposes 29 tools, 3 resources, and 4 prompts over the standard MCP protocol. Any MCP-compatible client can discover and call them with typed inputs.
47+
The MCP server exposes 31 tools, 3 resources, and 4 prompts over the standard MCP protocol. Any MCP-compatible client can discover and call them with typed inputs.
4848

4949
### Install
5050

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "scomp-link"
7-
version = "2.1.2"
7+
version = "2.2.0"
88
description = "The Astromech arm for your Python data projects — end-to-end ML toolkit"
99
readme = "README.md"
1010
license = {text = "MIT"}
@@ -174,7 +174,7 @@ shap = [
174174

175175
# MCP server for AI agent integration
176176
mcp = [
177-
"mcp>=1.0.0,<2.0.0",
177+
"mcp>=2.0.0,<3.0.0",
178178
]
179179

180180
# REST API serving

‎scomp_link/__init__.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from .utils.logger import set_verbosity
1111

12-
__version__ = "2.1.2"
12+
__version__ = "2.2.0"
1313

1414
__all__ = [
1515
"set_verbosity",
@@ -48,6 +48,8 @@
4848
"SaveStep",
4949
"CodeStep",
5050
"DiffStep",
51+
"MermaidStep",
52+
"TerminalStep",
5153
]
5254

5355
_LAZY_IMPORTS = {
@@ -96,6 +98,8 @@
9698
"LogStep": (".pipeline_dsl", "LogStep"),
9799
"CodeStep": (".pipeline_dsl", "CodeStep"),
98100
"DiffStep": (".pipeline_dsl", "DiffStep"),
101+
"MermaidStep": (".pipeline_dsl", "MermaidStep"),
102+
"TerminalStep": (".pipeline_dsl", "TerminalStep"),
99103
}
100104

101105

‎scomp_link/mcp_server.py‎

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pathlib import Path
2626
from typing import Literal, Optional, cast
2727

28-
from mcp.server.fastmcp import FastMCP
28+
from mcp.server.mcpserver import MCPServer
2929

3030
# ═══════════════════════════════════════════════════════════════════
3131
# AUTO-UPDATE SYSTEM
@@ -151,7 +151,7 @@ def _maybe_auto_update() -> Optional[dict]:
151151
return update_result
152152

153153

154-
mcp = FastMCP(
154+
mcp = MCPServer(
155155
"scomp-link",
156156
instructions="End-to-end ML toolkit: train models, tune hyperparameters, detect drift, "
157157
"generate HTML reports with 39 chart types, detect anomalies, forecast time series, "
@@ -1423,6 +1423,71 @@ def report_add_diff(
14231423
return json.dumps({"status": "diff_added", "language": language, "collapsed": collapsed})
14241424

14251425

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+
14261491
# ═══════════════════════════════════════════════════════════════════
14271492
# RESOURCES
14281493
# ═══════════════════════════════════════════════════════════════════

‎scomp_link/pipeline_dsl.py‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,73 @@ def execute(self, report: "ScompLinkHTMLReport") -> "ScompLinkHTMLReport":
534534
return report
535535

536536

537+
class MermaidStep(ReportStep):
538+
"""
539+
Adds a Mermaid.js diagram to the report.
540+
541+
Parameters
542+
----------
543+
diagram : str
544+
Mermaid diagram definition.
545+
title : str
546+
Optional title above the diagram.
547+
collapsed : bool
548+
Wrap in collapsible element (default: False).
549+
"""
550+
551+
def __init__(self, diagram: str, title: str = "", collapsed: bool = False):
552+
self.diagram = diagram
553+
self.title = title
554+
self.collapsed = collapsed
555+
556+
def execute(self, report: "ScompLinkHTMLReport") -> "ScompLinkHTMLReport":
557+
report.add_mermaid(self.diagram, self.title, collapsed=self.collapsed)
558+
return report
559+
560+
561+
class TerminalStep(ReportStep):
562+
"""
563+
Adds an embedded terminal replay (asciinema) to the report.
564+
565+
Parameters
566+
----------
567+
cast_data : str
568+
Asciinema cast file content (v2 format).
569+
title : str
570+
Optional title above the terminal.
571+
cols : int
572+
Terminal width (default: 80).
573+
rows : int
574+
Terminal height (default: 24).
575+
theme : str
576+
Player theme (default: "dracula").
577+
collapsed : bool
578+
Wrap in collapsible element (default: False).
579+
"""
580+
581+
def __init__(
582+
self,
583+
cast_data: str,
584+
title: str = "",
585+
cols: int = 80,
586+
rows: int = 24,
587+
theme: str = "dracula",
588+
collapsed: bool = False,
589+
):
590+
self.cast_data = cast_data
591+
self.title = title
592+
self.cols = cols
593+
self.rows = rows
594+
self.theme = theme
595+
self.collapsed = collapsed
596+
597+
def execute(self, report: "ScompLinkHTMLReport") -> "ScompLinkHTMLReport":
598+
report.add_terminal(
599+
self.cast_data, self.title, cols=self.cols, rows=self.rows, theme=self.theme, collapsed=self.collapsed
600+
)
601+
return report
602+
603+
537604
class SaveStep(ReportStep):
538605
"""
539606
Saves the report as HTML. Automatically closes any open section before saving.

0 commit comments

Comments
 (0)