Skip to content

feat: restartMcp key on custom ops#281

Merged
fdaviddpt merged 2 commits into
masterfrom
max/restart-mcp-custom-op
Jun 18, 2026
Merged

feat: restartMcp key on custom ops#281
fdaviddpt merged 2 commits into
masterfrom
max/restart-mcp-custom-op

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Context

A custom op that clears state the warm MCP daemons cache (autoload map, PHPStan/PHPUnit result caches) had no way to also reset those daemons — they kept serving stale analysis until the idle timeout. This adds a declarative restartMcp key so one cache-clearing op (e.g. DVSI's dvsi_clearcache) can clear caches and cold-restart the warm LSP layer in a single round-trip.

What changed

  • _resolve_custom_op: after a custom op's cmd succeeds, if the op declares restartMcp, SIGTERM the matching warm daemons via the existing stop.py path (_mcp_stop_server). Each cold-restarts on next call with a fresh index.
    • "restartMcp": true → every server in the mcp block
    • "restartMcp": ["name", ...] → only those servers
    • Skipped when the cmd fails.
  • restartMcp added to _RESERVED_KEYS so it isn't leaked as a SUPERTOOL_* env var.
  • Output gains a one-line mcp: restarted N daemon(s) suffix.

Test plan

  • tests/test_custom_ops.py — 5 new cases (all-servers, named-list, skip-on-cmd-failure, no-key-no-restart). Full file: 68 passed.

🤖 Generated by Max — daemons don't get to lie about what they've seen.

A custom op that clears state the warm MCP daemons cache (autoload map,
phpstan/phpunit result caches) can declare "restartMcp": true (all servers
in the mcp block) or a list of names. After the cmd succeeds, supertool
SIGTERMs those daemons via stop.py; each cold-restarts on next use with a
fresh index. Skipped on cmd failure. Reserved key, not leaked as env var.

Lets a single cache-clearing op also reset the warm LSP layer in one
round-trip instead of leaving daemons serving stale analysis.

Co-Authored-By: Max <noreply>
…nown names

- Filter restartMcp names against the configured mcp block: unknown names are
  reported on a separate "unknown server(s) ignored" line instead of being
  counted as restarted (no more "restarted 1 daemon(s) (typo)" lie).
- Drop the ↻ glyph from the status line for log-parser safety (ASCII).
- Tests: add single-string restartMcp case, unknown-name case, and assert the
  excluded server is not stopped in the named-list case.

Co-Authored-By: Max <noreply>
@fdaviddpt fdaviddpt merged commit 1561931 into master Jun 18, 2026
12 checks passed
@fdaviddpt fdaviddpt deleted the max/restart-mcp-custom-op branch June 18, 2026 15:33
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.

1 participant