Skip to content

refactor(mcp): split server entrypoint from CLI - #679

Merged
Sinity merged 1 commit into
masterfrom
feature/refactor/mcp-entrypoint
May 1, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/refactor/mcp-entrypoint

Conversation

@Sinity

@Sinity Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

Move MCP out of the interactive query-first CLI and expose it as the standalone polylogue-mcp console script.

Problem

polylogue mcp put a protocol adapter beside query verbs and archive/operator commands. MCP stdio servers are normally launched by MCP clients, so the root CLI help and setup docs were advertising a service/protocol mode as if it were an interactive archive command.

Solution

  • Added polylogue-mcp = polylogue.mcp.cli:main to project scripts.
  • Moved the Click entrypoint to polylogue/mcp/cli.py and kept --role read|write|admin.
  • Removed polylogue mcp from root command registration and CLI exports.
  • Updated README and MCP setup docs to use polylogue-mcp --role read.
  • Regenerated CLI reference, topology, verification catalog, quality docs, showcase baselines, and terminal snapshots.
  • Updated CLI/MCP tests and the CLI command-surface witness.

Verification

  • pytest -q tests/unit/mcp/test_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_cli_error_boundaries.py tests/unit/cli/test_operator_support_runtime.py tests/unit/cli/test_terminal_snapshots.py tests/unit/proof/test_witnesses.py -> 116 passed
  • devtools render-all --check
  • devtools verify-topology
  • devtools verify-layering
  • devtools verify-test-ownership
  • mypy polylogue/
  • devtools verify --quick -> all checks passed
  • git push -u origin feature/refactor/mcp-entrypoint -> pre-push devtools verify --quick all checks passed

Ref #635
Ref #593

Problem: the interactive Polylogue CLI exposed MCP as a root subcommand even though MCP is a protocol adapter launched by clients, not a query-first archive verb. That polluted root help and kept MCP setup examples tied to polylogue mcp.\n\nWhat changed: remove the root polylogue mcp command, add the standalone polylogue-mcp console script, move the click entrypoint into polylogue.mcp.cli, update MCP setup docs and README examples, and regenerate CLI/topology/verification/showcase surfaces. The MCP server internals and role-gated tool registration are unchanged.\n\nVerification: pytest -q tests/unit/mcp/test_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_cli_error_boundaries.py tests/unit/cli/test_operator_support_runtime.py tests/unit/cli/test_terminal_snapshots.py tests/unit/proof/test_witnesses.py; devtools render-all --check; devtools verify-topology; devtools verify-layering; devtools verify-test-ownership; mypy polylogue/; devtools verify --quick.\n\nRef #635\nRef #593
Copilot AI review requested due to automatic review settings May 1, 2026 23:43
@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Polylogue Proof Pack

Refs: origin/master..HEAD
Changed paths: 20

Affected Domains

  • architecture_discipline — 2 claim(s), maturity growing
  • distribution — 0 claim(s), maturity seed
  • docs_media — 0 claim(s), maturity seed
  • spec_completeness — 1 claim(s), maturity seed
  • test_quality — 0 claim(s), maturity growing
  • unclassified — 4 claim(s), maturity seed

Required Gates

  • devtools render-all --check — generated surface or renderer changed
  • devtools verify-manifests — structural manifest changed
  • devtools affected-obligations --path docs/plans/topology-target.yaml — refresh structural obligation routing
  • devtools verify-topology — topology projection changed
  • pytest tests/unit/cli — CLI command surface changed
  • pytest tests/unit/proof/test_evidence_runners.py — CLI proof runners exercise command output
  • devtools render-cli-reference --check — CLI reference is generated from command help
  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit
  • devtools build-package — deployment readiness gate; run when packaging or release confidence matters
  • nix flake check — deployment readiness gate; run when packaging or release confidence matters

Known Gaps

  • distribution: dev_install: Not verified in CI; devshell is canonical environment [owner: distribution; next: Add package/build or cross-artifact CI gate], distribution: No scenario for install/package verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], install_parity: No cross-artifact equivalence verification (wheel vs sdist vs Nix) [owner: distribution; next: Add package/build or cross-artifact CI gate], macos: No macOS CI runner [owner: distribution; next: Add package/build or cross-artifact CI gate], sdist: Not built or tested in CI [owner: distribution; next: Add package/build or cross-artifact CI gate], wheel: Not built or tested in CI [owner: distribution; next: Add package/build or cross-artifact CI gate], windows: No Windows CI runner [owner: distribution; next: Add package/build or cross-artifact CI gate]
  • docs_media: docs_media: No scenario for documentation freshness verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], docs_media: README examples and media are not yet generated from executable scenario projections. [owner: docs-media; next: Add executable scenario projection or media integrity gate], docs_media: Screenshots and VHS media have no committed nonblank/readability verification. [owner: docs-media; next: Add executable scenario projection or media integrity gate]
  • test_quality: direct_coverage: Coverage per-module not tracked (only aggregate fail_under) [owner: test-quality; next: Add measurable quality gate for this dimension], flakiness: No systematic flakiness tracking, CI retry, or quarantine [owner: test-quality; next: Add measurable quality gate for this dimension], fuzz: Atheris fuzz targets not run in CI [owner: test-quality; next: Add measurable quality gate for this dimension], mock_depth: Mock depth not measured or enforced [owner: test-quality; next: Add measurable quality gate for this dimension]

Oracle / Cost

  • oracle mix: {"construction_sanity": 187, "drift_check": 2}
  • cost tier: {"static": 184, "unit": 5}
  • stale evidence: 189
  • manual review cells: 0

@Sinity
Sinity merged commit 92f1fc9 into master May 1, 2026
15 checks passed
@Sinity
Sinity deleted the feature/refactor/mcp-entrypoint branch May 1, 2026 23:44
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 3 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1ad03ad-49b5-43e9-96e6-3f82c2be4ca8

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc3647 and 4ae6d8e.

📒 Files selected for processing (20)
  • README.md
  • devtools/render_cli_reference.py
  • docs/cli-reference.md
  • docs/mcp-integration.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/verification-catalog.md
  • polylogue/cli/click_app.py
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/commands/mcp.py
  • polylogue/mcp/cli.py
  • pyproject.toml
  • tests/baselines/showcase/help-main.txt
  • tests/baselines/showcase/help-mcp.txt
  • tests/data/witnesses/cli-command-surface.json
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_cli_error_boundaries.py
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_operator_support_runtime.py
  • tests/unit/mcp/test_cli.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/mcp-entrypoint

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 9 minutes and 3 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors the MCP (Model Context Protocol) server launch surface out of the interactive polylogue CLI into a standalone polylogue-mcp console script, and updates tests/docs/generated references accordingly.

Changes:

  • Add polylogue-mcp = polylogue.mcp.cli:main console script and implement standalone Click entrypoint.
  • Remove polylogue mcp subcommand from root CLI registration and update CLI tests/snapshots/witnesses.
  • Update MCP integration docs/README and regenerate CLI reference + verification/topology artifacts.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pyproject.toml Declares new polylogue-mcp console script.
polylogue/mcp/cli.py New standalone Click entrypoint for starting MCP stdio server.
polylogue/cli/commands/mcp.py Removes old polylogue mcp subcommand implementation.
polylogue/cli/click_command_registration.py Stops registering MCP as a root subcommand.
polylogue/cli/click_app.py Updates CLI docstring/exports to reflect MCP removal.
tests/unit/mcp/test_cli.py Adds unit tests for polylogue.mcp.cli:main and script declaration.
tests/unit/cli/test_operator_support_runtime.py Removes tests tied to the old polylogue mcp command.
tests/unit/cli/test_click_app.py Updates help/subcommand registration expectations after MCP removal.
tests/unit/cli/test_cli_error_boundaries.py Removes MCP-specific error-boundary test now that MCP isn’t a subcommand.
tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr Updates CLI help snapshots to omit MCP command.
tests/data/witnesses/cli-command-surface.json Updates command-surface witness; requires polylogue-mcp script.
tests/baselines/showcase/help-mcp.txt Removes baseline for deleted polylogue mcp help output.
tests/baselines/showcase/help-main.txt Updates main help baseline to omit MCP command.
docs/mcp-integration.md Updates setup instructions to use polylogue-mcp --role read.
docs/cli-reference.md Removes MCP section from polylogue CLI reference.
devtools/render_cli_reference.py Stops rendering MCP section in CLI reference generator.
docs/verification-catalog.md Regenerated verification catalog counts/command list after MCP removal.
docs/test-quality-workflows.md Regenerated scenario projection registry; removes help-mcp exercise.
docs/plans/topology-target.yaml Regenerated topology targets; removes MCP command file, adds polylogue/mcp/cli.py.
README.md Updates usage examples to launch MCP via polylogue-mcp.

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

Comment thread polylogue/mcp/cli.py
Comment on lines +22 to +31
try:
from polylogue.mcp.server import serve_stdio
except ImportError as exc:
click.echo(f"MCP dependencies not installed: {exc}", err=True)
click.echo(
"Install the base polylogue package in an environment that includes its runtime dependencies.", err=True
)
raise SystemExit(1) from None

serve_stdio(role=cast(MCPRole, role))
Comment on lines +33 to +48
def test_polylogue_mcp_handles_missing_dependency() -> None:
runner = CliRunner()
real_import = __import__

def raise_mcp_import_error(name: str, *args: Any, **kwargs: Any) -> object:
if name == "polylogue.mcp.server":
raise ImportError("No module named 'mcp'")
return real_import(name, *args, **kwargs)

with patch("builtins.__import__", side_effect=raise_mcp_import_error):
result = runner.invoke(main, [])

assert result.exit_code == 1
assert "MCP dependencies not installed" in result.stderr
assert "Install the base polylogue package" in result.stderr

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ae6d8eef6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sinity added a commit that referenced this pull request May 7, 2026
Summary
Move MCP out of the interactive query-first CLI and expose it as the standalone `polylogue-mcp` console script.

Problem
`polylogue mcp` put a protocol adapter beside query verbs and archive/operator commands. MCP stdio servers are normally launched by MCP clients, so the root CLI help and setup docs were advertising a service/protocol mode as if it were an interactive archive command.

Solution
- Added `polylogue-mcp = polylogue.mcp.cli:main` to project scripts.
- Moved the Click entrypoint to `polylogue/mcp/cli.py` and kept `--role read|write|admin`.
- Removed `polylogue mcp` from root command registration and CLI exports.
- Updated README and MCP setup docs to use `polylogue-mcp --role read`.
- Regenerated CLI reference, topology, verification catalog, quality docs, showcase baselines, and terminal snapshots.
- Updated CLI/MCP tests and the CLI command-surface witness.

Verification
- `pytest -q tests/unit/mcp/test_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_cli_error_boundaries.py tests/unit/cli/test_operator_support_runtime.py tests/unit/cli/test_terminal_snapshots.py tests/unit/proof/test_witnesses.py` -> 116 passed
- `devtools render-all --check`
- `devtools verify-topology`
- `devtools verify-layering`
- `devtools verify-test-ownership`
- `mypy polylogue/`
- `devtools verify --quick` -> all checks passed
- `git push -u origin feature/refactor/mcp-entrypoint` -> pre-push `devtools verify --quick` all checks passed
- CI: auto-merge waits for all required checks.

Ref #635
Ref #593
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 61.F007 / P2: fixed-already at the checked revision: polylogue/cli/query_group.py:380 rejects an unknown plain-word root before query execution. The removed polylogue mcp spelling therefore produces the missing-command guidance rather than a silent archive search.

Only the rows listed above are dispositioned. Held findings remain open.

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