ssh_add_server
Add new SSH servers to the mcpHydroSSH configuration by specifying connection details like host, username, and authentication method.
Instructions
Add a new SSH server to config
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Unique server ID | |
| name | Yes | Server display name | |
| host | Yes | Server hostname or IP | |
| port | No | SSH port (default: 22) | |
| username | Yes | SSH username | |
| authMethod | No | Authentication method (default: "key") | |
| privateKeyPath | No | Path to private key (required for "key" auth) | |
| password | No | Password (required for "password" auth) |
Implementation Reference
- src/index.ts:427-461 (handler)Handler implementation for 'ssh_add_server'. It constructs a server object, persists it using `addServer` (imported helper), updates the in-memory configuration, and returns a success/error message.
case 'ssh_add_server': { const server = { id: args.id as string, name: args.name as string, host: args.host as string, port: (args.port as number) || 22, username: args.username as string, authMethod: (args.authMethod as 'agent' | 'key' | 'password') || 'key', privateKeyPath: args.privateKeyPath as string | undefined, password: args.password as string | undefined, }; try { addServer(server); // Update in-memory config config.servers.push(server); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Server "${server.id}" added` }, null, 2), }, ], }; } catch (err: unknown) { return { content: [ { type: 'text', text: JSON.stringify({ error: err instanceof Error ? err.message : String(err) }, null, 2), }, ], isError: true, }; } } - src/index.ts:150-191 (registration)Tool registration for 'ssh_add_server' within the `ListToolsRequestSchema` handler. Defines the tool's name, description, and input schema.
name: 'ssh_add_server', description: 'Add a new SSH server to config', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Unique server ID', }, name: { type: 'string', description: 'Server display name', }, host: { type: 'string', description: 'Server hostname or IP', }, port: { type: 'number', description: 'SSH port (default: 22)', }, username: { type: 'string', description: 'SSH username', }, authMethod: { type: 'string', enum: ['agent', 'key', 'password'], description: 'Authentication method (default: "key")', }, privateKeyPath: { type: 'string', description: 'Path to private key (required for "key" auth)', }, password: { type: 'string', description: 'Password (required for "password" auth)', }, }, required: ['id', 'name', 'host', 'username'], }, },