@jive-ai/cli 0.0.13 → 0.0.15
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.mjs +70 -38
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
|
17
17
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
18
18
|
import fs$1 from "fs";
|
|
19
19
|
import { fileURLToPath } from "url";
|
|
20
|
+
import dedent from "dedent";
|
|
20
21
|
|
|
21
22
|
//#region src/lib/config.ts
|
|
22
23
|
const CREDENTIALS_PATH = path.join(os.homedir(), ".jive", "credentials.json");
|
|
@@ -719,7 +720,10 @@ async function initCommand() {
|
|
|
719
720
|
}
|
|
720
721
|
}
|
|
721
722
|
spinner.text = "Adding Jive server to .mcp.json...";
|
|
722
|
-
await addMcpServer("jive-mcp", {
|
|
723
|
+
await addMcpServer("jive-mcp", {
|
|
724
|
+
command: "jive",
|
|
725
|
+
args: ["mcp", "start"]
|
|
726
|
+
});
|
|
723
727
|
spinner.text = "Removing uploaded MCP servers from local .mcp.json...";
|
|
724
728
|
if (mcpConfig?.mcpServers) {
|
|
725
729
|
const serversToRemove = [...uploadedServers.map((server) => server.name), ...skippedServers.map((server) => server.name)];
|
|
@@ -1176,6 +1180,13 @@ function generateToolId(serverName, toolName) {
|
|
|
1176
1180
|
return `${serverName}__${toolName}`;
|
|
1177
1181
|
}
|
|
1178
1182
|
|
|
1183
|
+
//#endregion
|
|
1184
|
+
//#region src/utils/truncateString.ts
|
|
1185
|
+
function truncateString(str, maxLength) {
|
|
1186
|
+
if (str.length <= maxLength) return str;
|
|
1187
|
+
return `${str.slice(0, maxLength)}...`;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1179
1190
|
//#endregion
|
|
1180
1191
|
//#region src/mcp/connection-manager.ts
|
|
1181
1192
|
/**
|
|
@@ -1270,6 +1281,13 @@ var McpConnectionManager = class {
|
|
|
1270
1281
|
}
|
|
1271
1282
|
return results;
|
|
1272
1283
|
}
|
|
1284
|
+
listTools(serverName) {
|
|
1285
|
+
return Array.from(this.tools.values()).filter((tool) => tool.serverName === serverName).map((tool) => ({
|
|
1286
|
+
id: tool.id,
|
|
1287
|
+
name: tool.toolName,
|
|
1288
|
+
description: truncateString(tool.description, 100)
|
|
1289
|
+
}));
|
|
1290
|
+
}
|
|
1273
1291
|
/**
|
|
1274
1292
|
* Get full tool definitions including TypeScript code
|
|
1275
1293
|
*/
|
|
@@ -1344,7 +1362,8 @@ function log(...args) {
|
|
|
1344
1362
|
*/
|
|
1345
1363
|
async function startMcpServer() {
|
|
1346
1364
|
log("=== Jive Server Starting ===");
|
|
1347
|
-
|
|
1365
|
+
const teamId = (await getProjectConfig())?.activeTeamId;
|
|
1366
|
+
if (!teamId) {
|
|
1348
1367
|
log("Error: No team ID found, select one with `jive team switch`");
|
|
1349
1368
|
process.exit(1);
|
|
1350
1369
|
return;
|
|
@@ -1358,20 +1377,9 @@ async function startMcpServer() {
|
|
|
1358
1377
|
const apiUrl = API_URL;
|
|
1359
1378
|
log(`Jive server connecting to ${apiUrl}`);
|
|
1360
1379
|
const connectionManager = new McpConnectionManager();
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
headers: { "X-API-Key": apiKey }
|
|
1365
|
-
});
|
|
1366
|
-
if (!response.ok) throw new Error(`Failed to fetch MCP configs: ${response.status} ${response.statusText}`);
|
|
1367
|
-
const { servers } = await response.json();
|
|
1368
|
-
log(`Found ${servers.length} MCP server config(s)`);
|
|
1369
|
-
if (servers.length > 0) await connectionManager.initialize(servers);
|
|
1370
|
-
else log("No MCP servers configured for this team");
|
|
1371
|
-
} catch (error) {
|
|
1372
|
-
log("Error fetching MCP configs:", error);
|
|
1373
|
-
log("Continuing without MCP tool connections...");
|
|
1374
|
-
}
|
|
1380
|
+
const mcpServers = await getApiClient().getMcpServers(teamId);
|
|
1381
|
+
if (mcpServers.length > 0) await connectionManager.initialize(mcpServers);
|
|
1382
|
+
else log("No MCP servers configured for this team");
|
|
1375
1383
|
const server = new Server({
|
|
1376
1384
|
name: "jive-mcp",
|
|
1377
1385
|
version: "1.0.0"
|
|
@@ -1379,16 +1387,8 @@ async function startMcpServer() {
|
|
|
1379
1387
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
1380
1388
|
return { tools: [
|
|
1381
1389
|
{
|
|
1382
|
-
name: "
|
|
1383
|
-
description: "
|
|
1384
|
-
inputSchema: {
|
|
1385
|
-
type: "object",
|
|
1386
|
-
properties: { query: {
|
|
1387
|
-
type: "string",
|
|
1388
|
-
description: "Search query for subagents"
|
|
1389
|
-
} },
|
|
1390
|
-
required: ["query"]
|
|
1391
|
-
}
|
|
1390
|
+
name: "list_subagents",
|
|
1391
|
+
description: "List all subagents for the selected team. Returns lightweight list of subagent names, descriptions and IDs."
|
|
1392
1392
|
},
|
|
1393
1393
|
{
|
|
1394
1394
|
name: "call_subagent",
|
|
@@ -1409,15 +1409,19 @@ async function startMcpServer() {
|
|
|
1409
1409
|
}
|
|
1410
1410
|
},
|
|
1411
1411
|
{
|
|
1412
|
-
name: "
|
|
1413
|
-
description: "
|
|
1412
|
+
name: "list_mcp_servers",
|
|
1413
|
+
description: "List all MCP servers for the selected team. Returns lightweight list of server names, descriptions and IDs."
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
name: "list_tools",
|
|
1417
|
+
description: "List all MCP tools for the selected team. Returns lightweight list of tool names, descriptions and IDs.",
|
|
1414
1418
|
inputSchema: {
|
|
1415
1419
|
type: "object",
|
|
1416
|
-
properties: {
|
|
1420
|
+
properties: { server: {
|
|
1417
1421
|
type: "string",
|
|
1418
|
-
description: "
|
|
1422
|
+
description: "MCP server name to list tools for"
|
|
1419
1423
|
} },
|
|
1420
|
-
required: ["
|
|
1424
|
+
required: ["server"]
|
|
1421
1425
|
}
|
|
1422
1426
|
},
|
|
1423
1427
|
{
|
|
@@ -1440,7 +1444,26 @@ async function startMcpServer() {
|
|
|
1440
1444
|
type: "object",
|
|
1441
1445
|
properties: { code: {
|
|
1442
1446
|
type: "string",
|
|
1443
|
-
description:
|
|
1447
|
+
description: dedent`
|
|
1448
|
+
TypeScript code to execute. Must call the \`callMcpTool\` function to call MCP tools.
|
|
1449
|
+
If applicable, write code that transforms the result of the tool call into your desired output to save tokens.
|
|
1450
|
+
|
|
1451
|
+
Don't import \`callMcpTool\` -- it is injected into the execution environment.
|
|
1452
|
+
You can call multiple MCP tools if you wish. You must include the relevant TypeScript definitions returned by the \`get_tools\` tool.
|
|
1453
|
+
Return the value you want to return to agent context.
|
|
1454
|
+
|
|
1455
|
+
Example:
|
|
1456
|
+
|
|
1457
|
+
\`\`\`ts
|
|
1458
|
+
// With code execution - filter in the execution environment
|
|
1459
|
+
const allRows = await callMcpTool('gdrive', 'getSheet', { sheetId: 'abc123' });
|
|
1460
|
+
const pendingOrders = allRows.filter(row =>
|
|
1461
|
+
row["Status"] === 'pending'
|
|
1462
|
+
);
|
|
1463
|
+
console.log(\`Found \${pendingOrders.length} pending orders\`);
|
|
1464
|
+
return pendingOrders.slice(0, 5); // Only log first 5 for review
|
|
1465
|
+
\`\`\`
|
|
1466
|
+
`
|
|
1444
1467
|
} },
|
|
1445
1468
|
required: ["code"]
|
|
1446
1469
|
}
|
|
@@ -1480,8 +1503,8 @@ async function startMcpServer() {
|
|
|
1480
1503
|
try {
|
|
1481
1504
|
if (!args) throw new Error("Missing arguments");
|
|
1482
1505
|
switch (name) {
|
|
1483
|
-
case "
|
|
1484
|
-
const results = await apiRequest(
|
|
1506
|
+
case "list_subagents": {
|
|
1507
|
+
const results = await apiRequest(`/api/teams/${teamId}/subagents`);
|
|
1485
1508
|
return { content: [{
|
|
1486
1509
|
type: "text",
|
|
1487
1510
|
text: JSON.stringify(results, null, 2)
|
|
@@ -1491,8 +1514,16 @@ async function startMcpServer() {
|
|
|
1491
1514
|
type: "text",
|
|
1492
1515
|
text: (await apiRequest(`/api/subagents/${args.id}/call`, { prompt: args.prompt })).prompt
|
|
1493
1516
|
}] };
|
|
1494
|
-
case "
|
|
1495
|
-
const
|
|
1517
|
+
case "list_mcp_servers": {
|
|
1518
|
+
const serverQuery = args.server;
|
|
1519
|
+
const results = mcpServers.filter((server$1) => [server$1.id, server$1.name].some((name$1) => name$1.toLowerCase().includes(serverQuery.toLowerCase())));
|
|
1520
|
+
return { content: [{
|
|
1521
|
+
type: "text",
|
|
1522
|
+
text: JSON.stringify(results, null, 2)
|
|
1523
|
+
}] };
|
|
1524
|
+
}
|
|
1525
|
+
case "list_tools": {
|
|
1526
|
+
const results = connectionManager.listTools(args.server);
|
|
1496
1527
|
return { content: [{
|
|
1497
1528
|
type: "text",
|
|
1498
1529
|
text: JSON.stringify(results, null, 2)
|
|
@@ -1509,7 +1540,8 @@ async function startMcpServer() {
|
|
|
1509
1540
|
code = code.replace(/import\s+.*?from\s+['"].*?['"];?\s*/g, "");
|
|
1510
1541
|
const result = ts.transpileModule(code, { compilerOptions: {
|
|
1511
1542
|
module: ts.ModuleKind.ESNext,
|
|
1512
|
-
target: ts.ScriptTarget.ES2020
|
|
1543
|
+
target: ts.ScriptTarget.ES2020,
|
|
1544
|
+
strict: true
|
|
1513
1545
|
} });
|
|
1514
1546
|
if (result.diagnostics && result.diagnostics.length > 0) return {
|
|
1515
1547
|
content: [{
|
|
@@ -2063,7 +2095,7 @@ async function checkTeamMembership() {
|
|
|
2063
2095
|
|
|
2064
2096
|
//#endregion
|
|
2065
2097
|
//#region package.json
|
|
2066
|
-
var version = "0.0.
|
|
2098
|
+
var version = "0.0.14";
|
|
2067
2099
|
|
|
2068
2100
|
//#endregion
|
|
2069
2101
|
//#region src/index.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@jive-ai/cli",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"axios": "^1.13.2",
|
|
31
31
|
"chalk": "^5.6.2",
|
|
32
32
|
"commander": "^14.0.2",
|
|
33
|
+
"dedent": "^1.7.0",
|
|
33
34
|
"gray-matter": "^4.0.3",
|
|
34
35
|
"ora": "^9.0.0",
|
|
35
36
|
"prompts": "^2.4.2",
|