toolcraft 0.0.185 → 0.0.187

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/composition.json CHANGED
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "name": "tiny-http-mcp-server",
101
- "version": "0.1.10",
101
+ "version": "0.1.11",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.185",
116
+ "version": "0.0.187",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.185",
126
+ "version": "0.0.187",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "name": "tiny-http-mcp-server",
101
- "version": "0.1.10",
101
+ "version": "0.1.11",
102
102
  "license": "MIT"
103
103
  },
104
104
  {
@@ -113,7 +113,7 @@
113
113
  },
114
114
  {
115
115
  "name": "toolcraft",
116
- "version": "0.0.185",
116
+ "version": "0.0.187",
117
117
  "license": "MIT"
118
118
  },
119
119
  {
@@ -123,7 +123,7 @@
123
123
  },
124
124
  {
125
125
  "name": "toolcraft-schema",
126
- "version": "0.0.185",
126
+ "version": "0.0.187",
127
127
  "license": "MIT"
128
128
  },
129
129
  {
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "name": "tiny-http-mcp-server",
21
- "version": "0.1.10",
21
+ "version": "0.1.11",
22
22
  "license": "MIT"
23
23
  },
24
24
  {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-http-mcp-server",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Minimal MCP server over HTTP built on tiny-stdio-mcp-server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -567,6 +567,7 @@ declare class HttpTransport implements McpTransport {
567
567
  private cancelOpenSseReaders;
568
568
  private fetchWithAbort;
569
569
  private consumeWrittenLines;
570
+ private sendPost;
570
571
  private createPostHeaders;
571
572
  private createGetHeaders;
572
573
  private createDeleteHeaders;
@@ -2919,6 +2919,9 @@ var HttpTransport = class {
2919
2919
  this.openSseReaders.clear();
2920
2920
  }
2921
2921
  async fetchWithAbort(input, init) {
2922
+ if (this.disposed) {
2923
+ throw new Error("HTTP transport disposed");
2924
+ }
2922
2925
  const abortController = new AbortController();
2923
2926
  this.inFlightFetchAbortControllers.add(abortController);
2924
2927
  try {
@@ -2935,25 +2938,44 @@ var HttpTransport = class {
2935
2938
  if (this.disposed || line.length === 0) {
2936
2939
  continue;
2937
2940
  }
2938
- const hasSessionId = this.sessionId !== void 0;
2939
- const response = await this.fetchWithOAuthRetry({
2940
- method: "POST",
2941
- createHeaders: () => this.createPostHeaders(),
2942
- body: line
2943
- });
2944
- if (hasSessionId && response.status === 404) {
2945
- this.sessionId = void 0;
2946
- this.dispose(new Error("HTTP transport session expired (404 response)"));
2947
- return;
2941
+ const parsed = parseJsonRpcMessage(line);
2942
+ const post = this.sendPost(line);
2943
+ if (parsed.type === "request" && parsed.message.method === "initialize" || parsed.type === "notification" && parsed.message.method === "notifications/initialized") {
2944
+ await post;
2945
+ } else {
2946
+ void post.catch((error) => {
2947
+ this.dispose(error instanceof Error ? error : new Error(String(error)));
2948
+ });
2948
2949
  }
2949
- await this.throwForPostHttpError(response);
2950
- this.captureSessionId(response);
2951
- this.maybeOpenGetSseStream();
2952
- void this.forwardResponseMessages(response).catch((error) => {
2953
- this.dispose(error instanceof Error ? error : new Error(String(error)));
2954
- });
2955
2950
  }
2956
2951
  }
2952
+ async sendPost(line) {
2953
+ const hasSessionId = this.sessionId !== void 0;
2954
+ const response = await this.fetchWithOAuthRetry({
2955
+ method: "POST",
2956
+ createHeaders: () => this.createPostHeaders(),
2957
+ body: line
2958
+ });
2959
+ if (this.disposed) {
2960
+ await response.body?.cancel();
2961
+ return;
2962
+ }
2963
+ if (hasSessionId && response.status === 404) {
2964
+ this.sessionId = void 0;
2965
+ this.dispose(new Error("HTTP transport session expired (404 response)"));
2966
+ return;
2967
+ }
2968
+ await this.throwForPostHttpError(response);
2969
+ if (this.disposed) {
2970
+ await response.body?.cancel();
2971
+ return;
2972
+ }
2973
+ this.captureSessionId(response);
2974
+ this.maybeOpenGetSseStream();
2975
+ void this.forwardResponseMessages(response).catch((error) => {
2976
+ this.dispose(error instanceof Error ? error : new Error(String(error)));
2977
+ });
2978
+ }
2957
2979
  async createPostHeaders() {
2958
2980
  const headers = new Headers(this.headers);
2959
2981
  headers.set("Accept", "application/json, text/event-stream");
@@ -3750,6 +3772,19 @@ function isJsonRpcErrorObject(value) {
3750
3772
  }
3751
3773
  return value.data === void 0 || hasOwn(value, "data");
3752
3774
  }
3775
+ function parseJsonRpcMessage(line) {
3776
+ let parsed;
3777
+ try {
3778
+ parsed = JSON.parse(line);
3779
+ } catch {
3780
+ return {
3781
+ type: "invalid",
3782
+ id: null,
3783
+ error: parseError()
3784
+ };
3785
+ }
3786
+ return parseJsonRpcPayload(parsed);
3787
+ }
3753
3788
  function parseJsonRpcPayload(parsed) {
3754
3789
  if (!isObjectRecord5(parsed)) {
3755
3790
  return {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  {
10
10
  "name": "toolcraft-schema",
11
- "version": "0.0.185",
11
+ "version": "0.0.187",
12
12
  "license": "MIT"
13
13
  }
14
14
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.185",
3
+ "version": "0.0.187",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft",
3
- "version": "0.0.185",
3
+ "version": "0.0.187",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -158,7 +158,7 @@
158
158
  "yaml"
159
159
  ],
160
160
  "optionalDependencies": {
161
- "toolcraft-schema": "0.0.185",
161
+ "toolcraft-schema": "0.0.187",
162
162
  "toolcraft-design": "*",
163
163
  "@poe-code/frontmatter": "*",
164
164
  "@poe-code/agent-mcp-config": "*",