Skip to content

Replace is_read_log with read_log_when_error in stata_do#65

Merged
SepineTam merged 1 commit intodev/1.16.0from
codex/task-title-8745mf
Apr 18, 2026
Merged

Replace is_read_log with read_log_when_error in stata_do#65
SepineTam merged 1 commit intodev/1.16.0from
codex/task-title-8745mf

Conversation

@SepineTam
Copy link
Copy Markdown
Owner

Motivation

  • Change stata_do behavior to avoid reading full logs by default and only read text logs when checking for Stata return-code errors (pattern r(\d+)).
  • Provide a clear informational message when no return-code error is found, and keep existing behavior when callers explicitly opt out of reading logs.
  • Remove an unused is_read_log parameter from stata_help and update callers and CLI wiring to match the new API.

Description

  • Updated src/stata_mcp/api/stata_do.py to replace the is_read_log parameter with read_log_when_error: bool = False, added conditional log-reading logic, and introduced the helper _has_stata_error(content: str) -> bool using re.search(r"r\(\d+\)", ...) to detect Stata return-code errors.
  • Adjusted src/stata_mcp/api/ado_install.py to call stata_do(..., read_log_when_error=False) when invoking the non-Unix installation flow.
  • Removed the unused is_read_log parameter from src/stata_mcp/api/stata_help.py and simplified its local unused-variable handling.
  • Updated src/stata_mcp/mcp_servers.py to expose the MCP tool with read_log_when_error in the stata_do signature, added import re, inserted _has_stata_error helper, and updated docs/tool description to reflect the new semantics.
  • Updated CLI wiring in src/stata_mcp/cli/_handlers.py so the do tool maps the existing CLI --is-read-log flag to the new read_log_when_error argument and removed the obsolete is_read_log pass-through for help.

Testing

  • Ran unit tests with PYTHONPATH=src pytest -q, which completed successfully (10 tests passed).
  • Compiled updated modules with python -m compileall src/stata_mcp/api/stata_do.py src/stata_mcp/api/ado_install.py src/stata_mcp/api/stata_help.py src/stata_mcp/mcp_servers.py src/stata_mcp/cli/_handlers.py, which succeeded without errors.
  • Note: a plain pytest -q run without PYTHONPATH=src fails in this environment due to import path setup, but the tests pass when src is added to PYTHONPATH.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying stata-mcp with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8bd7e2
Status:⚡️  Build in progress...

View logs

@SepineTam SepineTam merged commit abc42f2 into dev/1.16.0 Apr 18, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant