@barivia/barsom-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # @barivia/barsom-mcp
2
+
3
+ MCP proxy for the Barivia Analytics Engine -- connects any stdio MCP client (Cursor, Claude Desktop, etc.) to the barSOM cloud API. 20 tools covering the full data analysis lifecycle: upload, preview, train, analyze, compare, and export.
4
+
5
+ ## Installation
6
+
7
+ No install step needed. MCP clients run it via `npx`:
8
+
9
+ ```json
10
+ {
11
+ "mcpServers": {
12
+ "analytics-engine": {
13
+ "command": "npx",
14
+ "args": ["-y", "@barivia/barsom-mcp"],
15
+ "env": {
16
+ "BARIVIA_API_KEY": "bv_your_key",
17
+ "BARIVIA_API_URL": "https://api.barivia.se"
18
+ }
19
+ }
20
+ }
21
+ }
22
+ ```
23
+
24
+ This is the standard pattern for MCP servers distributed as npm packages (same as `firecrawl-mcp`, `@paypal/mcp`, etc.).
25
+
26
+ ## Environment Variables
27
+
28
+ | Variable | Required | Default | Description |
29
+ |---|---|---|---|
30
+ | `BARIVIA_API_KEY` | Yes | -- | API key (starts with `bv_`) |
31
+ | `BARIVIA_API_URL` | No | `https://api.barivia.se` | API base URL |
32
+
33
+ Legacy `BARSOM_API_KEY` / `BARSOM_API_URL` are also accepted as fallbacks.
34
+
35
+ ## Tools (20)
36
+
37
+ ### Data Management
38
+
39
+ | Tool | Description |
40
+ |---|---|
41
+ | `upload_dataset` | Upload CSV data for SOM analysis |
42
+ | `list_datasets` | List uploaded datasets with row/column counts |
43
+ | `preview_dataset` | Inspect columns, statistics, sample rows, detect datetime columns, suggest temporal features |
44
+ | `delete_dataset` | Delete dataset and S3 artifacts |
45
+
46
+ ### Training Lifecycle
47
+
48
+ | Tool | Description |
49
+ |---|---|
50
+ | `train_som` | Submit training job with full control: model type (SOM/RSOM/SOM-SOFT/RSOM-SOFT), grid size, epochs, learning rate curves, feature weights, cyclic encoding, temporal features |
51
+ | `get_job_status` | Check training progress and estimated completion |
52
+ | `cancel_job` | Cancel a pending or running job |
53
+ | `list_jobs` | List all jobs with status, parameters, and timing |
54
+ | `delete_job` | Delete job and all result artifacts |
55
+
56
+ ### Results & Export
57
+
58
+ | Tool | Description |
59
+ |---|---|
60
+ | `get_results` | Download results with inline images and quality metrics |
61
+ | `get_training_log` | Per-epoch learning curves (QE residuals) for diagnostics |
62
+ | `get_weights` | Export raw SOM weight matrix and normalization parameters |
63
+ | `get_node_data` | Per-node hit counts and feature-value distributions |
64
+
65
+ ### Analysis (9 types via `analyze`)
66
+
67
+ | Type | Description |
68
+ |---|---|
69
+ | `u_matrix` | Distance matrix heatmap showing cluster boundaries |
70
+ | `component_planes` | Per-feature spatial distribution across the SOM |
71
+ | `bmu_hits` | Hit histogram showing data density |
72
+ | `clusters` | Automated cluster quality assessment |
73
+ | `feature_importance` | Feature ranking by variance contribution |
74
+ | `feature_correlation` | Inter-feature correlation analysis |
75
+ | `transition_flow` | Temporal trajectory analysis with quiver plots |
76
+ | `local_density` | Node neighborhood density analysis |
77
+ | `feature_gradient` | Spatial gradient magnitude across the SOM |
78
+
79
+ ### Advanced Analysis
80
+
81
+ | Tool | Description |
82
+ |---|---|
83
+ | `compare_runs` | Side-by-side metric comparison across training runs |
84
+ | `project_variable` | Project a derived variable onto a trained SOM |
85
+ | `transition_flow` | Dedicated temporal flow analysis |
86
+ | `quality_report` | Extended quality metrics (trustworthiness, neighborhood preservation) |
87
+
88
+ ### System
89
+
90
+ | Tool | Description |
91
+ |---|---|
92
+ | `system_info` | Runtime environment, CPU cores, worker topology, queue state |
93
+ | `configure_resources` | Set worker threads, replica count, max concurrency |
94
+
95
+ ## How It Works
96
+
97
+ The proxy implements the MCP stdio transport locally and translates tool calls into REST API requests to the Barivia backend. Results are returned as rich MCP content with text summaries, inline base64 images, and resource links.
98
+
99
+ ```
100
+ MCP Client (Cursor/Claude) ←stdio→ @barivia/barsom-mcp ←HTTPS→ api.barivia.se
101
+ ```
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ cd apps/mcp-proxy
107
+ npm install
108
+ npm run dev # Run with tsx (hot reload)
109
+ npm run build # Compile to dist/
110
+ ```
111
+
112
+ For local development against a local API stack:
113
+
114
+ ```bash
115
+ BARIVIA_API_URL=http://localhost:8080 BARIVIA_API_KEY=bv_test_key npm run dev
116
+ ```
117
+
118
+ ## Publishing
119
+
120
+ Published to npm via GitHub Actions on tag `mcp-proxy-v*`:
121
+
122
+ ```bash
123
+ git tag mcp-proxy-v0.1.0
124
+ git push origin mcp-proxy-v0.1.0
125
+ ```
126
+
127
+ Requires `NPM_TOKEN` secret in GitHub repository settings.
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @barivia/barsom-mcp
4
+ *
5
+ * Thin MCP proxy: implements stdio MCP locally and forwards every tool call
6
+ * to the Barivia cloud REST API. Users configure BARIVIA_API_KEY and
7
+ * BARIVIA_API_URL as environment variables.
8
+ *
9
+ * Usage (in MCP client config, e.g. Cursor / Claude Desktop):
10
+ *
11
+ * {
12
+ * "mcpServers": {
13
+ * "analytics-engine": {
14
+ * "command": "npx",
15
+ * "args": ["-y", "@barivia/barsom-mcp"],
16
+ * "env": {
17
+ * "BARIVIA_API_KEY": "bv_live_xxxx",
18
+ * "BARIVIA_API_URL": "https://api.barivia.se"
19
+ * }
20
+ * }
21
+ * }
22
+ * }
23
+ */
24
+ export {};
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG"}