Commit Graph

545 Commits

Author SHA1 Message Date
Peter Steinberger
a02dda1b44
fix: handle auth status codes from error metadata (#94) (thanks @KentonYu) 2026-03-28 19:20:55 +00:00
yukaibo.me
049f3b7d6b
fix: detect auth errors from error.code property (StreamableHTTPError/SseError)
MCP SDK's StreamableHTTPError/SseError store the HTTP status code in
error.code, but the message text may not contain the numeric status.
analyzeConnectionError now reads error.code (100-599) before falling
back to message-text parsing, so OAuth promotion triggers correctly
for 401 responses on Streamable HTTP transport.
2026-03-28 19:17:48 +00:00
Peter Steinberger
8af1a77c45
chore: bump version to 0.8.0 2026-03-28 19:03:19 +00:00
Peter Steinberger
74dd794645 fix: stabilize generated config schema + oauthScope coverage (#43) (thanks @aryasaatvik) 2026-03-03 01:07:35 +00:00
Saatvik Arya
1dc2e70061 feat: add JSON Schema generation for config files
- Add .describe() to Zod schemas for rich documentation
- Create generate-json-schema.ts using Zod v4's toJSONSchema()
- Add generate:schema npm script
- Generate mcporter.schema.json at repo root
- Document $schema usage in docs/config.md
2026-03-03 01:07:35 +00:00
Peter Steinberger
a272e00784 refactor(config): split path discovery and config reading 2026-03-03 00:37:42 +00:00
Peter Steinberger
41b0cbcc9c refactor(daemon): extract host support utilities 2026-03-03 00:37:40 +00:00
Peter Steinberger
507bb6de95 refactor(cli): split call argument parsing helpers 2026-03-03 00:37:38 +00:00
Peter Steinberger
0c3e8233de refactor(cli): extract auth/help and template help modules 2026-03-03 00:37:36 +00:00
Peter Steinberger
7270f1f7b9 fix: finalize jsonc config support coverage (#42) (thanks @aryasaatvik) 2026-03-03 00:26:13 +00:00
Saatvik Arya
16a09ae048 fix: support JSONC in config files
Use the existing parseJsonBuffer helper (which leverages jsonc-parser)
instead of JSON.parse() when reading config files. This enables:

- Single-line comments (//)
- Multi-line comments (/* */)
- Trailing commas

The jsonc-parser dependency was already present but wasn't being used
for the main config file parsing.
2026-03-03 00:26:13 +00:00
Peter Steinberger
83db4fb1ec fix: add oauth retry regression coverage (#48) (thanks @caseyg) 2026-03-03 00:02:21 +00:00
Casey Gollan
e1fdd99b23 Discover OAuth scopes from protected resource metadata
Instead of hardcoding scope 'mcp:tools' during dynamic client
registration, fetch /.well-known/oauth-protected-resource from the
server to discover its supported scopes. This fixes InvalidScopeError
when connecting to servers like Todoist that only accept their own
scopes (e.g. 'data:read_write').

Also includes the fix from #38: remove the ad-hoc source restriction
in maybeEnableOAuth() so config-file servers can be promoted to OAuth.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-03 00:02:21 +00:00
Casey Gollan
67785b95eb Fix 405 misclassified as auth error in error-classifier
HTTP 405 (Method Not Allowed) was included in AUTH_STATUSES, causing it
to be treated as an authentication error. This leads to premature OAuth
session cleanup when StreamableHTTP returns 405, leaving the SSE
fallback without credentials. Remove 405 from AUTH_STATUSES so transport
errors are classified correctly.

Fixes #47

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-03 00:02:21 +00:00
Peter Steinberger
af2f60eecf refactor: streamline call parsing/output pipeline 2026-03-02 22:58:07 +00:00
Peter Steinberger
7ff297ef2e fix: make image handling opt-in and preserve output contracts (#61) (thanks @daniella-11ways) 2026-03-02 22:38:01 +00:00
root
11bbd67969 feat: add image content block support
- Add ImageContent interface and images() method to CallResult
- Extract type: 'image' content blocks from MCP responses
- Save images to files in auto/image output modes
- Include images in JSON output when present
- Print images alongside text/markdown content

Fixes issue where MCP servers returning image content blocks
(e.g., photos_get_images) had their image data silently dropped.
2026-03-02 22:38:01 +00:00
Peter Steinberger
8988adda77 docs: document call coercion flags 2026-03-02 21:48:42 +00:00
Peter Steinberger
cb179c903d fix: align --raw-strings and --no-coerce semantics (#59) (thanks @nobrainer-tech) 2026-03-02 21:37:25 +00:00
nobrainer-tech
079b217f63 Add --raw-strings flag to prevent numeric string coercion
Values like phone numbers, PINs, or codes with leading zeros (e.g. 000123)
are auto-coerced to numbers by default. The --raw-strings flag (or --no-coerce
alias) preserves them as strings.

Note: Cannot use --raw as the flag name because it conflicts with the
existing --raw output format shortcut in output-format.ts.

Fixes: numeric strings being silently converted to numbers
2026-03-02 21:35:45 +00:00
Peter Steinberger
30abe3d9a5 fix: stabilize oauth wait/redirect deferred lifecycle (#70) (thanks @monotykamary) 2026-03-02 20:02:11 +00:00
Tom X Nguyen
5edc213a9e fix(oauth): prevent race condition in authorization code wait
Ensure waitForAuthorizationCode uses the same deferred created by redirectToAuthorization instead of creating a new one. If waitForAuthorizationCode is called before redirectToAuthorization has been invoked, it now waits for the redirect to be initiated before proceeding. This fixes the race condition where the OAuth callback could resolve a different promise than what the runtime was waiting on, causing authentication to fail with a timeout.

Fixes #36
2026-03-02 20:02:11 +00:00
Peter Steinberger
cb06392738 fix: harden raw output inspect depth and add regression coverage (#91) (thanks @Blankdlh) 2026-03-02 19:17:29 +00:00
Blankdlh
9746dab9d2 fix: collect all JSON entries from MCP content arrays instead of only the first
Previously json() in createCallResult returned early on the first
parseable JSON entry. When an MCP server returned multiple results
in the content array, only the first item was ever surfaced.

Now all parseable entries are collected. A single item still returns
as a single object (backward compatible); multiple items return as
an array.

Also increased inspect depth in printRaw from 2 to null to prevent
truncation of deeply nested list results.
2026-03-02 19:17:29 +00:00
Peter Steinberger
98c300b3dc fix: harden oauth headless flow + add scope override/tests (#72) (thanks @mgonto) 2026-03-02 18:32:55 +00:00
Martin Gontovnikas
b908c4bbe3 fix: close callback server on persistence errors during stale-client check
Address review feedback: wrap the redirect URI mismatch check in
try/catch so that if readClientInfo() or clear() throws (malformed
cache JSON, filesystem permissions), the already-bound HTTP callback
server is closed before rethrowing. Prevents the process from hanging
with an open listener in failure paths.
2026-03-02 18:32:55 +00:00
Martin Gontovnikas
31142e03a6 fix(oauth): three fixes for headless servers and non-standard OAuth providers
1. Remove hardcoded scope='mcp:tools' from client metadata.
   Providers like Granola reject this scope at the authorize endpoint
   (invalid_scope). Let the MCP SDK derive scope from server metadata
   instead, falling back to the auth server's scopes_supported.

2. Swallow xdg-open ENOENT on headless Linux servers.
   On VPS/CI environments without a desktop, spawning xdg-open throws
   an unhandled error event that crashes the process before the OAuth
   callback server can receive the redirect.

3. Clear stale client registration when dynamic callback port changes.
   With dynamic ports (the default), each run picks a different port.
   If a previous client registration is cached with a different
   redirect_uri, the auth server rejects subsequent requests with
   invalid_redirect_uri. Now detects the mismatch and re-registers.

Fixes #67
2026-03-02 18:32:55 +00:00
Peter Steinberger
938c09cf0f chore(deps): update dependencies to latest 2026-03-02 17:39:57 +00:00
Peter Steinberger
8cc23a2388 chore: update copyright year to 2026 2026-01-01 14:22:48 +01:00
Peter Steinberger
d55b813c4f fix: preserve config imports defaults 2025-12-30 01:25:04 +01:00
Peter Steinberger
6b9fa78bdb chore: start 0.7.4 2025-12-30 00:48:30 +01:00
Peter Steinberger
e18af40078 docs: add front matter to live tests 2025-12-30 00:09:03 +01:00
Peter Steinberger
3c092e7a0f docs: finalize 0.7.3 release notes 2025-12-30 00:08:27 +01:00
Peter Steinberger
103aa63cfd docs: clarify release definition 2025-12-29 23:56:46 +01:00
Peter Steinberger
9b216b9820 test(windows): run pnpm via cmd.exe 2025-12-29 23:38:06 +01:00
Peter Steinberger
3f654d1ae9 test(windows): use pnpm.cmd in integration builds 2025-12-29 23:30:07 +01:00
Peter Steinberger
522276c599 test: rename bun cli e2e 2025-12-29 23:22:00 +01:00
Peter Steinberger
4a6f25478f test(oauth): isolate callback state persistence 2025-12-29 23:16:14 +01:00
Peter Steinberger
08128fe3b6 test: avoid generate-cli timeouts under coverage 2025-12-29 23:14:28 +01:00
Peter Steinberger
ea85104bb0 style: format ban cli test 2025-12-29 23:12:34 +01:00
Peter Steinberger
cabe3f47d6 chore: set version to 0.7.3 2025-12-29 23:11:07 +01:00
Peter Steinberger
78d7631d3f test: add ban CLI end-to-end 2025-12-29 23:11:07 +01:00
Peter Steinberger
2670b59e91 chore(deps): update lockfile 2025-12-29 23:11:07 +01:00
Peter Steinberger
4cc11329f7 chore: add vitest coverage 2025-12-29 23:07:02 +01:00
Peter Steinberger
53eedf8f29 test: increase generate-cli integration timeout 2025-12-29 23:06:53 +01:00
Peter Steinberger
91386bbc67 feat(generate-cli): filter tools in generated CLIs
Co-authored-by: Zack Leman <6403966+zackleman@users.noreply.github.com>
2025-12-29 21:23:46 +01:00
Peter Steinberger
523b6f377a docs: credit contributors 2025-12-29 21:00:45 +01:00
Peter Steinberger
eca5af9a09
Merge pull request #27 from rawwerks/fix/array-item-type-coercion
fix: coerce array elements to proper types based on JSON schema
2025-12-29 20:48:22 +01:00
Peter Steinberger
ecfbaee7f9 fix: coerce array option items 2025-12-29 20:47:04 +01:00
Raymond Weitekamp
d2f0de130b fix: coerce array elements to proper types based on schema
When parsing CLI array arguments like `--corner1 0,0`, the values were
being split by comma but kept as strings. This caused JSON schema
validation to fail when the schema specified number arrays.

Changes:
- Add `arrayItemType` field to `GeneratedOption` interface
- Add `inferArrayItemType()` function to extract item type from schema
- Update `optionParser()` to coerce array elements based on item type:
  - number arrays: parseFloat each element
  - boolean arrays: compare against 'false'
  - string arrays: trim whitespace (existing behavior)

Fixes issues with MCP tools that have array<number> parameters like
Onshape's `create_sketch_rectangle` which expects corner coordinates.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 20:45:51 +01:00