@wrongstack/mcp 1.0.19 → 1.0.26
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/authorization-callback-server.d.ts +24 -0
- package/dist/authorization-discovery.d.ts +96 -0
- package/dist/authorization-manager.d.ts +46 -1
- package/dist/authorization-registration.d.ts +39 -0
- package/dist/authorization.d.ts +6 -61
- package/dist/client-capabilities.d.ts +15 -0
- package/dist/client-http-connection.d.ts +22 -0
- package/dist/client-process.d.ts +6 -0
- package/dist/client-types.d.ts +70 -0
- package/dist/client.d.ts +17 -47
- package/dist/config-env.d.ts +18 -0
- package/dist/constants.d.ts +26 -5
- package/dist/contracts.d.ts +21 -0
- package/dist/elicitation-form.d.ts +26 -0
- package/dist/elicitation.d.ts +151 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +2176 -805
- package/dist/manage.d.ts +1 -0
- package/dist/manifest-cache.d.ts +1 -0
- package/dist/protocol.d.ts +10 -0
- package/dist/registry-authorization.d.ts +3 -2
- package/dist/registry-connect-loop.d.ts +1 -0
- package/dist/registry-slots.d.ts +6 -0
- package/dist/registry-types.d.ts +6 -0
- package/dist/registry.d.ts +12 -1
- package/dist/server.d.ts +6 -3
- package/dist/structured-result.d.ts +7 -0
- package/dist/token-store.d.ts +5 -1
- package/dist/tool-schema.d.ts +14 -1
- package/dist/transport-base.d.ts +21 -4
- package/dist/transport-streamable.d.ts +14 -1
- package/dist/wrap-tool.d.ts +4 -2
- package/package.json +2 -2
package/dist/contracts.d.ts
CHANGED
|
@@ -18,11 +18,32 @@ export interface MCPTool {
|
|
|
18
18
|
name: string;
|
|
19
19
|
description?: string | undefined;
|
|
20
20
|
inputSchema: Record<string, unknown>;
|
|
21
|
+
/** JSON Schema of the tool's `structuredContent` (spec 2025-06-18). */
|
|
22
|
+
outputSchema?: Record<string, unknown> | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* URL-mode elicitation (spec 2025-11-25): the server asks the user to open a
|
|
26
|
+
* web page for something that must not pass through the client — a
|
|
27
|
+
* third-party sign-in, an API key, a payment. Only the user's consent crosses
|
|
28
|
+
* the protocol; what happens on the page stays between the user and the server.
|
|
29
|
+
*/
|
|
30
|
+
export interface UrlElicitation {
|
|
31
|
+
mode: 'url';
|
|
32
|
+
message: string;
|
|
33
|
+
url: string;
|
|
34
|
+
elicitationId: string;
|
|
21
35
|
}
|
|
22
36
|
/** Result envelope returned by an MCP `tools/call`. */
|
|
23
37
|
export interface ToolCallResult {
|
|
24
38
|
content: unknown;
|
|
25
39
|
isError: boolean;
|
|
40
|
+
/** The typed result object, when the tool returns one (spec 2025-06-18). */
|
|
41
|
+
structuredContent?: Record<string, unknown> | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Pages the user must open before the call can succeed: the server answered
|
|
44
|
+
* with a URL-elicitation-required error (`-32042`, spec 2025-11-25).
|
|
45
|
+
*/
|
|
46
|
+
urlElicitations?: UrlElicitation[] | undefined;
|
|
26
47
|
}
|
|
27
48
|
/** JSON-RPC 2.0 response shape (success or error). */
|
|
28
49
|
export interface JsonRpcResponse {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ElicitationRequester, type MCPElicitationRequest, type MCPElicitationResult } from './elicitation.js';
|
|
2
|
+
/** Opens a page in the user's browser; given by a host that can. */
|
|
3
|
+
export type OpenUrl = (url: string) => void;
|
|
4
|
+
export interface ElicitViaUserInputOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Opens a URL-mode page once the user agrees. Without it the user is only
|
|
7
|
+
* shown the URL to open themselves (the right thing when the browser is on
|
|
8
|
+
* another machine than this process).
|
|
9
|
+
*/
|
|
10
|
+
openUrl?: OpenUrl | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Put a server's elicitation in front of the user as a `clarify`-style form on
|
|
14
|
+
* the run that made the call (or `fallback` when the server asks outside a
|
|
15
|
+
* call), and turn the answers back into schema-checked content.
|
|
16
|
+
*
|
|
17
|
+
* No surface to show it on answers `cancel`; the user dismissing the form is an
|
|
18
|
+
* explicit `decline`. An answer the schema rejects is asked again with the
|
|
19
|
+
* reason, a few times, before giving up.
|
|
20
|
+
*
|
|
21
|
+
* A URL-mode request asks for consent to open a page instead. Nothing is
|
|
22
|
+
* fetched or opened before the user agrees, and `accept` then only means they
|
|
23
|
+
* agreed: the page's outcome reaches the server, not this client.
|
|
24
|
+
*/
|
|
25
|
+
export declare function elicitViaUserInput(request: MCPElicitationRequest, fallback?: ElicitationRequester | undefined, options?: ElicitViaUserInputOptions): Promise<MCPElicitationResult>;
|
|
26
|
+
//# sourceMappingURL=elicitation-form.d.ts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { UserInputRequest, UserInputResponse } from '@wrongstack/core/types';
|
|
2
|
+
import type { UrlElicitation } from './contracts.js';
|
|
3
|
+
export type { UrlElicitation };
|
|
4
|
+
/**
|
|
5
|
+
* MCP elicitation (`elicitation/create`, client feature since 2025-06-18): a
|
|
6
|
+
* server asks the user for a small, flat form of values mid-operation.
|
|
7
|
+
*
|
|
8
|
+
* The requested schema is deliberately restricted by the spec to a flat object
|
|
9
|
+
* of primitive properties, so it is parsed into a list of typed fields here and
|
|
10
|
+
* anything richer is refused as invalid params instead of half-rendered.
|
|
11
|
+
*/
|
|
12
|
+
export type ElicitationValue = string | number | boolean | string[];
|
|
13
|
+
export interface ElicitationOption {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}
|
|
17
|
+
interface ElicitationFieldBase {
|
|
18
|
+
name: string;
|
|
19
|
+
title?: string | undefined;
|
|
20
|
+
description?: string | undefined;
|
|
21
|
+
required: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type ElicitationField = (ElicitationFieldBase & {
|
|
24
|
+
kind: 'string';
|
|
25
|
+
minLength?: number | undefined;
|
|
26
|
+
maxLength?: number | undefined;
|
|
27
|
+
format?: string | undefined;
|
|
28
|
+
default?: string | undefined;
|
|
29
|
+
}) | (ElicitationFieldBase & {
|
|
30
|
+
kind: 'number' | 'integer';
|
|
31
|
+
minimum?: number | undefined;
|
|
32
|
+
maximum?: number | undefined;
|
|
33
|
+
default?: number | undefined;
|
|
34
|
+
}) | (ElicitationFieldBase & {
|
|
35
|
+
kind: 'boolean';
|
|
36
|
+
default?: boolean | undefined;
|
|
37
|
+
}) | (ElicitationFieldBase & {
|
|
38
|
+
kind: 'enum';
|
|
39
|
+
options: ElicitationOption[];
|
|
40
|
+
default?: string | undefined;
|
|
41
|
+
}) | (ElicitationFieldBase & {
|
|
42
|
+
kind: 'multi-enum';
|
|
43
|
+
options: ElicitationOption[];
|
|
44
|
+
minItems?: number | undefined;
|
|
45
|
+
maxItems?: number | undefined;
|
|
46
|
+
default?: string[] | undefined;
|
|
47
|
+
});
|
|
48
|
+
export interface ElicitationForm {
|
|
49
|
+
message: string;
|
|
50
|
+
fields: ElicitationField[];
|
|
51
|
+
}
|
|
52
|
+
/** What a server can put in front of the user: a form, or a page to open. */
|
|
53
|
+
export type ElicitationPrompt = (ElicitationForm & {
|
|
54
|
+
mode?: 'form' | undefined;
|
|
55
|
+
}) | UrlElicitation;
|
|
56
|
+
export type MCPElicitationResult = {
|
|
57
|
+
action: 'accept';
|
|
58
|
+
content: Record<string, ElicitationValue>;
|
|
59
|
+
} | {
|
|
60
|
+
action: 'decline';
|
|
61
|
+
} | {
|
|
62
|
+
action: 'cancel';
|
|
63
|
+
};
|
|
64
|
+
/** The slice of a tool call's run context that can put a form in front of its user. */
|
|
65
|
+
export interface ElicitationRequester {
|
|
66
|
+
requestUserInput(request: UserInputRequest, signal?: AbortSignal): Promise<UserInputResponse | undefined>;
|
|
67
|
+
}
|
|
68
|
+
/** What a host sees: the form or page, which server asks, and the run that caused it. */
|
|
69
|
+
export type MCPElicitationRequest = ElicitationPrompt & {
|
|
70
|
+
server: string;
|
|
71
|
+
/**
|
|
72
|
+
* Context of the newest in-flight tool call to this server, when there is
|
|
73
|
+
* one — the run whose user should answer. Undefined when the server asks
|
|
74
|
+
* outside any tool call.
|
|
75
|
+
*/
|
|
76
|
+
requester?: ElicitationRequester | undefined;
|
|
77
|
+
/** Aborts when the server cancels the request, the connection closes, or the wait runs out. */
|
|
78
|
+
signal: AbortSignal;
|
|
79
|
+
};
|
|
80
|
+
export type MCPElicitationHandler = (request: MCPElicitationRequest) => Promise<MCPElicitationResult>;
|
|
81
|
+
/** The per-connection slice of {@link MCPElicitationHandler} a client is given. */
|
|
82
|
+
export type MCPClientElicitationHandler = (request: ElicitationPrompt & {
|
|
83
|
+
signal: AbortSignal;
|
|
84
|
+
}) => Promise<MCPElicitationResult>;
|
|
85
|
+
type Parsed<T> = {
|
|
86
|
+
ok: true;
|
|
87
|
+
value: T;
|
|
88
|
+
} | {
|
|
89
|
+
ok: false;
|
|
90
|
+
error: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* A URL-mode request: a web page the user is asked to open. Only `http(s)` is
|
|
94
|
+
* accepted — the page is handed to the system browser, and a `file:` or
|
|
95
|
+
* custom-scheme URL would have the operating system run something instead.
|
|
96
|
+
*/
|
|
97
|
+
export declare function parseUrlElicitation(params: unknown): Parsed<UrlElicitation>;
|
|
98
|
+
/**
|
|
99
|
+
* Check accepted content against the form: every required field present, each
|
|
100
|
+
* value of its declared kind and within its bounds, nothing the server did not
|
|
101
|
+
* ask for. Numeric text is coerced so a text box can answer a number field.
|
|
102
|
+
*/
|
|
103
|
+
export declare function validateElicitationContent(fields: readonly ElicitationField[], content: Record<string, unknown>): Parsed<Record<string, ElicitationValue>>;
|
|
104
|
+
type JsonRpcId = number | string;
|
|
105
|
+
export interface ServerRequest {
|
|
106
|
+
id: JsonRpcId;
|
|
107
|
+
method: string;
|
|
108
|
+
params?: unknown;
|
|
109
|
+
}
|
|
110
|
+
export type ServerResponse = {
|
|
111
|
+
jsonrpc: '2.0';
|
|
112
|
+
id: JsonRpcId;
|
|
113
|
+
result: unknown;
|
|
114
|
+
} | {
|
|
115
|
+
jsonrpc: '2.0';
|
|
116
|
+
id: JsonRpcId;
|
|
117
|
+
error: {
|
|
118
|
+
code: number;
|
|
119
|
+
message: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Answers the requests an MCP server sends to this client — one per
|
|
124
|
+
* connection, shared by the stdio, SSE and Streamable HTTP transports so they
|
|
125
|
+
* cannot drift apart on what the client supports.
|
|
126
|
+
*/
|
|
127
|
+
export declare class ServerRequestResponder {
|
|
128
|
+
private readonly elicitation?;
|
|
129
|
+
private readonly pending;
|
|
130
|
+
constructor(elicitation?: MCPClientElicitationHandler | undefined);
|
|
131
|
+
/** Client capabilities to declare in `initialize` — only what can be answered. */
|
|
132
|
+
capabilities(): Record<string, unknown>;
|
|
133
|
+
/** True while an elicitation waits on the user; request timeouts hold meanwhile. */
|
|
134
|
+
get awaitingUser(): boolean;
|
|
135
|
+
answer(request: ServerRequest): Promise<ServerResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Pages a tool call's `-32042` (URL elicitation required) error names, put
|
|
138
|
+
* to the user one at a time. Returns what the user chose for each; nothing
|
|
139
|
+
* is opened without their consent, and without a handler every one is
|
|
140
|
+
* `cancel`.
|
|
141
|
+
*/
|
|
142
|
+
presentUrl(elicitations: readonly UrlElicitation[], signal: AbortSignal): Promise<Array<{
|
|
143
|
+
elicitation: UrlElicitation;
|
|
144
|
+
action: MCPElicitationResult['action'];
|
|
145
|
+
}>>;
|
|
146
|
+
/** `notifications/cancelled` from the server: stop waiting for that answer. */
|
|
147
|
+
cancel(params: unknown): void;
|
|
148
|
+
/** The connection is gone: abandon every open form. */
|
|
149
|
+
dispose(): void;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=elicitation.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
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
|
-
export { type
|
|
2
|
+
export { type MCPOAuthCallbackServer, type MCPOAuthCallbackServerOptions, startMcpOAuthCallbackServer, } from './authorization-callback-server.js';
|
|
3
|
+
export { type MCPAuthorizationCompleteInput, type MCPAuthorizationLoginHandle, type MCPAuthorizationLoginInput, MCPAuthorizationManager, type MCPAuthorizationManagerOptions, type MCPAuthorizationStartInput, type MCPAuthorizationStartResult, type MCPAuthorizationStatus, } from './authorization-manager.js';
|
|
4
|
+
export { type MCPClientRegistration, type MCPClientRegistrationOptions, registerMcpOAuthClient, } from './authorization-registration.js';
|
|
3
5
|
export { MCPClient, type MCPClientOptions, type MCPListChangedListener, type MCPPageOptions, type MCPRequestOptions, type Transport, } from './client.js';
|
|
6
|
+
export { mcpEnvPlaceholders } from './config-env.js';
|
|
4
7
|
export { MCP_CONSTANTS, negotiateProtocolVersion, SUPPORTED_PROTOCOL_VERSIONS, } from './constants.js';
|
|
5
8
|
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
9
|
export type { ConnectionState, JsonRpcResponse, MCPTool, ToolCallResult, } from './contracts.js';
|
|
10
|
+
export type { ElicitationField, ElicitationRequester, MCPElicitationHandler, MCPElicitationRequest, MCPElicitationResult, } from './elicitation.js';
|
|
11
|
+
export { elicitViaUserInput } from './elicitation-form.js';
|
|
7
12
|
export { addMcp, disableMcp, discoverMcp, enableMcp, listMcp, MCP_ENV_MASK, type McpManageDeps, type McpOpResult, type McpServerInfo, type McpServerInput, removeMcp, restartMcp, updateMcp, } from './manage.js';
|
|
8
13
|
export { type MCPCapabilityManifest, manifestConfigHash, readCapabilityManifest, readManifest, writeCapabilityManifest, writeManifest, } from './manifest-cache.js';
|
|
9
14
|
export { MCP_OPERATION_LIMITS, type MCPFailureKind, type MCPHealthState, type MCPLatencySummary, type MCPOperationEvent, type MCPOperationKind, type MCPServerOperationalHealth, } from './operations.js';
|