Commit Graph

559 Commits

Author SHA1 Message Date
Peter Steinberger
b8b90f221f
fix: improve generated CLI object parsing (#114) (thanks @v2nic) 2026-03-28 21:17:01 +00:00
Nicolas Marchildon
855446ca39
fix: parse object-type parameters as JSON in generated CLIs
When an MCP tool schema declares a parameter with type 'object' (e.g.
Atlassian's editJiraIssue fields parameter), the generated CLI previously
passed the value as a raw string, causing MCP validation errors.

Root cause: inferType() didn't recognize 'object' as a valid type, so it
returned 'unknown'. optionParser() had no case for 'object', so no
JSON.parse was generated for the Commander option.

Changes:
- Add 'object' to GeneratedOption type union in tools.ts
- Add 'object' to resolveType whitelist in inferType()
- Add 'case object' returning JSON.parse in optionParser()

Fixes #113
2026-03-28 21:09:35 +00:00
Peter Steinberger
b49af49402
fix: trim managed runtime spillover from #125 2026-03-28 21:08:07 +00:00
Lil Z
8c66f1c49a
fix: add managed runtime and dedupe keep-alive restarts (#125)
* fix: add managed runtime and dedupe keep-alive restarts

* test: cover cli managed runtime wiring
2026-03-28 21:05:31 +00:00
Peter Dedene
586c57d11b fix(daemon): skip Bun virtual entry path in detached child spawn
In Bun compiled binaries, process.argv[1] is a virtual /$bunfs/...
path that Bun auto-injects into every spawned child process. The
daemon launcher was including this path explicitly in the spawn args,
causing it to appear twice in the child's argv. The child then parsed
the duplicate path as the CLI command instead of "daemon", silently
failing to start.

Detect the /$bunfs/ prefix and omit the entry from spawn args, letting
Bun handle it automatically.
2026-03-28 20:59:33 +00:00
Peter Steinberger
41e049ddc0
refactor: simplify oauth transport flow 2026-03-28 20:01:24 +00:00
Peter Steinberger
72e3a16f0a fix: preserve oauth failure context (#97) (thanks @mavam) 2026-03-28 19:48:14 +00:00
Matthias Vallentin
a61c0475f8 fix(oauth): preserve auth failure context
Track OAuth flow failures separately from post-auth reconnect
failures so Streamable HTTP can still fall back to legacy SSE
on real 404/405 transport mismatches without masking terminal
provider errors.

Also recreate transports after finishAuth and add regression
coverage for generic 401 promotions, OAuth flow failures, and
post-auth retry paths.
2026-03-28 19:48:14 +00:00
Peter Steinberger
914e03f89c fix: keep json output valid on raw fallback (#128) (thanks @armanddp) 2026-03-28 19:41:21 +00:00
Peter Steinberger
e77b22378b fix: prefer oauth auth headers over static overrides (#123) (thanks @ahonn) 2026-03-28 19:36:22 +00:00
ahonn
6d7c54646a fix: strip static Authorization header when OAuth is active
When mcporter imports server definitions from external clients that
include static Authorization headers, these override the OAuth access
token in the SDK, causing 401 retry storms.

Fixes #121
2026-03-28 19:36:22 +00:00
Peter Steinberger
666fec0fa6 fix: preserve full structured payloads (#106) (thanks @AielloChan) 2026-03-28 19:31:23 +00:00
奥尘
a04d663f03 fix(result-utils): avoid collapsing error payloads to data 2026-03-28 19:31:23 +00:00
Peter Steinberger
e7c6bef1a2 fix: render resource content blocks consistently (#124) (thanks @mvanhorn) 2026-03-28 19:27:25 +00:00
Matt Van Horn
2bd30c235c fix: handle resource content blocks in output rendering
Fixes #108

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 19:27:25 +00:00
yukaibo.me
cc06993494 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:21:23 +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