B2B-Leads bewerten und EN/KO-Follow-ups entwerfen: MCP-Server fuer Claude Desktop
Ein Open-Source-MCP-Server mit 116 Zeilen Code ermoeglicht das Scoring von B2B-Leads und das Entwerfen von Follow-ups in englischer und koreanischer Sprache direkt in Claude Desktop. Das Projekt steht unter MIT-Lizenz und ist kostenlos nutzbar.

Offenlegung: Ich habe das hier verwendete Open-Source-Projekt geschrieben und pflege es (MIT). Ich biete außerdem bezahlte Einrichtungsarbeit an, die am Ende verlinkt ist. Alles im Folgenden funktioniert, ohne dass jemandem Geld gezahlt werden muss.
Die meisten Demo-Ansätze für Lead-Scoring mit KI fügen einen Lead in einen Chat ein und fragen: Ist das ein guter Lead? Fragt man morgen erneut, erhält man eine andere Antwort. Das ist für Brainstorming in Ordnung und für eine Vertriebs-Warteschlange katastrophal.
Das Model Context Protocol (MCP) ist die saubere Nahtstelle zwischen diesen beiden Welten. In diesem Beitrag bauen wir, genauer gesagt lesen wir, einen vollständigen MCP-Server in 116 Zeilen purem Node.js: ohne SDK, ohne npm install, ohne API-Schlüssel, ohne Netzwerkzugriffe.
Repository: github.com/alborotar/mcp-automation-starter · Live-Übersicht: alborotar.github.io/mcp-automation-starter
Zwei Dateien erledigen die gesamte Arbeit: src/tools.js (reine Funktionen) und src/server.js (JSON-RPC über stdio).
const FREE_MAIL = new Set ( [ 'gmail.com', 'naver.com', 'daum.net', 'hanmail.net', 'yahoo.com', 'outlook.com', 'hotmail.com' ] ); const INTENT_WORDS = [ 'budget', 'urgent', 'asap', 'contract', 'quote', 'pricing', 'demo', '견적', '예산', '도입', '계약', '긴급' ]; export function scoreLead ( { email = '', company = '', message = '', employees = 0 } = { } ) { let score = 0; const reasons = [ ]; const domain = String ( email ). split ( '@' ) [ 1 ]?. toLowerCase ( ) || ''; if ( domain &&! FREE_MAIL. has ( domain ) ) { score += 30; reasons. push ( 'business email domain' ); } if ( company ) { score += 10; reasons. push ( 'company provided' ); } const n = Number ( employees ) || 0; if ( n >= 200 ) { score += 30; reasons. push ( '200+ employees' ); } else if ( n >= 20 ) { score += 20; reasons. push ( '20-199 employees' ); } const text = String ( message ). toLowerCase ( ); const hits = INTENT_WORDS. filter ( ( w ) => text. includes ( w ) ); if ( hits. length ) { score += Math. min ( 30, hits. length * 10 ); reasons. push ( `intent keywords: ${hits.join(', ')}` ); } score = Math. min ( 100, score ); const tier = score >= 70? 'hot': score >= 40? 'warm': 'cold'; return { score, tier, reasons }; } Enter fullscreen mode Exit fullscreen mode Ein paar Designentscheidungen, die es wert sind, übernommen zu werden:
export function triageLeads ( { leads = [ ] } = { } ) { const scored = leads. map ( ( l ) => ( {... l,... scoreLead ( l ) } ) ). sort ( ( a, b ) => b. score - a. score ); return { leads: scored. map ( ( { reasons,... r } ) => ( {... r, reasons: reasons. join ( '; ' ) } ) ), hot: scored. filter ( ( l ) => l. tier === 'hot' ). length, }; } Enter fullscreen mode Exit fullscreen mode Das Zusammenführen der Begründungen zu einem String ist bewusst so gewählt: Dadurch bleibt der CSV-Export bei einer Zeile pro Lead.
{ "leads": [ { "email": "mina@acme-logistics.co.kr", "employees": 250, "message": "견적 and pricing for a demo, budget approved", "score": 100, "tier": "hot", "reasons": "business email domain; company provided; 200+ employees; intent keywords: budget, pricing, demo, 견적" }, { "email": "sam@brightdesk.io", "employees": 35, "message": "Need a quote ASAP", "score": 80, "tier": "hot", "reasons": "business email domain; company provided; 20-199 employees; intent keywords: asap, quote" }, { "email": "joe@gmail.com", "message": "just curious", "score": 0, "tier": "cold", "reasons": "" } ], "hot": 2 } Enter fullscreen mode Exit fullscreen mode Teil 2: der komplette MCP-Server, ohne SDK MCP über stdio ist zeilengetrenntes JSON-RPC 2.0. Für einen Server, der nur Tools anbietet, benötigt man fünf Methoden:
export function handle ( msg ) { const { id, method, params = { } } = msg || { }; const ok = ( result ) => ( { jsonrpc: '2.0', id, result } ); const err = ( code, message ) => ( { jsonrpc: '2.0', id, error: { code, message } } ); if ( id === undefined ) return null; // notifications (e.g. notifications/initialized) get no reply switch ( method ) { case 'initialize': return ok ( { protocolVersion: params. protocolVersion || '2025-06-18', capabilities: { tools: { } }, serverInfo: { name: 'mcp-automation-starter', version: '1.0.0' } } ); case 'ping': return ok ( { } ); case 'tools/list': return ok ( { tools: TOOLS. map ( ( { run,... t } ) => t ) } ); // strip the function, keep the schema case 'tools/call': { const tool = TOOLS. find ( ( t ) => t. name === params. name ); if (! tool ) return err ( - 32602, `Unknown tool: ${params.name}` ); try { const out = tool. run ( params. arguments || { } ); return ok ( { content: [ { type: 'text', text: JSON. stringify ( out, null, 2 ) } ], structuredContent: out, isError: false } ); } catch ( e ) { return ok ( { content: [ { type: 'text', text: String ( e?. message || e ) } ], isError: true } ); } } default: return err ( - 32601, `Method not found: ${method}` ); } } Enter fullscreen mode Exit fullscreen mode Die Schleife darum umfasst mit node:readline zehn Zeilen: jede Zeile parsen, handle aufrufen, die JSON-Antwort plus \n schreiben und unlesbare Eingaben mit -32700 Parse error beantworten.
Jedes Tool ist ein einfaches Objekt, daher ist das Hinzufügen eines Tools ein einzelner Eintrag:
{ name: 'score_lead', description: 'Score one inbound B2B lead 0-100 and assign hot/warm/cold tier.', inputSchema: { type: 'object', properties: { email: { type: 'string' }, company: { type: 'string' }, message: { type: 'string' }, employees: { type: 'number' } }, required: [ 'email' ] }, run: scoreLead } Enter fullscreen mode Exit fullscreen mode Teil 3: Entwürfe für Follow-ups in EN/KO (für Leads, die sich gemeldet haben) draft_outreach liefert eine Betreff- und Textvorlage auf Englisch oder Koreanisch. Zwei Regeln, an die ich mich halte und die ich auch Ihnen empfehle:
Die Sprachauswahl ist ein enum im Schema ( ['en', 'ko'] ), sodass das Modell keinen dritten Sprachwert erfinden kann. Die koreanische Vorlage verwendet die Höflichkeitsform 님 und eine höfliche Schlussformel; passen Sie beide Vorlagen an Ihren eigenen Ton an, bevor Sie sie verwenden.
function csvCell ( v ) { const s = v == null? '': String ( v ); return / [ ",\n]/.test(s)? `" ${s.replace(/"/g, '""')} "`: s; } export function toCsv({ rows = [] } = {}) { if (!Array.isArray(rows) || rows.length === 0) return { csv: '' }; const cols = [...new Set(rows.flatMap((r) => Object.keys(r)))]; // union of keys, first-seen order return { csv: [cols.join(','),...rows.map((r) => cols.map((c) => csvCell(r[c])).join(','))].join('\n') }; } Enter fullscreen mode Exit fullscreen mode Die Vereinigung der Schlüssel zu nehmen ist wichtig: Leads aus unterschiedlichen Formularen haben selten identische Felder.
git clone https://github.com/alborotar/mcp-automation-starter cd mcp-automation-starter npm test # unit tests + an end-to-end test that spawns the server over stdio Enter fullscreen mode Exit fullscreen mode Claude Desktop ( claude_desktop_config.json ):
{ "mcpServers": { "automation": { "command": "node", "args": [ "/ABSOLUTE/PATH/src/server.js" ] } } } Enter fullscreen mode Exit fullscreen mode Claude Code:
claude mcp add automation -- node /ABSOLUTE/PATH/src/server.js Enter fullscreen mode Exit fullscreen mode Starten Sie den Client neu und probieren Sie dann Folgendes:
"Triage these 40 inbound leads, draft Korean follow-ups for the hot ones so I can review them, and give me a CSV."
Das Modell ruft triage_leads auf, dann draft_outreach einmal pro Hot-Lead mit lang: "ko" und anschließend to_csv. Die Bewertungen sind bei jedem Durchlauf identisch; nur der Prosa-Text variiert.
Testen Sie die reinen Funktionen direkt mit Unit-Tests. Ergänzen Sie dann einen End-to-End-Test, der node src/server.js startet, initialize → tools/list → tools/call als Zeilen auf stdin schreibt und die JSON-Zeilen auf stdout prüft. Dieser eine Test findet die meisten Fehler der Art läuft in meinem Editor, bricht im Client ab (störende stdout-Logs, fehlender Zeilenumbruch, Antworten auf Notifications).
Da jedes Tool eine reine Funktion plus Schema ist, fallen typische Erweiterungen klein aus: ein CRM-Schreibzugriff (HubSpot/Pipedrive), ein Anhang in Google Sheets, ein Slack-Ping für Hot-Leads oder eine Notion/Linear-Aufgabe. Halten Sie alles, was etwas sendet oder schreibt, hinter einer expliziten menschlichen Bestätigung.
Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.
Original (Englisch) anzeigen
Disclosure: I wrote and maintain the open-source project used here (MIT). I also offer paid setup work, linked at the end. Everything below works without paying anyone.
Most "AI lead scoring" demos paste a lead into a chat and ask "is this a good lead?". Ask again tomorrow and you get a different answer. That is fine for brainstorming and terrible for a sales queue.
The Model Context Protocol (MCP) is the clean seam between those two. In this post we build (well, read) a complete MCP server in 116 lines of plain Node.js: no SDK, no npm install, no API key, no network calls.
Repo: github.com/alborotar/mcp-automation-starter · Live overview: alborotar.github.io/mcp-automation-starter
Two files do all the work: src/tools.js (pure functions) and src/server.js (JSON-RPC over stdio).
const FREE_MAIL = new Set ( [ 'gmail.com', 'naver.com', 'daum.net', 'hanmail.net', 'yahoo.com', 'outlook.com', 'hotmail.com' ] ); const INTENT_WORDS = [ 'budget', 'urgent', 'asap', 'contract', 'quote', 'pricing', 'demo', '견적', '예산', '도입', '계약', '긴급' ]; export function scoreLead ( { email = '', company = '', message = '', employees = 0 } = { } ) { let score = 0; const reasons = [ ]; const domain = String ( email ). split ( '@' ) [ 1 ]?. toLowerCase ( ) || ''; if ( domain &&! FREE_MAIL. has ( domain ) ) { score += 30; reasons. push ( 'business email domain' ); } if ( company ) { score += 10; reasons. push ( 'company provided' ); } const n = Number ( employees ) || 0; if ( n >= 200 ) { score += 30; reasons. push ( '200+ employees' ); } else if ( n >= 20 ) { score += 20; reasons. push ( '20-199 employees' ); } const text = String ( message ). toLowerCase ( ); const hits = INTENT_WORDS. filter ( ( w ) => text. includes ( w ) ); if ( hits. length ) { score += Math. min ( 30, hits. length * 10 ); reasons. push ( `intent keywords: ${hits.join(', ')}` ); } score = Math. min ( 100, score ); const tier = score >= 70? 'hot': score >= 40? 'warm': 'cold'; return { score, tier, reasons }; } Enter fullscreen mode Exit fullscreen mode A few design choices worth copying:
export function triageLeads ( { leads = [ ] } = { } ) { const scored = leads. map ( ( l ) => ( {... l,... scoreLead ( l ) } ) ). sort ( ( a, b ) => b. score - a. score ); return { leads: scored. map ( ( { reasons,... r } ) => ( {... r, reasons: reasons. join ( '; ' ) } ) ), hot: scored. filter ( ( l ) => l. tier === 'hot' ). length, }; } Enter fullscreen mode Exit fullscreen mode Joining reasons into a string is deliberate: it keeps the CSV export one row per lead.
{ "leads": [ { "email": "mina@acme-logistics.co.kr", "employees": 250, "message": "견적 and pricing for a demo, budget approved", "score": 100, "tier": "hot", "reasons": "business email domain; company provided; 200+ employees; intent keywords: budget, pricing, demo, 견적" }, { "email": "sam@brightdesk.io", "employees": 35, "message": "Need a quote ASAP", "score": 80, "tier": "hot", "reasons": "business email domain; company provided; 20-199 employees; intent keywords: asap, quote" }, { "email": "joe@gmail.com", "message": "just curious", "score": 0, "tier": "cold", "reasons": "" } ], "hot": 2 } Enter fullscreen mode Exit fullscreen mode Part 2: the whole MCP server, no SDK MCP over stdio is newline-delimited JSON-RPC 2.0. For a tools-only server you need five methods:
export function handle ( msg ) { const { id, method, params = { } } = msg || { }; const ok = ( result ) => ( { jsonrpc: '2.0', id, result } ); const err = ( code, message ) => ( { jsonrpc: '2.0', id, error: { code, message } } ); if ( id === undefined ) return null; // notifications (e.g. notifications/initialized) get no reply switch ( method ) { case 'initialize': return ok ( { protocolVersion: params. protocolVersion || '2025-06-18', capabilities: { tools: { } }, serverInfo: { name: 'mcp-automation-starter', version: '1.0.0' } } ); case 'ping': return ok ( { } ); case 'tools/list': return ok ( { tools: TOOLS. map ( ( { run,... t } ) => t ) } ); // strip the function, keep the schema case 'tools/call': { const tool = TOOLS. find ( ( t ) => t. name === params. name ); if (! tool ) return err ( - 32602, `Unknown tool: ${params.name}` ); try { const out = tool. run ( params. arguments || { } ); return ok ( { content: [ { type: 'text', text: JSON. stringify ( out, null, 2 ) } ], structuredContent: out, isError: false } ); } catch ( e ) { return ok ( { content: [ { type: 'text', text: String ( e?. message || e ) } ], isError: true } ); } } default: return err ( - 32601, `Method not found: ${method}` ); } } Enter fullscreen mode Exit fullscreen mode The loop around it is ten lines with node:readline: parse each line, call handle, write the JSON reply plus \n, and answer unparseable input with -32700 Parse error.
Each tool is a plain object, so adding one is a single entry:
{ name: 'score_lead', description: 'Score one inbound B2B lead 0-100 and assign hot/warm/cold tier.', inputSchema: { type: 'object', properties: { email: { type: 'string' }, company: { type: 'string' }, message: { type: 'string' }, employees: { type: 'number' } }, required: [ 'email' ] }, run: scoreLead } Enter fullscreen mode Exit fullscreen mode Part 3: EN/KO follow-up drafts (for leads who contacted you) draft_outreach returns a subject and body template in English or Korean. Two rules I hold myself to, and recommend you do too:
The lang switch is an enum in the schema ( ['en', 'ko'] ), so the model cannot invent a third language value. The Korean template uses the honorific 님 and a polite closing; adapt both templates to your own voice before using them.
function csvCell ( v ) { const s = v == null? '': String ( v ); return / [ ",\n]/.test(s)? `" ${s.replace(/"/g, '""')} "`: s; } export function toCsv({ rows = [] } = {}) { if (!Array.isArray(rows) || rows.length === 0) return { csv: '' }; const cols = [...new Set(rows.flatMap((r) => Object.keys(r)))]; // union of keys, first-seen order return { csv: [cols.join(','),...rows.map((r) => cols.map((c) => csvCell(r[c])).join(','))].join('\n') }; } Enter fullscreen mode Exit fullscreen mode Taking the union of keys matters: leads from different forms rarely have identical fields.
git clone https://github.com/alborotar/mcp-automation-starter cd mcp-automation-starter npm test # unit tests + an end-to-end test that spawns the server over stdio Enter fullscreen mode Exit fullscreen mode Claude Desktop ( claude_desktop_config.json ):
{ "mcpServers": { "automation": { "command": "node", "args": [ "/ABSOLUTE/PATH/src/server.js" ] } } } Enter fullscreen mode Exit fullscreen mode Claude Code:
claude mcp add automation -- node /ABSOLUTE/PATH/src/server.js Enter fullscreen mode Exit fullscreen mode Restart the client, then try:
"Triage these 40 inbound leads, draft Korean follow-ups for the hot ones so I can review them, and give me a CSV."
The model calls triage_leads, then draft_outreach once per hot lead with lang: "ko", then to_csv. The scores are identical every run; only the prose varies.
Unit-test the pure functions directly. Then add one end-to-end test that spawns node src/server.js, writes initialize → tools/list → tools/call as lines on stdin, and asserts the JSON lines on stdout. That single test catches most "works in my editor, breaks in the client" bugs (stray stdout logging, missing newline, replying to notifications).
Because every tool is a pure function plus a schema, typical extensions are small: a CRM write (HubSpot/Pipedrive), a Google Sheets append, a Slack "hot lead" ping, or a Notion/Linear task. Keep anything that sends or writes behind an explicit human confirmation.