flow-codeblock-rust-mcp 0.1.6 → 0.1.7

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.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +17 -12
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@ Local stdio MCP server for Flow Codeblock Rust+Bun. It calls the server-side Rus
7
7
  Bun 1.4.0 or newer is required:
8
8
 
9
9
  ```bash
10
- bunx --bun flow-codeblock-rust-mcp@0.1.6
10
+ bunx --bun flow-codeblock-rust-mcp@0.1.7
11
11
  ```
12
12
 
13
13
  Configure the environment:
@@ -26,7 +26,7 @@ export FLOW_CODEBLOCK_TOKEN='<YOUR_INTERNAL_ACCESS_TOKEN>'
26
26
  "mcpServers": {
27
27
  "flow-codeblock-rust": {
28
28
  "command": "bunx",
29
- "args": ["--bun", "flow-codeblock-rust-mcp@0.1.6"],
29
+ "args": ["--bun", "flow-codeblock-rust-mcp@0.1.7"],
30
30
  "env": {
31
31
  "FLOW_CODEBLOCK_BASE_URL": "https://flow.example.com",
32
32
  "FLOW_CODEBLOCK_TOKEN": "<YOUR_INTERNAL_ACCESS_TOKEN>"
@@ -42,7 +42,7 @@ The code contract follows the current Rust+Bun module allowlist. `crypto-js` has
42
42
 
43
43
  The tools cover code-contract generation, unpublished-code tests, script listing, version reads, documentation validation/preview/save, script creation/update, locking/unlocking, and published-script execution. Creates and code updates can submit a complete interface document or RFC 6902 `interface_doc_patch`; preview calls `/flow/scripts/validate`, and apply re-submits patches with transactional `expected_version` conflict detection. Every script write requires a preview and explicit `confirm: true`.
44
44
 
45
- Final delivery is mode-specific. `non_script` returns complete JavaScript, invocation instructions, request parameters and examples, execution logic, success/error examples, and a complete `execution_url`. `script` omits JavaScript and raw `interface_doc` by default and returns invocation instructions, request parameters and examples, execution logic, success/error examples, and the published `script_url`. Script code and `interface_doc` remain internal inputs to MCP preview, validation, and publication unless the user explicitly requests source or raw documentation.
45
+ When generated code and the available safe input are sufficient for a meaningful runtime test, the client executes it immediately without waiting for user confirmation. If required input or credentials are missing, it reports that runtime verification was not performed instead of inventing them. Final delivery is mode-specific. `non_script` always returns the complete generated JavaScript, even after runtime verification, plus invocation instructions, request parameters and examples, execution logic, success/error examples, and a complete `execution_url`. `script` omits JavaScript and raw `interface_doc` by default and returns invocation instructions, request parameters and examples, execution logic, success/error examples, and the published `script_url`. Script code and `interface_doc` remain internal inputs to MCP preview, validation, and publication unless the user explicitly requests source or raw documentation.
46
46
 
47
47
  Execution errors preserve a concise `message` and verified user-code locations in `error.details.line`, `error.details.column`, and `error.details.lineContent` with one-based line and column numbers. Source location, matched text, and source line are not duplicated in security-policy messages. The details are omitted when the location cannot be verified; direct parse and execution-policy failures use `SyntaxError` and `SecurityError` respectively and return HTTP 422 with `retryable: false`.
48
48
 
package/dist/index.js CHANGED
@@ -28295,7 +28295,7 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28295
28295
  code_rules: [
28296
28296
  "Read all business data from the global input only; do not read environment variables, persistent globals, or other external state. Return values must be JSON-serializable.",
28297
28297
  "Use top-level return by default. Use qf_output only for event-style/asynchronous flows or when explicitly requested, and assign it as a bare qf_output = { ... } object literal. Never mix it with top-level return or shadow the identifier.",
28298
- "Prefer standard JavaScript, server-side fetch, and node:crypto. Use a whitelisted CommonJS literal require only when native capabilities cannot meet the requirement and the user explicitly requests it. crypto-js has been removed and must not be generated.",
28298
+ "Prefer standard JavaScript, Bun-native fetch, real axios, and node:crypto. Network requests use Bun's native network stack. Use a whitelisted CommonJS literal require only when native capabilities cannot meet the requirement and the user explicitly requests it. crypto-js has been removed and must not be generated.",
28299
28299
  "Do not use import/export, dynamic require, browser APIs, timers, forbidden identifiers or members, or blacklisted Node modules. Never write real credentials.",
28300
28300
  "Put business logic and asynchronous operations in try-catch; return errors as strings or plain objects.",
28301
28301
  "Do not create unbounded loops, unsettled Promises, or background tasks that outlive execution; every request must be awaited or returned.",
@@ -28315,6 +28315,7 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28315
28315
  "eval",
28316
28316
  "Function",
28317
28317
  "Proxy",
28318
+ "constructor",
28318
28319
  "__proto__",
28319
28320
  "child_process",
28320
28321
  "exec",
@@ -28335,6 +28336,7 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28335
28336
  "Reflect.apply",
28336
28337
  "Reflect.get",
28337
28338
  "Reflect.set",
28339
+ "process.env",
28338
28340
  "process.exit",
28339
28341
  "process.kill",
28340
28342
  "process.binding",
@@ -28346,6 +28348,8 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28346
28348
  "cluster",
28347
28349
  "dgram",
28348
28350
  "dns",
28351
+ "fs",
28352
+ "node:fs",
28349
28353
  "http",
28350
28354
  "http2",
28351
28355
  "https",
@@ -28374,6 +28378,7 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28374
28378
  "Return only plain serializable values or Promises; do not return circular references, BigInt, functions, Symbols, unhandled complex class instances, or unbounded arrays/strings.",
28375
28379
  "The platform places immediate-interface return values in the outer HTTP response's result field; script interfaces usually return the business value directly. Prefer { success: true, data: value } or { success: false, error: message }."
28376
28380
  ],
28381
+ verification_rule: "After generating code, run a meaningful execution test immediately when the available requirement and safe input are sufficient; execution-only verification does not require user confirmation. If required input or credentials are missing, state that runtime verification was not performed instead of inventing them.",
28377
28382
  allowed_modules: allowedModules
28378
28383
  };
28379
28384
  if (mode === "non_script") {
@@ -28389,12 +28394,12 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28389
28394
  "Generate immediate non_script mode when the user does not specify a mode.",
28390
28395
  "If the requirement includes an HTTP redirect, use script mode with /flow/codeblock/{{script_id}}."
28391
28396
  ],
28392
- deliverables: ["A javascript code block containing executable JavaScript only", "Input and output contracts"],
28397
+ deliverables: ["A complete javascript code block containing executable JavaScript only", "Input and output contracts"],
28393
28398
  test_tool: { name: "flow_execute_code", arguments: { code: "<JavaScript>", input: inputExample ?? {}, timeout_ms: 3000 } },
28394
- rule: "Do not call flow_execute_code unless the user explicitly requests a test.",
28399
+ rule: "Call flow_execute_code immediately when the available requirement and safe input are sufficient for a meaningful test; do not wait for user confirmation.",
28395
28400
  response_format: [
28396
28401
  "Unless the user explicitly requests code only, explain the mode and output first, then provide the JavaScript code block, followed by request/response examples.",
28397
- "For non_script interfaces, deliver complete JavaScript, invocation instructions, request parameters and examples, execution logic, success/error output examples, and execution_url."
28402
+ "For non_script interfaces, always deliver the complete generated JavaScript in the final response, even after runtime verification, plus invocation instructions, request parameters and examples, execution logic, success/error output examples, and execution_url."
28398
28403
  ]
28399
28404
  };
28400
28405
  }
@@ -28448,7 +28453,7 @@ function codeWriterContext(mode, requirement, inputExample, includeFullSchema, b
28448
28453
  "For updates, call flow_get_script first to read the current version; for documentation updates, flow_get_script_documentation may be called first.",
28449
28454
  "Generate code and a complete interface_doc together; call flow_preview_script_change once for a create or code update.",
28450
28455
  "Call flow_apply_script_change or flow_apply_script_documentation only after explicit user confirmation, with confirm=true.",
28451
- "Call flow_execute_script only when the user requests a test of a published script; call flow_execute_code only to test unpublished code.",
28456
+ "When the available requirement and safe input are sufficient for a meaningful test, immediately call flow_execute_code for unpublished code or flow_execute_script for published code; execution-only verification does not require user confirmation.",
28452
28457
  "On a version conflict, expired preview, or validation failure, stop and read/preview again; never retry an old preview_id."
28453
28458
  ],
28454
28459
  response_format: [
@@ -28525,15 +28530,15 @@ var serverInstructions = [
28525
28530
  "This is the Flow Codeblock Rust+Bun MCP server. All tools except flow_write_code call the server-side REST API; flow_write_code returns an authoring contract only. Do not guess REST paths or put MCP credentials in business arguments.",
28526
28531
  "User code runs in a server-side Bun async function context with modern JavaScript, async/await, Promises, arrow functions, and top-level return. Default limits are 100 ms minimum timeout, 15,000 ms maximum timeout, 65,535 code bytes, 2 MiB input, and 10 MiB result.",
28527
28532
  "User-code execution failures preserve the server error type, concise message, and stack when available. Verified source locations are in error.details with one-based line, column, and lineContent; details are omitted when the location cannot be verified. Security-policy messages contain the rule reason only; do not parse source locations from message or expect duplicated location text. Direct execution uses SyntaxError for parse failures and SecurityError for execution policy failures; these user-code failures are non-retryable HTTP 422 responses. Script-save validation may retain ValidationError for policy failures.",
28528
- "Tool routing: flow_write_code only generates code and its contract; flow_execute_code is for explicitly requested tests of unpublished non-script code; flow_execute_script runs only published scripts.",
28533
+ "Tool routing: flow_write_code only generates code and its contract; flow_execute_code tests unpublished generated code; flow_execute_script runs published scripts. When the generated code and available safe input are sufficient for a meaningful runtime test, execute it immediately without waiting for user confirmation. If required input or credentials are missing, report that runtime verification was not performed instead of inventing them.",
28529
28534
  "Script workflow: read the current version with flow_get_script before updates; creates require a complete interface_doc, while code or document updates may use a complete interface_doc or an RFC 6902 interface_doc_patch (never both, and patches require expected_version). Preview with flow_preview_script_change, then call flow_apply_script_change(confirm=true) only after explicit user confirmation. Documentation-only changes use flow_preview_script_documentation -> flow_apply_script_documentation.",
28530
28535
  "Preview IDs are single-use and time-limited. On a version conflict, expired preview, or validation failure, stop, read again, and preview again; never retry an old preview_id. Every flow_apply_* call requires confirm=true.",
28531
28536
  "script-interface-doc.v1 requires schema_version, title, summary, endpoint, request, responses, and logic_description. endpoint requires methods and description; request.query and request.headers are required arrays (use [] when empty); POST requires request.body and GET-only documents must omit it. JSON Patch supports at most 256 add/remove/replace/move/copy/test operations; preview responses show operation counts and paths, not merged documents.",
28532
28537
  "Every query parameter and request header requires name, type, required, description, and example. Request bodies and responses require content_type=application/json, schema, and example; every response also requires status and description. Every JSON Schema node declares type, and object schemas and examples must cover each other.",
28533
28538
  "Keep endpoint.path relative: omit it on create and use /flow/codeblock/<actual-script-id> on update. Public call URLs use the caller-provided domain plus /flow/codeblock/{{script_id}}; never put real tokens, passwords, cookies, or Authorization values in code, documents, examples, or URLs.",
28534
28539
  "Script input comes from input.query, input.header, input.body, and input.cookies; for immediate non-script POST /flow/codeblock, body.input becomes global input unchanged. Use top-level return by default; use a bare qf_output assignment only for event-style/asynchronous flows or when explicitly requested, never both.",
28535
- "Non-script delivery includes complete JavaScript, caller-facing invocation instructions, parameters/examples, logic, success/error examples, and execution_url. Script delivery omits JavaScript and raw interface_doc by default and includes invocation instructions, parameters/examples, logic, success/error examples, and the published script_url unless the user asks for source or raw documentation. Code and interface_doc remain internal preview/validation/publication inputs.",
28536
- "Prefer native JavaScript, URL/URLSearchParams, fetch, and node:crypto; crypto-js has been removed. Do not generate browser APIs, timers, dynamic module loading, blacklisted Node modules, or dangerous identifiers. Excel imports are limited to read-excel-file/node, read-excel-file/universal, write-excel-file/node, write-excel-file/universal, and write-excel-file/utility. Check HTTP status and handle JSON, text, and empty responses; await or return every async task.",
28540
+ "Non-script delivery always includes the complete generated JavaScript in the final response, even after runtime verification, plus caller-facing invocation instructions, parameters/examples, logic, success/error examples, and execution_url. Script delivery omits JavaScript and raw interface_doc by default and includes invocation instructions, parameters/examples, logic, success/error examples, and the published script_url unless the user asks for source or raw documentation. Code and interface_doc remain internal preview/validation/publication inputs.",
28541
+ "Prefer native JavaScript, URL/URLSearchParams, Bun-native fetch, and node:crypto; crypto-js has been removed. Do not generate browser APIs, timers, dynamic module loading, constructor-based code generation, blacklisted Node modules (including fs/node:fs), or dangerous identifiers. Excel imports are limited to read-excel-file/node, read-excel-file/universal, write-excel-file/node, write-excel-file/universal, and write-excel-file/utility. Check HTTP status and handle JSON, text, and empty responses; await or return every async task.",
28537
28542
  "Script execution accepts only GET or POST. MCP authentication, cookies, CSRF, proxy-source headers, and test-tool markers are filtered. There is no script deletion, emergency unlock, or arbitrary HTTP proxy tool; direct those requests to the web UI or controlled REST/operations flow."
28538
28543
  ].join(`
28539
28544
  `);
@@ -28768,10 +28773,10 @@ function assertPreview(record3, operation) {
28768
28773
  return record3;
28769
28774
  }
28770
28775
  function createMcpServer({ api: api2, previews = new PreviewStore }) {
28771
- const server = new McpServer({ name: "flow-codeblock-rust", version: "0.1.6" }, { instructions: serverInstructions });
28776
+ const server = new McpServer({ name: "flow-codeblock-rust", version: "0.1.7" }, { instructions: serverInstructions });
28772
28777
  server.registerTool("flow_write_code", {
28773
28778
  title: "Get the Flow JavaScript authoring contract",
28774
- description: "Call this before writing Flow Codeblock JavaScript. It returns the mode-specific authoring contract and never writes the database, publishes a script, or executes code. Use non_script for immediate POST /flow/codeblock code and return a complete execution_url; use script for persistent GET/POST /flow/codeblock/{{script_id}} code with a complete script-interface-doc.v1 for preview, validation, and publication. Script delivery includes invocation instructions, parameters/examples, logic, success/error examples, and script_url rather than source or raw interface_doc unless requested. Set base_url only when a caller-facing URL template is needed.",
28779
+ description: "Call this before writing Flow Codeblock JavaScript. It returns the mode-specific authoring contract and never writes the database, publishes a script, or executes code. Use non_script for immediate POST /flow/codeblock code and always deliver the complete generated JavaScript plus execution_url; use script for persistent GET/POST /flow/codeblock/{{script_id}} code with a complete script-interface-doc.v1 for preview, validation, and publication. Script delivery includes invocation instructions, parameters/examples, logic, success/error examples, and script_url rather than source or raw interface_doc unless requested. Set base_url only when a caller-facing URL template is needed.",
28775
28780
  inputSchema: {
28776
28781
  mode: exports_external.enum(["non_script", "script"]).describe("Generation mode. Use non_script for immediate, non-persistent execution; use script for a persistent GET/POST endpoint or HTTP redirects."),
28777
28782
  requirement: exports_external.string().min(1).max(20000).describe("Complete business requirements, input fields, expected output, external APIs, synchronization/async needs, and error behavior. Include only requirements relevant to this code."),
@@ -29022,7 +29027,7 @@ function createMcpServer({ api: api2, previews = new PreviewStore }) {
29022
29027
  const queryValueSchema = exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean(), exports_external.array(exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean()]))]);
29023
29028
  server.registerTool("flow_execute_script", {
29024
29029
  title: "Execute published script",
29025
- description: "Execute a published script only when the user explicitly requests a test or call. method must be GET or POST; the result includes a complete script_url built from FLOW_CODEBLOCK_BASE_URL and script_id. Array query values become repeated parameters, and a POST body is sent as JSON. User-code failures preserve verified error.details source locations when available. MCP authentication, cookies, CSRF, proxy-source headers, and test-tool markers are filtered; qingcodeToken and qingcodeTimeout cannot be supplied as business parameters.",
29030
+ description: "Execute a published script when requested or when the available safe input is sufficient to verify newly generated code; execution-only verification does not require user confirmation. method must be GET or POST; the result includes a complete script_url built from FLOW_CODEBLOCK_BASE_URL and script_id. Array query values become repeated parameters, and a POST body is sent as JSON. User-code failures preserve verified error.details source locations when available. MCP authentication, cookies, CSRF, proxy-source headers, and test-tool markers are filtered; qingcodeToken and qingcodeTimeout cannot be supplied as business parameters.",
29026
29031
  inputSchema: {
29027
29032
  script_id: exports_external.string().min(1).describe("Published script ID; the tool calls /flow/codeblock/{script_id}."),
29028
29033
  method: exports_external.enum(["GET", "POST"]).default("POST").describe("Script request method, either GET or POST; defaults to POST."),
@@ -29059,7 +29064,7 @@ function createMcpServer({ api: api2, previews = new PreviewStore }) {
29059
29064
  }));
29060
29065
  server.registerTool("flow_execute_code", {
29061
29066
  title: "Execute unpublished code",
29062
- description: "Execute unpublished non-script JavaScript only when the user explicitly requests a test. The result includes a complete execution_url. The request is always POST /flow/codeblock, and body.input is injected unchanged as global input; provide exactly one of code or code_base64. User-code failures preserve verified error.details source locations when available. MCP authentication is never written into user input, and this tool does not create or publish scripts.",
29067
+ description: "Execute unpublished generated JavaScript when requested or when the available safe input is sufficient for a meaningful runtime test; execution-only verification does not require user confirmation. The result includes a complete execution_url. The request is always POST /flow/codeblock, and body.input is injected unchanged as global input; provide exactly one of code or code_base64. User-code failures preserve verified error.details source locations when available. MCP authentication is never written into user input, and this tool does not create or publish scripts.",
29063
29068
  inputSchema: {
29064
29069
  code: exports_external.string().min(1).optional().describe("UTF-8 JavaScript source, mutually exclusive with code_base64."),
29065
29070
  code_base64: exports_external.string().min(1).optional().describe("Non-empty Base64-encoded JavaScript source, mutually exclusive with code."),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flow-codeblock-rust-mcp",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Flow Codeblock Rust+Bun stdio MCP Server for script management and execution.",
5
5
  "license": "MIT",
6
6
  "repository": {