@rb2b/rb2b-apis-mcp 1.1.1 → 1.1.3

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.
Files changed (3) hide show
  1. package/README.md +23 -11
  2. package/dist/init.js +66 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,7 @@ Resolve IP addresses to companies, look up LinkedIn profiles from emails, find c
8
8
 
9
9
  ## Requirements
10
10
 
11
+ - **An MCP-compatible AI client** — [Claude Desktop](https://claude.ai/download) or [Claude Code](https://claude.ai/code) must be installed before setting up this server
11
12
  - Node.js 18+
12
13
  - An [RB2B APIs](https://ui.api.rb2b.com) account and API key. Don't have an account? Get your first 100 credits for just $9.
13
14
 
@@ -15,19 +16,36 @@ Resolve IP addresses to companies, look up LinkedIn profiles from emails, find c
15
16
 
16
17
  ## Quick Start
17
18
 
18
- ### 1. Initialize
19
+ ### 1. Install Claude Desktop or Claude Code
19
20
 
20
- Run the setup wizard to configure your API key:
21
+ This server requires an MCP-compatible client. Install one first:
22
+
23
+ - **[Claude Desktop](https://claude.ai/download)** — the Claude desktop app for macOS and Windows
24
+ - **[Claude Code](https://claude.ai/code)** — the Claude CLI for developers
25
+
26
+ ### 2. Run the setup wizard
21
27
 
22
28
  ```bash
23
29
  npx @rb2b/rb2b-apis-mcp init
24
30
  ```
25
31
 
26
- This will prompt for your RB2B API key, validate it against the API, and store it securely in `~/.rb2b/config.json` (permissions: `600`).
32
+ This will:
33
+ - Prompt for your RB2B API key and validate it
34
+ - Store it securely in `~/.rb2b/config.json` (permissions: `600`)
35
+ - Automatically register the server with Claude Code and Claude Desktop if detected
36
+
37
+ That's it. No manual config editing needed in most cases.
38
+
39
+ ### Manual registration (if needed)
27
40
 
28
- ### 2. Add to Claude Desktop
41
+ If auto-registration didn't run or you're using a different MCP client:
29
42
 
30
- Edit your Claude Desktop config file:
43
+ **Claude Code:**
44
+ ```bash
45
+ claude mcp add rb2b -- npx @rb2b/rb2b-apis-mcp
46
+ ```
47
+
48
+ **Claude Desktop** — edit your config file:
31
49
 
32
50
  - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
33
51
  - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
@@ -45,12 +63,6 @@ Edit your Claude Desktop config file:
45
63
 
46
64
  Restart Claude Desktop after saving.
47
65
 
48
- ### 3. Add to Claude Code
49
-
50
- ```bash
51
- claude mcp add rb2b -- npx @rb2b/rb2b-apis-mcp
52
- ```
53
-
54
66
  ---
55
67
 
56
68
  ## Tools
package/dist/init.js CHANGED
@@ -1,10 +1,61 @@
1
1
  #!/usr/bin/env node
2
2
  import { createInterface } from "readline";
3
+ import { spawnSync } from "child_process";
4
+ import { existsSync, readFileSync, writeFileSync } from "fs";
5
+ import { homedir, platform } from "os";
6
+ import { join } from "path";
3
7
  import { BASE_URL, loadConfig, saveConfig } from "./config.js";
4
8
  const rl = createInterface({ input: process.stdin, output: process.stdout });
5
9
  function prompt(question) {
6
10
  return new Promise((resolve) => rl.question(question, resolve));
7
11
  }
12
+ function registerClaudeCode() {
13
+ // Check if the claude CLI is available.
14
+ const check = spawnSync("claude", ["mcp", "list"], { encoding: "utf-8" });
15
+ if (check.error || check.status !== 0)
16
+ return;
17
+ // Skip if already registered.
18
+ if (check.stdout?.includes("rb2b")) {
19
+ console.log("Claude Code: already registered.");
20
+ return;
21
+ }
22
+ const result = spawnSync("claude", ["mcp", "add", "rb2b", "--", "npx", "@rb2b/rb2b-apis-mcp"], { encoding: "utf-8" });
23
+ if (result.error || result.status !== 0) {
24
+ console.log("Claude Code: could not auto-register. Run manually:");
25
+ console.log(" claude mcp add rb2b -- npx @rb2b/rb2b-apis-mcp");
26
+ }
27
+ else {
28
+ console.log("Claude Code: registered successfully.");
29
+ }
30
+ }
31
+ function registerClaudeDesktop() {
32
+ const configPath = platform() === "win32"
33
+ ? join(process.env.APPDATA ?? homedir(), "Claude", "claude_desktop_config.json")
34
+ : join(homedir(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
35
+ if (!existsSync(configPath))
36
+ return;
37
+ let config = {};
38
+ try {
39
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
40
+ }
41
+ catch {
42
+ return;
43
+ }
44
+ const mcpServers = (config.mcpServers ?? {});
45
+ if (mcpServers.rb2b) {
46
+ console.log("Claude Desktop: already registered.");
47
+ return;
48
+ }
49
+ mcpServers.rb2b = { command: "npx", args: ["@rb2b/rb2b-apis-mcp"] };
50
+ config.mcpServers = mcpServers;
51
+ try {
52
+ writeFileSync(configPath, JSON.stringify(config, null, 2));
53
+ console.log("Claude Desktop: registered successfully. Restart Claude Desktop to apply.");
54
+ }
55
+ catch {
56
+ console.log("Claude Desktop: could not auto-register. Add manually to:", configPath);
57
+ }
58
+ }
8
59
  async function main() {
9
60
  const existing = loadConfig();
10
61
  if (existing) {
@@ -16,15 +67,23 @@ async function main() {
16
67
  console.log("RB2B MCP Server — Initial Setup");
17
68
  console.log("=================================\n");
18
69
  }
19
- const apiKey = await prompt("Enter your RB2B API key: ");
20
- if (!apiKey.trim()) {
70
+ const input = await prompt(existing
71
+ ? "Enter a new RB2B API key (or press Enter to keep the existing one): "
72
+ : "Enter your RB2B API key: ");
73
+ if (!input.trim()) {
74
+ if (existing) {
75
+ console.log("\nKeeping existing API key. No changes made.");
76
+ rl.close();
77
+ process.exit(0);
78
+ }
21
79
  console.error("Error: API key cannot be empty.");
22
80
  process.exit(1);
23
81
  }
82
+ const apiKey = input.trim();
24
83
  console.log("\nValidating API key...");
25
84
  try {
26
85
  const res = await fetch(`${BASE_URL}/credits`, {
27
- headers: { "Api-Key": apiKey.trim() },
86
+ headers: { "Api-Key": apiKey },
28
87
  });
29
88
  if (!res.ok) {
30
89
  const text = await res.text().catch(() => res.statusText);
@@ -34,17 +93,11 @@ async function main() {
34
93
  const data = await res.json();
35
94
  console.log("\nAPI key valid!");
36
95
  console.log("Credits info:", JSON.stringify(data, null, 2));
37
- saveConfig({ apiKey: apiKey.trim() });
96
+ saveConfig({ apiKey });
38
97
  console.log("\nConfiguration saved to ~/.rb2b/config.json");
39
- console.log("\nYou can now add the MCP server to your Claude config:\n");
40
- console.log(JSON.stringify({
41
- mcpServers: {
42
- rb2b: {
43
- command: "npx",
44
- args: ["@rb2b/rb2b-apis-mcp"],
45
- },
46
- },
47
- }, null, 2));
98
+ console.log("\nRegistering with MCP clients...");
99
+ registerClaudeCode();
100
+ registerClaudeDesktop();
48
101
  }
49
102
  catch (err) {
50
103
  const message = err instanceof Error ? err.message : String(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rb2b/rb2b-apis-mcp",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "MCP server exposing RB2B API tools for identity resolution and enrichment",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",