Skip to main content
Glama

ssh_save_credential

Store SSH credentials for secure reuse across multiple connections, supporting both password and private key authentication methods.

Instructions

Save SSH credentials for reuse

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
credentialIdYesUnique identifier for this credential
hostYesSSH server hostname or IP address
portNoSSH port number
usernameYesSSH username
passwordNoSSH password (if not using key)
privateKeyPathNoPath to private key file
passphraseNoPassphrase for private key

Implementation Reference

  • Main execution logic for the 'ssh_save_credential' tool: parses args with schema, validates uniqueness and auth method, stores credential in in-memory Map, returns success response.
    private async handleSaveCredential(args: unknown) { const params = SaveCredentialSchema.parse(args); if (credentialStore.has(params.credentialId)) { throw new McpError( ErrorCode.InvalidParams, `Credential ID '${params.credentialId}' already exists` ); } if (!params.password && !params.privateKeyPath) { throw new McpError( ErrorCode.InvalidParams, 'Either password or privateKeyPath must be provided' ); } const credential: StoredCredential = { host: params.host, port: params.port || 22, username: params.username, password: params.password, privateKeyPath: params.privateKeyPath, passphrase: params.passphrase, createdAt: new Date().toISOString(), lastUsed: new Date().toISOString() }; credentialStore.set(params.credentialId, credential); return { content: [ { type: 'text', text: `Credential '${params.credentialId}' saved successfully for ${params.username}@${params.host}:${params.port || 22}`, }, ], }; }
  • Zod input schema defining parameters for saving SSH credentials: credentialId (required), host, port (default 22), username (required), optional password/privateKeyPath/passphrase.
    const SaveCredentialSchema = z.object({ credentialId: z.string().describe('Unique identifier for this credential'), host: z.string().describe('SSH server hostname or IP address'), port: z.number().default(22).describe('SSH port number'), username: z.string().describe('SSH username'), password: z.string().optional().describe('SSH password (if not using key)'), privateKeyPath: z.string().optional().describe('Path to private key file'), passphrase: z.string().optional().describe('Passphrase for private key') });
  • src/index.ts:372-387 (registration)
    Tool definition in ListTools response: name, description, and JSON schema mirroring the Zod schema.
    name: 'ssh_save_credential', description: 'Save SSH credentials for reuse', inputSchema: { type: 'object', properties: { credentialId: { type: 'string', description: 'Unique identifier for this credential' }, host: { type: 'string', description: 'SSH server hostname or IP address' }, port: { type: 'number', default: 22, description: 'SSH port number' }, username: { type: 'string', description: 'SSH username' }, password: { type: 'string', description: 'SSH password (if not using key)' }, privateKeyPath: { type: 'string', description: 'Path to private key file' }, passphrase: { type: 'string', description: 'Passphrase for private key' } }, required: ['credentialId', 'host', 'username'] }, },
  • src/index.ts:505-506 (registration)
    Dispatch case in CallToolRequest handler mapping 'ssh_save_credential' name to handleSaveCredential method.
    case 'ssh_save_credential': return await this.handleSaveCredential(args);
  • In-memory Map storing saved credentials, key: credentialId, value: StoredCredential object.
    const credentialStore = new Map<string, StoredCredential>();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/widjis/mcp-ssh'

If you have feedback or need assistance with the MCP directory API, please join our Discord server