@contextstream/mcp-server 0.4.7 → 0.4.8

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 CHANGED
@@ -4051,8 +4051,9 @@ var coerce = {
4051
4051
  var NEVER = INVALID;
4052
4052
 
4053
4053
  // src/config.ts
4054
+ var DEFAULT_API_URL = "https://api.contextstream.io";
4054
4055
  var configSchema = external_exports.object({
4055
- apiUrl: external_exports.string().url(),
4056
+ apiUrl: external_exports.string().url().default(DEFAULT_API_URL),
4056
4057
  apiKey: external_exports.string().min(1).optional(),
4057
4058
  jwt: external_exports.string().min(1).optional(),
4058
4059
  defaultWorkspaceId: external_exports.string().uuid().optional(),
@@ -4060,6 +4061,13 @@ var configSchema = external_exports.object({
4060
4061
  userAgent: external_exports.string().default("contextstream-mcp/0.1.0"),
4061
4062
  allowHeaderAuth: external_exports.boolean().optional()
4062
4063
  });
4064
+ var MISSING_CREDENTIALS_ERROR = "Set CONTEXTSTREAM_API_KEY or CONTEXTSTREAM_JWT for authentication (or CONTEXTSTREAM_ALLOW_HEADER_AUTH=true for header-based auth).";
4065
+ function isMissingCredentialsError(err) {
4066
+ if (err instanceof Error) {
4067
+ return err.message === MISSING_CREDENTIALS_ERROR;
4068
+ }
4069
+ return false;
4070
+ }
4063
4071
  function loadConfig() {
4064
4072
  const allowHeaderAuth = process.env.CONTEXTSTREAM_ALLOW_HEADER_AUTH === "1" || process.env.CONTEXTSTREAM_ALLOW_HEADER_AUTH === "true" || process.env.CONTEXTSTREAM_ALLOW_HEADER_AUTH === "yes";
4065
4073
  const parsed = configSchema.safeParse({
@@ -4078,7 +4086,7 @@ function loadConfig() {
4078
4086
  );
4079
4087
  }
4080
4088
  if (!parsed.data.apiKey && !parsed.data.jwt && !parsed.data.allowHeaderAuth) {
4081
- throw new Error("Set CONTEXTSTREAM_API_KEY or CONTEXTSTREAM_JWT for authentication (or CONTEXTSTREAM_ALLOW_HEADER_AUTH=true for header-based auth).");
4089
+ throw new Error(MISSING_CREDENTIALS_ERROR);
4082
4090
  }
4083
4091
  return parsed.data;
4084
4092
  }
@@ -13485,6 +13493,40 @@ Each domain tool has an 'action' parameter for specific operations.` : "";
13485
13493
  console.error(`[ContextStream] Consolidated mode: Registered ${CONSOLIDATED_TOOLS.size} domain tools.`);
13486
13494
  }
13487
13495
  }
13496
+ function registerLimitedTools(server) {
13497
+ server.registerTool(
13498
+ "contextstream_setup",
13499
+ {
13500
+ title: "ContextStream Setup Required",
13501
+ description: "ContextStream is not configured. Call this tool for setup instructions.",
13502
+ inputSchema: { type: "object", properties: {} }
13503
+ },
13504
+ async () => {
13505
+ return {
13506
+ content: [
13507
+ {
13508
+ type: "text",
13509
+ text: `ContextStream: API key not configured.
13510
+
13511
+ To set up (creates key + configures your editor):
13512
+ npx -y @contextstream/mcp-server setup
13513
+
13514
+ This will:
13515
+ - Start a 5-day Pro trial
13516
+ - Auto-configure your editor's MCP settings
13517
+ - Write rules files for better AI assistance
13518
+
13519
+ Preview first:
13520
+ npx -y @contextstream/mcp-server setup --dry-run
13521
+
13522
+ After setup, restart your editor to enable all ContextStream tools.`
13523
+ }
13524
+ ]
13525
+ };
13526
+ }
13527
+ );
13528
+ console.error("[ContextStream] Limited mode: Registered setup helper tool only.");
13529
+ }
13488
13530
 
13489
13531
  // src/resources.ts
13490
13532
  import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -15903,6 +15945,13 @@ Applying to ${projects.length} project(s)...`);
15903
15945
  if (toolset === "router") {
15904
15946
  console.log("- Router mode uses 2 meta-tools (session_init + context_smart) for ultra-minimal token usage.");
15905
15947
  }
15948
+ console.log("");
15949
+ console.log("You're set up! Now try these prompts in your AI tool:");
15950
+ console.log(' 1) "session summary"');
15951
+ console.log(` 2) "remember we're using PostgreSQL"`);
15952
+ console.log(' 3) "what did we decide about auth?"');
15953
+ console.log("");
15954
+ console.log("More at: https://contextstream.io/docs/mcp");
15906
15955
  } finally {
15907
15956
  rl.close();
15908
15957
  }
@@ -15986,6 +16035,18 @@ Notes:
15986
16035
  set these env vars in the client's MCP server configuration.
15987
16036
  - The server communicates over stdio; logs are written to stderr.`);
15988
16037
  }
16038
+ async function runLimitedModeServer() {
16039
+ const server = new McpServer2({
16040
+ name: "contextstream-mcp",
16041
+ version: VERSION
16042
+ });
16043
+ registerLimitedTools(server);
16044
+ console.error(`ContextStream MCP server v${VERSION} (limited mode)`);
16045
+ console.error('Run "npx -y @contextstream/mcp-server setup" to enable all tools.');
16046
+ const transport = new StdioServerTransport();
16047
+ await server.connect(transport);
16048
+ console.error("ContextStream MCP server connected (limited mode - setup required)");
16049
+ }
15989
16050
  async function main() {
15990
16051
  const args = process.argv.slice(2);
15991
16052
  if (args.includes("--help") || args.includes("-h")) {
@@ -16007,7 +16068,23 @@ async function main() {
16007
16068
  await runHttpGateway();
16008
16069
  return;
16009
16070
  }
16010
- const config = loadConfig();
16071
+ if (!process.env.CONTEXTSTREAM_API_KEY && !process.env.CONTEXTSTREAM_JWT) {
16072
+ const saved = await readSavedCredentials();
16073
+ if (saved) {
16074
+ process.env.CONTEXTSTREAM_API_URL = saved.api_url;
16075
+ process.env.CONTEXTSTREAM_API_KEY = saved.api_key;
16076
+ }
16077
+ }
16078
+ let config;
16079
+ try {
16080
+ config = loadConfig();
16081
+ } catch (err) {
16082
+ if (isMissingCredentialsError(err)) {
16083
+ await runLimitedModeServer();
16084
+ return;
16085
+ }
16086
+ throw err;
16087
+ }
16011
16088
  const client = new ContextStreamClient(config);
16012
16089
  const server = new McpServer2({
16013
16090
  name: "contextstream-mcp",
@@ -4051,8 +4051,9 @@ var coerce = {
4051
4051
  var NEVER = INVALID;
4052
4052
 
4053
4053
  // src/config.ts
4054
+ var DEFAULT_API_URL = "https://api.contextstream.io";
4054
4055
  var configSchema = external_exports.object({
4055
- apiUrl: external_exports.string().url(),
4056
+ apiUrl: external_exports.string().url().default(DEFAULT_API_URL),
4056
4057
  apiKey: external_exports.string().min(1).optional(),
4057
4058
  jwt: external_exports.string().min(1).optional(),
4058
4059
  defaultWorkspaceId: external_exports.string().uuid().optional(),
@@ -4060,6 +4061,7 @@ var configSchema = external_exports.object({
4060
4061
  userAgent: external_exports.string().default("contextstream-mcp/0.1.0"),
4061
4062
  allowHeaderAuth: external_exports.boolean().optional()
4062
4063
  });
4064
+ var MISSING_CREDENTIALS_ERROR = "Set CONTEXTSTREAM_API_KEY or CONTEXTSTREAM_JWT for authentication (or CONTEXTSTREAM_ALLOW_HEADER_AUTH=true for header-based auth).";
4063
4065
  function loadConfig() {
4064
4066
  const allowHeaderAuth = process.env.CONTEXTSTREAM_ALLOW_HEADER_AUTH === "1" || process.env.CONTEXTSTREAM_ALLOW_HEADER_AUTH === "true" || process.env.CONTEXTSTREAM_ALLOW_HEADER_AUTH === "yes";
4065
4067
  const parsed = configSchema.safeParse({
@@ -4078,7 +4080,7 @@ function loadConfig() {
4078
4080
  );
4079
4081
  }
4080
4082
  if (!parsed.data.apiKey && !parsed.data.jwt && !parsed.data.allowHeaderAuth) {
4081
- throw new Error("Set CONTEXTSTREAM_API_KEY or CONTEXTSTREAM_JWT for authentication (or CONTEXTSTREAM_ALLOW_HEADER_AUTH=true for header-based auth).");
4083
+ throw new Error(MISSING_CREDENTIALS_ERROR);
4082
4084
  }
4083
4085
  return parsed.data;
4084
4086
  }
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.4.7",
4
+ "version": "0.4.8",
5
5
  "description": "ContextStream MCP server - v0.4.x with consolidated domain tools (~11 tools, ~75% token reduction). Code context, memory, search, and AI tools.",
6
6
  "type": "module",
7
7
  "license": "MIT",