@toolgrain/node 0.1.1 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @toolgrain/node
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - @toolgrain/http@0.1.3
8
+ - @toolgrain/mcp@0.1.3
9
+ - @toolgrain/protocol@0.1.3
10
+
11
+ ## 0.1.2
12
+
13
+ ### Patch Changes
14
+
15
+ - da94c47: Document the public API with JSDoc for exported types, members, options, and functions. Preserve field documentation in auth accessor return types and protocol constant hovers.
16
+ - f199707: Point package homepages and README documentation links to the live Toolgrain documentation site.
17
+ - d0c10ac: Use matching stable Toolgrain packages in installation instructions instead of
18
+ embedding outdated release pins.
19
+ - Updated dependencies [da94c47]
20
+ - Updated dependencies [f199707]
21
+ - Updated dependencies [d0c10ac]
22
+ - @toolgrain/http@0.1.2
23
+ - @toolgrain/mcp@0.1.2
24
+ - @toolgrain/protocol@0.1.2
25
+
3
26
  ## 0.1.1
4
27
 
5
28
  ### Patch Changes
package/README.md CHANGED
@@ -13,16 +13,17 @@
13
13
  Node.js transports for Toolgrain: process stdio, a managed HTTP listener, and
14
14
  handlers for an existing Node application.
15
15
 
16
- [Documentation](https://github.com/keshavkatwe/toolgrain/blob/main/docs/transports.md) ·
17
- [Examples](https://github.com/keshavkatwe/toolgrain/blob/main/apps/README.md) ·
16
+ [Documentation](https://toolgrain.mintlify.site/transports/overview) ·
17
+ [Examples](https://toolgrain.mintlify.site/examples) ·
18
18
  [npm](https://www.npmjs.com/package/@toolgrain/node)
19
19
 
20
20
  ## Installation
21
21
 
22
- Install the same `0.1.0` version across Toolgrain libraries.
22
+ Install matching stable versions across Toolgrain libraries. These commands
23
+ resolve npm's `latest` tag.
23
24
 
24
25
  ```sh
25
- npm install @toolgrain/node@0.1.0 @toolgrain/mcp@0.1.0 zod@^4.6.6
26
+ npm install @toolgrain/node @toolgrain/mcp zod@^4.6.6
26
27
  npm install --save-dev typescript @types/node
27
28
  ```
28
29
 
@@ -87,7 +88,7 @@ default to loopback on any port. Set production hosts explicitly. Applications
87
88
  own CORS, TLS, and trusted proxy normalization. Forwarded headers are ignored.
88
89
 
89
90
  Auth-configured servers require HTTP. See the
90
- [authorization guide](https://github.com/keshavkatwe/toolgrain/blob/main/docs/authorization.md).
91
+ [authorization guide](https://toolgrain.mintlify.site/guides/authorization).
91
92
 
92
93
  ## Requirements and protocol support
93
94
 
@@ -95,8 +96,8 @@ ESM only. Node.js `^24.20.0` or Bun `>=1.4.4 <2`; Zod `^4.6.6` through MCP;
95
96
  TypeScript 5.5.4 or later with `strict` enabled. Both MCP `2026-07-28` and
96
97
  `2025-06-18` are supported over stdio and independent HTTP POSTs with JSON
97
98
  responses. See the
98
- [support policy](https://github.com/keshavkatwe/toolgrain/blob/main/docs/support-policy.md)
99
- and [client compatibility notes](https://github.com/keshavkatwe/toolgrain/blob/main/docs/compatibility.md).
99
+ [support policy](https://toolgrain.mintlify.site/project/support-policy)
100
+ and [client compatibility notes](https://toolgrain.mintlify.site/compatibility/protocol).
100
101
 
101
102
  ## License
102
103
 
@@ -1,15 +1,27 @@
1
1
  import type { AddressInfo } from "node:net";
2
2
  import type { HttpOptions } from "@toolgrain/http";
3
3
  import type { RequestTransport } from "@toolgrain/mcp";
4
+ /** Managed listener settings plus the shared HTTP endpoint and validation options. */
4
5
  export interface HttpTransportOptions extends HttpOptions {
5
6
  /** Defaults to 3000. Use 0 to let the operating system choose a port. */
6
7
  port?: number;
7
8
  /** Bind address; defaults to 127.0.0.1. This is separate from allowedHosts. */
8
9
  hostname?: string;
9
10
  }
11
+ /** Single-use Node HTTP listener owned by the MCP server to which it is attached. */
10
12
  export interface HttpTransport extends RequestTransport {
11
13
  /** A copied bound address, or undefined before startup and after closing. */
12
14
  address(): AddressInfo | undefined;
13
15
  }
14
- /** Own a Node HTTP listener with combined MCP routing and local host defaults. */
16
+ /**
17
+ * Create a managed Node HTTP transport for independent MCP POSTs with JSON responses.
18
+ * `server.listen()` starts its listener and public auth metadata routes when configured.
19
+ * Default accepted hosts are loopback authorities on the actual listening port;
20
+ * `hostname` controls binding separately from the `allowedHosts` request policy.
21
+ *
22
+ * @param options - Listener settings, exact endpoint path, allowlists, and body limit.
23
+ * @returns A single-use request transport with a copied bound-address accessor.
24
+ * Closing through the server aborts active requests and closes listener connections.
25
+ * @throws For an invalid port or bind hostname; listener startup errors reject `listen()`.
26
+ */
15
27
  export declare function http(options?: HttpTransportOptions): HttpTransport;
@@ -1,6 +1,16 @@
1
1
  import { createServer as createHttpServer, } from "node:http";
2
2
  import { createNodeHttpHandler } from "./http.js";
3
- /** Own a Node HTTP listener with combined MCP routing and local host defaults. */
3
+ /**
4
+ * Create a managed Node HTTP transport for independent MCP POSTs with JSON responses.
5
+ * `server.listen()` starts its listener and public auth metadata routes when configured.
6
+ * Default accepted hosts are loopback authorities on the actual listening port;
7
+ * `hostname` controls binding separately from the `allowedHosts` request policy.
8
+ *
9
+ * @param options - Listener settings, exact endpoint path, allowlists, and body limit.
10
+ * @returns A single-use request transport with a copied bound-address accessor.
11
+ * Closing through the server aborts active requests and closes listener connections.
12
+ * @throws For an invalid port or bind hostname; listener startup errors reject `listen()`.
13
+ */
4
14
  export function http(options = {}) {
5
15
  const port = options.port ?? 3000;
6
16
  const hostname = options.hostname ?? "127.0.0.1";
package/dist/http.d.ts CHANGED
@@ -1,5 +1,26 @@
1
1
  import { type HttpOptions } from "@toolgrain/http";
2
2
  import type { Server } from "@toolgrain/mcp";
3
- /** Mount at the root before body parsing. Delegates unmatched paths when next is supplied. */
3
+ /**
4
+ * Create a Node handler combining MCP and public protected-resource metadata routes.
5
+ * Mount it at the application root before body parsing. Owned routes validate hosts
6
+ * before authentication or body work; forwarded headers are ignored.
7
+ *
8
+ * @param server - Server that authorizes and dispatches each independent request.
9
+ * @param options - Endpoint, host/origin allowlists, and request-body limit.
10
+ * @returns An async `(input, output, next?)` handler for Node requests/responses.
11
+ * Unmatched paths call `next()` when supplied; otherwise they return 404.
12
+ * The application owns its listener, TLS, CORS, and trusted proxy normalization.
13
+ * @throws For invalid HTTP configuration when constructing the handler.
14
+ */
4
15
  export declare function createNodeHttpHandler(server: Server, options?: HttpOptions): (input: import("http").IncomingMessage, output: import("http").ServerResponse, next?: () => void) => Promise<void>;
16
+ /**
17
+ * Create a public GET/HEAD handler for an auth-configured server's well-known metadata route.
18
+ * Register it separately when a framework requires explicit route registration.
19
+ * Hosts are checked before metadata work; unmatched metadata paths return 404.
20
+ *
21
+ * @param server - Auth-configured MCP server whose public resource metadata is advertised.
22
+ * @param options - Host allowlist; defaults to loopback hosts on any port.
23
+ * @returns An async handler accepting a Node request and response; it does not own a listener.
24
+ * @throws If authorization is not configured or the host allowlist is invalid.
25
+ */
5
26
  export declare function createNodeProtectedResourceMetadataHandler(server: Server, options?: Pick<HttpOptions, "allowedHosts">): (input: import("http").IncomingMessage, output: import("http").ServerResponse, next?: () => void) => Promise<void>;
package/dist/http.js CHANGED
@@ -1,10 +1,31 @@
1
1
  import { createHttpHandler, createProtectedResourceMetadataHandler, } from "@toolgrain/http";
2
2
  import { nodeHttpHandler } from "./http-handler.js";
3
- /** Mount at the root before body parsing. Delegates unmatched paths when next is supplied. */
3
+ /**
4
+ * Create a Node handler combining MCP and public protected-resource metadata routes.
5
+ * Mount it at the application root before body parsing. Owned routes validate hosts
6
+ * before authentication or body work; forwarded headers are ignored.
7
+ *
8
+ * @param server - Server that authorizes and dispatches each independent request.
9
+ * @param options - Endpoint, host/origin allowlists, and request-body limit.
10
+ * @returns An async `(input, output, next?)` handler for Node requests/responses.
11
+ * Unmatched paths call `next()` when supplied; otherwise they return 404.
12
+ * The application owns its listener, TLS, CORS, and trusted proxy normalization.
13
+ * @throws For invalid HTTP configuration when constructing the handler.
14
+ */
4
15
  export function createNodeHttpHandler(server, options) {
5
16
  const handle = createHttpHandler(server, options);
6
17
  return nodeHttpHandler(handle, handle.matches);
7
18
  }
19
+ /**
20
+ * Create a public GET/HEAD handler for an auth-configured server's well-known metadata route.
21
+ * Register it separately when a framework requires explicit route registration.
22
+ * Hosts are checked before metadata work; unmatched metadata paths return 404.
23
+ *
24
+ * @param server - Auth-configured MCP server whose public resource metadata is advertised.
25
+ * @param options - Host allowlist; defaults to loopback hosts on any port.
26
+ * @returns An async handler accepting a Node request and response; it does not own a listener.
27
+ * @throws If authorization is not configured or the host allowlist is invalid.
28
+ */
8
29
  export function createNodeProtectedResourceMetadataHandler(server, options) {
9
30
  return nodeHttpHandler(createProtectedResourceMetadataHandler(server, options));
10
31
  }
package/dist/stdio.d.ts CHANGED
@@ -1,10 +1,21 @@
1
1
  import type { Readable, Writable } from "node:stream";
2
2
  import type { Transport } from "@toolgrain/mcp";
3
+ /** Streams and framing limit for a single-use, newline-delimited JSON transport. */
3
4
  export interface StdioOptions {
5
+ /** Incoming UTF-8 JSON stream; defaults to process stdin and remains application-owned. */
4
6
  input?: Readable;
7
+ /** Outgoing MCP response stream; defaults to process stdout and must not contain application logs. */
5
8
  output?: Writable;
6
9
  /** Maximum UTF-8 bytes per incoming message, excluding its newline. Default: 1 MiB. */
7
10
  maxMessageBytes?: number;
8
11
  }
9
- /** A single-use transport; supplied streams remain owned by the caller. */
12
+ /**
13
+ * Create a single-use stdio transport with newline framing and write backpressure.
14
+ * Attach it through `server.listen()`. Closing detaches listeners and pauses input;
15
+ * supplied streams remain application-owned and are not ended or destroyed.
16
+ *
17
+ * @param options - Input/output streams and a positive incoming-message byte limit.
18
+ * @returns A transport that can be attached once and cannot restart after closing.
19
+ * @throws `RangeError` if `maxMessageBytes` is not a positive safe integer.
20
+ */
10
21
  export declare function stdio(options?: StdioOptions): Transport;
package/dist/stdio.js CHANGED
@@ -1,7 +1,15 @@
1
1
  import { stdin, stdout } from "node:process";
2
2
  import { createMessageDecoder } from "./framing.js";
3
3
  import { writeLine } from "./write.js";
4
- /** A single-use transport; supplied streams remain owned by the caller. */
4
+ /**
5
+ * Create a single-use stdio transport with newline framing and write backpressure.
6
+ * Attach it through `server.listen()`. Closing detaches listeners and pauses input;
7
+ * supplied streams remain application-owned and are not ended or destroyed.
8
+ *
9
+ * @param options - Input/output streams and a positive incoming-message byte limit.
10
+ * @returns A transport that can be attached once and cannot restart after closing.
11
+ * @throws `RangeError` if `maxMessageBytes` is not a positive safe integer.
12
+ */
5
13
  export function stdio(options = {}) {
6
14
  return new StdioTransport(options);
7
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toolgrain/node",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Node.js stdio and HTTP transports for Toolgrain MCP servers.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,7 +8,7 @@
8
8
  "url": "git+https://github.com/keshavkatwe/toolgrain.git",
9
9
  "directory": "packages/node"
10
10
  },
11
- "homepage": "https://github.com/keshavkatwe/toolgrain/tree/main/packages/node#readme",
11
+ "homepage": "https://toolgrain.mintlify.site/reference/node",
12
12
  "bugs": {
13
13
  "url": "https://github.com/keshavkatwe/toolgrain/issues"
14
14
  },
@@ -53,9 +53,9 @@
53
53
  "@toolgrain/repo-tools": "0.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@toolgrain/mcp": "0.1.1",
57
- "@toolgrain/protocol": "0.1.1",
58
- "@toolgrain/http": "0.1.1"
56
+ "@toolgrain/mcp": "0.1.3",
57
+ "@toolgrain/protocol": "0.1.3",
58
+ "@toolgrain/http": "0.1.3"
59
59
  },
60
60
  "engines": {
61
61
  "node": "^24.20.0",