@wrongstack/mcp 1.0.3 → 1.0.4
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/dist/constants.d.ts +29 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -3
- package/package.json +2 -2
package/dist/constants.d.ts
CHANGED
|
@@ -6,9 +6,36 @@
|
|
|
6
6
|
* - Reconnect parameters can be overridden via config in the future
|
|
7
7
|
* - No scattered magic values across multiple files
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Protocol revisions this package actually implements, newest first.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately conservative: a revision belongs here only once its wire
|
|
13
|
+
* requirements are met, because the version we send in `initialize` is a
|
|
14
|
+
* promise about what the peer may then use. WrongStack speaks the 2024-11-05
|
|
15
|
+
* shape — tools, resources, prompts, sampling — and does not implement the
|
|
16
|
+
* additions of later revisions (elicitation, structured tool output, resource
|
|
17
|
+
* links), so listing one of those would advertise capabilities that are not
|
|
18
|
+
* there.
|
|
19
|
+
*
|
|
20
|
+
* Adding a revision: implement its additions, then put it at the FRONT.
|
|
21
|
+
* `PROTOCOL_VERSION` follows automatically, and the negotiation below starts
|
|
22
|
+
* accepting a peer that asks for it.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Pick the version to answer an `initialize` with.
|
|
27
|
+
*
|
|
28
|
+
* The spec's rule: echo what the peer asked for when it is supported,
|
|
29
|
+
* otherwise reply with our own latest and let the peer decide whether it can
|
|
30
|
+
* continue. Before this existed the server ignored the request entirely and
|
|
31
|
+
* always answered `2024-11-05`, so a peer that asked for a newer revision was
|
|
32
|
+
* told it had been granted nothing of the sort — silently, with no way to see
|
|
33
|
+
* the mismatch.
|
|
34
|
+
*/
|
|
35
|
+
export declare function negotiateProtocolVersion(requested: unknown): string;
|
|
9
36
|
export declare const MCP_CONSTANTS: Readonly<{
|
|
10
|
-
/** MCP protocol version advertised during handshake. */
|
|
11
|
-
readonly PROTOCOL_VERSION:
|
|
37
|
+
/** MCP protocol version advertised during handshake: the newest we implement. */
|
|
38
|
+
readonly PROTOCOL_VERSION: string;
|
|
12
39
|
/** Identity announced to MCP servers during `initialize`. */
|
|
13
40
|
readonly CLIENT_INFO: Readonly<{
|
|
14
41
|
name: "wrongstack";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { authorizationHeaderForToken, authorizationServerMetadataUrls, canonicalMcpResource, createMcpAuthorizationRequest, discoverMcpAuthorization, exchangeMcpAuthorizationCode, type MCPAccessToken, type MCPAuthorizationChallenge, type MCPAuthorizationContext, type MCPAuthorizationDiscoveryOptions, type MCPAuthorizationDiscoveryResult, type MCPAuthorizationJsonFetcher, type MCPAuthorizationProvider, type MCPAuthorizationRequestOptions, type MCPAuthorizationServerMetadata, type MCPAuthorizationSession, type MCPProtectedResourceMetadata, type MCPTokenExchangeOptions, type MCPTokenRefreshOptions, type MCPTokenSet, parseAuthorizationServerMetadata, parseMcpAuthorizationCallback, parseMcpBearerChallenge, parseProtectedResourceMetadata, protectedResourceMetadataUrls, refreshMcpAccessToken, validateMcpAuthorizationServerMetadata, } from './authorization.js';
|
|
2
2
|
export { type MCPAuthorizationCompleteInput, MCPAuthorizationManager, type MCPAuthorizationManagerOptions, type MCPAuthorizationStartInput, type MCPAuthorizationStartResult, type MCPAuthorizationStatus, } from './authorization-manager.js';
|
|
3
3
|
export { MCPClient, type MCPClientOptions, type MCPListChangedListener, type MCPPageOptions, type MCPRequestOptions, type Transport, } from './client.js';
|
|
4
|
-
export { MCP_CONSTANTS } from './constants.js';
|
|
4
|
+
export { MCP_CONSTANTS, negotiateProtocolVersion, SUPPORTED_PROTOCOL_VERSIONS, } from './constants.js';
|
|
5
5
|
export { DEFAULT_MCP_INSERTION_MAX_BYTES, DEFAULT_MCP_RESOURCE_SCHEMES, type MCPContentProvenance, type MCPInsertionPolicy, type MCPPromptInsertion, type MCPResourceInsertion, preparePromptInsertion, prepareResourceInsertion, } from './content-selection.js';
|
|
6
6
|
export type { ConnectionState, JsonRpcResponse, MCPTool, ToolCallResult, } from './contracts.js';
|
|
7
7
|
export { addMcp, disableMcp, discoverMcp, enableMcp, listMcp, MCP_ENV_MASK, type McpManageDeps, type McpOpResult, type McpServerInfo, type McpServerInput, removeMcp, restartMcp, updateMcp, } from './manage.js';
|
package/dist/index.js
CHANGED
|
@@ -875,9 +875,16 @@ function parseEmptyResult(value) {
|
|
|
875
875
|
}
|
|
876
876
|
|
|
877
877
|
// src/constants.ts
|
|
878
|
+
var SUPPORTED_PROTOCOL_VERSIONS = Object.freeze(["2024-11-05"]);
|
|
879
|
+
function negotiateProtocolVersion(requested) {
|
|
880
|
+
if (typeof requested === "string" && SUPPORTED_PROTOCOL_VERSIONS.includes(requested)) {
|
|
881
|
+
return requested;
|
|
882
|
+
}
|
|
883
|
+
return MCP_CONSTANTS.PROTOCOL_VERSION;
|
|
884
|
+
}
|
|
878
885
|
var MCP_CONSTANTS = Object.freeze({
|
|
879
|
-
/** MCP protocol version advertised during handshake. */
|
|
880
|
-
PROTOCOL_VERSION:
|
|
886
|
+
/** MCP protocol version advertised during handshake: the newest we implement. */
|
|
887
|
+
PROTOCOL_VERSION: SUPPORTED_PROTOCOL_VERSIONS[0],
|
|
881
888
|
/** Identity announced to MCP servers during `initialize`. */
|
|
882
889
|
CLIENT_INFO: Object.freeze({
|
|
883
890
|
name: "wrongstack",
|
|
@@ -2464,6 +2471,7 @@ var MCPClient = class _MCPClient {
|
|
|
2464
2471
|
this.disconnectListeners.delete(listener);
|
|
2465
2472
|
}
|
|
2466
2473
|
async connect() {
|
|
2474
|
+
if (this.state === "connected" || this.state === "connecting") return;
|
|
2467
2475
|
this.state = "connecting";
|
|
2468
2476
|
this._serverMetadata = void 0;
|
|
2469
2477
|
try {
|
|
@@ -5029,7 +5037,9 @@ var MCPServer = class {
|
|
|
5029
5037
|
switch (method) {
|
|
5030
5038
|
case "initialize":
|
|
5031
5039
|
return {
|
|
5032
|
-
protocolVersion:
|
|
5040
|
+
protocolVersion: negotiateProtocolVersion(
|
|
5041
|
+
params?.protocolVersion
|
|
5042
|
+
),
|
|
5033
5043
|
capabilities: {
|
|
5034
5044
|
tools: { listChanged: false },
|
|
5035
5045
|
...this.resources.length > 0 ? { resources: { subscribe: false, listChanged: false } } : {},
|
|
@@ -5807,6 +5817,7 @@ export {
|
|
|
5807
5817
|
MCP_OPERATION_LIMITS,
|
|
5808
5818
|
SSEReader,
|
|
5809
5819
|
SSETransport,
|
|
5820
|
+
SUPPORTED_PROTOCOL_VERSIONS,
|
|
5810
5821
|
StreamableHTTPTransport,
|
|
5811
5822
|
addMcp,
|
|
5812
5823
|
authorizationHeaderForToken,
|
|
@@ -5821,6 +5832,7 @@ export {
|
|
|
5821
5832
|
exchangeMcpAuthorizationCode,
|
|
5822
5833
|
listMcp,
|
|
5823
5834
|
manifestConfigHash,
|
|
5835
|
+
negotiateProtocolVersion,
|
|
5824
5836
|
parseAuthorizationServerMetadata,
|
|
5825
5837
|
parseGetPromptResult,
|
|
5826
5838
|
parseListPromptsResult,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wrongstack/mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "WrongStack Model Context Protocol client and registry: stdio, SSE, and streamable HTTP transports.",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"!dist/**/*.map"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@wrongstack/core": "1.0.
|
|
29
|
+
"@wrongstack/core": "1.0.4",
|
|
30
30
|
"undici": "^8.10.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|