A programmatic n8n community node wrapping the hosted Mem0 v3 REST API: add, search, get, get-many, update, delete, plus usableAsTool so the n8n AI Agent can call it. - Zero runtime dependencies (calls REST directly), TypeScript, ESLint clean — meets n8n verified-node requirements - Add supports custom_instructions, custom_categories, includes, excludes, a client-side entity-id guard, and async event polling (itemIndex on errors) - Anonymous opt-out telemetry (MEM0_TELEMETRY=false) - Docs page + docs.json/llms.txt entry, ci-gate + release wiring, AGENTS.md rows - Verified: tsc + ESLint + live E2E (add → search → get → delete) vs api.mem0.ai Split out of #6057 per review (separate PRs per integration).
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import {
|
|
IAuthenticateGeneric,
|
|
ICredentialTestRequest,
|
|
ICredentialType,
|
|
INodeProperties,
|
|
} from 'n8n-workflow';
|
|
|
|
export class Mem0Api implements ICredentialType {
|
|
name = 'mem0Api';
|
|
|
|
displayName = 'Mem0 API';
|
|
|
|
documentationUrl = 'https://docs.mem0.ai/platform/quickstart';
|
|
|
|
properties: INodeProperties[] = [
|
|
{
|
|
displayName: 'API Key',
|
|
name: 'apiKey',
|
|
type: 'string',
|
|
typeOptions: { password: true },
|
|
default: '',
|
|
required: true,
|
|
description: 'Your Mem0 API key (starts with "m0-"). Create one at app.mem0.ai → Settings → API Keys.',
|
|
},
|
|
{
|
|
displayName: 'Base URL',
|
|
name: 'baseUrl',
|
|
type: 'string',
|
|
default: 'https://api.mem0.ai',
|
|
description: 'Mem0 API base URL. Override only for self-hosted or non-default deployments.',
|
|
},
|
|
];
|
|
|
|
// Injects "Authorization: Token <apiKey>" on every request, matching the
|
|
// scheme used by Mem0's official SDKs (Authorization: Token m0-...).
|
|
authenticate: IAuthenticateGeneric = {
|
|
type: 'generic',
|
|
properties: {
|
|
headers: {
|
|
Authorization: '=Token {{$credentials.apiKey}}',
|
|
},
|
|
},
|
|
};
|
|
|
|
// Cheap authenticated GET; validates the key when the user clicks "Test".
|
|
test: ICredentialTestRequest = {
|
|
request: {
|
|
baseURL: '={{$credentials.baseUrl}}',
|
|
url: '/v1/ping/',
|
|
method: 'GET',
|
|
},
|
|
};
|
|
}
|