Skip to content

Improve connect reliability, error messages, and AI agent UX#144

Merged
jancurn merged 8 commits intomainfrom
claude/review-mcpc-improvements-Qmdww
Apr 7, 2026
Merged

Improve connect reliability, error messages, and AI agent UX#144
jancurn merged 8 commits intomainfrom
claude/review-mcpc-improvements-Qmdww

Conversation

@jancurn
Copy link
Copy Markdown
Member

@jancurn jancurn commented Apr 7, 2026

Summary

Addresses 5 of 8 improvement suggestions from the mcpc benchmark sessions (36 errors across 9 sessions). The remaining 3 were already fixed (#4), not applicable (#7), or low-value (#8).

P0: Connect health check + better error messages (#1, #2)

  • connect now verifies the server responds before printing success. Previously it printed ✓ Session created before the health check, so agents spent 14+ calls debugging connections that never worked. Now shows a warning with the actual error when the server is unreachable.
  • HTTP 404 no longer misclassified as "session expired" during initial connect. isSessionExpiredError is now context-aware — bare 404 is only treated as session expiration when an MCP session ID was active. During initial connect, 404 correctly indicates a wrong URL.
  • enrichErrorMessage helper maps common errors (404, redirect, ECONNREFUSED, DNS, timeout, TLS) to actionable messages with the server URL.

P1: "Did you mean?" suggestions (#3)

  • Unknown commands now suggest the closest match using Levenshtein distance.
  • Detects reversed hyphenated names: list-toolstools-list, get-resourcesresources-get.
  • Works in both the main CLI and the interactive shell.

P1: Output truncation (#5)

  • New --max-output <chars> global option truncates large tool/prompt/resource output with a notice showing total size.
  • Prevents AI agents from hitting token limits on 45KB+ responses.

P3: Inline tool help (#6)

  • tools-call <tool> --help now shows the tool's parameter schema (equivalent to tools-get).
  • Works in both CLI and interactive shell, saving a discovery call per session.

Test plan

  • Unit tests for isSessionExpiredError with hadActiveSession context (36 tests)
  • Unit tests for enrichErrorMessage and isHttpRedirectError
  • Unit tests for suggestCommand with reversed names, typos, case insensitivity (75 parser tests)
  • Unit tests for truncateOutput
  • All 468 tests pass, lint clean, build clean

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L

claude added 8 commits April 7, 2026 21:33
- Move success message after health check so `connect` only reports
  success when the server actually responds. Show a warning with the
  actual error when the server is unreachable.
- Make `isSessionExpiredError` context-aware: bare HTTP 404 is only
  treated as session expiration when an MCP session was active. During
  initial connect a 404 now correctly indicates a wrong URL.
- Add `enrichErrorMessage` helper that maps common HTTP/network errors
  (404, redirect, ECONNREFUSED, DNS, timeout, TLS) to actionable
  messages with the server URL.
- Add `isHttpRedirectError` helper for redirect detection.
- Update bridge and bridge-manager callers to pass session context.
- Add unit tests for all new and updated helpers.

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
When an unknown command is entered (e.g., 'list-tools'), suggest the
closest valid command. Uses Levenshtein distance for typos and detects
reversed hyphenated names (e.g., 'list-tools' → 'tools-list').

Works in both the main CLI and the interactive shell.

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
When tool calls, prompt results, or resource reads return very large
responses, AI agents hit token limits and can't read the full output.

Add --max-output <chars> global option that truncates formatted output
to the specified character count, with a notice showing total size and
how to adjust the limit.

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
Intercept --help on tools-call to display the tool's parameter schema
(equivalent to tools-get). Works in both the main CLI and interactive
shell. Saves an extra discovery call when exploring tool parameters.

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
Resolve merge conflicts with main (f05538e):
- CHANGELOG.md: combine both branches' [Unreleased] entries
- tools.ts imports: include both formatToolCallExample (main) and
  truncateOutput (ours)
- index.ts tools-call: keep helpOption(false) from our branch with
  main's updated descriptions and addHelpText; handle edge case
  where name is '--help' by showing Commander help

Also rename --max-output to --max-chars for clarity (the flag
truncates by character count, not bytes).

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
The CI build failed because maxChars was added to CommandOptions but
not to the separate HandlerOptions interface in index.ts, which is
what getOptionsFromCommand returns.

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
The readme-help test compares mcpc --help output against the README.
Adding --max-chars changed the help output, so the README code block
needs updating to match.

https://claude.ai/code/session_011PpTVfJKv47kZEvNajk46L
@jancurn
Copy link
Copy Markdown
Member Author

jancurn commented Apr 7, 2026

Thanks @vystrcild for the suggestions

@jancurn jancurn merged commit 86aefbd into main Apr 7, 2026
10 of 11 checks passed
@jancurn jancurn deleted the claude/review-mcpc-improvements-Qmdww branch April 7, 2026 22:41
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.

3 participants