-
Notifications
You must be signed in to change notification settings - Fork 0
Remote pc access #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote pc access #18
Changes from all commits
bc8140e
867b06e
fd1205d
5038880
2cfa55e
a8fd2fd
1d37312
e3b4ea8
5f88826
05064e6
8dca07d
0b983c0
e16ae80
d0a32eb
516101a
7f5ce4a
c1de78f
115d465
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| export { createDelegateTaskTool } from "./delegateTools.js"; | ||
| export { getFileSystemTools } from "./fileSystemTools.js"; | ||
| export { loadPrivateTools } from "./private-loader.js"; | ||
| export { getRemoteFileSystemTools } from "./remoteFileSystemTools.js"; | ||
| export { scheduleTools, setSchedulerDeps } from "./scheduleTools.js"; | ||
| export { execShellTool, shellTools } from "./shellTools.js"; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||
| /** | ||||||
| * Remote file system tools for SSH-based access to a remote machine | ||||||
| * Uses the same @modelcontextprotocol/server-filesystem via SSH stdio tunnel | ||||||
| * Tools are prefixed with "remote_" to avoid conflicts with local filesystem tools | ||||||
| */ | ||||||
|
|
||||||
| import { type McpConfig, McpToolset } from "@iqai/adk"; | ||||||
| import { getConfig, getRawConfig } from "../config/index.js"; | ||||||
|
|
||||||
| /** Prefix applied to all remote filesystem tool names to distinguish from local tools */ | ||||||
| const REMOTE_TOOL_PREFIX = "remote_"; | ||||||
|
|
||||||
| /** | ||||||
| * Get remote filesystem MCP tools via SSH tunnel | ||||||
| * Returns empty array when disabled — zero impact on existing functionality | ||||||
| */ | ||||||
| export async function getRemoteFileSystemTools() { | ||||||
| const rawConfig = getRawConfig(); | ||||||
| const remoteFsConfig = rawConfig.tools.remoteFileSystem; | ||||||
|
|
||||||
| if (!remoteFsConfig?.enabled) { | ||||||
| return []; | ||||||
| } | ||||||
|
|
||||||
| const mcpConfig: McpConfig = { | ||||||
| name: "Remote Filesystem MCP Client", | ||||||
| description: "Access to files on remote machine via SSH", | ||||||
| transport: { | ||||||
| mode: "stdio", | ||||||
| command: "ssh", | ||||||
| args: [ | ||||||
| "-o", | ||||||
| "StrictHostKeyChecking=accept-new", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||||||
| "-o", | ||||||
| "BatchMode=yes", | ||||||
| "-i", | ||||||
| remoteFsConfig.sshKeyPath, | ||||||
| "-p", | ||||||
| String(remoteFsConfig.sshPort), | ||||||
| remoteFsConfig.sshHost, | ||||||
| "npx", | ||||||
| "-y", | ||||||
| "@modelcontextprotocol/server-filesystem", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Executing
Suggested change
|
||||||
| ...remoteFsConfig.allowedPaths, | ||||||
| ], | ||||||
| env: { PATH: process.env.PATH || "" }, | ||||||
| }, | ||||||
| retryOptions: { maxRetries: 2, initialDelay: 500 }, | ||||||
| debug: getConfig().debug, | ||||||
| }; | ||||||
|
|
||||||
| if (getConfig().debug) { | ||||||
| console.log( | ||||||
| `[RemoteFileSystemTools] SSH tunnel to ${remoteFsConfig.sshHost}, paths: ${remoteFsConfig.allowedPaths.join(", ")}`, | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| const mcpToolset = new McpToolset(mcpConfig); | ||||||
| const tools = await mcpToolset.getTools(); | ||||||
|
|
||||||
| // Prefix tool names with "remote_" to avoid collisions with local filesystem tools | ||||||
| for (const tool of tools) { | ||||||
| tool.name = `${REMOTE_TOOL_PREFIX}${tool.name}`; | ||||||
| tool.description = `[Remote PC] ${tool.description}`; | ||||||
| } | ||||||
|
|
||||||
| return tools; | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current schema allows
remoteFileSystemto be enabled with an emptysshHostorsshKeyPath, which will cause runtime errors when the SSH command is executed. You should add a.refine()validation to the Zod schema to ensure these fields are non-empty strings whenenabledistrue.