@noelclaw/mcp 1.5.6 → 1.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,16 +30,57 @@ const AskNoelSchema = zod_1.z.object({
30
30
  question: zod_1.z.string().min(1),
31
31
  messages: zod_1.z.array(zod_1.z.object({ role: zod_1.z.enum(["user", "assistant"]), content: zod_1.z.string() })).optional(),
32
32
  });
33
+ const BANKR_LLM_URL = "https://llm.bankr.bot/v1/chat/completions";
34
+ const BANKR_MODEL = process.env.BANKR_MODEL ?? "grok-3";
35
+ const NOEL_SYSTEM_PROMPT = `You are Noel, a crypto AI analyst with deep expertise in DeFi, on-chain data, market structure, and trading psychology. You provide sharp, direct analysis — no fluff, no disclaimers. You understand narratives, liquidity flows, whale behavior, and how sentiment drives price. When asked about a token or market, give your honest read with supporting reasoning.`;
36
+ async function askViaBankr(question, messages) {
37
+ const res = await fetch(BANKR_LLM_URL, {
38
+ method: "POST",
39
+ headers: {
40
+ "X-API-Key": process.env.BANKR_API_KEY,
41
+ "Content-Type": "application/json",
42
+ },
43
+ body: JSON.stringify({
44
+ model: BANKR_MODEL,
45
+ messages: [
46
+ { role: "system", content: NOEL_SYSTEM_PROMPT },
47
+ ...messages,
48
+ { role: "user", content: question },
49
+ ],
50
+ max_tokens: 1024,
51
+ }),
52
+ signal: AbortSignal.timeout(30000),
53
+ });
54
+ if (!res.ok) {
55
+ const err = await res.text().catch(() => res.statusText);
56
+ throw new Error(`Bankr LLM error ${res.status}: ${err.slice(0, 200)}`);
57
+ }
58
+ const data = await res.json();
59
+ return data.choices?.[0]?.message?.content ?? "No response from model";
60
+ }
33
61
  async function handleInsightTool(name, args) {
34
62
  if (name !== "ask_noel")
35
63
  return null;
36
64
  const parsed = AskNoelSchema.safeParse(args);
37
65
  if (!parsed.success)
38
66
  return { content: [{ type: "text", text: `Invalid input: question ${parsed.error.issues[0].message}` }], isError: true };
67
+ const { question, messages = [] } = parsed.data;
68
+ // If BANKR_API_KEY is set, call Bankr LLM directly — faster, no Convex hop
69
+ if (process.env.BANKR_API_KEY) {
70
+ try {
71
+ const answer = await askViaBankr(question, messages);
72
+ return { content: [{ type: "text", text: answer }] };
73
+ }
74
+ catch (err) {
75
+ // Fall through to Convex if Bankr call fails
76
+ console.error(`Bankr LLM failed, falling back to Convex: ${err.message}`);
77
+ }
78
+ }
79
+ // Fallback: route through Convex backend
39
80
  const data = await (0, convex_js_1.callConvex)("/mcp/chat", "POST", {
40
- question: parsed.data.question,
81
+ question,
41
82
  agentId: "noel-default",
42
- messages: parsed.data.messages ?? [],
83
+ messages,
43
84
  }, "ask_noel");
44
85
  return { content: [{ type: "text", text: data.answer ?? JSON.stringify(data) }] };
45
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noelclaw/mcp",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "Noelclaw as an MCP skill — persistent memory, multi-agent coordination, scenario simulation, DeFi execution, and Sentinel-gated playbooks.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {