You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/scenario-modeler/README.md
+35-29Lines changed: 35 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,52 +4,58 @@ A SaaS financial scenario modeler MCP App. Interactive 12-month projections with
4
4
5
5
## Quick Start
6
6
7
+
### CLI Mode (TUI)
8
+
7
9
```bash
8
10
cd examples/scenario-modeler
9
11
npm install
10
12
npm --prefix ../.. run build
11
13
npm start
12
14
```
13
15
14
-
`npm start` launches the current repo build of dscode from this example directory. dscode then starts the `scenario-modeler` MCP server through the existing stdio MCP config, so you only need one terminal.
15
-
16
-
Then ask the agent: "Show me the current SaaS scenario projections."
17
-
18
-
If the agent replies with plain text only, ask it to use the `get-scenario-data` MCP tool explicitly.
16
+
Then ask: "Show me the current SaaS scenario projections."
19
17
20
18
Agent calls `get-scenario-data` → dscode renders the MCP App → TUI highlights the localhost link → open it in your browser.
21
19
22
-
## Alternate startup modes
20
+
### Web Mode
21
+
22
+
Run from the example directory so dscode picks up the local `.dscode/settings.json`:
23
23
24
24
```bash
25
-
npm run start:server # start only the HTTP MCP server on localhost:3100
26
-
npm run start:stdio # start only the stdio MCP server
25
+
cd examples/scenario-modeler
26
+
npm install
27
+
npm --prefix ../.. run build
28
+
npm --prefix ../.. run build:web
29
+
npm start -- --web --web-port 3000
27
30
```
28
31
29
-
## How it works
30
-
31
-
-**server.ts** — Standard MCP server using `@modelcontextprotocol/sdk`. Registers:
32
-
-`get-scenario-data` tool with `_meta.ui.resourceUri = "ui://scenario-modeler/mcp-app"`
33
-
- Returns `structuredContent` with templates, projections, and summary data
34
-
- Includes `_ui.mdx` to demonstrate a custom MDX layout override
35
-
-**No HTML required** — dscode renders the dashboard from data + MDX
36
-
-**Auto-generated UI** — dscode inspects `structuredContent` and renders:
37
-
- Chart from projection arrays (line chart with MRR/netProfit curves)
38
-
- Metrics cards from summary key-value pairs
39
-
- Table from template/projection data
40
-
-**No external dependencies** — UI is rendered by dscode's built-in MDX Runtime
32
+
> `npm start` runs `node ../../dist/dscode.mjs` from the current directory — no `--prefix` needed, so cwd stays as `examples/scenario-modeler` and the local MCP config is loaded.
41
33
42
-
## Features
34
+
Open `http://localhost:3000`, then ask: "Show me the current SaaS scenario projections."
43
35
44
-
- 12-month line chart (MRR, Gross Profit, Net Profit) — auto-generated from data
- Custom projection computation via tool arguments
48
-
- Light/dark theme support (via CSS custom properties)
36
+
When the agent calls `get-scenario-data`, the MCP App renders **inline in the chat** — click **"Open App ▼"** to expand the interactive dashboard with sliders, chart, and templates.
49
37
50
-
## Transport
38
+
## Alternate startup
51
39
52
40
```bash
53
-
npm start # HTTP (default, port 3100)
54
-
npm run start:stdio # stdio for direct MCP client connection
41
+
npm run start:server# HTTP MCP server only (localhost:3100)
42
+
npm run start:stdio # stdio MCP server only
55
43
```
44
+
45
+
## How it works
46
+
47
+
-**server.ts** — MCP server using `@modelcontextprotocol/sdk`. Registers:
48
+
-`get-scenario-data` tool with `_meta.ui.resourceUri = "ui://scenario-modeler/mcp-app"`
49
+
-`mcp-app.html` as a UI resource (`text/html;profile=mcp-app`)
50
+
-`structuredContent` + `_ui.mdx` for MDX auto-layout fallback
51
+
-**mcp-app.html** — Pure JS dashboard with Canvas chart, 5 sliders, template comparison, postMessage bridge
52
+
-**Web inline rendering** — iframe embedded in the tool card, communicating via SSE bridge
53
+
54
+
## Files
55
+
56
+
| File | Purpose |
57
+
|------|---------|
58
+
|`server.ts`| MCP server with tool + resource registration |
59
+
|`mcp-app.html`| Interactive dashboard (served as MCP resource) |
60
+
|`package.json`| Dependencies and scripts |
61
+
|`.dscode/settings.json`| MCP config (loaded when running from this directory) |
0 commit comments