@contextstream/mcp-server 0.3.71 → 0.3.73
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 +513 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8282,6 +8282,235 @@ function getRecommendedToolset(clientName, fromEnv) {
|
|
|
8282
8282
|
}
|
|
8283
8283
|
var detectedClientInfo = null;
|
|
8284
8284
|
var clientDetectedFromEnv = false;
|
|
8285
|
+
var PROGRESSIVE_MODE = process.env.CONTEXTSTREAM_PROGRESSIVE_MODE === "true";
|
|
8286
|
+
var TOOL_BUNDLES = {
|
|
8287
|
+
// Core bundle (~12 tools) - always enabled, essential for any session
|
|
8288
|
+
core: /* @__PURE__ */ new Set([
|
|
8289
|
+
"session_init",
|
|
8290
|
+
"session_tools",
|
|
8291
|
+
"context_smart",
|
|
8292
|
+
"context_feedback",
|
|
8293
|
+
"session_capture",
|
|
8294
|
+
"session_capture_lesson",
|
|
8295
|
+
"session_get_lessons",
|
|
8296
|
+
"session_recall",
|
|
8297
|
+
"session_remember",
|
|
8298
|
+
"session_get_user_context",
|
|
8299
|
+
"tools_enable_bundle",
|
|
8300
|
+
// Meta-tool to enable other bundles
|
|
8301
|
+
"auth_me",
|
|
8302
|
+
"mcp_server_version"
|
|
8303
|
+
]),
|
|
8304
|
+
// Session bundle (~6 tools) - extended session management
|
|
8305
|
+
session: /* @__PURE__ */ new Set([
|
|
8306
|
+
"session_summary",
|
|
8307
|
+
"session_smart_search",
|
|
8308
|
+
"session_compress",
|
|
8309
|
+
"session_delta",
|
|
8310
|
+
"decision_trace",
|
|
8311
|
+
"generate_editor_rules"
|
|
8312
|
+
]),
|
|
8313
|
+
// Memory bundle (~12 tools) - full memory CRUD operations
|
|
8314
|
+
memory: /* @__PURE__ */ new Set([
|
|
8315
|
+
"memory_create_event",
|
|
8316
|
+
"memory_update_event",
|
|
8317
|
+
"memory_delete_event",
|
|
8318
|
+
"memory_list_events",
|
|
8319
|
+
"memory_get_event",
|
|
8320
|
+
"memory_search",
|
|
8321
|
+
"memory_decisions",
|
|
8322
|
+
"memory_timeline",
|
|
8323
|
+
"memory_summary",
|
|
8324
|
+
"memory_create_node",
|
|
8325
|
+
"memory_update_node",
|
|
8326
|
+
"memory_delete_node",
|
|
8327
|
+
"memory_list_nodes",
|
|
8328
|
+
"memory_get_node",
|
|
8329
|
+
"memory_supersede_node",
|
|
8330
|
+
"memory_distill_event"
|
|
8331
|
+
]),
|
|
8332
|
+
// Search bundle (~4 tools) - search capabilities
|
|
8333
|
+
search: /* @__PURE__ */ new Set([
|
|
8334
|
+
"search_semantic",
|
|
8335
|
+
"search_hybrid",
|
|
8336
|
+
"search_keyword"
|
|
8337
|
+
]),
|
|
8338
|
+
// Graph bundle (~9 tools) - code graph analysis
|
|
8339
|
+
graph: /* @__PURE__ */ new Set([
|
|
8340
|
+
"graph_related",
|
|
8341
|
+
"graph_decisions",
|
|
8342
|
+
"graph_path",
|
|
8343
|
+
"graph_dependencies",
|
|
8344
|
+
"graph_call_path",
|
|
8345
|
+
"graph_impact",
|
|
8346
|
+
"graph_circular_dependencies",
|
|
8347
|
+
"graph_unused_code",
|
|
8348
|
+
"graph_ingest"
|
|
8349
|
+
]),
|
|
8350
|
+
// Workspace bundle (~4 tools) - workspace management
|
|
8351
|
+
workspace: /* @__PURE__ */ new Set([
|
|
8352
|
+
"workspaces_list",
|
|
8353
|
+
"workspaces_get",
|
|
8354
|
+
"workspace_associate",
|
|
8355
|
+
"workspace_bootstrap"
|
|
8356
|
+
]),
|
|
8357
|
+
// Project bundle (~10 tools) - project management and indexing
|
|
8358
|
+
project: /* @__PURE__ */ new Set([
|
|
8359
|
+
"projects_create",
|
|
8360
|
+
"projects_update",
|
|
8361
|
+
"projects_list",
|
|
8362
|
+
"projects_get",
|
|
8363
|
+
"projects_overview",
|
|
8364
|
+
"projects_statistics",
|
|
8365
|
+
"projects_index",
|
|
8366
|
+
"projects_index_status",
|
|
8367
|
+
"projects_files",
|
|
8368
|
+
"projects_ingest_local"
|
|
8369
|
+
]),
|
|
8370
|
+
// Reminders bundle (~6 tools) - reminder management
|
|
8371
|
+
reminders: /* @__PURE__ */ new Set([
|
|
8372
|
+
"reminders_list",
|
|
8373
|
+
"reminders_active",
|
|
8374
|
+
"reminders_create",
|
|
8375
|
+
"reminders_snooze",
|
|
8376
|
+
"reminders_complete",
|
|
8377
|
+
"reminders_dismiss"
|
|
8378
|
+
]),
|
|
8379
|
+
// Integrations bundle - Slack/GitHub tools (auto-hidden when not connected)
|
|
8380
|
+
integrations: /* @__PURE__ */ new Set([
|
|
8381
|
+
"slack_stats",
|
|
8382
|
+
"slack_channels",
|
|
8383
|
+
"slack_search",
|
|
8384
|
+
"slack_discussions",
|
|
8385
|
+
"slack_activity",
|
|
8386
|
+
"slack_contributors",
|
|
8387
|
+
"slack_knowledge",
|
|
8388
|
+
"slack_summary",
|
|
8389
|
+
"slack_sync_users",
|
|
8390
|
+
"github_stats",
|
|
8391
|
+
"github_repos",
|
|
8392
|
+
"github_search",
|
|
8393
|
+
"github_issues",
|
|
8394
|
+
"github_activity",
|
|
8395
|
+
"github_contributors",
|
|
8396
|
+
"github_knowledge",
|
|
8397
|
+
"github_summary",
|
|
8398
|
+
"integrations_status",
|
|
8399
|
+
"integrations_search",
|
|
8400
|
+
"integrations_summary",
|
|
8401
|
+
"integrations_knowledge"
|
|
8402
|
+
])
|
|
8403
|
+
};
|
|
8404
|
+
var enabledBundles = /* @__PURE__ */ new Set(["core"]);
|
|
8405
|
+
function isToolInEnabledBundles(toolName) {
|
|
8406
|
+
for (const bundleName of enabledBundles) {
|
|
8407
|
+
const bundle = TOOL_BUNDLES[bundleName];
|
|
8408
|
+
if (bundle?.has(toolName)) {
|
|
8409
|
+
return true;
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8412
|
+
return false;
|
|
8413
|
+
}
|
|
8414
|
+
function getBundleInfo() {
|
|
8415
|
+
const descriptions = {
|
|
8416
|
+
core: "Essential session tools (always enabled)",
|
|
8417
|
+
session: "Extended session management and utilities",
|
|
8418
|
+
memory: "Full memory CRUD operations",
|
|
8419
|
+
search: "Semantic, hybrid, and keyword search",
|
|
8420
|
+
graph: "Code graph analysis and dependencies",
|
|
8421
|
+
workspace: "Workspace management",
|
|
8422
|
+
project: "Project management and indexing",
|
|
8423
|
+
reminders: "Reminder management",
|
|
8424
|
+
integrations: "Slack and GitHub integrations"
|
|
8425
|
+
};
|
|
8426
|
+
return Object.entries(TOOL_BUNDLES).map(([name, tools]) => ({
|
|
8427
|
+
name,
|
|
8428
|
+
size: tools.size,
|
|
8429
|
+
enabled: enabledBundles.has(name),
|
|
8430
|
+
description: descriptions[name] || `${name} tools`
|
|
8431
|
+
}));
|
|
8432
|
+
}
|
|
8433
|
+
var deferredTools = /* @__PURE__ */ new Map();
|
|
8434
|
+
var ROUTER_MODE = process.env.CONTEXTSTREAM_ROUTER_MODE === "true";
|
|
8435
|
+
var operationsRegistry = /* @__PURE__ */ new Map();
|
|
8436
|
+
function inferOperationCategory(name) {
|
|
8437
|
+
if (name.startsWith("session_") || name.startsWith("context_")) return "Session";
|
|
8438
|
+
if (name.startsWith("memory_")) return "Memory";
|
|
8439
|
+
if (name.startsWith("search_")) return "Search";
|
|
8440
|
+
if (name.startsWith("graph_")) return "Graph";
|
|
8441
|
+
if (name.startsWith("workspace")) return "Workspace";
|
|
8442
|
+
if (name.startsWith("project")) return "Project";
|
|
8443
|
+
if (name.startsWith("reminder")) return "Reminders";
|
|
8444
|
+
if (name.startsWith("slack_") || name.startsWith("github_") || name.startsWith("integration")) return "Integrations";
|
|
8445
|
+
if (name.startsWith("ai_")) return "AI";
|
|
8446
|
+
if (name === "auth_me" || name === "mcp_server_version" || name === "generate_editor_rules") return "Utility";
|
|
8447
|
+
if (name === "tools_enable_bundle" || name === "contextstream" || name === "contextstream_help") return "Meta";
|
|
8448
|
+
return "Other";
|
|
8449
|
+
}
|
|
8450
|
+
function getOperationCatalog(category) {
|
|
8451
|
+
const ops = {};
|
|
8452
|
+
for (const [name, config] of operationsRegistry) {
|
|
8453
|
+
const cat = config.category;
|
|
8454
|
+
if (category && cat.toLowerCase() !== category.toLowerCase()) continue;
|
|
8455
|
+
if (!ops[cat]) ops[cat] = [];
|
|
8456
|
+
ops[cat].push(name);
|
|
8457
|
+
}
|
|
8458
|
+
const lines = [];
|
|
8459
|
+
for (const [cat, names] of Object.entries(ops).sort()) {
|
|
8460
|
+
lines.push(`${cat}: ${names.join(", ")}`);
|
|
8461
|
+
}
|
|
8462
|
+
return lines.join("\n");
|
|
8463
|
+
}
|
|
8464
|
+
function getOperationSchema(name) {
|
|
8465
|
+
const op = operationsRegistry.get(name);
|
|
8466
|
+
if (!op) return null;
|
|
8467
|
+
const zodSchema = op.inputSchema;
|
|
8468
|
+
try {
|
|
8469
|
+
const shape = zodSchema?._def?.shape?.() || zodSchema?.shape || {};
|
|
8470
|
+
const properties = {};
|
|
8471
|
+
const required = [];
|
|
8472
|
+
for (const [key, field] of Object.entries(shape)) {
|
|
8473
|
+
const f = field;
|
|
8474
|
+
const isOptional = f?._def?.typeName === "ZodOptional" || f?.isOptional?.();
|
|
8475
|
+
const innerType = isOptional ? f?._def?.innerType : f;
|
|
8476
|
+
const typeName = innerType?._def?.typeName || "unknown";
|
|
8477
|
+
const description = f?._def?.description || innerType?._def?.description;
|
|
8478
|
+
let type = "string";
|
|
8479
|
+
if (typeName === "ZodNumber") type = "number";
|
|
8480
|
+
else if (typeName === "ZodBoolean") type = "boolean";
|
|
8481
|
+
else if (typeName === "ZodArray") type = "array";
|
|
8482
|
+
else if (typeName === "ZodObject") type = "object";
|
|
8483
|
+
else if (typeName === "ZodEnum") type = "enum";
|
|
8484
|
+
properties[key] = { type };
|
|
8485
|
+
if (description) properties[key].description = description;
|
|
8486
|
+
if (typeName === "ZodEnum") {
|
|
8487
|
+
properties[key].enum = innerType?._def?.values;
|
|
8488
|
+
}
|
|
8489
|
+
if (!isOptional) required.push(key);
|
|
8490
|
+
}
|
|
8491
|
+
return {
|
|
8492
|
+
name: op.name,
|
|
8493
|
+
title: op.title,
|
|
8494
|
+
description: op.description,
|
|
8495
|
+
category: op.category,
|
|
8496
|
+
schema: {
|
|
8497
|
+
type: "object",
|
|
8498
|
+
properties,
|
|
8499
|
+
required: required.length > 0 ? required : void 0
|
|
8500
|
+
}
|
|
8501
|
+
};
|
|
8502
|
+
} catch {
|
|
8503
|
+
return {
|
|
8504
|
+
name: op.name,
|
|
8505
|
+
title: op.title,
|
|
8506
|
+
description: op.description,
|
|
8507
|
+
category: op.category,
|
|
8508
|
+
schema: { type: "object" }
|
|
8509
|
+
};
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
var OUTPUT_FORMAT = process.env.CONTEXTSTREAM_OUTPUT_FORMAT || "compact";
|
|
8513
|
+
var COMPACT_OUTPUT = OUTPUT_FORMAT === "compact";
|
|
8285
8514
|
var TOOLSET_ALIASES = {
|
|
8286
8515
|
// Light mode - minimal, fastest
|
|
8287
8516
|
light: LIGHT_TOOLSET,
|
|
@@ -8344,8 +8573,9 @@ function resolveToolFilter() {
|
|
|
8344
8573
|
console.error(`[ContextStream] Unknown CONTEXTSTREAM_TOOLSET "${toolsetRaw}". Using standard toolset.`);
|
|
8345
8574
|
return { allowlist: STANDARD_TOOLSET, source: "standard", autoDetected: false };
|
|
8346
8575
|
}
|
|
8347
|
-
function formatContent(data) {
|
|
8348
|
-
|
|
8576
|
+
function formatContent(data, forceFormat) {
|
|
8577
|
+
const usePretty = forceFormat === "pretty" || !forceFormat && !COMPACT_OUTPUT;
|
|
8578
|
+
return usePretty ? JSON.stringify(data, null, 2) : JSON.stringify(data);
|
|
8349
8579
|
}
|
|
8350
8580
|
function toStructured(data) {
|
|
8351
8581
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
@@ -8478,6 +8708,21 @@ function registerTools(server, client, sessionManager) {
|
|
|
8478
8708
|
} else {
|
|
8479
8709
|
console.error("[ContextStream] Schema mode: full (set CONTEXTSTREAM_SCHEMA_MODE=compact to reduce token overhead)");
|
|
8480
8710
|
}
|
|
8711
|
+
if (PROGRESSIVE_MODE) {
|
|
8712
|
+
const coreBundle = TOOL_BUNDLES.core;
|
|
8713
|
+
console.error(`[ContextStream] Progressive mode: ENABLED (starting with ${coreBundle.size} core tools)`);
|
|
8714
|
+
console.error("[ContextStream] Use tools_enable_bundle to unlock additional tool bundles dynamically.");
|
|
8715
|
+
}
|
|
8716
|
+
if (ROUTER_MODE) {
|
|
8717
|
+
console.error("[ContextStream] Router mode: ENABLED (all operations accessed via contextstream/contextstream_help)");
|
|
8718
|
+
console.error("[ContextStream] Only 2 tools registered. Use contextstream_help to see available operations.");
|
|
8719
|
+
}
|
|
8720
|
+
if (COMPACT_OUTPUT) {
|
|
8721
|
+
console.error("[ContextStream] Output format: COMPACT (minified JSON, ~30% fewer tokens per response)");
|
|
8722
|
+
} else {
|
|
8723
|
+
console.error("[ContextStream] Output format: pretty (set CONTEXTSTREAM_OUTPUT_FORMAT=compact for fewer tokens)");
|
|
8724
|
+
}
|
|
8725
|
+
let serverRef = server;
|
|
8481
8726
|
const defaultProTools = /* @__PURE__ */ new Set([
|
|
8482
8727
|
// AI endpoints (typically paid/credit-metered)
|
|
8483
8728
|
"ai_context",
|
|
@@ -8771,13 +9016,7 @@ function registerTools(server, client, sessionManager) {
|
|
|
8771
9016
|
});
|
|
8772
9017
|
};
|
|
8773
9018
|
}
|
|
8774
|
-
function
|
|
8775
|
-
if (toolAllowlist && !toolAllowlist.has(name)) {
|
|
8776
|
-
return;
|
|
8777
|
-
}
|
|
8778
|
-
if (!shouldRegisterIntegrationTool(name)) {
|
|
8779
|
-
return;
|
|
8780
|
-
}
|
|
9019
|
+
function actuallyRegisterTool(name, config, handler) {
|
|
8781
9020
|
const accessLabel = getToolAccessLabel(name);
|
|
8782
9021
|
const showUpgrade = accessLabel !== "Free";
|
|
8783
9022
|
let finalDescription;
|
|
@@ -8834,12 +9073,73 @@ Upgrade: ${upgradeUrl2}` : "";
|
|
|
8834
9073
|
};
|
|
8835
9074
|
}
|
|
8836
9075
|
};
|
|
8837
|
-
|
|
9076
|
+
serverRef.registerTool(
|
|
8838
9077
|
name,
|
|
8839
9078
|
annotatedConfig,
|
|
8840
9079
|
wrapWithAutoContext(name, safeHandler)
|
|
8841
9080
|
);
|
|
8842
9081
|
}
|
|
9082
|
+
function enableBundle(bundleName) {
|
|
9083
|
+
if (enabledBundles.has(bundleName)) {
|
|
9084
|
+
return { success: true, message: `Bundle '${bundleName}' is already enabled.`, toolsEnabled: 0 };
|
|
9085
|
+
}
|
|
9086
|
+
const bundle = TOOL_BUNDLES[bundleName];
|
|
9087
|
+
if (!bundle) {
|
|
9088
|
+
return { success: false, message: `Unknown bundle '${bundleName}'. Available: ${Object.keys(TOOL_BUNDLES).join(", ")}`, toolsEnabled: 0 };
|
|
9089
|
+
}
|
|
9090
|
+
enabledBundles.add(bundleName);
|
|
9091
|
+
let toolsEnabled = 0;
|
|
9092
|
+
for (const toolName of bundle) {
|
|
9093
|
+
const deferred = deferredTools.get(toolName);
|
|
9094
|
+
if (deferred) {
|
|
9095
|
+
actuallyRegisterTool(deferred.name, deferred.config, deferred.handler);
|
|
9096
|
+
deferredTools.delete(toolName);
|
|
9097
|
+
toolsEnabled++;
|
|
9098
|
+
}
|
|
9099
|
+
}
|
|
9100
|
+
try {
|
|
9101
|
+
const lowLevelServer = serverRef;
|
|
9102
|
+
lowLevelServer.sendToolsListChanged?.();
|
|
9103
|
+
} catch {
|
|
9104
|
+
}
|
|
9105
|
+
console.error(`[ContextStream] Bundle '${bundleName}' enabled with ${toolsEnabled} tools.`);
|
|
9106
|
+
return { success: true, message: `Enabled bundle '${bundleName}' with ${toolsEnabled} tools.`, toolsEnabled };
|
|
9107
|
+
}
|
|
9108
|
+
const ROUTER_DIRECT_TOOLS = /* @__PURE__ */ new Set(["contextstream", "contextstream_help"]);
|
|
9109
|
+
function registerTool(name, config, handler) {
|
|
9110
|
+
if (toolAllowlist && !toolAllowlist.has(name)) {
|
|
9111
|
+
if (ROUTER_MODE && !ROUTER_DIRECT_TOOLS.has(name)) {
|
|
9112
|
+
operationsRegistry.set(name, {
|
|
9113
|
+
name,
|
|
9114
|
+
title: config.title,
|
|
9115
|
+
description: config.description,
|
|
9116
|
+
inputSchema: config.inputSchema,
|
|
9117
|
+
handler,
|
|
9118
|
+
category: inferOperationCategory(name)
|
|
9119
|
+
});
|
|
9120
|
+
}
|
|
9121
|
+
return;
|
|
9122
|
+
}
|
|
9123
|
+
if (!shouldRegisterIntegrationTool(name)) {
|
|
9124
|
+
return;
|
|
9125
|
+
}
|
|
9126
|
+
if (ROUTER_MODE && !ROUTER_DIRECT_TOOLS.has(name)) {
|
|
9127
|
+
operationsRegistry.set(name, {
|
|
9128
|
+
name,
|
|
9129
|
+
title: config.title,
|
|
9130
|
+
description: config.description,
|
|
9131
|
+
inputSchema: config.inputSchema,
|
|
9132
|
+
handler,
|
|
9133
|
+
category: inferOperationCategory(name)
|
|
9134
|
+
});
|
|
9135
|
+
return;
|
|
9136
|
+
}
|
|
9137
|
+
if (PROGRESSIVE_MODE && !isToolInEnabledBundles(name)) {
|
|
9138
|
+
deferredTools.set(name, { name, config, handler });
|
|
9139
|
+
return;
|
|
9140
|
+
}
|
|
9141
|
+
actuallyRegisterTool(name, config, handler);
|
|
9142
|
+
}
|
|
8843
9143
|
function errorResult(text) {
|
|
8844
9144
|
return {
|
|
8845
9145
|
content: [{ type: "text", text }],
|
|
@@ -8909,6 +9209,187 @@ Upgrade: ${upgradeUrl2}` : "";
|
|
|
8909
9209
|
return { content: [{ type: "text", text: formatContent(result) }], structuredContent: toStructured(result) };
|
|
8910
9210
|
}
|
|
8911
9211
|
);
|
|
9212
|
+
registerTool(
|
|
9213
|
+
"tools_enable_bundle",
|
|
9214
|
+
{
|
|
9215
|
+
title: "Enable tool bundle",
|
|
9216
|
+
description: `Enable a bundle of related tools dynamically. Only available when CONTEXTSTREAM_PROGRESSIVE_MODE=true.
|
|
9217
|
+
|
|
9218
|
+
Available bundles:
|
|
9219
|
+
- session: Extended session management (~6 tools)
|
|
9220
|
+
- memory: Full memory CRUD operations (~16 tools)
|
|
9221
|
+
- search: Semantic, hybrid, and keyword search (~3 tools)
|
|
9222
|
+
- graph: Code graph analysis and dependencies (~9 tools)
|
|
9223
|
+
- workspace: Workspace management (~4 tools)
|
|
9224
|
+
- project: Project management and indexing (~10 tools)
|
|
9225
|
+
- reminders: Reminder management (~6 tools)
|
|
9226
|
+
- integrations: Slack and GitHub integrations (~21 tools)
|
|
9227
|
+
|
|
9228
|
+
Example: Enable memory tools before using memory_create_event.`,
|
|
9229
|
+
inputSchema: external_exports.object({
|
|
9230
|
+
bundle: external_exports.enum(["session", "memory", "search", "graph", "workspace", "project", "reminders", "integrations"]).describe("Name of the bundle to enable"),
|
|
9231
|
+
list_bundles: external_exports.boolean().optional().describe("If true, list all available bundles and their status")
|
|
9232
|
+
})
|
|
9233
|
+
},
|
|
9234
|
+
async (input) => {
|
|
9235
|
+
if (input.list_bundles) {
|
|
9236
|
+
const bundles = getBundleInfo();
|
|
9237
|
+
const result2 = {
|
|
9238
|
+
progressive_mode: PROGRESSIVE_MODE,
|
|
9239
|
+
bundles,
|
|
9240
|
+
hint: PROGRESSIVE_MODE ? "Call tools_enable_bundle with a bundle name to enable additional tools." : "Progressive mode is disabled. All tools from your toolset are already available."
|
|
9241
|
+
};
|
|
9242
|
+
return { content: [{ type: "text", text: formatContent(result2) }], structuredContent: toStructured(result2) };
|
|
9243
|
+
}
|
|
9244
|
+
if (!PROGRESSIVE_MODE) {
|
|
9245
|
+
const result2 = {
|
|
9246
|
+
success: true,
|
|
9247
|
+
message: `Progressive mode is disabled. All tools from your toolset are already available. Bundle '${input.bundle}' tools are accessible.`,
|
|
9248
|
+
progressive_mode: false
|
|
9249
|
+
};
|
|
9250
|
+
return { content: [{ type: "text", text: formatContent(result2) }], structuredContent: toStructured(result2) };
|
|
9251
|
+
}
|
|
9252
|
+
const result = enableBundle(input.bundle);
|
|
9253
|
+
const response = {
|
|
9254
|
+
...result,
|
|
9255
|
+
progressive_mode: true,
|
|
9256
|
+
enabled_bundles: Array.from(enabledBundles),
|
|
9257
|
+
hint: result.success && result.toolsEnabled > 0 ? "New tools are now available. The client should refresh its tool list." : void 0
|
|
9258
|
+
};
|
|
9259
|
+
return { content: [{ type: "text", text: formatContent(response) }], structuredContent: toStructured(response) };
|
|
9260
|
+
}
|
|
9261
|
+
);
|
|
9262
|
+
if (ROUTER_MODE) {
|
|
9263
|
+
serverRef.registerTool(
|
|
9264
|
+
"contextstream",
|
|
9265
|
+
{
|
|
9266
|
+
title: "ContextStream Operation",
|
|
9267
|
+
description: `Execute any ContextStream operation. Use contextstream_help to see available operations.
|
|
9268
|
+
|
|
9269
|
+
Example: contextstream({ op: "session_init", args: { folder_path: "/path/to/project" } })
|
|
9270
|
+
|
|
9271
|
+
This single tool replaces 50+ individual tools, dramatically reducing token overhead.
|
|
9272
|
+
All ContextStream functionality is accessible through this dispatcher.`,
|
|
9273
|
+
inputSchema: {
|
|
9274
|
+
type: "object",
|
|
9275
|
+
properties: {
|
|
9276
|
+
op: { type: "string", description: "Operation name (e.g., session_init, memory_create_event)" },
|
|
9277
|
+
args: { type: "object", description: "Operation arguments (varies by operation)" }
|
|
9278
|
+
},
|
|
9279
|
+
required: ["op"]
|
|
9280
|
+
},
|
|
9281
|
+
annotations: {
|
|
9282
|
+
readOnlyHint: false,
|
|
9283
|
+
destructiveHint: false,
|
|
9284
|
+
idempotentHint: false,
|
|
9285
|
+
openWorldHint: false
|
|
9286
|
+
}
|
|
9287
|
+
},
|
|
9288
|
+
async (input) => {
|
|
9289
|
+
const opName = input.op;
|
|
9290
|
+
const operation = operationsRegistry.get(opName);
|
|
9291
|
+
if (!operation) {
|
|
9292
|
+
const available = getOperationCatalog();
|
|
9293
|
+
return {
|
|
9294
|
+
content: [{
|
|
9295
|
+
type: "text",
|
|
9296
|
+
text: `Unknown operation: ${opName}
|
|
9297
|
+
|
|
9298
|
+
Available operations:
|
|
9299
|
+
${available}
|
|
9300
|
+
|
|
9301
|
+
Use contextstream_help({ op: "operation_name" }) for details.`
|
|
9302
|
+
}],
|
|
9303
|
+
isError: true
|
|
9304
|
+
};
|
|
9305
|
+
}
|
|
9306
|
+
const args = input.args || {};
|
|
9307
|
+
const parsed = operation.inputSchema.safeParse(args);
|
|
9308
|
+
if (!parsed.success) {
|
|
9309
|
+
const schema = getOperationSchema(opName);
|
|
9310
|
+
return {
|
|
9311
|
+
content: [{
|
|
9312
|
+
type: "text",
|
|
9313
|
+
text: `Invalid arguments for ${opName}: ${parsed.error.message}
|
|
9314
|
+
|
|
9315
|
+
Expected schema:
|
|
9316
|
+
${JSON.stringify(schema?.schema || {}, null, 2)}`
|
|
9317
|
+
}],
|
|
9318
|
+
isError: true
|
|
9319
|
+
};
|
|
9320
|
+
}
|
|
9321
|
+
try {
|
|
9322
|
+
return await operation.handler(parsed.data);
|
|
9323
|
+
} catch (error) {
|
|
9324
|
+
return {
|
|
9325
|
+
content: [{
|
|
9326
|
+
type: "text",
|
|
9327
|
+
text: `Error executing ${opName}: ${error?.message || String(error)}`
|
|
9328
|
+
}],
|
|
9329
|
+
isError: true
|
|
9330
|
+
};
|
|
9331
|
+
}
|
|
9332
|
+
}
|
|
9333
|
+
);
|
|
9334
|
+
serverRef.registerTool(
|
|
9335
|
+
"contextstream_help",
|
|
9336
|
+
{
|
|
9337
|
+
title: "ContextStream Help",
|
|
9338
|
+
description: `Get help on available ContextStream operations or schema for a specific operation.
|
|
9339
|
+
|
|
9340
|
+
Examples:
|
|
9341
|
+
- contextstream_help({}) - List all operations by category
|
|
9342
|
+
- contextstream_help({ op: "session_init" }) - Get schema for session_init
|
|
9343
|
+
- contextstream_help({ category: "Memory" }) - List memory operations only`,
|
|
9344
|
+
inputSchema: {
|
|
9345
|
+
type: "object",
|
|
9346
|
+
properties: {
|
|
9347
|
+
op: { type: "string", description: "Operation name to get schema for" },
|
|
9348
|
+
category: { type: "string", description: "Category to filter (Session, Memory, Search, Graph, etc.)" }
|
|
9349
|
+
}
|
|
9350
|
+
},
|
|
9351
|
+
annotations: {
|
|
9352
|
+
readOnlyHint: true,
|
|
9353
|
+
destructiveHint: false,
|
|
9354
|
+
idempotentHint: true,
|
|
9355
|
+
openWorldHint: false
|
|
9356
|
+
}
|
|
9357
|
+
},
|
|
9358
|
+
async (input) => {
|
|
9359
|
+
if (input.op) {
|
|
9360
|
+
const schema = getOperationSchema(input.op);
|
|
9361
|
+
if (!schema) {
|
|
9362
|
+
return {
|
|
9363
|
+
content: [{
|
|
9364
|
+
type: "text",
|
|
9365
|
+
text: `Unknown operation: ${input.op}
|
|
9366
|
+
|
|
9367
|
+
Use contextstream_help({}) to see available operations.`
|
|
9368
|
+
}],
|
|
9369
|
+
isError: true
|
|
9370
|
+
};
|
|
9371
|
+
}
|
|
9372
|
+
return {
|
|
9373
|
+
content: [{ type: "text", text: JSON.stringify(schema, null, 2) }],
|
|
9374
|
+
structuredContent: schema
|
|
9375
|
+
};
|
|
9376
|
+
}
|
|
9377
|
+
const catalog = getOperationCatalog(input.category);
|
|
9378
|
+
const result = {
|
|
9379
|
+
router_mode: true,
|
|
9380
|
+
total_operations: operationsRegistry.size,
|
|
9381
|
+
categories: catalog,
|
|
9382
|
+
usage: 'Call contextstream({ op: "operation_name", args: {...} }) to execute an operation.',
|
|
9383
|
+
hint: 'Use contextstream_help({ op: "operation_name" }) to see the schema for a specific operation.'
|
|
9384
|
+
};
|
|
9385
|
+
return {
|
|
9386
|
+
content: [{ type: "text", text: formatContent(result) }],
|
|
9387
|
+
structuredContent: toStructured(result)
|
|
9388
|
+
};
|
|
9389
|
+
}
|
|
9390
|
+
);
|
|
9391
|
+
console.error(`[ContextStream] Router mode: Registered 2 meta-tools, ${operationsRegistry.size} operations available via dispatcher.`);
|
|
9392
|
+
}
|
|
8912
9393
|
registerTool(
|
|
8913
9394
|
"workspaces_list",
|
|
8914
9395
|
{
|
|
@@ -10110,9 +10591,26 @@ Memory: events(crud) nodes(knowledge) search(find) decisions(choices)`,
|
|
|
10110
10591
|
async (input) => {
|
|
10111
10592
|
const format = input.format || "grouped";
|
|
10112
10593
|
const catalog = generateToolCatalog(format, input.category);
|
|
10594
|
+
let bundleInfo = "";
|
|
10595
|
+
if (PROGRESSIVE_MODE) {
|
|
10596
|
+
const bundles = getBundleInfo();
|
|
10597
|
+
const enabledList = bundles.filter((b) => b.enabled).map((b) => b.name).join(", ");
|
|
10598
|
+
const availableList = bundles.filter((b) => !b.enabled).map((b) => `${b.name}(${b.size})`).join(", ");
|
|
10599
|
+
bundleInfo = `
|
|
10600
|
+
|
|
10601
|
+
[Progressive Mode]
|
|
10602
|
+
Enabled: ${enabledList}
|
|
10603
|
+
Available: ${availableList}
|
|
10604
|
+
Use tools_enable_bundle to unlock more tools.`;
|
|
10605
|
+
}
|
|
10113
10606
|
return {
|
|
10114
|
-
content: [{ type: "text", text: catalog }],
|
|
10115
|
-
structuredContent: {
|
|
10607
|
+
content: [{ type: "text", text: catalog + bundleInfo }],
|
|
10608
|
+
structuredContent: {
|
|
10609
|
+
format,
|
|
10610
|
+
catalog,
|
|
10611
|
+
progressive_mode: PROGRESSIVE_MODE,
|
|
10612
|
+
bundles: PROGRESSIVE_MODE ? getBundleInfo() : void 0
|
|
10613
|
+
}
|
|
10116
10614
|
};
|
|
10117
10615
|
}
|
|
10118
10616
|
);
|
|
@@ -14278,6 +14776,9 @@ Environment variables:
|
|
|
14278
14776
|
CONTEXTSTREAM_AUTO_TOOLSET Auto-detect client and adjust toolset (default: false)
|
|
14279
14777
|
CONTEXTSTREAM_AUTO_HIDE_INTEGRATIONS Auto-hide Slack/GitHub tools when not connected (default: true)
|
|
14280
14778
|
CONTEXTSTREAM_SCHEMA_MODE Schema verbosity: compact|full (default: full, compact reduces tokens)
|
|
14779
|
+
CONTEXTSTREAM_PROGRESSIVE_MODE Progressive disclosure: true|false (default: false, starts with ~13 core tools)
|
|
14780
|
+
CONTEXTSTREAM_ROUTER_MODE Router pattern: true|false (default: false, exposes only 2 meta-tools)
|
|
14781
|
+
CONTEXTSTREAM_OUTPUT_FORMAT Output verbosity: compact|pretty (default: compact, ~30% fewer tokens)
|
|
14281
14782
|
CONTEXTSTREAM_PRO_TOOLS Optional comma-separated PRO tool names (default: AI tools)
|
|
14282
14783
|
CONTEXTSTREAM_UPGRADE_URL Optional upgrade URL shown for PRO tools on Free plan
|
|
14283
14784
|
CONTEXTSTREAM_ENABLE_PROMPTS Enable MCP prompts list (default: true)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contextstream/mcp-server",
|
|
3
3
|
"mcpName": "io.github.contextstreamio/mcp-server",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.73",
|
|
5
5
|
"description": "MCP server exposing ContextStream public API - code context, memory, search, and AI tools for developers",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|