Skip to main content
Glama

list_credentials

Retrieve credential IDs from n8n for use in workflow nodes to manage authentication and access.

Instructions

List all credentials in n8n with their IDs - use these IDs in workflow nodes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler case in ToolHandler.handleTool that processes 'list_credentials' tool calls by delegating to N8nManager.listCredentials() and formatting the response as MCP content.
    case 'list_credentials': const credentials = await this.n8nManager.listCredentials(); return { content: [{ type: 'text', text: credentials.length > 0 ? `šŸ“‹ Found ${credentials.length} credentials in n8n:\n\n` + credentials.map((c: any) => `• ID: ${c.id}\n Name: ${c.name}\n Type: ${c.type}`).join('\n\n') + '\n\nšŸ’” Use these IDs in your workflow nodes to reference credentials' : 'šŸ“­ No credentials found in n8n\n\n' + 'šŸ’” Add credentials in the n8n UI first, then use this command to get their IDs' }] };
  • Core implementation in N8nManager that executes n8n CLI commands to list credentials, parses table/JSON output, falls back to API, and handles errors.
    async listCredentials(): Promise<any> { try { // Try different credential listing approaches // First try the credentials list command let command = 'n8n credential:list'; console.error(`Executing: ${command}`); let stdout: string; let stderr: string; try { ({ stdout, stderr } = await execAsync(command, { timeout: 10000, })); } catch (error: any) { // If that fails, try alternative command console.error('credential:list failed, trying list:credential'); command = 'n8n list:credential'; try { ({ stdout, stderr } = await execAsync(command, { timeout: 10000, })); } catch (error2: any) { // If both fail, provide helpful message throw new Error( 'Unable to list credentials via n8n CLI. ' + 'Please check credentials manually in n8n UI at http://localhost:5678/credentials' ); } } if (this.hasRealError(stderr, stdout)) { throw new Error(stderr); } // Parse the output - n8n outputs credentials as a table or JSON const lines = stdout.split('\n').filter(line => line.trim()); const credentials: Array<{id: string, name: string, type: string}> = []; // Try to parse as JSON first try { const parsed = JSON.parse(stdout); if (Array.isArray(parsed)) { return parsed; } } catch { // Not JSON, parse as table // Skip header lines, typically starts with "ID" or similar let inData = false; for (const line of lines) { if (line.includes('ID') && line.includes('Name')) { inData = true; continue; } if (inData && line.trim()) { // Parse table row - format is typically: ID | Name | Type | ... const parts = line.split(/\s{2,}|\t|\|/).map(s => s.trim()).filter(s => s); if (parts.length >= 2) { credentials.push({ id: parts[0], name: parts[1], type: parts[2] || 'unknown' }); } } } } return credentials; } catch (error: any) { // If CLI doesn't work, try using the API console.error('CLI approach failed, trying API approach'); try { // Use curl to access n8n API (if available) const apiCommand = 'curl -s http://localhost:5678/rest/credentials'; const { stdout: apiOutput } = await execAsync(apiCommand, { timeout: 5000, }); const apiCredentials = JSON.parse(apiOutput); if (Array.isArray(apiCredentials.data)) { return apiCredentials.data.map((cred: any) => ({ id: cred.id, name: cred.name, type: cred.type })); } } catch (apiError) { console.error('API approach also failed'); } // If n8n is not running or command fails if (error.message.includes('command not found')) { throw new Error('n8n CLI is not installed'); } if (error.message.includes('connect')) { throw new Error('n8n is not running. Start it with: n8n start'); } // Return informative error throw new Error( 'Unable to list credentials. The n8n CLI may not support this command. ' + 'Please check your credentials manually in the n8n UI at http://localhost:5678/credentials\n\n' + 'To find credential IDs:\n' + '1. Open n8n UI\n' + '2. Go to Credentials\n' + '3. Click on a credential\n' + '4. The ID is in the URL (e.g., /credentials/ABC123xyz/edit)' ); } }
  • Tool registration in getToolDefinitions() array, including name, description, and input schema (empty object).
    { name: 'list_credentials', description: 'List all credentials in n8n with their IDs - use these IDs in workflow nodes', inputSchema: { type: 'object', properties: {}, }, },
  • Input schema definition for the tool (no required properties).
    inputSchema: { type: 'object', properties: {}, },

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/mckinleymedia/mcflow-mcp'

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