ssh_list_credentials
Retrieve and display all stored SSH credentials for managing remote server connections, including passwords and private keys, using the SSH MCP Server.
Instructions
List all saved SSH credentials
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1127-1153 (handler)The main handler function for the 'ssh_list_credentials' tool. It parses input with ListCredentialsSchema, retrieves all stored credentials from the credentialStore Map, formats them into a list hiding sensitive data (passwords/keys), and returns a text response with the list or a message if none found.private async handleListCredentials(args: unknown) { ListCredentialsSchema.parse(args); const credentials = Array.from(credentialStore.entries()).map(([id, cred]) => ({ credentialId: id, host: cred.host, port: cred.port, username: cred.username, hasPassword: !!cred.password, hasPrivateKey: !!cred.privateKeyPath, createdAt: cred.createdAt, lastUsed: cred.lastUsed })); return { content: [ { type: 'text', text: credentials.length > 0 ? `Saved credentials:\n${credentials.map(c => `- ${c.credentialId}: ${c.username}@${c.host}:${c.port} (${c.hasPassword ? 'password' : 'key'}) - Last used: ${c.lastUsed}` ).join('\n')}` : 'No saved credentials found', }, ], }; }
- src/index.ts:137-138 (schema)Zod schema defining the input parameters for the ssh_list_credentials tool. It expects an empty object (no parameters required). Used for validation in the handler.const ListCredentialsSchema = z.object({});
- src/index.ts:388-396 (registration)Registration of the 'ssh_list_credentials' tool in the ListToolsRequestSchema handler. Defines the tool's name, description, and input schema for discovery by MCP clients.{ name: 'ssh_list_credentials', description: 'List all saved SSH credentials', inputSchema: { type: 'object', properties: {}, required: [] }, },
- src/index.ts:507-508 (registration)Dispatch/registration in the CallToolRequestSchema switch statement. Routes calls to the 'ssh_list_credentials' tool to its handler function.case 'ssh_list_credentials': return await this.handleListCredentials(args);
- src/index.ts:34-42 (helper)TypeScript interface defining the structure of stored SSH credentials used by the credentialStore and the list_credentials handler.interface StoredCredential { host: string; port: number; username: string; password?: string; privateKeyPath?: string; passphrase?: string; createdAt: string; lastUsed: string;