Fix Windows MCP spawn/DNS issues; add remote file rename support - #1
Open
15312618259 wants to merge 1 commit into
Open
Fix Windows MCP spawn/DNS issues; add remote file rename support#115312618259 wants to merge 1 commit into
15312618259 wants to merge 1 commit into
Conversation
- mcp-server: resolve CLI JS entry via require.resolve instead of spawning the npm .cmd shim (fixes ENOENT on Windows) - mcp-server: launch CLI child processes with --dns-result-order=ipv4first (fixes HTTP 400 InvalidSessionKey 'check ip error' on dual-stack networks) - cli/remote: add renameRemoteFile via official open API renameFile.action - cli: new 'rename-file <id> <newName>' command with --json output - agent-safe: add 'rename-file' to DANGEROUS_COMMANDS - mcp-server: add guarded cloud189_rename_folder/_file/rm/mv tools (require confirm: true, preview via cloud189_plan)
Author
|
@CodeSentryAI Happy to adjust anything — all changes are tested on a real 4.29 TB account on Windows 10. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-# PR: Windows compatibility fixes + remote file rename support
Summary
This PR fixes two Windows-specific breakages and adds remote file rename support
(the upstream SDK only wraps
renameFolder). All changes are additive; no existingbehavior is altered except how the MCP server spawns the CLI child process.
1. Fix: MCP server fails with ENOENT on Windows
mcp-server.jsspawns the CLI viaexecFileSync('cloud189', ...). On Windows, npminstalls
cloud189as a.cmdshim, whichexecFileSynccannot resolve — every MCPtool call fails with
ENOENT.Fix (
packages/mcp/src/mcp-server.js): resolve the CLI's real JS entryvia
require.resolve('@codesentryai/cloud189/package.json')and run it withexecFileSync(process.execPath, [CLI_JS, ...]).2. Fix: HTTP 400
InvalidSessionKey - check ip erroron dual-stack networksTianyi Cloud (Cloud189) binds the sessionKey to the egress IP used at login. On
dual-stack (IPv4/IPv6) networks, Node may resolve the API host to an IPv6 address
while the login request went out over IPv4, so every subsequent API call returns
HTTP 400
InvalidSessionKey - check ip error.Fix (
packages/mcp/src/mcp-server.js): launch every CLI child processwith
--dns-result-order=ipv4first, so API requests use the same address family aslogin. This is enforced in the spawn args, not via env vars, so it cannot be lost.
3. Feature: rename remote files
The SDK only wraps folder rename. This PR adds file rename across all layers:
packages/cli/src/remote.js: newrenameRemoteFile(client, fileId, fileName)calling the official open API endpoint
POST {API_URL}/open/file/renameFile.actionwith form
{ destFileName, fileId }(API_URL fromcloud189-sdk/dist/const).packages/cli/src/cli.js: new CLI commandrename-file <remoteFileId> <newName>with
--jsonoutput support.packages/cli/src/agent-safe.js:rename-fileadded toDANGEROUS_COMMANDSso the existing agent-mode confirmation flow covers it.
4. MCP: four new destructive/rename tools (guarded)
packages/mcp/src/mcp-server.jsregisters:cloud189_rename_folder,cloud189_rename_file,cloud189_rm,cloud189_mv.All four require an explicit
confirm: trueargument; the newassertConfirmed()helper refuses execution otherwise and instructs the caller to preview with
cloud189_planfirst.Files changed
packages/cli/src/remote.jsrenameRemoteFile(), + exportpackages/cli/src/cli.jsrename-filecommandpackages/cli/src/agent-safe.jsrename-fileinDANGEROUS_COMMANDSpackages/mcp/src/mcp-server.jsTesting
Tested on Windows 11 (Git Bash + Node 22) against a real account:
login-qr→ QR login OK;status --jsonreports session valid (previouslyHTTP 400
InvalidSessionKeyon every call after login).status,roots,quota,list,searchall return JSON via thepatched server (previously ENOENT).
rename-file <id> <newName> --json→{ ok: true, fileId, newName }; renameverified in the web UI.
mkdir-safe→upload-safe→rename-file→mv→rename-folder→rm(cleanup) — all returnstatus 4(task success);MCP
rm/mvrefuse withoutconfirm: true.tree -11 --jsonon a 4.29 TB / ~175k-entry account completed in~32 minutes (no code change needed; noted for docs only).
Notes for reviewers
renameFile.actionendpoint is the official open API used by Tianyi Cloud'sown web client; no reverse-engineered private endpoint is involved.
NODE_OPTIONS=--dns-result-order=ipv4firstbut is pinned in spawn args so the MCP server works regardless of the host env.