@mcp-b/webmcp-types 4.0.0 → 5.0.0
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/LICENSE +1 -1
- package/README.md +61 -175
- package/dist/common.d.ts +11 -293
- package/dist/common.d.ts.map +1 -1
- package/dist/index.d.ts +36 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/json-schema.d.ts +42 -186
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/model-context.d.ts +64 -276
- package/dist/model-context.d.ts.map +1 -1
- package/dist/tool.d.ts +38 -156
- package/dist/tool.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/common.ts +17 -362
- package/src/index.ts +45 -67
- package/src/json-schema.ts +62 -266
- package/src/model-context.ts +101 -378
- package/src/tool.ts +65 -212
package/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,50 +1,20 @@
|
|
|
1
1
|
# @mcp-b/webmcp-types
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript contracts for the current WebMCP API on `document.modelContext`. This package emits declarations only and has no runtime side effects.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Type Safety First
|
|
8
|
-
|
|
9
|
-
This package is the type-safety source of truth for WebMCP.
|
|
10
|
-
|
|
11
|
-
- Infer tool input args from literal `inputSchema`
|
|
12
|
-
- Infer `structuredContent` from literal `outputSchema`
|
|
13
|
-
- Keep safe fallbacks (`Record<string, unknown>`) when schemas are widened/runtime-defined
|
|
14
|
-
- Provide name-aware typed registries with `TypedModelContext`
|
|
15
|
-
|
|
16
|
-
## Why This Package
|
|
17
|
-
|
|
18
|
-
- Global `Document` augmentation for `document.modelContext`
|
|
19
|
-
- Deprecated global `Navigator` augmentation for backward-compatible `navigator.modelContext`
|
|
20
|
-
- Strongly typed tool descriptors and tool responses
|
|
21
|
-
- Literal JSON Schema inference for tool args and `structuredContent`
|
|
22
|
-
- Name-aware helper types for typed tool registries
|
|
23
|
-
- Runtime-agnostic: works with native implementations, polyfills, or adapters
|
|
24
|
-
|
|
25
|
-
## Package Selection
|
|
26
|
-
|
|
27
|
-
| Package | Use When |
|
|
28
|
-
| ------------------------ | ----------------------------------------------------------------------------- |
|
|
29
|
-
| `@mcp-b/webmcp-types` | You only need compile-time types |
|
|
30
|
-
| `@mcp-b/webmcp-polyfill` | You need strict WebMCP core runtime behavior |
|
|
31
|
-
| `@mcp-b/global` | You want core + MCPB bridge extensions (`callTool`, prompts, resources, etc.) |
|
|
5
|
+
The [WebMCP draft](https://webmachinelearning.github.io/webmcp/) is authoritative for the browser API. MCP-B extension types are kept separate from that standard surface.
|
|
32
6
|
|
|
33
7
|
## Install
|
|
34
8
|
|
|
35
9
|
```bash
|
|
36
10
|
pnpm add -D @mcp-b/webmcp-types
|
|
37
|
-
# or
|
|
38
|
-
npm install --save-dev @mcp-b/webmcp-types
|
|
39
11
|
```
|
|
40
12
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
## Activate Global Types
|
|
13
|
+
Use a production dependency when your published declarations reference these types.
|
|
44
14
|
|
|
45
|
-
|
|
15
|
+
## Activate the browser globals
|
|
46
16
|
|
|
47
|
-
|
|
17
|
+
Choose one activation method:
|
|
48
18
|
|
|
49
19
|
```json
|
|
50
20
|
{
|
|
@@ -54,19 +24,17 @@ TypeScript may not automatically include global declarations from npm packages.
|
|
|
54
24
|
}
|
|
55
25
|
```
|
|
56
26
|
|
|
57
|
-
2. Add a triple-slash reference in a global `.d.ts` file:
|
|
58
|
-
|
|
59
27
|
```ts
|
|
60
28
|
/// <reference types="@mcp-b/webmcp-types" />
|
|
61
29
|
```
|
|
62
30
|
|
|
63
|
-
3. Add a type-only import:
|
|
64
|
-
|
|
65
31
|
```ts
|
|
66
32
|
import type {} from '@mcp-b/webmcp-types';
|
|
67
33
|
```
|
|
68
34
|
|
|
69
|
-
|
|
35
|
+
Activation adds the canonical `document.modelContext` type and the optional deprecated navigator compatibility surfaces.
|
|
36
|
+
|
|
37
|
+
## Register a standard tool
|
|
70
38
|
|
|
71
39
|
```ts
|
|
72
40
|
import type { JsonSchemaForInference } from '@mcp-b/webmcp-types';
|
|
@@ -75,166 +43,84 @@ const inputSchema = {
|
|
|
75
43
|
type: 'object',
|
|
76
44
|
properties: {
|
|
77
45
|
query: { type: 'string' },
|
|
78
|
-
limit: { type: 'integer', minimum: 1
|
|
46
|
+
limit: { type: 'integer', minimum: 1 },
|
|
79
47
|
},
|
|
80
48
|
required: ['query'],
|
|
81
49
|
additionalProperties: false,
|
|
82
50
|
} as const satisfies JsonSchemaForInference;
|
|
83
51
|
|
|
84
|
-
const
|
|
85
|
-
type: 'object',
|
|
86
|
-
properties: {
|
|
87
|
-
total: { type: 'integer' },
|
|
88
|
-
items: { type: 'array', items: { type: 'string' } },
|
|
89
|
-
},
|
|
90
|
-
required: ['total'],
|
|
91
|
-
additionalProperties: false,
|
|
92
|
-
} as const satisfies JsonSchemaForInference;
|
|
52
|
+
const controller = new AbortController();
|
|
93
53
|
|
|
94
|
-
document.modelContext.registerTool(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// args is inferred as: { query: string; limit?: number }
|
|
101
|
-
return {
|
|
102
|
-
content: [{ type: 'text', text: `Searching for ${args.query}` }],
|
|
103
|
-
structuredContent: {
|
|
104
|
-
// inferred from outputSchema
|
|
105
|
-
total: 1,
|
|
106
|
-
items: [args.query],
|
|
107
|
-
},
|
|
108
|
-
};
|
|
54
|
+
await document.modelContext.registerTool(
|
|
55
|
+
{
|
|
56
|
+
name: 'search',
|
|
57
|
+
description: 'Search indexed docs',
|
|
58
|
+
inputSchema,
|
|
59
|
+
execute: ({ query, limit }) => ({ query, limit }),
|
|
109
60
|
},
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
## Strict Type Inference Deep Dive
|
|
114
|
-
|
|
115
|
-
### 1. Inference works best with literal schemas
|
|
116
|
-
|
|
117
|
-
Use `as const satisfies JsonSchemaForInference` so TypeScript preserves literal schema information.
|
|
61
|
+
{ signal: controller.signal }
|
|
62
|
+
);
|
|
118
63
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```ts
|
|
122
|
-
Record<string, unknown>;
|
|
64
|
+
controller.abort();
|
|
123
65
|
```
|
|
124
66
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
`InferArgsFromInputSchema<T>` and schema-driven `registerTool(...)` inference use a focused subset:
|
|
128
|
-
|
|
129
|
-
- `type`
|
|
130
|
-
- `properties`
|
|
131
|
-
- `required`
|
|
132
|
-
- `items`
|
|
133
|
-
- `enum`
|
|
134
|
-
- `const`
|
|
135
|
-
- `nullable`
|
|
136
|
-
- `additionalProperties`
|
|
137
|
-
|
|
138
|
-
Other schema keywords are accepted as metadata but do not add new inferred structure.
|
|
67
|
+
The callback input is `{ query: string; limit?: number }`. `registerTool()` returns `Promise<void>`; aborting the registration signal removes the tool.
|
|
139
68
|
|
|
140
|
-
|
|
69
|
+
## Type surfaces
|
|
141
70
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
| `
|
|
145
|
-
| `
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
71
|
+
| Type | Contract |
|
|
72
|
+
| ---------------------------- | ---------------------------------------------------------------- |
|
|
73
|
+
| `ModelContext` | Current standard `document.modelContext` producer API |
|
|
74
|
+
| `ChromeModelContext` | Standard API plus feature-detectable Chromium `executeTool()` |
|
|
75
|
+
| `ModelContextExtensions` | MCP-B registration and `listTools()` extensions |
|
|
76
|
+
| `ModelContextWithExtensions` | Standard event/discovery shape with MCP-B registration overloads |
|
|
77
|
+
| `ModelContextTesting` | Deprecated optional testing compatibility surface |
|
|
148
78
|
|
|
149
|
-
|
|
79
|
+
Both tool descriptor callbacks receive one input argument. MCP-B `ToolDescriptor` may also declare `outputSchema`.
|
|
150
80
|
|
|
151
|
-
|
|
81
|
+
## Schema inference
|
|
152
82
|
|
|
153
|
-
|
|
83
|
+
`JsonSchemaForInference` is the JSON Schema type owned by `@modelcontextprotocol/server`. The local inference helpers add no competing schema vocabulary.
|
|
154
84
|
|
|
155
|
-
|
|
85
|
+
`InferJsonSchema<T>` supports:
|
|
156
86
|
|
|
157
|
-
|
|
87
|
+
- `type`, including multi-type arrays such as `['string', 'null']`
|
|
88
|
+
- `const` and `enum`
|
|
89
|
+
- object `properties`, `required`, and `additionalProperties`
|
|
90
|
+
- array `items`
|
|
91
|
+
- boolean subschemas
|
|
158
92
|
|
|
159
|
-
|
|
93
|
+
Typeless object keywords infer an object. Unsupported compositions such as `$ref` and `oneOf` remain `unknown`.
|
|
160
94
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
You can always provide explicit generic args/results with `ToolDescriptor<TArgs, TResult, TName>` when schema inference is not enough for your use case.
|
|
164
|
-
|
|
165
|
-
## Name-Aware Typed Context (Advanced)
|
|
166
|
-
|
|
167
|
-
`TypedModelContext<TTools>` gives literal-name-aware `callTool(...)` typing for known registries.
|
|
168
|
-
|
|
169
|
-
```ts
|
|
170
|
-
import type { CallToolResult, ToolDescriptor, TypedModelContext } from '@mcp-b/webmcp-types';
|
|
95
|
+
`InferArgsFromInputSchema<T>` keeps object and array inputs. A widened or runtime-defined `InputSchema` safely falls back to `WebMcpToolInput`, which is `Record<string, unknown> | unknown[]`.
|
|
171
96
|
|
|
172
|
-
|
|
173
|
-
{ query: string; limit?: number },
|
|
174
|
-
CallToolResult & { structuredContent: { total: number } },
|
|
175
|
-
'search'
|
|
176
|
-
>;
|
|
97
|
+
MCP-B output inference uses `ToolResultFromOutputSchema<T>` or `ToolDescriptorFromSchema<TInput, TOutput>`. `outputSchema` is not part of the current standard `ModelContextTool` dictionary.
|
|
177
98
|
|
|
178
|
-
|
|
179
|
-
type AppModelContext = TypedModelContext<readonly [SearchTool, PingTool]>;
|
|
99
|
+
## Main exports
|
|
180
100
|
|
|
181
|
-
|
|
101
|
+
| Export | Purpose |
|
|
102
|
+
| ---------------------------- | -------------------------------------------- |
|
|
103
|
+
| `ModelContextTool` | Standard one-argument tool dictionary |
|
|
104
|
+
| `RegisteredTool` | Metadata returned by `getTools()` |
|
|
105
|
+
| `ToolDescriptor` | Explicit MCP-B input and result types |
|
|
106
|
+
| `ToolDescriptorFromSchema` | MCP-B input and output schema inference |
|
|
107
|
+
| `ToolListItem` | Metadata returned by `listTools()` |
|
|
108
|
+
| `InputSchema` | Broad runtime JSON Schema boundary |
|
|
109
|
+
| `JsonSchemaForInference` | Canonical upstream JSON Schema type |
|
|
110
|
+
| `InferJsonSchema` | Infer a value from supported schema keywords |
|
|
111
|
+
| `InferArgsFromInputSchema` | Infer an object or array callback input |
|
|
112
|
+
| `ToolResultFromOutputSchema` | Infer MCP `structuredContent` |
|
|
113
|
+
| `CallToolResult` | Canonical MCP tool result |
|
|
114
|
+
| `RegistrationHandle` | Handle returned by prompt/resource helpers |
|
|
182
115
|
|
|
183
|
-
|
|
184
|
-
name: 'search',
|
|
185
|
-
arguments: { query: 'webmcp' },
|
|
186
|
-
});
|
|
116
|
+
## Compatibility
|
|
187
117
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## Core and Extension Surfaces
|
|
193
|
-
|
|
194
|
-
`Document['modelContext']` is typed as strict core WebMCP methods only.
|
|
195
|
-
`Navigator['modelContext']` remains typed as a deprecated backward-compatible alias.
|
|
196
|
-
|
|
197
|
-
Extension methods are available via `ModelContextExtensions` and `ModelContextWithExtensions`:
|
|
198
|
-
|
|
199
|
-
```ts
|
|
200
|
-
import type { ModelContextExtensions } from '@mcp-b/webmcp-types';
|
|
201
|
-
|
|
202
|
-
const modelContext = document.modelContext as Document['modelContext'] & ModelContextExtensions;
|
|
203
|
-
const tools = modelContext.listTools();
|
|
204
|
-
const result = await modelContext.callTool({
|
|
205
|
-
name: 'search',
|
|
206
|
-
arguments: { query: 'docs' },
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
void tools;
|
|
210
|
-
void result;
|
|
211
|
-
```
|
|
118
|
+
- `navigator.modelContext` remains optional and deprecated.
|
|
119
|
+
- `navigator.modelContextTesting` remains optional and deprecated.
|
|
120
|
+
- `unregisterTool()`, `provideContext()`, and `clearContext()` are absent. Use an `AbortSignal` to own a tool registration.
|
|
121
|
+
- Strict and `strictNullChecks: false` projects are covered by package type tests.
|
|
212
122
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
| Export | Purpose |
|
|
216
|
-
| ------------------------------------ | ------------------------------------------------------------ |
|
|
217
|
-
| `ModelContext` | Strict core `document.modelContext` type |
|
|
218
|
-
| `ToolDescriptor` | Explicitly typed tool descriptor |
|
|
219
|
-
| `ToolDescriptorFromSchema` | Schema-driven descriptor with inferred args/result |
|
|
220
|
-
| `JsonSchemaForInference` | Supported JSON Schema subset for inference |
|
|
221
|
-
| `InferArgsFromInputSchema` | Derive args shape from a schema type |
|
|
222
|
-
| `ToolResultFromOutputSchema` | Derive `structuredContent` type from output schema |
|
|
223
|
-
| `TypedModelContext` | Name-aware typed `callTool`/`listTools` for known registries |
|
|
224
|
-
| `CallToolResult` | Tool response type |
|
|
225
|
-
| `ContentBlock` / `LooseContentBlock` | Strict and pragmatic content block typing |
|
|
226
|
-
| `ModelContextClient` | Tool execution client (`requestUserInteraction`) |
|
|
227
|
-
|
|
228
|
-
## Important Notes
|
|
229
|
-
|
|
230
|
-
- This package does not install any runtime behavior.
|
|
231
|
-
- Runtime validation/execution behavior depends on your WebMCP runtime package.
|
|
232
|
-
- Prefer `document.modelContext` for new code. `navigator.modelContext` is retained as a deprecated backward-compatible alias during the WebMCP migration.
|
|
233
|
-
- `provideContext()` and `clearContext()` were removed from the upstream WebMCP spec on March 5, 2026 and are intentionally not typed.
|
|
234
|
-
- `unregisterTool(name)` is `@deprecated`. The April 23, 2026 WebMCP draft removed it from the spec in favor of an `AbortSignal` passed via `registerTool(tool, { signal })`. The type is retained for compatibility with older native previews and existing MCP-B wrappers; it will be removed in the next major version.
|
|
235
|
-
- `registerTool(tool, options?)` accepts a `ModelContextRegisterToolOptions` dictionary with an optional `signal: AbortSignal`. Aborting the signal unregisters the tool.
|
|
236
|
-
- `ToolAnnotations.untrustedContentHint` was added to the spec on April 23, 2026 to flag tools whose output may include externally-sourced content.
|
|
237
|
-
- `navigator.modelContextTesting` is typed as optional for compatibility with Chromium preview/testing surfaces.
|
|
123
|
+
See the [package reference](https://docs.mcp-b.ai/packages/webmcp-types/reference) and [strict core versus MCP-B extensions](https://docs.mcp-b.ai/explanation/strict-core-vs-mcp-b-extensions).
|
|
238
124
|
|
|
239
125
|
## License
|
|
240
126
|
|
package/dist/common.d.ts
CHANGED
|
@@ -1,297 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
export type JsonPrimitive = string | number | boolean | null;
|
|
5
|
-
/**
|
|
6
|
-
* Object-shaped JSON value.
|
|
7
|
-
*/
|
|
8
|
-
export interface JsonObject {
|
|
9
|
-
[key: string]: JsonValue;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Any valid JSON value.
|
|
13
|
-
*/
|
|
14
|
-
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
15
|
-
/**
|
|
16
|
-
* JSON Schema property definition.
|
|
17
|
-
*
|
|
18
|
-
* @see {@link https://json-schema.org/}
|
|
19
|
-
*/
|
|
20
|
-
export interface InputSchemaProperty {
|
|
21
|
-
/**
|
|
22
|
-
* JSON Schema type for this property.
|
|
23
|
-
*/
|
|
24
|
-
type?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Human-readable description of the property.
|
|
27
|
-
*/
|
|
28
|
-
description?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Additional JSON Schema keywords.
|
|
31
|
-
*/
|
|
32
|
-
[key: string]: unknown;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* JSON Schema definition for tool input parameters.
|
|
36
|
-
*
|
|
37
|
-
* @see {@link https://json-schema.org/}
|
|
38
|
-
*/
|
|
1
|
+
export type { CallToolResult, ContentBlock, JSONObject as JsonObject, JSONValue as JsonValue, TextContent, } from '@modelcontextprotocol/server';
|
|
2
|
+
/** JSON Schema object accepted at the WebMCP boundary. */
|
|
39
3
|
export interface InputSchema {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* List of required property names.
|
|
50
|
-
*/
|
|
51
|
-
required?: readonly string[];
|
|
52
|
-
/**
|
|
53
|
-
* Additional JSON Schema keywords.
|
|
54
|
-
*/
|
|
55
|
-
[key: string]: unknown;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Plain text content.
|
|
59
|
-
*/
|
|
60
|
-
export interface TextContent {
|
|
61
|
-
/**
|
|
62
|
-
* Discriminator for text content.
|
|
63
|
-
*/
|
|
64
|
-
type: 'text';
|
|
65
|
-
/**
|
|
66
|
-
* UTF-8 text value.
|
|
67
|
-
*/
|
|
68
|
-
text: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Base64-encoded image content.
|
|
72
|
-
*/
|
|
73
|
-
export interface ImageContent {
|
|
74
|
-
/**
|
|
75
|
-
* Discriminator for image content.
|
|
76
|
-
*/
|
|
77
|
-
type: 'image';
|
|
78
|
-
/**
|
|
79
|
-
* Base64 payload.
|
|
80
|
-
*/
|
|
81
|
-
data: string;
|
|
82
|
-
/**
|
|
83
|
-
* MIME type for the encoded image.
|
|
84
|
-
*/
|
|
85
|
-
mimeType: string;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Base64-encoded audio content.
|
|
89
|
-
*/
|
|
90
|
-
export interface AudioContent {
|
|
91
|
-
/**
|
|
92
|
-
* Discriminator for audio content.
|
|
93
|
-
*/
|
|
94
|
-
type: 'audio';
|
|
95
|
-
/**
|
|
96
|
-
* Base64 payload.
|
|
97
|
-
*/
|
|
98
|
-
data: string;
|
|
99
|
-
/**
|
|
100
|
-
* MIME type for the encoded audio.
|
|
101
|
-
*/
|
|
102
|
-
mimeType: string;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Text resource contents.
|
|
106
|
-
*/
|
|
107
|
-
export interface TextResourceContents {
|
|
108
|
-
/**
|
|
109
|
-
* Canonical resource URI.
|
|
110
|
-
*/
|
|
111
|
-
uri: string;
|
|
112
|
-
/**
|
|
113
|
-
* Optional MIME type.
|
|
114
|
-
*/
|
|
115
|
-
mimeType?: string;
|
|
116
|
-
/**
|
|
117
|
-
* UTF-8 resource payload.
|
|
118
|
-
*/
|
|
119
|
-
text: string;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Binary resource contents encoded as base64.
|
|
123
|
-
*/
|
|
124
|
-
export interface BlobResourceContents {
|
|
125
|
-
/**
|
|
126
|
-
* Canonical resource URI.
|
|
127
|
-
*/
|
|
128
|
-
uri: string;
|
|
129
|
-
/**
|
|
130
|
-
* Optional MIME type.
|
|
131
|
-
*/
|
|
132
|
-
mimeType?: string;
|
|
133
|
-
/**
|
|
134
|
-
* Base64-encoded binary payload.
|
|
135
|
-
*/
|
|
136
|
-
blob: string;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Resource contents returned by resource reads.
|
|
140
|
-
*/
|
|
141
|
-
export type ResourceContents = TextResourceContents | BlobResourceContents;
|
|
142
|
-
/**
|
|
143
|
-
* Embedded resource content block.
|
|
144
|
-
*/
|
|
145
|
-
export interface EmbeddedResource {
|
|
146
|
-
/**
|
|
147
|
-
* Discriminator for embedded resources.
|
|
148
|
-
*/
|
|
149
|
-
type: 'resource';
|
|
150
|
-
/**
|
|
151
|
-
* Inlined resource contents.
|
|
152
|
-
*/
|
|
153
|
-
resource: ResourceContents;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Link to an externally retrievable resource.
|
|
157
|
-
*/
|
|
158
|
-
export interface ResourceLink {
|
|
159
|
-
/**
|
|
160
|
-
* Discriminator for resource links.
|
|
161
|
-
*/
|
|
162
|
-
type: 'resource_link';
|
|
163
|
-
/**
|
|
164
|
-
* Resource URI.
|
|
165
|
-
*/
|
|
166
|
-
uri: string;
|
|
167
|
-
/**
|
|
168
|
-
* Optional display name.
|
|
169
|
-
*/
|
|
170
|
-
name?: string;
|
|
171
|
-
/**
|
|
172
|
-
* Optional human-readable description.
|
|
173
|
-
*/
|
|
174
|
-
description?: string;
|
|
175
|
-
/**
|
|
176
|
-
* Optional MIME type hint.
|
|
177
|
-
*/
|
|
178
|
-
mimeType?: string;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Any content block allowed in tool responses.
|
|
182
|
-
*/
|
|
183
|
-
export type ContentBlock = TextContent | ImageContent | AudioContent | ResourceLink | EmbeddedResource;
|
|
184
|
-
/**
|
|
185
|
-
* Looser content block shape accepted by many MCP tool implementations.
|
|
186
|
-
*
|
|
187
|
-
* This keeps tool return typing practical while preserving strict content
|
|
188
|
-
* unions via {@link ContentBlock} for consumers that want discriminated checks.
|
|
189
|
-
*/
|
|
190
|
-
export type LooseContentBlock = Record<string, unknown> & {
|
|
191
|
-
type?: string;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* The result returned from tool execution.
|
|
195
|
-
*
|
|
196
|
-
* @see {@link https://spec.modelcontextprotocol.io/specification/server/tools/}
|
|
197
|
-
*/
|
|
198
|
-
export interface CallToolResult {
|
|
199
|
-
/**
|
|
200
|
-
* Ordered content blocks to return to the model.
|
|
201
|
-
*/
|
|
202
|
-
content: Array<ContentBlock | LooseContentBlock>;
|
|
203
|
-
/**
|
|
204
|
-
* Optional machine-readable payload.
|
|
205
|
-
*/
|
|
206
|
-
structuredContent?: JsonValue;
|
|
207
|
-
/**
|
|
208
|
-
* Marks the result as an error response.
|
|
209
|
-
*/
|
|
210
|
-
isError?: boolean;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Alias for {@link CallToolResult} for API consistency.
|
|
214
|
-
*/
|
|
215
|
-
export type ToolResponse = CallToolResult;
|
|
216
|
-
/**
|
|
217
|
-
* Form-based elicitation request parameters.
|
|
218
|
-
*/
|
|
219
|
-
export interface ElicitationFormParams {
|
|
220
|
-
/**
|
|
221
|
-
* Elicitation mode. Omit or set to `'form'` for form input.
|
|
222
|
-
*/
|
|
223
|
-
mode?: 'form';
|
|
224
|
-
/**
|
|
225
|
-
* User-facing message.
|
|
226
|
-
*/
|
|
227
|
-
message: string;
|
|
228
|
-
/**
|
|
229
|
-
* Requested form schema.
|
|
230
|
-
*/
|
|
231
|
-
requestedSchema: {
|
|
232
|
-
/**
|
|
233
|
-
* Root schema type.
|
|
234
|
-
*/
|
|
235
|
-
type: 'object';
|
|
236
|
-
/**
|
|
237
|
-
* Field definitions.
|
|
238
|
-
*/
|
|
239
|
-
properties: Record<string, InputSchema>;
|
|
240
|
-
/**
|
|
241
|
-
* Required field names.
|
|
242
|
-
*/
|
|
243
|
-
required?: readonly string[];
|
|
244
|
-
/**
|
|
245
|
-
* Additional schema keywords.
|
|
246
|
-
*/
|
|
247
|
-
[key: string]: unknown;
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* URL-based elicitation request parameters.
|
|
252
|
-
*/
|
|
253
|
-
export interface ElicitationUrlParams {
|
|
254
|
-
/**
|
|
255
|
-
* Elicitation mode.
|
|
256
|
-
*/
|
|
257
|
-
mode: 'url';
|
|
258
|
-
/**
|
|
259
|
-
* User-facing message.
|
|
260
|
-
*/
|
|
261
|
-
message: string;
|
|
262
|
-
/**
|
|
263
|
-
* Unique elicitation identifier.
|
|
264
|
-
*/
|
|
265
|
-
elicitationId: string;
|
|
266
|
-
/**
|
|
267
|
-
* URL to open.
|
|
268
|
-
*/
|
|
269
|
-
url: string;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Elicitation request parameters.
|
|
273
|
-
*/
|
|
274
|
-
export type ElicitationParams = ElicitationFormParams | ElicitationUrlParams;
|
|
275
|
-
/**
|
|
276
|
-
* Result returned by an elicitation request.
|
|
277
|
-
*/
|
|
278
|
-
export interface ElicitationResult {
|
|
279
|
-
/**
|
|
280
|
-
* User decision.
|
|
281
|
-
*/
|
|
282
|
-
action: 'accept' | 'decline' | 'cancel';
|
|
283
|
-
/**
|
|
284
|
-
* Submitted values when `action` is `'accept'`.
|
|
285
|
-
*/
|
|
286
|
-
content?: Record<string, string | number | boolean | string[]>;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Registration handle returned by registration methods.
|
|
290
|
-
*/
|
|
4
|
+
type?: unknown;
|
|
5
|
+
properties?: Readonly<Record<string, unknown>> | undefined;
|
|
6
|
+
required?: readonly string[] | undefined;
|
|
7
|
+
[keyword: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
/** Values accepted by WebMCP tool callbacks. */
|
|
10
|
+
export type WebMcpToolInput = Record<string, unknown> | unknown[];
|
|
11
|
+
/** Handle returned by MCP-B registration helpers. */
|
|
291
12
|
export interface RegistrationHandle {
|
|
292
|
-
|
|
293
|
-
* Unregisters the associated item.
|
|
294
|
-
*/
|
|
295
|
-
unregister: () => void;
|
|
13
|
+
unregister(): void;
|
|
296
14
|
}
|
|
297
15
|
//# sourceMappingURL=common.d.ts.map
|
package/dist/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,YAAY,EACZ,UAAU,IAAI,UAAU,EACxB,SAAS,IAAI,SAAS,EACtB,WAAW,GACZ,MAAM,8BAA8B,CAAC;AAEtC,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAC3D,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACzC,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,gDAAgD;AAChD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;AAElE,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,UAAU,IAAI,IAAI,CAAC;CACpB"}
|