Skip to content

fix(cli): reject non-GitHub origins during deploy - #2687

Merged
khandrew1 merged 1 commit into
mcp-use:canaryfrom
quifox:fix/typescript/github-deploy-origin
Oct 7, 2026
Merged

khandrew1 merged 1 commit into
mcp-use:canaryfrom
quifox:fix/typescript/github-deploy-origin

Conversation

@quifox

@quifox quifox commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Description

Where did you find this issue?

Found while reviewing the GitHub deployment path in the CLI, then reproduced with the existing deploy test harness.

parseGitHubRepository() matched github.com anywhere near the end of the remote string instead of validating the remote host. For example:

https://git.example.com/mirror/github.com/acme/service.git

was parsed as acme/service.

I also reproduced the downstream effect: when the mocked GitHub App has access to acme/service, mcp-use deploy proceeds to create a GitHub-backed server with repoFullName: "acme/service", even though the local origin is hosted on git.example.com.

I did not find an existing issue or PR covering this case.

Language / Project Scope

  • TypeScript
  • Python
  • Documentation only
  • CI/CD or tooling

Changes

  • Parse URL-style remotes and require the hostname to be exactly github.com.
  • Handle Git's SCP-style remotes such as [email protected]:owner/repo.git separately with an anchored, case-insensitive pattern.
  • Reject non-GitHub hosts that only contain github.com in the hostname or path before any Cloud API request is made.
  • Preserve HTTP(S), SSH, Git, and SCP-style GitHub remote syntax and case-insensitive GitHub hostnames.
  • Reject unsupported URL protocols, malformed separators, and paths whose original shape is not owner/repo; do not rely on URL normalization to repair the remote.
  • Add a patch changeset for @mcp-use/cli.

Implementation Details

  1. URL-style remotes use the platform URL parser so host identity is checked structurally instead of by substring.
  2. SCP-style Git remotes remain supported through a dedicated anchored matcher because they are not valid WHATWG URLs.
  3. Validate the original URL authority/path syntax before normalization, then share the owner/repo(.git) shape check with SCP-style remotes. Dot path segments are rejected.
  4. No dependencies were added.

TypeScript Checklist

Packages Modified

  • docs
  • tests
  • cli
  • create-mcp-use-app
  • mcp-use (server)
  • mcp-use (client)
  • inspector

Pre-commit Checklist

  • Lint passes (pnpm lint)
  • Formatting passes (pnpm format:check)
  • Ran pnpm build and build succeeds
  • Added a patch changeset for @mcp-use/cli
  • Added regression tests
  • Documentation update not required

Example Usage (Before)

git remote set-url origin https://git.example.com/mirror/github.com/acme/service.git
mcp-use deploy

The remote could be interpreted as the GitHub repository acme/service. If the connected GitHub App could access that repository, deployment could proceed against that unrelated GitHub source.

Example Usage (After)

git remote set-url origin https://git.example.com/mirror/github.com/acme/service.git
mcp-use deploy
# unsupported_remote

Normal GitHub remotes such as these remain supported:

https://github.com/acme/service.git
[email protected]:acme/service.git

Documentation Updates

No documentation changes are required; this corrects validation of the existing GitHub deploy behavior.

Testing

Tested on Linux with Node.js 24.19.0 and pnpm 11.13.1, against main.

  • pnpm install --frozen-lockfile: passed.
  • pnpm build: passed.
  • pnpm --filter @mcp-use/cli typecheck: passed.
  • pnpm --filter @mcp-use/cli test: 3 proxy/bin tests and 352 Vitest tests across 24 files passed.
  • pnpm --filter @mcp-use/cli exec vitest run tests/commands/deploy.test.ts: 54 passed.
  • pnpm format:check, pnpm lint, and git diff --check: passed.

With the same deploy tests on unmodified main, 16 fail and 38 pass. The fixed code passes all 54. Git remotes are created locally and Cloud API calls are mocked; rejected origins must not make an API request.

Regression coverage includes lookalike hosts, github.com in a non-GitHub path, unsupported protocols, malformed URL separators, original path shapes and dot segments, explicit ports including default ports, query strings/fragments, case-insensitive hosts, and supported URL/SCP-style remotes.

Backwards Compatibility

Explicit HTTP(S), SSH, Git, and SCP-style remotes with a GitHub host and an original owner/repo(.git) path remain recognized. Lookalike hosts, local/path-like strings, and dot path segments are rejected. URL-style remotes additionally require explicit HTTP(S)/SSH/Git syntax without repaired separators, extra path segments, explicit ports, query strings, or fragments. Rejections use unsupported_remote before a Cloud API call.

Related Issues

None.

Branch Update

Rebased the fix onto main and retargeted this PR to main as requested. The PR contains one commit limited to the CLI implementation, its regression tests, and the patch changeset.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@khandrew1 khandrew1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@quifox please rebase and retarget this PR on main. Open all your future PRs targeted against main, i change them to canary manually.

@quifox
quifox force-pushed the fix/typescript/github-deploy-origin branch from 3af329a to 6ca2e45 Compare October 2, 2026 05:46
@quifox
quifox changed the base branch from canary to main October 2, 2026 05:46
@quifox
quifox requested a review from khandrew1 October 2, 2026 08:53

@khandrew1 khandrew1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR!

@khandrew1
khandrew1 changed the base branch from main to canary October 7, 2026 22:05
@pkg-pr-new

pkg-pr-new Bot commented Oct 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@mcp-use/agent

npm i https://pkg.pr.new/@mcp-use/agent@2687

@mcp-use/cli

npm i https://pkg.pr.new/@mcp-use/cli@2687

@mcp-use/client

npm i https://pkg.pr.new/@mcp-use/client@2687

create-mcp-use-app

npm i https://pkg.pr.new/create-mcp-use-app@2687

@mcp-use/inspector

npm i https://pkg.pr.new/@mcp-use/inspector@2687

mcp-use

npm i https://pkg.pr.new/mcp-use@2687

@mcp-use/tunnel

npm i https://pkg.pr.new/@mcp-use/tunnel@2687

commit: 6ca2e45

@khandrew1
khandrew1 merged commit 45bc353 into mcp-use:canary Oct 7, 2026
33 of 36 checks passed
khandrew1 added a commit that referenced this pull request Oct 8, 2026
* fix(create-mcp-use-app): install dependencies on Windows (#2696)

* fix(create-mcp-use-app): install dependencies on Windows

npm and pnpm are .cmd shims on Windows, which spawn() only runs through a shell, so --install and the install prompt failed with "spawn npm ENOENT". On Windows, run the package manager through the shell as one command string, which also avoids Node's DEP0190 warning; other platforms keep the direct spawn. Move runPackageManager to utils.ts so it can be tested.

* test(create-mcp-use-app): cover a package manager that exits non-zero

Assert that the rejection carries the package manager's stderr, which the scaffolder prints when an install fails.

* chore: enter canary prerelease mode

* chore(typescript): version packages (canary)

* fix(server): avoid buffering SSE responses in request logging (#2789)

* chore(typescript): version packages (canary)

* fix(inspector): apply saved timeout settings to tool calls (#2656)

* fix(inspector): honor saved tool request timeouts

* fix(inspector): handle duplicate URLs and cleared timeouts

* fix(inspector): preserve cleared timeout settings

* fix(inspector): explain blank timeout settings

---------

Co-authored-by: Andrew Khadder <[email protected]>

* chore(typescript): version packages (canary)

* fix(cli): use canonical deployment dashboard URLs (#2744)

* chore(typescript): version packages (canary)

* fix(cli): reject non-GitHub origins during deploy (#2687)

* chore(typescript): version packages (canary)

* fix(client): implement listTools and protocol metadata on CodeModeConnector (#2488)

* fix(client): implement listTools and protocol metadata on CodeModeConnector

* fix(client): propagate cancellation and honor abort signals in CodeModeConnector

* docs(client): add JSDoc for CodeModeConnector resource and prompt methods to satisfy TypeDoc

* refactor(client): remove redundant listAllPrompts from CodeModeConnector

* ci: re-trigger preview workflow

* chore(typescript): version packages (canary)

* docs(changelog): document v2.8.1 and inspector v20.3.17

---------

Co-authored-by: Freetrip <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Lucien <[email protected]>
Co-authored-by: quifox <[email protected]>
Co-authored-by: Rohith Reddy Nama <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants