@barivia/barmesh-mcp 0.1.0 → 0.2.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 CHANGED
@@ -36,8 +36,8 @@ These complement, and do not replace, conventional numerical uncertainty analysi
36
36
  }
37
37
  ```
38
38
 
39
- Access to the analysis tools requires the **`cfd`** entitlement on your API key; otherwise
40
- the analysis calls return HTTP 403. Contact Barivia to enable it.
39
+ Access to the analysis tools requires the **`cfd`** (or **`all_plus_cfd`**) entitlement on your
40
+ API key; otherwise the analysis calls return HTTP 403. Contact Barivia to enable it.
41
41
 
42
42
  ## Tools
43
43
 
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{McpServer as e}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as s}from"@modelcontextprotocol/sdk/server/stdio.js";import{API_KEY as n,CLIENT_VERSION as r}from"./shared.js";import{registerGuideTool as o}from"./tools/guide.js";import{registerDatasetsTool as t}from"./tools/datasets.js";import{registerCfdTools as a}from"./tools/cfd.js";import{registerJobsTool as i}from"./tools/jobs.js";import{registerResultsTool as c}from"./tools/results.js";n||(console.error("Error: BARIVIA_API_KEY not set. Set it in your MCP client config."),process.exit(1));(async function(){const n=new e({name:"barmesh",version:r},{instructions:"# Barivia barmesh — CFD mesh-convergence analytics\n\nSOM-based mesh-convergence verification: compare CFD meshes of a refinement study by the\nvolume-weighted distribution their cells form on a shared self-organizing map, plus\nclassical Richardson/GCI on scalar quantities.\n\n## Two tracks\n- barmesh_mesh_convergence: high-dimensional field comparison. Symmetric KL and\n Wasserstein-1 (EMD) distances between each mesh's SOM fingerprint and a reference,\n and between consecutive meshes. Decreasing, plateauing distances toward the finest\n mesh indicate sufficiency. Complements (does not replace) numerical uncertainty analysis.\n- barmesh_richardson: classical grid-convergence index on scalar QoIs.\n\n## Workflow (read-only first)\n1. barmesh_guide_workflow — orient and confirm your plan includes CFD tools.\n2. barmesh_prepare_mesh_data — recipe for the combined per-cell CSV (mesh_id + features + cell volume V).\n3. barmesh_datasets(action=upload) then preview.\n4. barmesh_mesh_convergence (and/or barmesh_richardson) — returns a job id.\n5. barmesh_jobs(action=status) — poll every 10-20s, for minutes if needed.\n6. barmesh_results(action=get) — distances, convergence reading, and figures.\n\nThese tools are gated by the 'cfd' entitlement; analysis calls return 403 if your plan\ndoes not include it."});o(n),t(n),a(n),i(n),c(n);const m=new s;await n.connect(m),console.error(`barmesh-mcp ${r} ready (API: ${process.env.BARIVIA_API_URL??"https://api.barivia.se"})`)})().catch(e=>{console.error("Fatal error starting barmesh-mcp:",e),process.exit(1)});
2
+ import{McpServer as e}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as s}from"@modelcontextprotocol/sdk/server/stdio.js";import{API_KEY as r,CLIENT_VERSION as n}from"./shared.js";import{registerGuideTool as o}from"./tools/guide.js";import{registerDatasetsTool as t}from"./tools/datasets.js";import{registerCfdTools as a}from"./tools/cfd.js";import{registerJobsTool as i}from"./tools/jobs.js";import{registerResultsTool as c}from"./tools/results.js";import{registerFeedbackTool as m}from"./tools/feedback.js";r||(console.error("Error: BARIVIA_API_KEY not set. Set it in your MCP client config."),process.exit(1));(async function(){const r=new e({name:"barmesh",version:n},{instructions:"# Barivia barmesh — CFD mesh-convergence analytics\n\nSOM-based mesh-convergence verification: compare CFD meshes of a refinement study by the\nvolume-weighted distribution their cells form on a shared self-organizing map, plus\nclassical Richardson/GCI on scalar quantities.\n\n## Two tracks\n- barmesh_mesh_convergence: high-dimensional field comparison. Symmetric KL and\n Wasserstein-1 (EMD) distances between each mesh's SOM fingerprint and a reference,\n and between consecutive meshes. Decreasing, plateauing distances toward the finest\n mesh indicate sufficiency. Complements (does not replace) numerical uncertainty analysis.\n- barmesh_richardson: classical grid-convergence index on scalar QoIs.\n\n## Workflow (read-only first)\n1. barmesh_guide_workflow — orient and confirm your plan includes CFD tools.\n2. barmesh_prepare_mesh_data — recipe for the combined per-cell CSV (mesh_id + features + cell volume V).\n3. barmesh_datasets(action=upload) then preview.\n4. barmesh_mesh_convergence (and/or barmesh_richardson) — returns a job id.\n5. barmesh_jobs(action=status) — poll every 10-20s, for minutes if needed.\n6. barmesh_results(action=get) — distances, convergence reading, and figures.\n\nThese tools are gated by the 'cfd' entitlement; analysis calls return 403 if your plan\ndoes not include it."});o(r),t(r),a(r),i(r),c(r),m(r);const l=new s;await r.connect(l),console.error(`barmesh-mcp ${n} ready (API: ${process.env.BARIVIA_API_URL??"https://api.barivia.se"})`)})().catch(e=>{console.error("Fatal error starting barmesh-mcp:",e),process.exit(1)});
package/dist/shared.js CHANGED
@@ -16,7 +16,7 @@ export const FETCH_TIMEOUT_MS = parseInt(process.env.BARIVIA_FETCH_TIMEOUT_MS ??
16
16
  export const MAX_RETRIES = 2;
17
17
  export const RETRYABLE_STATUS = new Set([502, 503, 504]);
18
18
  /** Single source of truth for the proxy version. Keep in sync with package.json on bump. */
19
- export const CLIENT_VERSION = "0.1.0";
19
+ export const CLIENT_VERSION = "0.2.0";
20
20
  export const PUBLIC_SITE_ORIGIN = "https://barivia.se";
21
21
  /** Large per-cell CSV uploads may exceed the default fetch timeout. */
22
22
  export const UPLOAD_DATASET_TIMEOUT_MS = 180_000;
@@ -130,7 +130,7 @@ export function formatApiErrorMessage(status, bodyText, requestId) {
130
130
  : status === 401
131
131
  ? ` Check BARIVIA_API_KEY in your MCP config.${accountHint}`
132
132
  : status === 403
133
- ? ` Access denied (your plan may not include the CFD mesh-convergence tools).${accountHint}`
133
+ ? ` Access denied your plan does not include the CFD capability. Add the CFD capability at ${PUBLIC_SITE_ORIGIN}/dashboard to enable the barmesh tools.`
134
134
  : status === 404
135
135
  ? " The resource may not exist or may have been deleted."
136
136
  : status === 409
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { registerAuditedTool } from "../audit.js";
3
+ import { apiCall, API_URL, fetchWithTimeout, textResult } from "../shared.js";
4
+ export function registerFeedbackTool(server) {
5
+ registerAuditedTool(server, "send_feedback", `Send feedback or feature requests to Barivia developers (CFD mesh-convergence / barmesh workflow). Use when the user has suggestions, ran into issues, or wants something improved. Do NOT call without asking the user first — but after a mesh-convergence or Richardson session, you SHOULD prepare feedback based on the user's workflow or errors encountered, show it to them, and ask for permission to send it. Once they accept, call this tool.
6
+
7
+ For a substantial issue, prefer feedback_items: submit several focused instances (each max 1400 chars) covering, e.g., symptoms, exact reproduction steps, environment, and concrete asks — they are stored together as one batch so developers see the full picture. Use the single feedback field for a short one-off note.`, {
8
+ feedback: z.string().max(1400).optional().describe("Single feedback note (max 1400 characters). Use feedback_items instead for a multi-part report."),
9
+ feedback_items: z.array(z.string().max(1400)).max(10).optional().describe("Several feedback instances (each max 1400 characters, up to 10), stored together as one batch. Prefer this for a detailed issue: split it into focused parts (symptoms, reproduction, environment, asks)."),
10
+ }, async ({ feedback, feedback_items }) => {
11
+ const items = (feedback_items ?? []).map((s) => s.trim()).filter((s) => s.length > 0);
12
+ if (feedback && feedback.trim().length > 0)
13
+ items.unshift(feedback.trim());
14
+ if (items.length === 0) {
15
+ throw new Error("send_feedback requires feedback or feedback_items (at least one non-empty entry).");
16
+ }
17
+ const body = items.length === 1 ? { feedback: items[0] } : { feedback_items: items };
18
+ try {
19
+ const data = await apiCall("POST", "/v1/feedback", body);
20
+ return textResult(data);
21
+ }
22
+ catch (err) {
23
+ if (err?.httpStatus === 401) {
24
+ try {
25
+ const url = `${API_URL}/v1/feedback`;
26
+ const resp = await fetchWithTimeout(url, {
27
+ method: "POST",
28
+ headers: { "Content-Type": "application/json" },
29
+ body: JSON.stringify(body),
30
+ });
31
+ const text = await resp.text();
32
+ if (resp.ok) {
33
+ const parsed = JSON.parse(text);
34
+ return textResult({ ...parsed, note: "Feedback sent anonymously (API key invalid or expired)." });
35
+ }
36
+ }
37
+ catch { /* fall through to original error */ }
38
+ }
39
+ throw err;
40
+ }
41
+ });
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barivia/barmesh-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "barmesh MCP proxy — SOM-based CFD mesh-convergence and Richardson/GCI analysis on the Barivia cloud API",
5
5
  "keywords": [
6
6
  "mcp",