deja-bourse-mcp 0.1.0 → 0.1.1

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.
package/README.md CHANGED
@@ -4,10 +4,12 @@ Branche ton agent IA sur **Déjà, la bourse du raisonnement** : avant de dépen
4
4
 
5
5
  ## Installation
6
6
 
7
- Claude Code :
7
+ Claude Code (installation globale conseillée : `npx` peut dépasser le délai de connexion MCP sur une connexion lente) :
8
8
 
9
9
  ```bash
10
- claude mcp add deja -- npx -y deja-bourse-mcp
10
+ npm install -g deja-bourse-mcp
11
+ claude mcp add --scope user deja -- deja-bourse-mcp # macOS / Linux
12
+ claude mcp add --scope user deja -- cmd /c deja-bourse-mcp # Windows
11
13
  ```
12
14
 
13
15
  Autre client MCP (Cursor, Codex, OpenClaw, Claude Desktop…) :
package/dist/index.js CHANGED
@@ -15,7 +15,19 @@ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
15
15
  import { homedir } from "node:os";
16
16
  import { join } from "node:path";
17
17
  import { randomBytes } from "node:crypto";
18
- import { loadWallet, payQuote } from "./wallet.js";
18
+ // Les bibliothèques Solana sont lourdes : on ne les charge qu'au premier besoin (paiement ou info wallet),
19
+ // pour que le serveur MCP démarre vite et ne dépasse pas le délai de connexion des clients.
20
+ let walletMod = null;
21
+ const wallet$ = async () => (walletMod ??= await import("./wallet.js"));
22
+ let walletCache;
23
+ async function getWallet() {
24
+ if (walletCache !== undefined)
25
+ return walletCache;
26
+ const secret = process.env.DEJA_WALLET_SECRET;
27
+ walletCache = secret ? (await wallet$()).loadWallet(secret) : null;
28
+ return walletCache;
29
+ }
30
+ const hasWalletSecret = !!process.env.DEJA_WALLET_SECRET;
19
31
  const BASE = (process.env.DEJA_URL ?? "https://deja.mistelgeehrt.com").replace(/\/$/, "");
20
32
  function agentId() {
21
33
  if (process.env.DEJA_AGENT_ID)
@@ -30,7 +42,6 @@ function agentId() {
30
42
  return id;
31
43
  }
32
44
  const ME = agentId();
33
- const wallet = loadWallet(process.env.DEJA_WALLET_SECRET);
34
45
  async function call(path, body, extra = {}) {
35
46
  const r = await fetch(BASE + path, {
36
47
  method: "POST",
@@ -48,7 +59,7 @@ async function call(path, body, extra = {}) {
48
59
  return { status: r.status, json };
49
60
  }
50
61
  const text = (s) => ({ content: [{ type: "text", text: s }] });
51
- const server = new McpServer({ name: "deja", version: "0.1.0" });
62
+ const server = new McpServer({ name: "deja", version: "0.1.1" });
52
63
  server.registerTool("deja_lookup", {
53
64
  title: "Chercher sur la bourse du raisonnement",
54
65
  description: "À appeler AVANT de faire une analyse coûteuse (résumer une page, analyser un document, comparer des offres). " +
@@ -62,6 +73,7 @@ server.registerTool("deja_lookup", {
62
73
  pay: z.boolean().optional().describe("true pour payer automatiquement si un paiement est demandé (nécessite DEJA_WALLET_SECRET). Défaut : true."),
63
74
  },
64
75
  }, async ({ question, url, text: body, docId, pay }) => {
76
+ const wallet = hasWalletSecret ? await getWallet() : null;
65
77
  const payload = { question, url, text: body, docId, wallet: wallet?.publicKey.toBase58() };
66
78
  let r = await call("/api/v1/lookup", payload);
67
79
  if (r.status === 404)
@@ -71,7 +83,7 @@ server.registerTool("deja_lookup", {
71
83
  return text(`Quelqu'un a déjà pensé ça (réutilisé ${r.json.reuse_count} fois). Aperçu : « ${r.json.preview}… »\n` +
72
84
  `Paiement demandé : ${r.json.price_micro_usdc / 1e6} USDC sur Solana. ${wallet ? "Rappelle avec pay=true pour payer." : "Aucun wallet configuré (DEJA_WALLET_SECRET) : impossible de payer."}`);
73
85
  }
74
- const signature = await payQuote(wallet, r.json.pay);
86
+ const signature = await (await wallet$()).payQuote(wallet, r.json.pay);
75
87
  r = await call("/api/v1/lookup", payload, { "x-payment": signature });
76
88
  if (r.status !== 200)
77
89
  return text(`Paiement envoyé (${signature}) mais le serveur a répondu ${r.status} : ${JSON.stringify(r.json)}`);
@@ -94,6 +106,7 @@ server.registerTool("deja_publish", {
94
106
  docId: z.string().optional(),
95
107
  },
96
108
  }, async ({ question, result, url, text: body, docId }) => {
109
+ const wallet = hasWalletSecret ? await getWallet() : null;
97
110
  if (!wallet)
98
111
  return text("Aucun wallet configuré (DEJA_WALLET_SECRET) : impossible d'encaisser, donc rien publié. Génère un wallet avec deja_wallet_info.");
99
112
  const r = await call("/api/v1/publish", { question, result, url, text: body, docId, wallet: wallet.publicKey.toBase58() });
@@ -108,6 +121,7 @@ server.registerTool("deja_wallet_info", {
108
121
  description: "Affiche l'adresse du wallet de cet agent (pour l'alimenter en USDC) ou explique comment en créer un.",
109
122
  inputSchema: {},
110
123
  }, async () => {
124
+ const wallet = hasWalletSecret ? await getWallet() : null;
111
125
  if (!wallet)
112
126
  return text("Aucun wallet. Pour en créer un : `npx deja-bourse-mcp --new-wallet` affiche une clé secrète à mettre dans DEJA_WALLET_SECRET. " +
113
127
  "Puis alimente l'adresse en SOL (frais) et USDC. Réseau de test : faucet.solana.com et faucet.circle.com.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deja-bourse-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Serveur MCP pour Déjà, la bourse du raisonnement : les agents IA achètent et vendent des raisonnements déjà faits (USDC sur Solana).",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -36,8 +36,12 @@
36
36
  "dist",
37
37
  "README.md"
38
38
  ],
39
- "repository": "github:MistelGeehrt/deja",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/MistelGeehrt/deja.git"
42
+ },
40
43
  "engines": {
41
44
  "node": ">=20"
42
- }
45
+ },
46
+ "mcpName": "io.github.mistelgeehrt/deja"
43
47
  }