driggsby 0.1.5 → 0.1.7

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 CHANGED
@@ -48,11 +48,6 @@ driggsby logout
48
48
  driggsby broker-daemon
49
49
  ```
50
50
 
51
- ## Learn More
52
-
53
- - Product and source: https://github.com/thegoodsoftwareco/driggsby
54
- - Issues: https://github.com/thegoodsoftwareco/driggsby/issues
55
-
56
51
  ## License
57
52
 
58
53
  This package is currently published as `UNLICENSED`.
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable @typescript-eslint/no-deprecated */
2
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
3
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
4
  import { ensureBrokerRunning } from "../broker/launch.js";
@@ -9,6 +8,7 @@ import { KeyringSecretStore } from "../broker/secret-store.js";
9
8
  import { retryOperation } from "../lib/retry.js";
10
9
  import { buildBrokerInvestigationMessage, errorMessageIncludesReauthenticationCommand, formatRetryWindow, } from "../lib/user-guidance.js";
11
10
  import { formatStatusText } from "../cli/format.js";
11
+ import { LifecycleAwareStdioServerTransport } from "./stdio-transport.js";
12
12
  const LOCAL_STATUS_TOOL = {
13
13
  description: "Report readiness and connectivity for the shared local Driggsby broker.",
14
14
  inputSchema: {
@@ -27,7 +27,8 @@ export async function runMcpServerCommand(runtimePaths, entrypointPath) {
27
27
  secretStore,
28
28
  });
29
29
  const server = createLocalShimServer(runtimePaths, secretStore);
30
- await server.connect(new StdioServerTransport());
30
+ const transport = new LifecycleAwareStdioServerTransport();
31
+ await server.connect(transport);
31
32
  }
32
33
  export function createLocalShimServer(runtimePaths, secretStore) {
33
34
  const server = new Server({
@@ -0,0 +1,74 @@
1
+ import process from "node:process";
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ export class LifecycleAwareStdioServerTransport {
4
+ delegate;
5
+ stdin;
6
+ closingPromise = null;
7
+ started = false;
8
+ onclose;
9
+ onerror;
10
+ onmessage;
11
+ handleInputClosed = () => {
12
+ void this.close().catch((error) => {
13
+ this.onerror?.(error instanceof Error
14
+ ? error
15
+ : new Error("The Driggsby MCP transport could not close cleanly."));
16
+ });
17
+ };
18
+ constructor(stdin = process.stdin, stdout = process.stdout) {
19
+ this.stdin = stdin;
20
+ this.delegate = new StdioServerTransport(stdin, stdout);
21
+ this.delegate.onclose = () => {
22
+ this.onclose?.();
23
+ };
24
+ this.delegate.onerror = (error) => {
25
+ this.onerror?.(error);
26
+ };
27
+ this.delegate.onmessage = (message) => {
28
+ this.onmessage?.(message);
29
+ };
30
+ }
31
+ async start() {
32
+ if (this.started) {
33
+ throw new Error("LifecycleAwareStdioServerTransport already started.");
34
+ }
35
+ this.started = true;
36
+ this.stdin.once("close", this.handleInputClosed);
37
+ this.stdin.once("end", this.handleInputClosed);
38
+ try {
39
+ await this.delegate.start();
40
+ }
41
+ catch (error) {
42
+ this.removeInputListeners();
43
+ this.started = false;
44
+ throw error;
45
+ }
46
+ }
47
+ async close() {
48
+ if (this.closingPromise !== null) {
49
+ await this.closingPromise;
50
+ return;
51
+ }
52
+ this.closingPromise = (async () => {
53
+ if (!this.started) {
54
+ return;
55
+ }
56
+ this.started = false;
57
+ this.removeInputListeners();
58
+ await this.delegate.close();
59
+ })();
60
+ try {
61
+ await this.closingPromise;
62
+ }
63
+ finally {
64
+ this.closingPromise = null;
65
+ }
66
+ }
67
+ async send(message) {
68
+ await this.delegate.send(message);
69
+ }
70
+ removeInputListeners() {
71
+ this.stdin.off("close", this.handleInputClosed);
72
+ this.stdin.off("end", this.handleInputClosed);
73
+ }
74
+ }
package/package.json CHANGED
@@ -1,18 +1,9 @@
1
1
  {
2
2
  "name": "driggsby",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Local MCP broker and CLI for connecting AI clients to Driggsby",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/thegoodsoftwareco/driggsby.git",
10
- "directory": "packages/driggsby"
11
- },
12
- "homepage": "https://github.com/thegoodsoftwareco/driggsby/tree/main/packages/driggsby#readme",
13
- "bugs": {
14
- "url": "https://github.com/thegoodsoftwareco/driggsby/issues"
15
- },
16
7
  "keywords": [
17
8
  "driggsby",
18
9
  "mcp",