create-credential
Generate credentials for specific node types in MCP-N8N, such as 'cloudflareApi' or 'slackOAuth2Api'. Define required fields using get-credential-schema to ensure compatibility.
Instructions
Create a credential that can be used by nodes of the specified type. The credential type name can be found in the n8n UI when creating credentials (e.g., 'cloudflareApi', 'githubApi', 'slackOAuth2Api'). Use get-credential-schema first to see what fields are required for the credential type you want to create.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientId | Yes | ||
| data | Yes | ||
| name | Yes | ||
| type | Yes |
Implementation Reference
- src/index.ts:1489-1523 (handler)Executes the create-credential tool by retrieving the N8nClient instance using clientId and calling its createCredential method with provided name, type, and data. Handles client not found and API errors, returning formatted success or error messages.case "create-credential": { const { clientId, name, type, data } = args as { clientId: string; name: string; type: string; data: Record<string, any>; }; const client = clients.get(clientId); if (!client) { return { content: [{ type: "text", text: "Client not initialized. Please run init-n8n first.", }], isError: true }; } try { const credential = await client.createCredential(name, type, data); return { content: [{ type: "text", text: `Successfully created credential:\n${JSON.stringify(credential, null, 2)}`, }] }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : "Unknown error occurred", }], isError: true }; }
- src/index.ts:358-367 (helper)Core implementation in N8nClient class that sends a POST request to the n8n /credentials endpoint with the credential name, type, and data payload.async createCredential(name: string, type: string, data: Record<string, any>): Promise<any> { return this.makeRequest('/credentials', { method: 'POST', body: JSON.stringify({ name, type, data }), }); }
- src/index.ts:652-664 (registration)Registers the 'create-credential' tool in the list of tools returned by the ListToolsRequestSchema handler, including its name, description, and input schema.name: "create-credential", description: "Create a credential that can be used by nodes of the specified type. The credential type name can be found in the n8n UI when creating credentials (e.g., 'cloudflareApi', 'githubApi', 'slackOAuth2Api'). Use get-credential-schema first to see what fields are required for the credential type you want to create.", inputSchema: { type: "object", properties: { clientId: { type: "string" }, name: { type: "string" }, type: { type: "string" }, data: { type: "object" } }, required: ["clientId", "name", "type", "data"] } },
- src/index.ts:654-663 (schema)JSON schema defining the input parameters for the create-credential tool: clientId, name, type, and data object.inputSchema: { type: "object", properties: { clientId: { type: "string" }, name: { type: "string" }, type: { type: "string" }, data: { type: "object" } }, required: ["clientId", "name", "type", "data"] }