Skip to content

mcp: thread project arg through run_script and eval_expression#2701

Merged
borisbat merged 1 commit into
masterfrom
claude/sweet-bose-fc9afb
May 17, 2026
Merged

mcp: thread project arg through run_script and eval_expression#2701
borisbat merged 1 commit into
masterfrom
claude/sweet-bose-fc9afb

Conversation

@borisbat
Copy link
Copy Markdown
Collaborator

Summary

  • Thread project arg through run_script and eval_expression MCP tools — the last two compile-family outliers that shell out to daslang.exe but never piped -project <file> through. Any script/expression that needed .das_project-bound module resolution silently failed.
  • Document the previously-shipped-but-undocumented project arg on live_launch, and add the missing live_commands row to the Live-Reload Control tables in both utils/mcp/README.md and doc/source/reference/utils/mcp.rst.

What changed

File Change
utils/mcp/tools/run_script.das Trailing project : string = "" param, validate_project_arg early-return, -project <file> argv injection.
utils/mcp/tools/eval_expression.das Same shape, plus thread project through the daslib-require rewrite retry path.
utils/mcp/protocol.das PROJECT_PROP added to both tool schemas; dispatch_tool passes the already-extracted project string.
utils/mcp/test_tools.das Two new [test] functions mirroring test_compile_check_invalid_project — exercise both validate_project_arg error branches (nonexistent path, wrong extension) for both tools.
utils/mcp/README.md + doc/source/reference/utils/mcp.rst Tool tables updated; live_commands row inserted.

Out of scope

Removing the daslang-live single-instance OS-level lock and adding a -port CLI flag to unblock concurrent live instances. The MCP-side port arg already exists on every live_* tool — once the executable cooperates, the MCP surface needs minimal further work. Tracking separately.

Test plan

  • format_file clean on every changed .das file (all already_formatted).
  • utils/lint/main.das clean on all 4 changed .das files (0 issues, 0 errors).
  • compile_check on utils/mcp/main.das — entry point compiles, every require still resolves.
  • test_tools.das — 287/287 pass, including the two new tests:
    • test_run_script_invalid_project
    • test_eval_expression_invalid_project
  • Sphinx build with -W clean (handwritten-RST surface — list-table edits, no toctree changes).
  • CI: full matrix (lint, tests, AOT, extended_checks, sphinx).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 17, 2026 07:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes MCP “compile-family” parity by threading the optional .das_project-backed project argument through the remaining subprocess-based tools (run_script, eval_expression), ensuring module resolution works consistently when invoking daslang.exe. It also updates MCP documentation tables and adds targeted tests to lock in focused validation errors for invalid project paths.

Changes:

  • Add optional project parameter validation and -project <file> argv forwarding to run_script and eval_expression (including eval retry path).
  • Extend MCP tool schemas (protocol.das) to expose the project property for both tools and pass it through dispatch.
  • Add tests covering both invalid-project error branches for run_script and eval_expression, plus documentation updates (including live_commands row).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
utils/mcp/tools/run_script.das Validates project and forwards it to daslang.exe via -project.
utils/mcp/tools/eval_expression.das Adds project validation/forwarding and threads it through the retry/rewrite execution path.
utils/mcp/protocol.das Adds project to tool schemas for run_script/eval_expression and passes it through dispatch.
utils/mcp/test_tools.das Adds new unit tests ensuring focused errors for invalid project args in both tools.
utils/mcp/README.md Documents project for run_script/eval_expression and adds live_commands to the live tools table.
doc/source/reference/utils/mcp.rst Updates reference tables: documents project for execution tools and live_launch, and adds live_commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread utils/mcp/README.md Outdated
Every other compile-family MCP tool (compile_check, lint, aot, run_test,
ast_dump, find_symbol, etc.) accepts an optional project : string pointing
at a .das_project file for custom module resolution. run_script and
eval_expression were the last two outliers — both shell out to daslang.exe
(which supports -project) but never piped it through, so any script or
expression that needed project-bound module resolution silently failed.

- run_script.das / eval_expression.das: trailing project arg, validated
  via validate_project_arg, injected as -project <file> in argv before
  the script path. eval_expression also threads it through the daslib-
  rewrite retry.
- protocol.das: PROJECT_PROP registered on both tool schemas; dispatch_tool
  passes the already-extracted project string.
- test_tools.das: two new [test] functions mirroring the existing
  test_compile_check_invalid_project — exercise both validate_project_arg
  error branches (nonexistent path, wrong extension).
- README.md / doc/source/reference/utils/mcp.rst: document the new arg
  on run_script + eval_expression, document the previously-shipped-but-
  undocumented project arg on live_launch, and add the missing
  live_commands row to the Live-Reload Control tables.

Out of scope: removing daslang-live's single-instance lock + adding a
-port CLI flag to unblock concurrent live instances (MCP-side port arg
already exists on every live_* tool).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@borisbat borisbat force-pushed the claude/sweet-bose-fc9afb branch from 10d4bd9 to 6fbfcfd Compare May 17, 2026 07:16
@borisbat borisbat merged commit 7ee8202 into master May 17, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants