toolcraft 0.0.345 → 0.0.346
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 +3 -3
- package/dist/composition.json +3 -3
- package/node_modules/tiny-http-mcp-server/dist/composition.json +1 -1
- package/node_modules/tiny-http-mcp-server/package.json +1 -1
- package/node_modules/tiny-mcp-client/README.md +18 -13
- package/node_modules/tiny-mcp-client/dist/index.d.ts +7 -1
- package/node_modules/tiny-mcp-client/dist/index.js +25 -7
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +2 -2
package/composition.json
CHANGED
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"name": "tiny-http-mcp-server",
|
|
101
|
-
"version": "0.1.
|
|
101
|
+
"version": "0.1.74",
|
|
102
102
|
"license": "MIT"
|
|
103
103
|
},
|
|
104
104
|
{
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "toolcraft",
|
|
116
|
-
"version": "0.0.
|
|
116
|
+
"version": "0.0.346",
|
|
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.
|
|
126
|
+
"version": "0.0.346",
|
|
127
127
|
"license": "MIT"
|
|
128
128
|
},
|
|
129
129
|
{
|
package/dist/composition.json
CHANGED
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"name": "tiny-http-mcp-server",
|
|
101
|
-
"version": "0.1.
|
|
101
|
+
"version": "0.1.74",
|
|
102
102
|
"license": "MIT"
|
|
103
103
|
},
|
|
104
104
|
{
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "toolcraft",
|
|
116
|
-
"version": "0.0.
|
|
116
|
+
"version": "0.0.346",
|
|
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.
|
|
126
|
+
"version": "0.0.346",
|
|
127
127
|
"license": "MIT"
|
|
128
128
|
},
|
|
129
129
|
{
|
|
@@ -66,6 +66,10 @@ validation when preparing a registry before constructing transports.
|
|
|
66
66
|
Receive streams may carry many bounded events and keepalive comments; the limit
|
|
67
67
|
does not cap their lifetime bytes. Use request deadlines and cancellation to
|
|
68
68
|
bound pending operations.
|
|
69
|
+
Receive reconnections retain the last completed event ID through events and
|
|
70
|
+
keepalives without IDs. An explicit empty `id:` clears the resume header,
|
|
71
|
+
including any initially configured value.
|
|
72
|
+
Unicode event IDs use UTF-8 bytes in `Last-Event-ID` headers.
|
|
69
73
|
HTTP failures expose `HttpTransportError.status` and `.method`, so callers can
|
|
70
74
|
make transport decisions without parsing error messages. Legacy HTTP/SSE
|
|
71
75
|
`connect()` also waits for the initialized notification POST to complete before
|
|
@@ -83,29 +87,30 @@ the same optional `closeReason` promise when closing requires asynchronous work.
|
|
|
83
87
|
`HttpTransport` accepts `oauth` options from `mcp-oauth`. When a protected server returns a Bearer `WWW-Authenticate` challenge, the transport discovers protected-resource metadata, loads authorization-server metadata, lets the OAuth provider handle authorization, and retries the request when credentials are available.
|
|
84
88
|
|
|
85
89
|
```ts
|
|
86
|
-
import { HttpTransport
|
|
90
|
+
import { HttpTransport } from "tiny-mcp-client";
|
|
87
91
|
|
|
88
92
|
const transport = new HttpTransport({
|
|
89
93
|
url: "https://mcp.example.com/mcp",
|
|
90
94
|
oauth: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
clientName: "tiny-client"
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
browser: {
|
|
99
|
-
openBrowser: async (url) => {
|
|
100
|
-
console.log(`Open ${url}`);
|
|
101
|
-
}
|
|
95
|
+
client: {
|
|
96
|
+
mode: "dynamic",
|
|
97
|
+
metadata: {
|
|
98
|
+
clientName: "tiny-client"
|
|
102
99
|
}
|
|
103
|
-
}
|
|
100
|
+
},
|
|
101
|
+
browser: {
|
|
102
|
+
openBrowser: async (url) => {
|
|
103
|
+
console.log(`Open ${url}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
104
106
|
}
|
|
105
107
|
});
|
|
106
108
|
```
|
|
107
109
|
|
|
108
110
|
You can also call `discoverOAuthMetadata(resourceUrl, options)` directly, or instantiate `OAuthMetadataDiscovery` with a custom `fetch` implementation and shared cache. An explicit `resourceMetadataUrl` requires fresh network discovery without reading either cache; validated results still populate both caches. Lookup options accept `signal`; cancellation stops metadata fetches and body reads without trying another discovery candidate. It also settles while shared-cache reads, writes or eviction wait. Host cache work may finish afterward; its late rejection remains observed, and canceled discovery does not start another candidate.
|
|
111
|
+
Resource/issuer binding mismatches and exhausted authorization-server discovery
|
|
112
|
+
expose `OAuthMetadataError.phase` while retaining complete SDK messages.
|
|
113
|
+
`OAuthMetadataError.is(value)` recognizes separately bundled native copies.
|
|
109
114
|
|
|
110
115
|
OAuth provider inputs receive the originating request's `signal`, covering header authorization and unauthorized handling. Modern request cancellation stops its OAuth work while leaving other requests usable; transport disposal cancels all pending OAuth operations. The default provider propagates this signal to callback, registration and token work. Custom providers must observe it for their own operations.
|
|
111
116
|
|
|
@@ -304,6 +304,12 @@ interface OAuthMetadataLookupOptions {
|
|
|
304
304
|
resourceMetadataUrl?: string | URL;
|
|
305
305
|
signal?: AbortSignal;
|
|
306
306
|
}
|
|
307
|
+
/** Native metadata failure with complete SDK diagnostics and a safe phase. */
|
|
308
|
+
declare class OAuthMetadataError extends Error {
|
|
309
|
+
readonly phase: "protected-resource" | "authorization-server";
|
|
310
|
+
static is(value: unknown): value is OAuthMetadataError;
|
|
311
|
+
constructor(phase: "protected-resource" | "authorization-server", message: string);
|
|
312
|
+
}
|
|
307
313
|
declare class OAuthMetadataDiscovery {
|
|
308
314
|
private readonly fetchImpl;
|
|
309
315
|
private readonly cache;
|
|
@@ -874,5 +880,5 @@ declare class JsonRpcMessageLayer {
|
|
|
874
880
|
private handleCancellationNotification;
|
|
875
881
|
}
|
|
876
882
|
|
|
877
|
-
export { ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, HttpTransportError, JsonRpcMessageLayer, MCP_PROTOCOL_VERSIONS, McpClient, McpError, OAuthMetadataDiscovery, StdioTransport, createInMemoryTransportPair, createSdkTestPair, createTestPair, discoverOAuthMetadata, fetchMcpResponse, snapshotHttpTransportHeaders };
|
|
883
|
+
export { ERROR_INTERNAL, ERROR_INVALID_PARAMS, ERROR_INVALID_REQUEST, ERROR_METHOD_NOT_FOUND, ERROR_PARSE, HttpTransport, HttpTransportError, JsonRpcMessageLayer, MCP_PROTOCOL_VERSIONS, McpClient, McpError, OAuthMetadataDiscovery, OAuthMetadataError, StdioTransport, createInMemoryTransportPair, createSdkTestPair, createTestPair, discoverOAuthMetadata, fetchMcpResponse, snapshotHttpTransportHeaders };
|
|
878
884
|
export type { AudioContent, BlobResourceContents, CacheableResultMetadata, CallToolOptions, CallToolParams, CallToolResult, ClientCapabilities, CompleteArgument, CompleteParams, CompleteResult, Completion, ConnectResult, ContentItem, CreateMessageParams, CreateMessageResult, ElicitationParams, ElicitationResult, EmbeddedResource, GetPromptParams, GetPromptResult, HttpTransportFetch, HttpTransportOptions, ImageContent, InMemoryTransportPair, IncludeContext, InitializeParams, InitializeResult, JsonRpcErrorObject, JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcRequestOptions, JsonRpcResponse, JsonRpcSuccessResponse, LogLevel, LogMessage, McpClientConnection, McpClientOptions, McpProtocolVersion, McpRequestContext, McpSubscription, McpTransport, McpTransportClosedEvent, ModelHint, ModelPreferences, NotificationFilter, OAuthAuthorizationServerMetadata, OAuthClientProvider, OAuthClientProviderOptions, OAuthDiscoveryCache, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthSessionStore, OAuthUnauthorizedChallenge, PaginatedParams, PaginatedResult, ProgressParams, ProgressToken, PromptMessage, PromptReference, ReadResourceParams, RequestId, ResourceContents, ResourceReference, ResultMetadata, Root, SamplingContent, SamplingMessage, SdkTestPair, ServerCapabilities, StdioSpawn, StdioTransportOptions, StoredOAuthSession, SubscriptionOptions, TextContent, TextResourceContents, Tool, ToolResultContent, ToolUseContent };
|
|
@@ -6244,6 +6244,19 @@ function createParameterHeaders(definitions, argumentsValue) {
|
|
|
6244
6244
|
|
|
6245
6245
|
// src/oauth-discovery.ts
|
|
6246
6246
|
import { isIP as isIP2 } from "node:net";
|
|
6247
|
+
var metadataErrorBrand = /* @__PURE__ */ Symbol.for("poe-platform.tiny-mcp-client.OAuthMetadataError");
|
|
6248
|
+
var OAuthMetadataError = class extends Error {
|
|
6249
|
+
constructor(phase, message) {
|
|
6250
|
+
super(message);
|
|
6251
|
+
this.phase = phase;
|
|
6252
|
+
this.name = "OAuthMetadataError";
|
|
6253
|
+
Object.defineProperty(this, metadataErrorBrand, { value: true });
|
|
6254
|
+
}
|
|
6255
|
+
phase;
|
|
6256
|
+
static is(value) {
|
|
6257
|
+
return value instanceof Error && Object.getOwnPropertyDescriptor(value, metadataErrorBrand)?.value === true;
|
|
6258
|
+
}
|
|
6259
|
+
};
|
|
6247
6260
|
function defaultOAuthMetadataFetch(input, init) {
|
|
6248
6261
|
return fetch(input, init);
|
|
6249
6262
|
}
|
|
@@ -6281,7 +6294,8 @@ function validateProtectedResourceMetadata(value, resourceUrl) {
|
|
|
6281
6294
|
}
|
|
6282
6295
|
const normalizedResource = canonicalizeResourceIndicator(value.resource);
|
|
6283
6296
|
if (normalizedResource !== resourceUrl) {
|
|
6284
|
-
throw new
|
|
6297
|
+
throw new OAuthMetadataError(
|
|
6298
|
+
"protected-resource",
|
|
6285
6299
|
`Protected resource metadata resource mismatch: expected ${resourceUrl}, received ${value.resource}`
|
|
6286
6300
|
);
|
|
6287
6301
|
}
|
|
@@ -6303,7 +6317,8 @@ function validateAuthorizationServerMetadata(value, issuer) {
|
|
|
6303
6317
|
throw new Error("Authorization server metadata must include issuer");
|
|
6304
6318
|
}
|
|
6305
6319
|
if (value.issuer !== issuer) {
|
|
6306
|
-
throw new
|
|
6320
|
+
throw new OAuthMetadataError(
|
|
6321
|
+
"authorization-server",
|
|
6307
6322
|
`Authorization server metadata issuer mismatch: expected ${issuer}, received ${value.issuer}`
|
|
6308
6323
|
);
|
|
6309
6324
|
}
|
|
@@ -6546,7 +6561,8 @@ var OAuthMetadataDiscovery = class {
|
|
|
6546
6561
|
}
|
|
6547
6562
|
}
|
|
6548
6563
|
}
|
|
6549
|
-
throw new
|
|
6564
|
+
throw new OAuthMetadataError(
|
|
6565
|
+
"authorization-server",
|
|
6550
6566
|
`Unable to load authorization server metadata for ${cacheKey}: ${authorizationServerErrors.join(
|
|
6551
6567
|
"; "
|
|
6552
6568
|
)}`
|
|
@@ -8004,7 +8020,8 @@ var HttpTransport = class {
|
|
|
8004
8020
|
}
|
|
8005
8021
|
if (this.legacyProtocolVersion !== void 0) headers.set("MCP-Protocol-Version", this.legacyProtocolVersion);
|
|
8006
8022
|
if (this.lastEventId !== void 0) {
|
|
8007
|
-
headers.
|
|
8023
|
+
if (this.lastEventId === "") headers.delete("Last-Event-ID");
|
|
8024
|
+
else headers.set("Last-Event-ID", Buffer.from(this.lastEventId, "utf8").toString("latin1"));
|
|
8008
8025
|
}
|
|
8009
8026
|
return this.authorizeRequestHeaders(headers, signal);
|
|
8010
8027
|
}
|
|
@@ -8263,15 +8280,15 @@ var HttpTransport = class {
|
|
|
8263
8280
|
void reader.cancel().catch(() => void 0);
|
|
8264
8281
|
return;
|
|
8265
8282
|
}
|
|
8266
|
-
this.lastEventId = parser.lastEventId;
|
|
8283
|
+
this.lastEventId = parser.lastEventId ?? this.lastEventId;
|
|
8267
8284
|
}
|
|
8268
8285
|
const trailingChunk = decoder.decode();
|
|
8269
8286
|
if (trailingChunk.length > 0) {
|
|
8270
8287
|
this.writeSseMessages(parser.push(trailingChunk), context);
|
|
8271
|
-
this.lastEventId = parser.lastEventId;
|
|
8288
|
+
this.lastEventId = parser.lastEventId ?? this.lastEventId;
|
|
8272
8289
|
}
|
|
8273
8290
|
this.writeSseMessages(parser.flush(), context);
|
|
8274
|
-
this.lastEventId = parser.lastEventId;
|
|
8291
|
+
this.lastEventId = parser.lastEventId ?? this.lastEventId;
|
|
8275
8292
|
if (context !== void 0 && !context.completed) throw new Error("MCP HTTP stream ended before its final response");
|
|
8276
8293
|
} catch (error) {
|
|
8277
8294
|
void reader.cancel().catch(() => void 0);
|
|
@@ -9282,6 +9299,7 @@ export {
|
|
|
9282
9299
|
McpClient,
|
|
9283
9300
|
McpError,
|
|
9284
9301
|
OAuthMetadataDiscovery,
|
|
9302
|
+
OAuthMetadataError,
|
|
9285
9303
|
StdioTransport,
|
|
9286
9304
|
createInMemoryTransportPair,
|
|
9287
9305
|
createSdkTestPair,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.346",
|
|
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.
|
|
161
|
+
"toolcraft-schema": "0.0.346",
|
|
162
162
|
"toolcraft-design": "*",
|
|
163
163
|
"@poe-code/frontmatter": "*",
|
|
164
164
|
"@poe-code/agent-mcp-config": "*",
|