@vulcan-energy/mcp-helper 0.2.5 → 0.3.1
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 +57 -54
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/dist/bin/vulcan-mcp-helper.js +50 -104
- package/dist/hem-target-runtime/browser-adapter.mjs +89 -46
- package/dist/hem-target-runtime/host.mjs +297 -17895
- package/dist/hem-target-runtime/preparation.mjs +25372 -0
- package/dist/hem-target-runtime/python-worker.mjs +2885 -680
- package/dist/hem-target-runtime/release-manifests.mjs +32 -29
- package/dist/hem-target-runtime/rust-worker.mjs +2464 -39
- package/dist/hem-target-runtime/wasm-loader.mjs +1 -0
- package/dist/server.d.ts +26 -6
- package/dist/server.js +36 -92
- package/package.json +18 -12
- package/schemas/core-input.schema.json +8020 -0
- package/schemas/input_fhs.schema.json +4728 -0
- package/wasm/wasm_version.json +9 -9
- package/wasm/wasm_wrapper.js +6 -6
- package/wasm/wasm_wrapper_bg.wasm +0 -0
- package/dist/hem-target-runtime/csv-target.mjs +0 -126
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as W}from"node:crypto";import l from"node:fs";import f from"node:path";import{fileURLToPath as S}from"node:url";function _(e=process.cwd()){let r=f.resolve(e);for(l.existsSync(r)&&l.statSync(r).isFile()&&(r=f.dirname(r));;){if(l.existsSync(f.join(r,"package.json"))&&l.existsSync(f.join(r,"hem-batch-core"))&&l.existsSync(f.join(r,"web")))return r;let n=f.dirname(r);if(n===r)break;r=n}let t=f.dirname(S(import.meta.url));return f.resolve(t,"..","..","..")}import a from"node:fs";import o from"node:path";import{fileURLToPath as k,pathToFileURL as J}from"node:url";var h=new Map,v=!1,m=process.cwd(),b=!1;function G(e){let r=[o.join(_(e),"web","pkg"),...["../wasm/","../../wasm/"].map(n=>k(new URL(n,import.meta.url)))],t=r.find(n=>a.existsSync(o.join(n,"wasm_wrapper.js")));if(!t)throw new Error(`The Vulcan engine WASM is not installed (looked in ${r.join(", ")}). Reinstall the package.`);return t}async function j(e,r){let t=r?`${e}?verified`:e,n=h.get(t);if(n)return n;T();let i=o.join(e,"wasm_wrapper.js"),g=o.join(e,"wasm_wrapper_bg.wasm"),p=o.join(e,"wasm_version.json");if(!a.existsSync(i)||!a.existsSync(g))throw new Error(`Browser WASM artifact not found in ${e}`);let s=await import(J(i).href+(r?"?verified":""));if(typeof s.initSync!="function")throw new Error("WASM module is missing initSync");if(s.initSync({module:r??a.readFileSync(g)}),s.setup_panic_hook?.(),typeof s.convert_geometry_csv_to_json!="function")throw new Error("WASM module is missing convert_geometry_csv_to_json");let c={convertGeometryCsvToJson:s.convert_geometry_csv_to_json.bind(s),validateSnippetJs:s.validate_snippet_js?.bind(s),processBatchConfig:s.process_batch_config?.bind(s),calculateMetricsFromParsedData:s.calculate_metrics_from_parsed_data?.bind(s),setWorkspace:M,prepareTargetScenario:s.prepare_target_scenario?.bind(s),metadata:{source:i,wasm_path:g,wasm_version:x(p),build_stamp:u(s.build_stamp),build_info:E(s.get_build_info),runtime_origin_descriptor:u(s.runtime_origin_descriptor),hem_core_version:u(s.metadata_hem_core_version),fhs_wrapper_version:u(s.metadata_fhs_wrapper_version)}};return h.set(t,c),c}var w=new Map;async function q(e,r){let t=w.get(e);if(t)return t;let n=c=>{try{return a.readFileSync(o.join(e,c))}catch{throw new Error(`The package WASM is incomplete: ${o.join(e,c)} is missing. ${r}`)}},i=JSON.parse(n("wasm_version.json").toString("utf8"));for(let c of["js_sha256","sha256"])if(!i[c])throw new Error(`${o.join(e,"wasm_version.json")} has no ${c}. ${r}`);let g=c=>W("sha256").update(c).digest("hex"),p=n("wasm_wrapper_bg.wasm");if(g(n("wasm_wrapper.js"))!==i.js_sha256||g(p)!==i.sha256)throw new Error(`The WASM in ${e} does not match its wasm_version.json. ${r}`);let s={...await j(e,p),versionInfo:i};return w.set(e,s),s}function M(e,r={}){m=o.resolve(e),b=r.confineToWorkspace===!0}function T(){P(),R();let e=globalThis;e.self||(e.self=globalThis),e.window||(e.window=globalThis),typeof e.addEventListener!="function"&&(e.addEventListener=()=>{}),typeof e.postMessage!="function"&&(e.postMessage=()=>{});let r=e.self;typeof r.addEventListener!="function"&&(r.addEventListener=()=>{}),typeof r.postMessage!="function"&&(r.postMessage=()=>{}),typeof e.Worker!="function"&&(e.Worker=class{addEventListener(){}postMessage(){}terminate(){}}),e.write_file=(t,n)=>{let i=d(t);try{return a.mkdirSync(o.dirname(i),{recursive:!0}),a.writeFileSync(i,n),!0}catch(g){return console.error(`[FS Bridge] write_file failed for ${i}:`,g.message),!1}},e.read_file=t=>{let n=d(t);return a.readFileSync(n,"utf8")},e.file_exists=t=>{let n=d(t);return a.existsSync(n)},e.create_dir_all=t=>{let n=d(t);try{return a.mkdirSync(n,{recursive:!0}),!0}catch(i){return console.error(`[FS Bridge] create_dir_all failed for ${n}:`,i.message),!1}},e.list_dir=t=>{let n=d(t);try{return a.readdirSync(n)}catch{return[]}}}function d(e){let r=o.isAbsolute(e)?o.resolve(e):o.resolve(m,e);if(b){let t=o.relative(m,r);if(t===".."||t.startsWith(`..${o.sep}`)||o.isAbsolute(t))throw new Error(`WASM file access escaped the active Vulcan workspace: ${e}`)}return r}function P(){if(v)return;let e=console.error.bind(console);console.log=(...r)=>{let t=r[0];typeof t=="string"&&t.startsWith("[WASM]")||e(...r)},v=!0}var y=!1;function R(){if(y)return;let e=globalThis.fetch?.bind(globalThis);globalThis.fetch=(r,t)=>{let n=typeof r=="string"?r:r instanceof URL?r.href:typeof r?.url=="string"?r.url:String(r);if(n.startsWith("file:")&&n.includes("wasm-bindgen-rayon"))return new Promise(()=>{});if(!e)throw new Error("global fetch is unavailable for WASM bridge requests");return e(r,t)},y=!0}function x(e){try{return JSON.parse(a.readFileSync(e,"utf8"))}catch{return}}function u(e){return typeof e!="function"?void 0:e()||void 0}function E(e){let r=u(e);if(r)try{return JSON.parse(r)}catch{return r}}export{j as loadBrowserWasm,q as loadPackageWasm,G as resolveLegacyWasmDir,M as setBrowserWasmWorkspace};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
|
|
3
|
+
interface MCPConfig {
|
|
4
|
+
workspace: string;
|
|
5
|
+
/** A Vulcan Pro access token. Absent for Free use: Free tools need no account. */
|
|
6
|
+
license_token?: string;
|
|
7
|
+
/** The config file read, when there was one. */
|
|
8
|
+
configPath?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ResolveConfigOptions {
|
|
11
|
+
/** Explicit vulcan-mcp-config.json. */
|
|
12
|
+
configPath?: string;
|
|
13
|
+
/** Workspace folder, for use without a config file (Free). */
|
|
14
|
+
workspace?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare const HELPER_VERSION: string;
|
|
18
|
+
/** One server per connection: tools are stateless and a fresh instance keeps requests independent. */
|
|
19
|
+
declare function createVulcanMcpServer(config: MCPConfig): McpServer;
|
|
20
|
+
/** stdio: launched by the MCP client (Claude Code, Codex, Claude Desktop, Cursor). Free or Pro. */
|
|
21
|
+
declare function startStdioServer(options?: ResolveConfigOptions): Promise<void>;
|
|
1
22
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* @param port Optional port number (defaults to 5000)
|
|
23
|
+
* Local HTTP on 127.0.0.1. Requests must carry the configured Pro token as a Bearer
|
|
24
|
+
* credential: without it any web page could call the helper through the browser.
|
|
25
|
+
* Free use goes through stdio, which has no such exposure.
|
|
6
26
|
*/
|
|
7
|
-
declare function startServer(
|
|
27
|
+
declare function startServer(options?: ResolveConfigOptions, port?: number): Promise<void>;
|
|
8
28
|
|
|
9
|
-
export { startServer };
|
|
29
|
+
export { HELPER_VERSION, createVulcanMcpServer, startServer, startStdioServer };
|