@contextstream/mcp-server 0.3.2 → 0.3.4
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 +16 -0
- package/dist/index.js +79 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,22 @@ Add ContextStream to your AI tool's MCP configuration (works with **Cursor**, **
|
|
|
54
54
|
|
|
55
55
|
Get your API key at [contextstream.io](https://contextstream.io)
|
|
56
56
|
|
|
57
|
+
### Codex (CLI) configuration
|
|
58
|
+
|
|
59
|
+
For the Codex CLI, add the MCP server to your `~/.codex/config.toml`:
|
|
60
|
+
|
|
61
|
+
```toml
|
|
62
|
+
[mcpServers.contextstream]
|
|
63
|
+
command = "npx"
|
|
64
|
+
args = ["-y", "@contextstream/mcp-server"]
|
|
65
|
+
|
|
66
|
+
[mcpServers.contextstream.env]
|
|
67
|
+
CONTEXTSTREAM_API_URL = "https://api.contextstream.io"
|
|
68
|
+
CONTEXTSTREAM_API_KEY = "your_api_key"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
After saving the file, restart Codex. The ContextStream tools and auto-context will then be available in any trusted project that has a `.contextstream/config.json` (or a matching parent mapping in `~/.contextstream-mappings.json`).
|
|
72
|
+
|
|
57
73
|
## ✨ Auto-Context (v0.3.0+)
|
|
58
74
|
|
|
59
75
|
Context loads **automatically** on the first tool call of any conversation. No need to manually call `session_init` — your AI assistant gets workspace info, recent memory, and decisions immediately.
|
package/dist/index.js
CHANGED
|
@@ -6379,16 +6379,47 @@ var SessionManager = class {
|
|
|
6379
6379
|
return null;
|
|
6380
6380
|
}
|
|
6381
6381
|
try {
|
|
6382
|
-
const
|
|
6383
|
-
console.error("[ContextStream]
|
|
6384
|
-
if (
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
)
|
|
6388
|
-
|
|
6382
|
+
const capabilities = this.server.server.getClientCapabilities();
|
|
6383
|
+
console.error("[ContextStream] Client capabilities:", JSON.stringify(capabilities));
|
|
6384
|
+
if (capabilities?.roots) {
|
|
6385
|
+
const rootsResponse = await this.server.server.listRoots();
|
|
6386
|
+
console.error("[ContextStream] listRoots response:", JSON.stringify(rootsResponse));
|
|
6387
|
+
if (rootsResponse?.roots) {
|
|
6388
|
+
this.ideRoots = rootsResponse.roots.map(
|
|
6389
|
+
(r) => r.uri.replace("file://", "")
|
|
6390
|
+
);
|
|
6391
|
+
console.error("[ContextStream] IDE roots detected via listRoots:", this.ideRoots);
|
|
6392
|
+
}
|
|
6393
|
+
} else {
|
|
6394
|
+
console.error("[ContextStream] Client does not support roots capability");
|
|
6389
6395
|
}
|
|
6390
6396
|
} catch (e) {
|
|
6391
|
-
console.error("[ContextStream] listRoots
|
|
6397
|
+
console.error("[ContextStream] listRoots failed:", e?.message || e);
|
|
6398
|
+
}
|
|
6399
|
+
if (this.ideRoots.length === 0) {
|
|
6400
|
+
const envWorkspace = process.env.WORKSPACE_FOLDER || process.env.VSCODE_WORKSPACE_FOLDER || process.env.PROJECT_DIR || process.env.PWD;
|
|
6401
|
+
if (envWorkspace && envWorkspace !== process.env.HOME) {
|
|
6402
|
+
console.error("[ContextStream] Using workspace from env:", envWorkspace);
|
|
6403
|
+
this.ideRoots = [envWorkspace];
|
|
6404
|
+
}
|
|
6405
|
+
}
|
|
6406
|
+
if (this.ideRoots.length === 0) {
|
|
6407
|
+
const cwd = process.cwd();
|
|
6408
|
+
const fs3 = await import("fs");
|
|
6409
|
+
const projectIndicators = [".git", "package.json", "Cargo.toml", "pyproject.toml", ".contextstream"];
|
|
6410
|
+
const hasProjectIndicator = projectIndicators.some((f) => {
|
|
6411
|
+
try {
|
|
6412
|
+
return fs3.existsSync(`${cwd}/${f}`);
|
|
6413
|
+
} catch {
|
|
6414
|
+
return false;
|
|
6415
|
+
}
|
|
6416
|
+
});
|
|
6417
|
+
if (hasProjectIndicator) {
|
|
6418
|
+
console.error("[ContextStream] Using cwd as workspace:", cwd);
|
|
6419
|
+
this.ideRoots = [cwd];
|
|
6420
|
+
} else {
|
|
6421
|
+
console.error("[ContextStream] cwd does not look like a project:", cwd);
|
|
6422
|
+
}
|
|
6392
6423
|
}
|
|
6393
6424
|
if (this.ideRoots.length === 0 && this.folderPath) {
|
|
6394
6425
|
this.ideRoots = [this.folderPath];
|
|
@@ -6491,13 +6522,15 @@ var SessionManager = class {
|
|
|
6491
6522
|
parts.push(` \u2022 [${type}] ${title}`);
|
|
6492
6523
|
});
|
|
6493
6524
|
}
|
|
6525
|
+
parts.push("");
|
|
6494
6526
|
if (context.ide_roots && context.ide_roots.length > 0) {
|
|
6495
6527
|
const roots = context.ide_roots;
|
|
6496
|
-
parts.push("");
|
|
6497
6528
|
parts.push(`\u{1F5A5}\uFE0F IDE Roots: ${roots.join(", ")}`);
|
|
6498
6529
|
} else {
|
|
6499
|
-
parts.push(
|
|
6500
|
-
|
|
6530
|
+
parts.push(`\u{1F5A5}\uFE0F IDE Roots: (none detected)`);
|
|
6531
|
+
}
|
|
6532
|
+
if (this.ideRoots.length > 0) {
|
|
6533
|
+
parts.push(` Detection: ${this.ideRoots[0]}`);
|
|
6501
6534
|
}
|
|
6502
6535
|
parts.push("");
|
|
6503
6536
|
parts.push("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
@@ -6509,12 +6542,46 @@ var SessionManager = class {
|
|
|
6509
6542
|
};
|
|
6510
6543
|
|
|
6511
6544
|
// src/index.ts
|
|
6545
|
+
var VERSION = "0.3.4";
|
|
6546
|
+
function printHelp() {
|
|
6547
|
+
console.log(`ContextStream MCP Server (contextstream-mcp) v${VERSION}
|
|
6548
|
+
|
|
6549
|
+
Usage:
|
|
6550
|
+
npx -y @contextstream/mcp-server
|
|
6551
|
+
contextstream-mcp
|
|
6552
|
+
|
|
6553
|
+
Environment variables:
|
|
6554
|
+
CONTEXTSTREAM_API_URL Base API URL (e.g. https://api.contextstream.io)
|
|
6555
|
+
CONTEXTSTREAM_API_KEY API key for authentication (or use CONTEXTSTREAM_JWT)
|
|
6556
|
+
CONTEXTSTREAM_JWT JWT for authentication (alternative to API key)
|
|
6557
|
+
CONTEXTSTREAM_WORKSPACE_ID Optional default workspace ID
|
|
6558
|
+
CONTEXTSTREAM_PROJECT_ID Optional default project ID
|
|
6559
|
+
|
|
6560
|
+
Examples:
|
|
6561
|
+
CONTEXTSTREAM_API_URL="https://api.contextstream.io" \\
|
|
6562
|
+
CONTEXTSTREAM_API_KEY="your_api_key" \\
|
|
6563
|
+
npx -y @contextstream/mcp-server
|
|
6564
|
+
|
|
6565
|
+
Notes:
|
|
6566
|
+
- When used from an MCP client (e.g. Codex, Cursor, VS Code),
|
|
6567
|
+
set these env vars in the client's MCP server configuration.
|
|
6568
|
+
- The server communicates over stdio; logs are written to stderr.`);
|
|
6569
|
+
}
|
|
6512
6570
|
async function main() {
|
|
6571
|
+
const args = process.argv.slice(2);
|
|
6572
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
6573
|
+
printHelp();
|
|
6574
|
+
return;
|
|
6575
|
+
}
|
|
6576
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
6577
|
+
console.log(`contextstream-mcp v${VERSION}`);
|
|
6578
|
+
return;
|
|
6579
|
+
}
|
|
6513
6580
|
const config = loadConfig();
|
|
6514
6581
|
const client = new ContextStreamClient(config);
|
|
6515
6582
|
const server = new McpServer({
|
|
6516
6583
|
name: "contextstream-mcp",
|
|
6517
|
-
version:
|
|
6584
|
+
version: VERSION
|
|
6518
6585
|
});
|
|
6519
6586
|
const sessionManager = new SessionManager(server, client);
|
|
6520
6587
|
registerTools(server, client, sessionManager);
|
package/package.json
CHANGED