@getjack/jack 0.1.23 → 0.1.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getjack/jack",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Ship before you forget why you started. The vibecoder's deployment CLI.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -91,11 +91,11 @@ export async function checkForUpdate(
91
91
  skipCache = false,
92
92
  ): Promise<string | null> {
93
93
  const currentVersion = getCurrentVersion();
94
+ const now = Date.now();
94
95
 
95
96
  // Check cache first (unless skipCache is true)
96
97
  if (!skipCache) {
97
98
  const cache = await readVersionCache();
98
- const now = Date.now();
99
99
 
100
100
  if (cache && now - cache.checkedAt < CACHE_TTL_MS) {
101
101
  // Use cached value
@@ -106,7 +106,7 @@ export async function checkForUpdate(
106
106
  }
107
107
  }
108
108
 
109
- // Fetch fresh version (don't await in caller for non-blocking)
109
+ // Fetch fresh version
110
110
  const latestVersion = await fetchLatestVersion();
111
111
  if (!latestVersion) return null;
112
112
 
@@ -1,5 +1,9 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3
+ import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
4
+ import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
5
+ import { createMcpServer } from "./server.ts";
6
+ import type { McpServerOptions } from "./types.ts";
3
7
 
4
8
  export interface McpClientOptions {
5
9
  command: string;
@@ -12,12 +16,50 @@ export interface McpClientOptions {
12
16
 
13
17
  export interface McpTestClient {
14
18
  client: Client;
15
- transport: StdioClientTransport;
19
+ transport: Transport;
16
20
  getStderr(): string;
17
21
  close(): Promise<void>;
18
22
  }
19
23
 
20
- export async function openMcpTestClient(options: McpClientOptions): Promise<McpTestClient> {
24
+ /**
25
+ * Open an MCP test client using in-memory transport.
26
+ * This is the recommended approach for testing - no process spawning,
27
+ * no race conditions, deterministic behavior.
28
+ */
29
+ export async function openMcpTestClientInMemory(
30
+ serverOptions: McpServerOptions = {},
31
+ ): Promise<McpTestClient> {
32
+ // Create linked transport pair
33
+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
34
+
35
+ // Create and connect server
36
+ const { server } = await createMcpServer(serverOptions);
37
+ await server.connect(serverTransport);
38
+
39
+ // Create and connect client
40
+ const client = new Client({
41
+ name: "jack-mcp-test",
42
+ version: "0.1.0",
43
+ });
44
+ await client.connect(clientTransport);
45
+
46
+ return {
47
+ client,
48
+ transport: clientTransport,
49
+ getStderr: () => "(in-memory transport - no stderr)",
50
+ close: async () => {
51
+ await clientTransport.close();
52
+ await serverTransport.close();
53
+ },
54
+ };
55
+ }
56
+
57
+ /**
58
+ * Open an MCP test client using stdio transport (spawns a child process).
59
+ * This tests the full stdio path but is prone to race conditions.
60
+ * Use openMcpTestClientInMemory() for reliable testing.
61
+ */
62
+ export async function openMcpTestClientStdio(options: McpClientOptions): Promise<McpTestClient> {
21
63
  const transport = new StdioClientTransport({
22
64
  command: options.command,
23
65
  args: options.args ?? [],
@@ -51,6 +93,9 @@ export async function openMcpTestClient(options: McpClientOptions): Promise<McpT
51
93
  };
52
94
  }
53
95
 
96
+ // Legacy alias for backwards compatibility
97
+ export const openMcpTestClient = openMcpTestClientStdio;
98
+
54
99
  export function parseMcpToolResult(toolResult: {
55
100
  content?: Array<{ type: string; text?: string }>;
56
101
  [key: string]: unknown;