Skip to content

fix(mcp): handle invalid request payloads and hidden surface - #42

Merged
Coding-Dev-Tools merged 5 commits into
masterfrom
cowork/improve-click-to-mcp
Oct 3, 2026
Merged

Coding-Dev-Tools merged 5 commits into
masterfrom
cowork/improve-click-to-mcp

Conversation

@Coding-Dev-Tools

Copy link
Copy Markdown
Owner

Restores repository tree integrity, handles non-object payloads with -32600, excludes hidden options, and adds comprehensive tests.

Coding-Dev-Tools and others added 5 commits August 21, 2026 04:34
…f crashing

A JSON body that parses but is not an object ([1,2], "x", 5, null)
reached msg.get() outside the per-request try/except in all three
transports: the stdio server loop died with AttributeError and both
HTTP transports returned 500. Now stdio replies with a JSON-RPC
-32600 Invalid Request error and keeps serving; HTTP transports
return 400 with the same error. Adds regression tests for all three.
… adapter handler

- Boolean False on a flag pair (--x/--no-x) previously dropped the value
  silently, so the command ran with its default instead of the caller's
  explicit False. The handler now emits the negative flag.
- Options without a long name (e.g. short-only '-n') had an invented
  '--name' emitted, which Click rejects as unknown. The handler now uses
  each parameter's actual option string.
- Adds tests/test_flag_pairs.py covering both paths (4 tests).
… adapter handler

- Boolean False on a flag pair (--x/--no-x) previously dropped the value
  silently, so the command ran with its default instead of the caller's
  explicit False. The handler now emits the negative flag.
- Options without a long name (e.g. short-only '-n') had an invented
  '--name' emitted, which Click rejects as unknown. The handler now uses
  each parameter's actual option string.
- Adds tests/test_flag_pairs.py covering both paths (4 tests).
Hidden click surface is intentionally undocumented; exposing it as MCP tool
properties/commands leaks internal knobs to model callers. Skip hidden
commands (incl. nested groups), options and arguments during introspection.
+3 tests (7 pass, ruff clean).
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

🤖 Automated Code Review

✅ Ruff Lint — No issues

⚠️ Ruff Format — Formatting needed

unformatted: File would be reformatted
   --> README.md:220:1
    |
219 |
220 +
221 | @click.group()
--------------------------------------------------------------------------------
225 |
226 +
227 | @my_cli.command()
--------------------------------------------------------------------------------
236 |
237 +
238 | if __name__ == "__main__":
--------------------------------------------------------------------------------
276 |
277 +
278 | @click.group()
--------------------------------------------------------------------------------
282 |
283 +
284 | @cli.command()
--------------------------------------------------------------------------------
290 |
291 +
292 | # Run as MCP server
--------------------------------------------------------------------------------
377 |
378 +
379 | @app.command()

✅ Secret Detection — Clean

✅ Large Files — Within limits

📊 Diff Stats — 4 file(s) changed

 click_to_mcp/http_server.py            |   8 +++
 click_to_mcp/server.py                 |  11 ++++
 click_to_mcp/streamable_http.py        |   7 +++
 tests/test_invalid_request_payloads.py | 100 +++++++++++++++++++++++++++++++++
 4 files changed, 126 insertions(+)

Verdict: ⚠️ Warnings — Lint/format issues found. Recommend fixing before merge.

Automated by Coding-Dev-Tools/.github reusable workflow.

@Coding-Dev-Tools
Coding-Dev-Tools merged commit ff7058c into master Oct 3, 2026
9 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