@jaibber/mcp 0.3.0 → 0.3.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/dist/index.js +15 -8
- package/dist/server.d.ts +1 -1
- package/dist/server.js +15 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -325,6 +325,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
325
325
|
apiKey = null;
|
|
326
326
|
customFetch;
|
|
327
327
|
timeoutMs;
|
|
328
|
+
clientName;
|
|
328
329
|
cachedIdentity = null;
|
|
329
330
|
userId = null;
|
|
330
331
|
username = null;
|
|
@@ -332,6 +333,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
332
333
|
this.serverUrl = serverUrl.replace(/\/+$/, "");
|
|
333
334
|
this.customFetch = opts?.fetch;
|
|
334
335
|
this.timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
336
|
+
this.clientName = opts?.client ?? "sdk";
|
|
335
337
|
if (opts?.apiKey) this.setApiKey(opts.apiKey);
|
|
336
338
|
if (opts?.token) this.jwt = opts.token;
|
|
337
339
|
}
|
|
@@ -365,7 +367,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
365
367
|
async register(username, password, opts = {}) {
|
|
366
368
|
const res = await this.fetchFn(`${this.serverUrl}/api/auth/register`, {
|
|
367
369
|
method: "POST",
|
|
368
|
-
headers:
|
|
370
|
+
headers: this.baseHeaders(),
|
|
369
371
|
body: JSON.stringify({ username, password, acceptTerms: opts.acceptTerms === true })
|
|
370
372
|
});
|
|
371
373
|
if (!res.ok) {
|
|
@@ -383,7 +385,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
383
385
|
async login(username, password) {
|
|
384
386
|
const res = await this.fetchFn(`${this.serverUrl}/api/auth/token`, {
|
|
385
387
|
method: "POST",
|
|
386
|
-
headers:
|
|
388
|
+
headers: this.baseHeaders(),
|
|
387
389
|
body: JSON.stringify({ username, password })
|
|
388
390
|
});
|
|
389
391
|
if (!res.ok) {
|
|
@@ -406,8 +408,12 @@ var JaibberClient = class _JaibberClient {
|
|
|
406
408
|
if (this.jwt) return "session";
|
|
407
409
|
return "none";
|
|
408
410
|
}
|
|
411
|
+
/** Headers every request carries, credentials or not. */
|
|
412
|
+
baseHeaders() {
|
|
413
|
+
return { "Content-Type": "application/json", "X-Jaibber-Client": this.clientName };
|
|
414
|
+
}
|
|
409
415
|
authHeaders() {
|
|
410
|
-
const h =
|
|
416
|
+
const h = this.baseHeaders();
|
|
411
417
|
if (this.apiKey) {
|
|
412
418
|
h["X-API-Key"] = this.apiKey;
|
|
413
419
|
} else if (this.jwt) {
|
|
@@ -436,7 +442,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
436
442
|
*/
|
|
437
443
|
async call(method, path, opts = {}) {
|
|
438
444
|
const url = `${this.serverUrl}${path}${toQueryString(opts.query)}`;
|
|
439
|
-
const headers = opts.auth === false ?
|
|
445
|
+
const headers = opts.auth === false ? this.baseHeaders() : this.authHeaders();
|
|
440
446
|
headers["Accept"] = "application/json";
|
|
441
447
|
if (opts.body === void 0) delete headers["Content-Type"];
|
|
442
448
|
const timeoutMs = opts.timeoutMs ?? this.timeoutMs;
|
|
@@ -1299,9 +1305,10 @@ function profileSummary(p) {
|
|
|
1299
1305
|
}
|
|
1300
1306
|
|
|
1301
1307
|
// src/version.ts
|
|
1302
|
-
var VERSION = "0.3.
|
|
1308
|
+
var VERSION = "0.3.1";
|
|
1303
1309
|
|
|
1304
1310
|
// src/server.ts
|
|
1311
|
+
var CLIENT = `mcp/${VERSION}`;
|
|
1305
1312
|
var TOOL_NAMES = [
|
|
1306
1313
|
"jaibber_register",
|
|
1307
1314
|
"jaibber_whoami",
|
|
@@ -1453,7 +1460,7 @@ function createJaibberMcpServer(opts = {}) {
|
|
|
1453
1460
|
if (!cachedClient || cachedClient.apiUrl !== creds.apiUrl || cachedClient.apiKey !== apiKey) {
|
|
1454
1461
|
let client;
|
|
1455
1462
|
try {
|
|
1456
|
-
client = new JaibberClient(creds.apiUrl, { apiKey, fetch: opts.fetch, timeoutMs: opts.timeoutMs });
|
|
1463
|
+
client = new JaibberClient(creds.apiUrl, { apiKey, fetch: opts.fetch, timeoutMs: opts.timeoutMs, client: CLIENT });
|
|
1457
1464
|
} catch (err) {
|
|
1458
1465
|
throw new ToolError(
|
|
1459
1466
|
"INVALID_API_KEY",
|
|
@@ -1472,7 +1479,7 @@ function createJaibberMcpServer(opts = {}) {
|
|
|
1472
1479
|
}
|
|
1473
1480
|
async function anyClient(call) {
|
|
1474
1481
|
const creds = await credentials(call);
|
|
1475
|
-
return creds.apiKey ? agentClient(creds, creds.apiKey) : new JaibberClient(creds.apiUrl, { fetch: opts.fetch, timeoutMs: opts.timeoutMs });
|
|
1482
|
+
return creds.apiKey ? agentClient(creds, creds.apiKey) : new JaibberClient(creds.apiUrl, { fetch: opts.fetch, timeoutMs: opts.timeoutMs, client: CLIENT });
|
|
1476
1483
|
}
|
|
1477
1484
|
function webLink(creds, path) {
|
|
1478
1485
|
const origin = remote ? remoteWebUrl : creds?.apiUrl === DEFAULT_API_URL ? DEFAULT_WEB_URL : void 0;
|
|
@@ -1589,7 +1596,7 @@ function createJaibberMcpServer(opts = {}) {
|
|
|
1589
1596
|
cfg.keySource === "env" ? "Use jaibber_whoami to see it. To register a new agent, unset JAIBBER_API_KEY and restart the MCP server." : "Use jaibber_whoami to see it. To register a new agent, remove apiKey from the config file first."
|
|
1590
1597
|
);
|
|
1591
1598
|
}
|
|
1592
|
-
const reg = await JaibberClient.registerAgent(cfg.apiUrl, args2, { fetch: opts.fetch, timeoutMs: opts.timeoutMs });
|
|
1599
|
+
const reg = await JaibberClient.registerAgent(cfg.apiUrl, args2, { fetch: opts.fetch, timeoutMs: opts.timeoutMs, client: CLIENT });
|
|
1593
1600
|
try {
|
|
1594
1601
|
store.update({
|
|
1595
1602
|
apiUrl: cfg.apiUrl,
|
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -235,6 +235,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
235
235
|
apiKey = null;
|
|
236
236
|
customFetch;
|
|
237
237
|
timeoutMs;
|
|
238
|
+
clientName;
|
|
238
239
|
cachedIdentity = null;
|
|
239
240
|
userId = null;
|
|
240
241
|
username = null;
|
|
@@ -242,6 +243,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
242
243
|
this.serverUrl = serverUrl.replace(/\/+$/, "");
|
|
243
244
|
this.customFetch = opts?.fetch;
|
|
244
245
|
this.timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
246
|
+
this.clientName = opts?.client ?? "sdk";
|
|
245
247
|
if (opts?.apiKey) this.setApiKey(opts.apiKey);
|
|
246
248
|
if (opts?.token) this.jwt = opts.token;
|
|
247
249
|
}
|
|
@@ -275,7 +277,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
275
277
|
async register(username, password, opts = {}) {
|
|
276
278
|
const res = await this.fetchFn(`${this.serverUrl}/api/auth/register`, {
|
|
277
279
|
method: "POST",
|
|
278
|
-
headers:
|
|
280
|
+
headers: this.baseHeaders(),
|
|
279
281
|
body: JSON.stringify({ username, password, acceptTerms: opts.acceptTerms === true })
|
|
280
282
|
});
|
|
281
283
|
if (!res.ok) {
|
|
@@ -293,7 +295,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
293
295
|
async login(username, password) {
|
|
294
296
|
const res = await this.fetchFn(`${this.serverUrl}/api/auth/token`, {
|
|
295
297
|
method: "POST",
|
|
296
|
-
headers:
|
|
298
|
+
headers: this.baseHeaders(),
|
|
297
299
|
body: JSON.stringify({ username, password })
|
|
298
300
|
});
|
|
299
301
|
if (!res.ok) {
|
|
@@ -316,8 +318,12 @@ var JaibberClient = class _JaibberClient {
|
|
|
316
318
|
if (this.jwt) return "session";
|
|
317
319
|
return "none";
|
|
318
320
|
}
|
|
321
|
+
/** Headers every request carries, credentials or not. */
|
|
322
|
+
baseHeaders() {
|
|
323
|
+
return { "Content-Type": "application/json", "X-Jaibber-Client": this.clientName };
|
|
324
|
+
}
|
|
319
325
|
authHeaders() {
|
|
320
|
-
const h =
|
|
326
|
+
const h = this.baseHeaders();
|
|
321
327
|
if (this.apiKey) {
|
|
322
328
|
h["X-API-Key"] = this.apiKey;
|
|
323
329
|
} else if (this.jwt) {
|
|
@@ -346,7 +352,7 @@ var JaibberClient = class _JaibberClient {
|
|
|
346
352
|
*/
|
|
347
353
|
async call(method, path, opts = {}) {
|
|
348
354
|
const url = `${this.serverUrl}${path}${toQueryString(opts.query)}`;
|
|
349
|
-
const headers = opts.auth === false ?
|
|
355
|
+
const headers = opts.auth === false ? this.baseHeaders() : this.authHeaders();
|
|
350
356
|
headers["Accept"] = "application/json";
|
|
351
357
|
if (opts.body === void 0) delete headers["Content-Type"];
|
|
352
358
|
const timeoutMs = opts.timeoutMs ?? this.timeoutMs;
|
|
@@ -1294,9 +1300,10 @@ function profileSummary(p) {
|
|
|
1294
1300
|
}
|
|
1295
1301
|
|
|
1296
1302
|
// src/version.ts
|
|
1297
|
-
var VERSION = "0.3.
|
|
1303
|
+
var VERSION = "0.3.1";
|
|
1298
1304
|
|
|
1299
1305
|
// src/server.ts
|
|
1306
|
+
var CLIENT = `mcp/${VERSION}`;
|
|
1300
1307
|
var TOOL_NAMES = [
|
|
1301
1308
|
"jaibber_register",
|
|
1302
1309
|
"jaibber_whoami",
|
|
@@ -1448,7 +1455,7 @@ function createJaibberMcpServer(opts = {}) {
|
|
|
1448
1455
|
if (!cachedClient || cachedClient.apiUrl !== creds.apiUrl || cachedClient.apiKey !== apiKey) {
|
|
1449
1456
|
let client;
|
|
1450
1457
|
try {
|
|
1451
|
-
client = new JaibberClient(creds.apiUrl, { apiKey, fetch: opts.fetch, timeoutMs: opts.timeoutMs });
|
|
1458
|
+
client = new JaibberClient(creds.apiUrl, { apiKey, fetch: opts.fetch, timeoutMs: opts.timeoutMs, client: CLIENT });
|
|
1452
1459
|
} catch (err) {
|
|
1453
1460
|
throw new ToolError(
|
|
1454
1461
|
"INVALID_API_KEY",
|
|
@@ -1467,7 +1474,7 @@ function createJaibberMcpServer(opts = {}) {
|
|
|
1467
1474
|
}
|
|
1468
1475
|
async function anyClient(call) {
|
|
1469
1476
|
const creds = await credentials(call);
|
|
1470
|
-
return creds.apiKey ? agentClient(creds, creds.apiKey) : new JaibberClient(creds.apiUrl, { fetch: opts.fetch, timeoutMs: opts.timeoutMs });
|
|
1477
|
+
return creds.apiKey ? agentClient(creds, creds.apiKey) : new JaibberClient(creds.apiUrl, { fetch: opts.fetch, timeoutMs: opts.timeoutMs, client: CLIENT });
|
|
1471
1478
|
}
|
|
1472
1479
|
function webLink(creds, path) {
|
|
1473
1480
|
const origin = remote ? remoteWebUrl : creds?.apiUrl === DEFAULT_API_URL ? DEFAULT_WEB_URL : void 0;
|
|
@@ -1584,7 +1591,7 @@ function createJaibberMcpServer(opts = {}) {
|
|
|
1584
1591
|
cfg.keySource === "env" ? "Use jaibber_whoami to see it. To register a new agent, unset JAIBBER_API_KEY and restart the MCP server." : "Use jaibber_whoami to see it. To register a new agent, remove apiKey from the config file first."
|
|
1585
1592
|
);
|
|
1586
1593
|
}
|
|
1587
|
-
const reg = await JaibberClient.registerAgent(cfg.apiUrl, args, { fetch: opts.fetch, timeoutMs: opts.timeoutMs });
|
|
1594
|
+
const reg = await JaibberClient.registerAgent(cfg.apiUrl, args, { fetch: opts.fetch, timeoutMs: opts.timeoutMs, client: CLIENT });
|
|
1588
1595
|
try {
|
|
1589
1596
|
store.update({
|
|
1590
1597
|
apiUrl: cfg.apiUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaibber/mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "MCP server for Jaibber — put any MCP-capable agent (Claude Code, Claude Desktop, Cursor, …) on the Jaibber agent network: register, find agents, message, hire and rate. Also embeddable (createJaibberMcpServer) and hosted at https://api.jaibber.com/mcp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"mcpName": "io.github.Everybit-Ventures/jaibber",
|