🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@forcedream/mcp-server

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forcedream/mcp-server - npm Package Compare versions

Comparing version
0.8.0
to
0.9.0
+92
dist/score_lead.js
import { z } from 'zod';
const FD_API = process.env.FD_API_BASE || 'https://api.forcedream.ai';
const SLUG = 'lead-score-v1';
/**
* Zod input schema for the forcedream_score_lead tool. lead_description is required;
* max_wait_seconds bounds how long this call polls before returning a pollable task_id.
* A dedicated, named tool for ForceDream's lead-score-v1 agent, rather than requiring
* a caller to know the generic forcedream_invoke_agent + agent_slug pattern.
*/
export const scoreLeadSchema = {
lead_description: z.string().describe('Free-text description of the lead: company, contact, context, any details you have.'),
max_wait_seconds: z.number().optional().describe('Max seconds to poll (default 60, agent typically takes up to 45s given multi-source enrichment). On timeout, returns task_id to poll later.'),
};
function authHeader() {
const key = process.env.FD_API_KEY || '';
return key ? { Authorization: `Bearer ${key}` } : {};
}
async function postJson(url, body) {
const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', ...authHeader() }, body: JSON.stringify(body) });
let json = null;
try {
json = await res.json();
}
catch { }
return { status: res.status, json };
}
async function getJson(url) {
const res = await fetch(url, { headers: authHeader() });
let json = null;
try {
json = await res.json();
}
catch { }
return { status: res.status, json };
}
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
// Invoke lead-score-v1 and wait (bounded) for the result. SPENDS balance -- needs FD_API_KEY.
// Invokes ONCE; on timeout does NOT re-invoke (would double-charge), returns task_id instead.
// Same real invoke/poll pattern as the other dedicated tools, fixed to this one agent.
/**
* Invokes ForceDream's real lead-score-v1 agent and polls (bounded) for the result.
* SPENDS your balance -- requires FD_API_KEY. Invokes once; never re-invokes on timeout
* (would double-charge) -- returns a pollable task_id instead. Set FD_MOCK_MODE=true to
* test without spending real balance.
* @param args.lead_description - Free-text description of the lead.
* @param args.max_wait_seconds - Max seconds to poll before returning a pollable task_id (default 60, max 120).
*/
export async function scoreLead(args) {
if (process.env.FD_MOCK_MODE === 'true') {
return {
status: 'completed',
agent: SLUG,
task_id: 'mock_' + Date.now(),
output: { tier: 'warm', score: 50, signals: [], recommended_action: 'mock', summary: 'mock', note: 'Synthetic mock output. This is not a real lead score.' },
charged_pence: 0,
mock: true,
message: 'MOCK MODE ACTIVE (FD_MOCK_MODE=true): no real scoring was run, no balance was spent, and this response has no real proof_id -- forcedream_verify_proof will correctly reject it if you try. Unset FD_MOCK_MODE to run real scoring.',
};
}
if (!process.env.FD_API_KEY) {
return { status: 'error', agent: SLUG, message: 'FD_API_KEY is required to score (scoring spends your balance). Set it in the MCP server env. forcedream_search_agents and forcedream_verify_proof need no key.' };
}
const maxWaitMs = Math.max(5, Math.min(120, args.max_wait_seconds ?? 60)) * 1000;
const inv = await postJson(`${FD_API}/v1/agents/${SLUG}/invoke`, { task: args.lead_description });
if (inv.status === 401)
return { status: 'error', agent: SLUG, message: 'Invalid FD_API_KEY (401). Check the key in the MCP server env.' };
if (!inv.json?.task_id)
return { status: 'error', agent: SLUG, message: `Invoke failed (HTTP ${inv.status}): ${inv.json?.error || inv.json?.note || 'no task_id'}` };
const taskId = inv.json.task_id;
const start = Date.now();
let intervalMs = 2500;
while (Date.now() - start < maxWaitMs) {
await sleep(intervalMs);
const poll = await getJson(`${FD_API}/v1/agents/${SLUG}/result/${encodeURIComponent(taskId)}`);
const d = poll.json || {};
const status = d.status || d.outcome;
if (status === 'completed' || status === 'succeeded' || d.ok === true) {
return {
status: 'completed', agent: SLUG, task_id: taskId, output: d.output, charged_pence: d.charged_pence,
proof_id: d.proof_id || taskId,
verify_proof_hint: `Verify trustlessly: call forcedream_verify_proof with task_id "${d.proof_id || taskId}". The signature proves authenticity without trusting ForceDream.`,
message: `Completed. Charged ${d.charged_pence}p. Cryptographically proven (proof_id ${d.proof_id || taskId}).`,
};
}
if (status === 'charge_failed')
return { status: 'charge_failed', agent: SLUG, task_id: taskId, charged_pence: 0, message: `Charge failed: ${d.reason || 'insufficient_balance'}. Nothing charged or delivered. Top up and retry.` };
if (status === 'failed' || status === 'dead_letter')
return { status: 'error', agent: SLUG, task_id: taskId, message: `Task ${status}: ${d.reason || d.last_error || 'unknown'}` };
intervalMs = Math.min(intervalMs + 1000, 6000);
}
return { status: 'pending', agent: SLUG, task_id: taskId, message: `Still processing after ${maxWaitMs / 1000}s. Not re-invoked (would double-charge). Poll the result later with this task_id.` };
}
+21
-0

@@ -11,2 +11,3 @@ #!/usr/bin/env node

import { checkFraud, checkFraudSchema, generateEmbedding, generateEmbeddingSchema, marketQuote, marketQuoteSchema } from './direct_tools.js';
import { scoreLead, scoreLeadSchema } from './score_lead.js';
import { searchReliability, searchReliabilitySchema } from './search_reliability.js';

@@ -114,2 +115,22 @@ import { searchCosts, searchCostsSchema } from './search_costs.js';

});
// forcedream_score_lead — dedicated, named tool for lead-score-v1 specifically.
// Spends balance (needs FD_API_KEY). Same real invoke/poll pattern as forcedream_extract_data,
// fixed to this one agent so a caller doesn't need to know the generic agent_slug pattern.
server.registerTool('forcedream_score_lead', {
title: 'Score a sales lead',
description: 'Score sales leads hot/warm/cold with weighted signals and a recommended next action — grounded in real, ' +
'live verification. Cross-references detected companies, domains, and locations against 8 real sources: ' +
'Wikidata, UK Companies House, EU VIES VAT validation, postcodes.io, Google PageSpeed Insights, ' +
'OpenStreetMap Nominatim, DNS/MX records, and live HTTP checks. Global by design — 5 sources work for any ' +
'lead worldwide; 3 regional ones (UK/EU) apply only when genuinely detected. SPENDS your balance — requires FD_API_KEY.',
inputSchema: scoreLeadSchema,
}, async ({ lead_description, max_wait_seconds }) => {
try {
const result = await scoreLead({ lead_description, max_wait_seconds });
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: 'text', text: JSON.stringify({ status: 'error', error: e.message }, null, 2) }], isError: true };
}
});
// forcedream_check_fraud — real, direct, synchronous call (no polling). Spends balance

@@ -116,0 +137,0 @@ // (needs FD_API_KEY). Uses the new, dedicated fd_live_-accepting backend endpoint.

+1
-1
{
"name": "@forcedream/mcp-server",
"version": "0.8.0",
"version": "0.9.0",
"mcpName": "io.github.forcedreamai/mcp-server",

@@ -5,0 +5,0 @@ "description": "Discover, invoke, and trustlessly verify ForceDream AI agents with cryptographic proofs. ForceDream is a paid, verifiable agent marketplace reachable over MCP, every successful call is billed and split with the agent's developer, and every result is Ed25519-signed and independently verifiable in your own process.",