Skip to main content
Glama

add_credential

Store a new SSH credential on the SSH MCP Server by specifying the host, username, and private key file path for secure remote command execution.

Instructions

Add a new SSH credential with private key file path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
nameYes
privateKeyPathYes
usernameYes

Implementation Reference

  • The main handler function for the 'add_credential' tool. It extracts arguments, validates the private key path, inserts the credential into the SQLite database, and returns success or error response.
    case 'add_credential': { const { name, host, username, privateKeyPath } = request.params.arguments as { name: string; host: string; username: string; privateKeyPath: string; }; try { const validatedKeyPath = validatePrivateKeyPath(privateKeyPath); await db.run( 'INSERT INTO credentials (name, host, username, privateKeyPath) VALUES (?, ?, ?, ?)', [name, host, username, validatedKeyPath] ); return { content: [{ type: 'text', text: `Credential ${name} added successfully` }] }; } catch (error: unknown) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}`, }], isError: true, }; } }
  • src/index.ts:97-110 (registration)
    Registration of the 'add_credential' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.
    { name: 'add_credential', description: 'Add a new SSH credential with private key file path', inputSchema: { type: 'object', properties: { name: { type: 'string' }, host: { type: 'string' }, username: { type: 'string' }, privateKeyPath: { type: 'string' }, }, required: ['name', 'host', 'username', 'privateKeyPath'], }, },
  • Input schema definition for the 'add_credential' tool, specifying required parameters: name, host, username, privateKeyPath.
    inputSchema: { type: 'object', properties: { name: { type: 'string' }, host: { type: 'string' }, username: { type: 'string' }, privateKeyPath: { type: 'string' }, }, required: ['name', 'host', 'username', 'privateKeyPath'], },
  • Helper function to validate and resolve the private key file path, ensuring it exists, called within the add_credential handler.
    function validatePrivateKeyPath(path: string): string { console.error('DEBUG: Validating key path input:', path); // Log input if (typeof path !== 'string') { throw new Error('validatePrivateKeyPath received non-string input'); } const resolvedPath = resolve(path); console.error('DEBUG: Resolved key path:', resolvedPath); // Log resolved if (!existsSync(resolvedPath)) { throw new Error(`Private key file not found at path: ${resolvedPath}`); } return resolvedPath; }

Other Tools

Related Tools

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/KinoThe-Kafkaesque/ssh-mcp-server'

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