aibrain-mcp 0.1.0
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 +100 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +67 -0
- package/dist/setup.d.ts +6 -0
- package/dist/setup.js +127 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# AI Brain MCP
|
|
2
|
+
|
|
3
|
+
**3 IA debattent. 1 reponse.** Claude, GPT et Gemini collaborent pour resoudre vos problemes complexes.
|
|
4
|
+
|
|
5
|
+
## Installation rapide
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Installer le package
|
|
9
|
+
npm install -g aibrain-mcp
|
|
10
|
+
|
|
11
|
+
# 2. Configurer Claude Code
|
|
12
|
+
aibrain-setup --api-key VOTRE_CLE_API
|
|
13
|
+
|
|
14
|
+
# 3. Redemarrer Claude Code
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Obtenez votre cle API sur [aibrain.dev/dashboard](https://aibrain.dev/dashboard)
|
|
18
|
+
|
|
19
|
+
## Utilisation avec npx (sans installation)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx aibrain-mcp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Outils disponibles
|
|
26
|
+
|
|
27
|
+
### `debate(question)`
|
|
28
|
+
Lance un debat complet entre 3 IA :
|
|
29
|
+
1. Chaque IA analyse la question
|
|
30
|
+
2. Les IA critiquent mutuellement leurs reponses
|
|
31
|
+
3. Une synthese finale consolidee est produite
|
|
32
|
+
|
|
33
|
+
### `quick_review(question)`
|
|
34
|
+
Analyse rapide par 3 IA sans debat complet. Plus rapide mais moins approfondi.
|
|
35
|
+
|
|
36
|
+
## Configuration manuelle
|
|
37
|
+
|
|
38
|
+
### Claude Code (global)
|
|
39
|
+
Ajoutez dans `~/.claude/.mcp.json` :
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"aibrain": {
|
|
44
|
+
"command": "npx",
|
|
45
|
+
"args": ["-y", "aibrain-mcp"],
|
|
46
|
+
"env": {
|
|
47
|
+
"AIBRAIN_API_KEY": "votre_cle_api"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Claude Desktop
|
|
55
|
+
Ajoutez dans votre `claude_desktop_config.json` :
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"aibrain": {
|
|
60
|
+
"command": "npx",
|
|
61
|
+
"args": ["-y", "aibrain-mcp"],
|
|
62
|
+
"env": {
|
|
63
|
+
"AIBRAIN_API_KEY": "votre_cle_api"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Mode BYOK (Bring Your Own Keys)
|
|
71
|
+
|
|
72
|
+
Si vous preferez utiliser vos propres cles API :
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"aibrain": {
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["-y", "aibrain-mcp"],
|
|
79
|
+
"env": {
|
|
80
|
+
"ANTHROPIC_API_KEY": "sk-ant-...",
|
|
81
|
+
"OPENAI_API_KEY": "sk-...",
|
|
82
|
+
"GOOGLE_API_KEY": "AIza..."
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Plans
|
|
90
|
+
|
|
91
|
+
| Plan | Debats/jour | Prix |
|
|
92
|
+
|------|-------------|------|
|
|
93
|
+
| Gratuit | 5 | 0 EUR |
|
|
94
|
+
| Pro | 100 | 19 EUR/mois |
|
|
95
|
+
| Team | Illimite | 49 EUR/mois |
|
|
96
|
+
|
|
97
|
+
## Support
|
|
98
|
+
|
|
99
|
+
- Site : [aibrain.dev](https://aibrain.dev)
|
|
100
|
+
- Issues : [GitHub](https://github.com/aibrain-dev/aibrain-mcp/issues)
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
// ---------- Config ----------
|
|
6
|
+
const API_BASE = process.env.AIBRAIN_API_URL || "https://aibrain-mcp-backend.vercel.app";
|
|
7
|
+
const API_KEY = process.env.AIBRAIN_API_KEY || "";
|
|
8
|
+
// BYOK mode — user brings their own keys, runs debate locally via the API
|
|
9
|
+
const BYOK = !API_KEY && (!!process.env.ANTHROPIC_API_KEY ||
|
|
10
|
+
!!process.env.OPENAI_API_KEY ||
|
|
11
|
+
!!process.env.GOOGLE_API_KEY);
|
|
12
|
+
async function callAPI(req) {
|
|
13
|
+
const headers = {
|
|
14
|
+
"Content-Type": "application/json",
|
|
15
|
+
};
|
|
16
|
+
if (API_KEY) {
|
|
17
|
+
headers["Authorization"] = `Bearer ${API_KEY}`;
|
|
18
|
+
}
|
|
19
|
+
// In BYOK mode, forward the user's own API keys
|
|
20
|
+
if (BYOK) {
|
|
21
|
+
if (process.env.ANTHROPIC_API_KEY)
|
|
22
|
+
headers["X-Anthropic-Key"] = process.env.ANTHROPIC_API_KEY;
|
|
23
|
+
if (process.env.OPENAI_API_KEY)
|
|
24
|
+
headers["X-OpenAI-Key"] = process.env.OPENAI_API_KEY;
|
|
25
|
+
if (process.env.GOOGLE_API_KEY)
|
|
26
|
+
headers["X-Google-Key"] = process.env.GOOGLE_API_KEY;
|
|
27
|
+
}
|
|
28
|
+
const endpoint = req.mode === "debate" ? "/v1/debate" : "/v1/quick-review";
|
|
29
|
+
const res = await fetch(`${API_BASE}${endpoint}`, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers,
|
|
32
|
+
body: JSON.stringify({ question: req.question }),
|
|
33
|
+
});
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
const error = await res.text();
|
|
36
|
+
throw new Error(`API error ${res.status}: ${error}`);
|
|
37
|
+
}
|
|
38
|
+
const data = (await res.json());
|
|
39
|
+
return data.result;
|
|
40
|
+
}
|
|
41
|
+
// ---------- MCP Server ----------
|
|
42
|
+
const server = new McpServer({
|
|
43
|
+
name: "AI Brain MCP",
|
|
44
|
+
version: "0.1.0",
|
|
45
|
+
});
|
|
46
|
+
server.tool("debate", "Lance un débat complet entre 3 IA différentes (Claude, GPT, Gemini). " +
|
|
47
|
+
"Chaque IA analyse la question depuis sa perspective, critique les autres, " +
|
|
48
|
+
"puis une synthèse finale consolidée est produite. " +
|
|
49
|
+
"Utilise pour les questions complexes (architecture, code, sécurité).", { question: z.string().describe("La question ou le problème à résoudre") }, async ({ question }) => {
|
|
50
|
+
const result = await callAPI({ question, mode: "debate" });
|
|
51
|
+
return { content: [{ type: "text", text: result }] };
|
|
52
|
+
});
|
|
53
|
+
server.tool("quick_review", "Analyse rapide par 3 IA (Claude, GPT, Gemini) sans débat complet. " +
|
|
54
|
+
"Chaque IA donne son avis, puis synthèse directe. " +
|
|
55
|
+
"Plus rapide que debate() mais moins approfondi.", { question: z.string().describe("La question ou le problème à analyser") }, async ({ question }) => {
|
|
56
|
+
const result = await callAPI({ question, mode: "quick_review" });
|
|
57
|
+
return { content: [{ type: "text", text: result }] };
|
|
58
|
+
});
|
|
59
|
+
// ---------- Start ----------
|
|
60
|
+
async function main() {
|
|
61
|
+
const transport = new StdioServerTransport();
|
|
62
|
+
await server.connect(transport);
|
|
63
|
+
}
|
|
64
|
+
main().catch((err) => {
|
|
65
|
+
console.error("Fatal:", err);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
package/dist/setup.d.ts
ADDED
package/dist/setup.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI setup for AI Brain MCP.
|
|
4
|
+
* Configures Claude Desktop or Claude Code to use the aibrain-mcp server.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync, copyFileSync, mkdirSync } from "fs";
|
|
7
|
+
import { join, dirname } from "path";
|
|
8
|
+
import { homedir, platform } from "os";
|
|
9
|
+
// ---------- Config paths ----------
|
|
10
|
+
function getClaudeDesktopConfigPath() {
|
|
11
|
+
const home = homedir();
|
|
12
|
+
const paths = {
|
|
13
|
+
darwin: join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json"),
|
|
14
|
+
win32: join(home, "AppData", "Roaming", "Claude", "claude_desktop_config.json"),
|
|
15
|
+
linux: join(home, ".config", "Claude", "claude_desktop_config.json"),
|
|
16
|
+
};
|
|
17
|
+
const p = paths[platform()];
|
|
18
|
+
return p && existsSync(p) ? p : null;
|
|
19
|
+
}
|
|
20
|
+
function getClaudeCodeConfigPath() {
|
|
21
|
+
return join(homedir(), ".claude", ".mcp.json");
|
|
22
|
+
}
|
|
23
|
+
// ---------- MCP config entry ----------
|
|
24
|
+
function getMcpEntry(apiKey) {
|
|
25
|
+
return {
|
|
26
|
+
command: "npx",
|
|
27
|
+
args: ["-y", "aibrain-mcp"],
|
|
28
|
+
env: {
|
|
29
|
+
AIBRAIN_API_KEY: apiKey,
|
|
30
|
+
AIBRAIN_API_URL: "https://aibrain-mcp-backend.vercel.app",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
// ---------- Update config file ----------
|
|
35
|
+
function updateConfig(configPath, apiKey) {
|
|
36
|
+
let config = {};
|
|
37
|
+
if (existsSync(configPath)) {
|
|
38
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
39
|
+
try {
|
|
40
|
+
config = JSON.parse(raw);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
console.error(` Error: Could not parse ${configPath}`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
// Backup
|
|
47
|
+
const backupPath = configPath + ".backup";
|
|
48
|
+
copyFileSync(configPath, backupPath);
|
|
49
|
+
console.log(` Backup: ${backupPath}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Create parent dir if needed
|
|
53
|
+
const dir = dirname(configPath);
|
|
54
|
+
mkdirSync(dir, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
const servers = config.mcpServers || {};
|
|
57
|
+
servers["aibrain"] = getMcpEntry(apiKey);
|
|
58
|
+
config.mcpServers = servers;
|
|
59
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
60
|
+
}
|
|
61
|
+
// ---------- Main ----------
|
|
62
|
+
function main() {
|
|
63
|
+
const args = process.argv.slice(2);
|
|
64
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
65
|
+
console.log(`
|
|
66
|
+
AI Brain MCP - Setup
|
|
67
|
+
|
|
68
|
+
Usage:
|
|
69
|
+
aibrain-setup --api-key YOUR_KEY Configure Claude Code (global)
|
|
70
|
+
aibrain-setup --api-key YOUR_KEY --desktop Configure Claude Desktop
|
|
71
|
+
aibrain-setup --api-key YOUR_KEY --all Configure both
|
|
72
|
+
|
|
73
|
+
Options:
|
|
74
|
+
--api-key KEY Your AI Brain API key (from your dashboard)
|
|
75
|
+
--desktop Configure Claude Desktop
|
|
76
|
+
--all Configure both Claude Code and Claude Desktop
|
|
77
|
+
--help Show this help
|
|
78
|
+
`);
|
|
79
|
+
process.exit(0);
|
|
80
|
+
}
|
|
81
|
+
// Parse --api-key
|
|
82
|
+
const keyIdx = args.indexOf("--api-key");
|
|
83
|
+
if (keyIdx === -1 || !args[keyIdx + 1]) {
|
|
84
|
+
console.error("Error: --api-key is required.\n");
|
|
85
|
+
console.error("Usage: aibrain-setup --api-key YOUR_KEY");
|
|
86
|
+
console.error("Get your key at https://aibrainfront.vercel.app/dashboard");
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
const apiKey = args[keyIdx + 1];
|
|
90
|
+
// Validate API key format
|
|
91
|
+
if (!apiKey.startsWith("ab_live_") || apiKey.length < 20) {
|
|
92
|
+
console.error("Error: Invalid API key format.");
|
|
93
|
+
console.error("Keys start with 'ab_live_' and are 56 characters long.");
|
|
94
|
+
console.error("Get your key at https://aibrainfront.vercel.app/dashboard");
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
const configureDesktop = args.includes("--desktop") || args.includes("--all");
|
|
98
|
+
const configureCode = !args.includes("--desktop") || args.includes("--all");
|
|
99
|
+
console.log("\n AI Brain MCP - Configuration\n");
|
|
100
|
+
// Claude Code (global config)
|
|
101
|
+
if (configureCode) {
|
|
102
|
+
const codePath = getClaudeCodeConfigPath();
|
|
103
|
+
updateConfig(codePath, apiKey);
|
|
104
|
+
console.log(` Claude Code: configured (${codePath})`);
|
|
105
|
+
}
|
|
106
|
+
// Claude Desktop
|
|
107
|
+
if (configureDesktop) {
|
|
108
|
+
const desktopPath = getClaudeDesktopConfigPath();
|
|
109
|
+
if (desktopPath) {
|
|
110
|
+
updateConfig(desktopPath, apiKey);
|
|
111
|
+
console.log(` Claude Desktop: configured (${desktopPath})`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.log(" Claude Desktop: config not found (is it installed?)");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
console.log(`
|
|
118
|
+
Done! Restart Claude to activate AI Brain MCP.
|
|
119
|
+
|
|
120
|
+
Tools available:
|
|
121
|
+
- debate(question) Full multi-AI debate
|
|
122
|
+
- quick_review(question) Quick multi-perspective analysis
|
|
123
|
+
|
|
124
|
+
Dashboard: https://aibrainfront.vercel.app/dashboard
|
|
125
|
+
`);
|
|
126
|
+
}
|
|
127
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aibrain-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for multi-AI debate — Claude, GPT & Gemini collaborate to solve complex problems",
|
|
5
|
+
"author": "AI Brain <contact@aibrain.dev>",
|
|
6
|
+
"homepage": "https://aibrain.dev",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/aibrain-dev/aibrain-mcp"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"bin": {
|
|
13
|
+
"aibrain-mcp": "./dist/index.js",
|
|
14
|
+
"aibrain-setup": "./dist/setup.js"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"prepublishOnly": "npm run build"
|
|
20
|
+
},
|
|
21
|
+
"keywords": ["mcp", "ai", "debate", "claude", "gpt", "gemini", "multi-agent", "claude-code", "claude-desktop"],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/**/*.js",
|
|
25
|
+
"dist/**/*.d.ts",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
33
|
+
"zod": "^3.23.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^22.0.0",
|
|
37
|
+
"typescript": "^5.7.0"
|
|
38
|
+
}
|
|
39
|
+
}
|