@outfitter/mcp 0.4.1 → 0.4.3
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/README.md +39 -29
- package/dist/actions.d.ts +3 -3
- package/dist/actions.js +25 -4
- package/dist/core-tools.d.ts +3 -3
- package/dist/core-tools.js +140 -6
- package/dist/index.d.ts +7 -952
- package/dist/index.js +7 -959
- package/dist/logging.d.ts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/server.js +2 -2
- package/dist/shared/@outfitter/{mcp-jk0ka9hw.d.ts → mcp-7kcw2814.d.ts} +4 -4
- package/dist/shared/@outfitter/{mcp-nmp5wf0w.js → mcp-b502y16n.js} +1 -1
- package/dist/shared/@outfitter/{mcp-a0cgfsnw.d.ts → mcp-d8vs6vry.d.ts} +1 -1
- package/dist/shared/@outfitter/{mcp-h2twz77x.d.ts → mcp-gqjg15f5.d.ts} +166 -196
- package/dist/shared/@outfitter/mcp-hw5wz4gb.js +1 -0
- package/dist/shared/@outfitter/{mcp-2vqyt1fj.d.ts → mcp-knq080yt.d.ts} +1 -1
- package/dist/shared/@outfitter/{mcp-dwd800vf.d.ts → mcp-s6afm4ff.d.ts} +14 -14
- package/dist/transport.d.ts +3 -3
- package/dist/transport.js +161 -5
- package/dist/types.d.ts +2 -2
- package/package.json +31 -30
- package/dist/shared/@outfitter/mcp-ktapzh9d.js +0 -28
- package/dist/shared/@outfitter/mcp-mzky3ck8.js +0 -165
- package/dist/shared/@outfitter/mcp-zv3ej45k.js +0 -143
- package/dist/shared/@outfitter/mcp-zy7b487d.js +0 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,953 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* server-to-client log message notifications.
|
|
9
|
-
*
|
|
10
|
-
* @packageDocumentation
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* MCP log levels as defined in the MCP specification.
|
|
14
|
-
* Ordered from least to most severe.
|
|
15
|
-
*/
|
|
16
|
-
type McpLogLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
|
|
17
|
-
/**
|
|
18
|
-
* Outfitter log levels.
|
|
19
|
-
*/
|
|
20
|
-
type OutfitterLogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
|
|
21
|
-
/**
|
|
22
|
-
* Map an Outfitter log level to the corresponding MCP log level.
|
|
23
|
-
*/
|
|
24
|
-
declare function mapLogLevelToMcp(level: OutfitterLogLevel): McpLogLevel;
|
|
25
|
-
/**
|
|
26
|
-
* Check whether a message at the given level should be emitted
|
|
27
|
-
* based on the client-requested threshold.
|
|
28
|
-
*/
|
|
29
|
-
declare function shouldEmitLog(messageLevel: McpLogLevel, threshold: McpLogLevel): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Configuration options for creating an MCP server.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* const options: McpServerOptions = {
|
|
36
|
-
* name: "my-mcp-server",
|
|
37
|
-
* version: "1.0.0",
|
|
38
|
-
* logger: createLogger({ name: "mcp" }),
|
|
39
|
-
* };
|
|
40
|
-
*
|
|
41
|
-
* const server = createMcpServer(options);
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
interface McpServerOptions {
|
|
45
|
-
/**
|
|
46
|
-
* Server name, used in MCP protocol handshake.
|
|
47
|
-
* Should be a short, descriptive identifier.
|
|
48
|
-
*/
|
|
49
|
-
name: string;
|
|
50
|
-
/**
|
|
51
|
-
* Server version (semver format recommended).
|
|
52
|
-
* Sent to clients during initialization.
|
|
53
|
-
*/
|
|
54
|
-
version: string;
|
|
55
|
-
/**
|
|
56
|
-
* Optional logger instance for server logging.
|
|
57
|
-
* If not provided, the server uses the Outfitter logger factory defaults.
|
|
58
|
-
*/
|
|
59
|
-
logger?: Logger;
|
|
60
|
-
/**
|
|
61
|
-
* Default MCP log level for client-facing log forwarding.
|
|
62
|
-
*
|
|
63
|
-
* Precedence (highest wins):
|
|
64
|
-
* 1. `OUTFITTER_LOG_LEVEL` environment variable
|
|
65
|
-
* 2. This option
|
|
66
|
-
* 3. Environment profile (`OUTFITTER_ENV`)
|
|
67
|
-
* 4. `null` (no forwarding until client opts in)
|
|
68
|
-
*
|
|
69
|
-
* Set to `null` to explicitly disable forwarding regardless of environment.
|
|
70
|
-
* The MCP client can always override via `logging/setLevel`.
|
|
71
|
-
*/
|
|
72
|
-
defaultLogLevel?: McpLogLevel | null;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Behavioral hints for MCP tools.
|
|
76
|
-
*
|
|
77
|
-
* Annotations help clients understand tool behavior without invoking them.
|
|
78
|
-
* All fields are optional — only include hints that apply.
|
|
79
|
-
*
|
|
80
|
-
* @see https://spec.modelcontextprotocol.io/specification/2025-03-26/server/tools/#annotations
|
|
81
|
-
*/
|
|
82
|
-
interface ToolAnnotations {
|
|
83
|
-
/** When true, the tool does not modify any state. */
|
|
84
|
-
readOnlyHint?: boolean;
|
|
85
|
-
/** When true, the tool may perform destructive operations (e.g., deleting data). */
|
|
86
|
-
destructiveHint?: boolean;
|
|
87
|
-
/** When true, calling the tool multiple times with the same input has the same effect. */
|
|
88
|
-
idempotentHint?: boolean;
|
|
89
|
-
/** When true, the tool may interact with external systems beyond the server. */
|
|
90
|
-
openWorldHint?: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Common annotation presets for MCP tools.
|
|
94
|
-
*
|
|
95
|
-
* Use these as a starting point and spread-override individual hints:
|
|
96
|
-
*
|
|
97
|
-
* ```typescript
|
|
98
|
-
* annotations: { ...TOOL_ANNOTATIONS.readOnly, openWorldHint: true }
|
|
99
|
-
* ```
|
|
100
|
-
*
|
|
101
|
-
* For multi-action tools (e.g., a single tool with read and write actions),
|
|
102
|
-
* use the most conservative union of hints — if any action is destructive,
|
|
103
|
-
* mark the whole tool as destructive. Per-action annotations are an MCP spec
|
|
104
|
-
* limitation; presets + spread cover most edge cases.
|
|
105
|
-
*/
|
|
106
|
-
declare const TOOL_ANNOTATIONS: {
|
|
107
|
-
/** Read-only, safe to call repeatedly. */
|
|
108
|
-
readonly readOnly: {
|
|
109
|
-
readonly readOnlyHint: true;
|
|
110
|
-
readonly destructiveHint: false;
|
|
111
|
-
readonly idempotentHint: true;
|
|
112
|
-
readonly openWorldHint: false;
|
|
113
|
-
};
|
|
114
|
-
/** Creates or updates state, not destructive. */
|
|
115
|
-
readonly write: {
|
|
116
|
-
readonly readOnlyHint: false;
|
|
117
|
-
readonly destructiveHint: false;
|
|
118
|
-
readonly idempotentHint: false;
|
|
119
|
-
readonly openWorldHint: false;
|
|
120
|
-
};
|
|
121
|
-
/** Idempotent write (PUT-like). */
|
|
122
|
-
readonly writeIdempotent: {
|
|
123
|
-
readonly readOnlyHint: false;
|
|
124
|
-
readonly destructiveHint: false;
|
|
125
|
-
readonly idempotentHint: true;
|
|
126
|
-
readonly openWorldHint: false;
|
|
127
|
-
};
|
|
128
|
-
/** Deletes or permanently modifies data. */
|
|
129
|
-
readonly destructive: {
|
|
130
|
-
readonly readOnlyHint: false;
|
|
131
|
-
readonly destructiveHint: true;
|
|
132
|
-
readonly idempotentHint: true;
|
|
133
|
-
readonly openWorldHint: false;
|
|
134
|
-
};
|
|
135
|
-
/** Interacts with external systems (APIs, network). */
|
|
136
|
-
readonly openWorld: {
|
|
137
|
-
readonly readOnlyHint: false;
|
|
138
|
-
readonly destructiveHint: false;
|
|
139
|
-
readonly idempotentHint: false;
|
|
140
|
-
readonly openWorldHint: true;
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Definition of an MCP tool that can be invoked by clients.
|
|
145
|
-
*
|
|
146
|
-
* Tools are the primary way clients interact with MCP servers.
|
|
147
|
-
* Each tool has a name, description, input schema (for validation),
|
|
148
|
-
* and a handler function that processes requests.
|
|
149
|
-
*
|
|
150
|
-
* @typeParam TInput - The validated input type (inferred from Zod schema)
|
|
151
|
-
* @typeParam TOutput - The success output type
|
|
152
|
-
* @typeParam TError - The error type (must extend OutfitterError)
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```typescript
|
|
156
|
-
* const getUserTool: ToolDefinition<
|
|
157
|
-
* { userId: string },
|
|
158
|
-
* { name: string; email: string },
|
|
159
|
-
* NotFoundError
|
|
160
|
-
* > = {
|
|
161
|
-
* name: "get-user",
|
|
162
|
-
* description: "Retrieve a user by ID",
|
|
163
|
-
* inputSchema: z.object({ userId: z.string().uuid() }),
|
|
164
|
-
* handler: async (input, ctx) => {
|
|
165
|
-
* ctx.logger.debug("Fetching user", { userId: input.userId });
|
|
166
|
-
* const user = await db.users.find(input.userId);
|
|
167
|
-
* if (!user) {
|
|
168
|
-
* return Result.err(new NotFoundError({
|
|
169
|
-
* message: `User ${input.userId} not found`,
|
|
170
|
-
* resourceType: "user",
|
|
171
|
-
* resourceId: input.userId,
|
|
172
|
-
* }));
|
|
173
|
-
* }
|
|
174
|
-
* return Result.ok({ name: user.name, email: user.email });
|
|
175
|
-
* },
|
|
176
|
-
* };
|
|
177
|
-
* ```
|
|
178
|
-
*/
|
|
179
|
-
interface ToolDefinition<
|
|
180
|
-
TInput,
|
|
181
|
-
TOutput,
|
|
182
|
-
TError extends OutfitterError = OutfitterError
|
|
183
|
-
> {
|
|
184
|
-
/**
|
|
185
|
-
* Unique tool name (kebab-case recommended).
|
|
186
|
-
* Used by clients to invoke the tool.
|
|
187
|
-
*/
|
|
188
|
-
name: string;
|
|
189
|
-
/**
|
|
190
|
-
* Human-readable description of what the tool does.
|
|
191
|
-
* Shown to clients and used by LLMs to understand tool capabilities.
|
|
192
|
-
*/
|
|
193
|
-
description: string;
|
|
194
|
-
/**
|
|
195
|
-
* Whether the tool should be deferred for tool search.
|
|
196
|
-
* Defaults to true for domain tools; core tools set this to false.
|
|
197
|
-
*/
|
|
198
|
-
deferLoading?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* Zod schema for validating and parsing input.
|
|
201
|
-
* The schema defines the expected input structure.
|
|
202
|
-
*/
|
|
203
|
-
inputSchema: z.ZodType<TInput>;
|
|
204
|
-
/**
|
|
205
|
-
* Optional behavioral annotations for the tool.
|
|
206
|
-
* Helps clients understand tool behavior without invoking it.
|
|
207
|
-
*/
|
|
208
|
-
annotations?: ToolAnnotations;
|
|
209
|
-
/**
|
|
210
|
-
* Handler function that processes the tool invocation.
|
|
211
|
-
* Receives validated input and HandlerContext, returns Result.
|
|
212
|
-
*/
|
|
213
|
-
handler: Handler<TInput, TOutput, TError>;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Serialized tool information for MCP protocol.
|
|
217
|
-
* This is the format sent to clients during tool listing.
|
|
218
|
-
*/
|
|
219
|
-
interface SerializedTool {
|
|
220
|
-
/** Tool name */
|
|
221
|
-
name: string;
|
|
222
|
-
/** Tool description */
|
|
223
|
-
description: string;
|
|
224
|
-
/** JSON Schema representation of the input schema */
|
|
225
|
-
inputSchema: Record<string, unknown>;
|
|
226
|
-
/** MCP tool-search hint: whether tool is deferred */
|
|
227
|
-
defer_loading?: boolean;
|
|
228
|
-
/** Behavioral annotations for the tool */
|
|
229
|
-
annotations?: ToolAnnotations;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Annotations for content items (resource content, prompt messages).
|
|
233
|
-
*
|
|
234
|
-
* Provides hints about content audience and priority.
|
|
235
|
-
*
|
|
236
|
-
* @see https://spec.modelcontextprotocol.io/specification/2025-03-26/server/utilities/annotations/
|
|
237
|
-
*/
|
|
238
|
-
interface ContentAnnotations {
|
|
239
|
-
/**
|
|
240
|
-
* Who the content is intended for.
|
|
241
|
-
* Can include "user", "assistant", or both.
|
|
242
|
-
*/
|
|
243
|
-
audience?: Array<"user" | "assistant">;
|
|
244
|
-
/**
|
|
245
|
-
* Priority level from 0.0 (least) to 1.0 (most important).
|
|
246
|
-
*/
|
|
247
|
-
priority?: number;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Text content returned from a resource read.
|
|
251
|
-
*/
|
|
252
|
-
interface TextResourceContent {
|
|
253
|
-
/** Resource URI */
|
|
254
|
-
uri: string;
|
|
255
|
-
/** Text content */
|
|
256
|
-
text: string;
|
|
257
|
-
/** Optional MIME type */
|
|
258
|
-
mimeType?: string;
|
|
259
|
-
/** Optional content annotations */
|
|
260
|
-
annotations?: ContentAnnotations;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Binary (base64-encoded) content returned from a resource read.
|
|
264
|
-
*/
|
|
265
|
-
interface BlobResourceContent {
|
|
266
|
-
/** Resource URI */
|
|
267
|
-
uri: string;
|
|
268
|
-
/** Base64-encoded binary content */
|
|
269
|
-
blob: string;
|
|
270
|
-
/** Optional MIME type */
|
|
271
|
-
mimeType?: string;
|
|
272
|
-
/** Optional content annotations */
|
|
273
|
-
annotations?: ContentAnnotations;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Content returned from reading a resource.
|
|
277
|
-
*/
|
|
278
|
-
type ResourceContent = TextResourceContent | BlobResourceContent;
|
|
279
|
-
/**
|
|
280
|
-
* Handler for reading a resource's content.
|
|
281
|
-
*
|
|
282
|
-
* @param uri - The resource URI being read
|
|
283
|
-
* @param ctx - Handler context with logger and requestId
|
|
284
|
-
* @returns Array of resource content items
|
|
285
|
-
*/
|
|
286
|
-
type ResourceReadHandler = (uri: string, ctx: HandlerContext) => Promise<Result<ResourceContent[], OutfitterError>>;
|
|
287
|
-
/**
|
|
288
|
-
* Definition of an MCP resource that can be read by clients.
|
|
289
|
-
*
|
|
290
|
-
* Resources represent data that clients can access, such as files,
|
|
291
|
-
* database records, or API responses.
|
|
292
|
-
*
|
|
293
|
-
* @example
|
|
294
|
-
* ```typescript
|
|
295
|
-
* const configResource: ResourceDefinition = {
|
|
296
|
-
* uri: "file:///etc/app/config.json",
|
|
297
|
-
* name: "Application Config",
|
|
298
|
-
* description: "Main application configuration file",
|
|
299
|
-
* mimeType: "application/json",
|
|
300
|
-
* handler: async (uri, ctx) => {
|
|
301
|
-
* const content = await readFile(uri);
|
|
302
|
-
* return Result.ok([{ uri, text: content }]);
|
|
303
|
-
* },
|
|
304
|
-
* };
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
interface ResourceDefinition {
|
|
308
|
-
/**
|
|
309
|
-
* Unique resource URI.
|
|
310
|
-
* Must be a valid URI (file://, https://, custom://, etc.).
|
|
311
|
-
*/
|
|
312
|
-
uri: string;
|
|
313
|
-
/**
|
|
314
|
-
* Human-readable resource name.
|
|
315
|
-
* Displayed to users in resource listings.
|
|
316
|
-
*/
|
|
317
|
-
name: string;
|
|
318
|
-
/**
|
|
319
|
-
* Optional description of the resource.
|
|
320
|
-
* Provides additional context about the resource contents.
|
|
321
|
-
*/
|
|
322
|
-
description?: string;
|
|
323
|
-
/**
|
|
324
|
-
* Optional MIME type of the resource content.
|
|
325
|
-
* Helps clients understand how to process the resource.
|
|
326
|
-
*/
|
|
327
|
-
mimeType?: string;
|
|
328
|
-
/**
|
|
329
|
-
* Optional handler for reading the resource content.
|
|
330
|
-
* If not provided, the resource is metadata-only.
|
|
331
|
-
*/
|
|
332
|
-
handler?: ResourceReadHandler;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Handler for reading a resource template's content.
|
|
336
|
-
*
|
|
337
|
-
* @param uri - The matched URI
|
|
338
|
-
* @param variables - Extracted template variables
|
|
339
|
-
* @param ctx - Handler context
|
|
340
|
-
*/
|
|
341
|
-
type ResourceTemplateReadHandler = (uri: string, variables: Record<string, string>, ctx: HandlerContext) => Promise<Result<ResourceContent[], OutfitterError>>;
|
|
342
|
-
/**
|
|
343
|
-
* Definition of an MCP resource template with URI pattern matching.
|
|
344
|
-
*
|
|
345
|
-
* Templates use RFC 6570 Level 1 URI templates (e.g., `{param}`)
|
|
346
|
-
* to match and extract variables from URIs.
|
|
347
|
-
*
|
|
348
|
-
* @example
|
|
349
|
-
* ```typescript
|
|
350
|
-
* const userTemplate: ResourceTemplateDefinition = {
|
|
351
|
-
* uriTemplate: "db:///users/{userId}/profile",
|
|
352
|
-
* name: "User Profile",
|
|
353
|
-
* handler: async (uri, variables) => {
|
|
354
|
-
* const profile = await getProfile(variables.userId);
|
|
355
|
-
* return Result.ok([{ uri, text: JSON.stringify(profile) }]);
|
|
356
|
-
* },
|
|
357
|
-
* };
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
interface ResourceTemplateDefinition {
|
|
361
|
-
/** URI template with `{param}` placeholders (RFC 6570 Level 1). */
|
|
362
|
-
uriTemplate: string;
|
|
363
|
-
/** Human-readable name for the template. */
|
|
364
|
-
name: string;
|
|
365
|
-
/** Optional description. */
|
|
366
|
-
description?: string;
|
|
367
|
-
/** Optional MIME type. */
|
|
368
|
-
mimeType?: string;
|
|
369
|
-
/** Optional completion handlers keyed by parameter name. */
|
|
370
|
-
complete?: Record<string, CompletionHandler>;
|
|
371
|
-
/** Handler for reading matched resources. */
|
|
372
|
-
handler: ResourceTemplateReadHandler;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Result of a completion request.
|
|
376
|
-
*/
|
|
377
|
-
interface CompletionResult {
|
|
378
|
-
/** Completion values */
|
|
379
|
-
values: string[];
|
|
380
|
-
/** Total number of available values (for pagination) */
|
|
381
|
-
total?: number;
|
|
382
|
-
/** Whether there are more values */
|
|
383
|
-
hasMore?: boolean;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Handler for generating completions.
|
|
387
|
-
*/
|
|
388
|
-
type CompletionHandler = (value: string) => Promise<CompletionResult>;
|
|
389
|
-
/**
|
|
390
|
-
* Reference to a prompt or resource for completion.
|
|
391
|
-
*/
|
|
392
|
-
type CompletionRef = {
|
|
393
|
-
type: "ref/prompt";
|
|
394
|
-
name: string;
|
|
395
|
-
} | {
|
|
396
|
-
type: "ref/resource";
|
|
397
|
-
uri: string;
|
|
398
|
-
};
|
|
399
|
-
/**
|
|
400
|
-
* Argument definition for a prompt.
|
|
401
|
-
*/
|
|
402
|
-
interface PromptArgument {
|
|
403
|
-
/** Argument name */
|
|
404
|
-
name: string;
|
|
405
|
-
/** Human-readable description */
|
|
406
|
-
description?: string;
|
|
407
|
-
/** Whether this argument is required */
|
|
408
|
-
required?: boolean;
|
|
409
|
-
/** Optional completion handler for this argument */
|
|
410
|
-
complete?: CompletionHandler;
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Content block within a prompt message.
|
|
414
|
-
*/
|
|
415
|
-
interface PromptMessageContent {
|
|
416
|
-
/** Content type */
|
|
417
|
-
type: "text";
|
|
418
|
-
/** Text content */
|
|
419
|
-
text: string;
|
|
420
|
-
/** Optional content annotations */
|
|
421
|
-
annotations?: ContentAnnotations;
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* A message in a prompt response.
|
|
425
|
-
*/
|
|
426
|
-
interface PromptMessage {
|
|
427
|
-
/** Message role */
|
|
428
|
-
role: "user" | "assistant";
|
|
429
|
-
/** Message content */
|
|
430
|
-
content: PromptMessageContent;
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Result returned from getting a prompt.
|
|
434
|
-
*/
|
|
435
|
-
interface PromptResult {
|
|
436
|
-
/** Prompt messages */
|
|
437
|
-
messages: PromptMessage[];
|
|
438
|
-
/** Optional description override */
|
|
439
|
-
description?: string;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* Handler for generating prompt messages.
|
|
443
|
-
*/
|
|
444
|
-
type PromptHandler = (args: Record<string, string | undefined>) => Promise<Result<PromptResult, OutfitterError>>;
|
|
445
|
-
/**
|
|
446
|
-
* Definition of an MCP prompt.
|
|
447
|
-
*
|
|
448
|
-
* Prompts are reusable templates that generate messages for LLMs.
|
|
449
|
-
*
|
|
450
|
-
* @example
|
|
451
|
-
* ```typescript
|
|
452
|
-
* const reviewPrompt: PromptDefinition = {
|
|
453
|
-
* name: "code-review",
|
|
454
|
-
* description: "Review code changes",
|
|
455
|
-
* arguments: [
|
|
456
|
-
* { name: "language", description: "Programming language", required: true },
|
|
457
|
-
* ],
|
|
458
|
-
* handler: async (args) => Result.ok({
|
|
459
|
-
* messages: [{ role: "user", content: { type: "text", text: `Review this ${args.language} code` } }],
|
|
460
|
-
* }),
|
|
461
|
-
* };
|
|
462
|
-
* ```
|
|
463
|
-
*/
|
|
464
|
-
interface PromptDefinition {
|
|
465
|
-
/** Unique prompt name */
|
|
466
|
-
name: string;
|
|
467
|
-
/** Human-readable description */
|
|
468
|
-
description?: string;
|
|
469
|
-
/** Prompt arguments */
|
|
470
|
-
arguments: PromptArgument[];
|
|
471
|
-
/** Handler to generate messages */
|
|
472
|
-
handler: PromptHandler;
|
|
473
|
-
}
|
|
474
|
-
declare const McpErrorBase: TaggedErrorClass<"McpError", {
|
|
475
|
-
message: string;
|
|
476
|
-
code: number;
|
|
477
|
-
context?: Record<string, unknown>;
|
|
478
|
-
}>;
|
|
479
|
-
/**
|
|
480
|
-
* MCP-specific error with JSON-RPC error code.
|
|
481
|
-
*
|
|
482
|
-
* Used when tool invocations fail or when there are protocol-level errors.
|
|
483
|
-
* Follows the JSON-RPC 2.0 error object format.
|
|
484
|
-
*
|
|
485
|
-
* Standard error codes:
|
|
486
|
-
* - `-32700`: Parse error
|
|
487
|
-
* - `-32600`: Invalid request
|
|
488
|
-
* - `-32601`: Method not found
|
|
489
|
-
* - `-32602`: Invalid params
|
|
490
|
-
* - `-32603`: Internal error
|
|
491
|
-
* - `-32000` to `-32099`: Server errors (reserved)
|
|
492
|
-
*
|
|
493
|
-
* @example
|
|
494
|
-
* ```typescript
|
|
495
|
-
* const error = new McpError({
|
|
496
|
-
* message: "Tool not found: unknown-tool",
|
|
497
|
-
* code: -32601,
|
|
498
|
-
* context: { tool: "unknown-tool" },
|
|
499
|
-
* });
|
|
500
|
-
* ```
|
|
501
|
-
*/
|
|
502
|
-
declare class McpError extends McpErrorBase {
|
|
503
|
-
/** Error category for Outfitter error taxonomy compatibility */
|
|
504
|
-
readonly category: "internal";
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Options for invoking a tool.
|
|
508
|
-
*/
|
|
509
|
-
interface InvokeToolOptions {
|
|
510
|
-
/** Abort signal for cancellation */
|
|
511
|
-
signal?: AbortSignal;
|
|
512
|
-
/** Custom request ID (auto-generated if not provided) */
|
|
513
|
-
requestId?: string;
|
|
514
|
-
/** Progress token from client for tracking progress */
|
|
515
|
-
progressToken?: string | number;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* MCP Server instance.
|
|
519
|
-
*
|
|
520
|
-
* Provides methods for registering tools and resources, and for
|
|
521
|
-
* starting/stopping the server.
|
|
522
|
-
*
|
|
523
|
-
* @example
|
|
524
|
-
* ```typescript
|
|
525
|
-
* const server = createMcpServer({
|
|
526
|
-
* name: "my-server",
|
|
527
|
-
* version: "1.0.0",
|
|
528
|
-
* });
|
|
529
|
-
*
|
|
530
|
-
* server.registerTool(myTool);
|
|
531
|
-
* server.registerResource(myResource);
|
|
532
|
-
*
|
|
533
|
-
* await server.start();
|
|
534
|
-
* ```
|
|
535
|
-
*/
|
|
536
|
-
interface McpServer {
|
|
537
|
-
/** Server name */
|
|
538
|
-
readonly name: string;
|
|
539
|
-
/** Server version */
|
|
540
|
-
readonly version: string;
|
|
541
|
-
/**
|
|
542
|
-
* Register a tool with the server.
|
|
543
|
-
* @param tool - Tool definition to register
|
|
544
|
-
*/
|
|
545
|
-
registerTool<
|
|
546
|
-
TInput,
|
|
547
|
-
TOutput,
|
|
548
|
-
TError extends OutfitterError
|
|
549
|
-
>(tool: ToolDefinition<TInput, TOutput, TError>): void;
|
|
550
|
-
/**
|
|
551
|
-
* Register a resource with the server.
|
|
552
|
-
* @param resource - Resource definition to register
|
|
553
|
-
*/
|
|
554
|
-
registerResource(resource: ResourceDefinition): void;
|
|
555
|
-
/**
|
|
556
|
-
* Get all registered tools.
|
|
557
|
-
* @returns Array of serialized tool information
|
|
558
|
-
*/
|
|
559
|
-
getTools(): SerializedTool[];
|
|
560
|
-
/**
|
|
561
|
-
* Register a resource template with the server.
|
|
562
|
-
* @param template - Resource template definition to register
|
|
563
|
-
*/
|
|
564
|
-
registerResourceTemplate(template: ResourceTemplateDefinition): void;
|
|
565
|
-
/**
|
|
566
|
-
* Get all registered resources.
|
|
567
|
-
* @returns Array of resource definitions
|
|
568
|
-
*/
|
|
569
|
-
getResources(): ResourceDefinition[];
|
|
570
|
-
/**
|
|
571
|
-
* Get all registered resource templates.
|
|
572
|
-
* @returns Array of resource template definitions
|
|
573
|
-
*/
|
|
574
|
-
getResourceTemplates(): ResourceTemplateDefinition[];
|
|
575
|
-
/**
|
|
576
|
-
* Complete an argument value.
|
|
577
|
-
* @param ref - Reference to the prompt or resource template
|
|
578
|
-
* @param argumentName - Name of the argument to complete
|
|
579
|
-
* @param value - Current value to complete
|
|
580
|
-
* @returns Result with completion values or McpError
|
|
581
|
-
*/
|
|
582
|
-
complete(ref: CompletionRef, argumentName: string, value: string): Promise<Result<CompletionResult, InstanceType<typeof McpError>>>;
|
|
583
|
-
/**
|
|
584
|
-
* Register a prompt with the server.
|
|
585
|
-
* @param prompt - Prompt definition to register
|
|
586
|
-
*/
|
|
587
|
-
registerPrompt(prompt: PromptDefinition): void;
|
|
588
|
-
/**
|
|
589
|
-
* Get all registered prompts.
|
|
590
|
-
* @returns Array of prompt definitions (without handlers)
|
|
591
|
-
*/
|
|
592
|
-
getPrompts(): Array<{
|
|
593
|
-
name: string;
|
|
594
|
-
description?: string;
|
|
595
|
-
arguments: PromptArgument[];
|
|
596
|
-
}>;
|
|
597
|
-
/**
|
|
598
|
-
* Get a specific prompt's messages.
|
|
599
|
-
* @param name - Prompt name
|
|
600
|
-
* @param args - Prompt arguments
|
|
601
|
-
* @returns Result with prompt result or McpError
|
|
602
|
-
*/
|
|
603
|
-
getPrompt(name: string, args: Record<string, string | undefined>): Promise<Result<PromptResult, InstanceType<typeof McpError>>>;
|
|
604
|
-
/**
|
|
605
|
-
* Read a resource by URI.
|
|
606
|
-
* @param uri - Resource URI
|
|
607
|
-
* @returns Result with resource content or McpError
|
|
608
|
-
*/
|
|
609
|
-
readResource(uri: string): Promise<Result<ResourceContent[], InstanceType<typeof McpError>>>;
|
|
610
|
-
/**
|
|
611
|
-
* Invoke a tool by name.
|
|
612
|
-
* @param name - Tool name
|
|
613
|
-
* @param input - Tool input (will be validated)
|
|
614
|
-
* @param options - Optional invocation options
|
|
615
|
-
* @returns Result with tool output or McpError
|
|
616
|
-
*/
|
|
617
|
-
invokeTool<T = unknown>(name: string, input: unknown, options?: InvokeToolOptions): Promise<Result<T, InstanceType<typeof McpError>>>;
|
|
618
|
-
/**
|
|
619
|
-
* Subscribe to updates for a resource URI.
|
|
620
|
-
* @param uri - Resource URI to subscribe to
|
|
621
|
-
*/
|
|
622
|
-
subscribe(uri: string): void;
|
|
623
|
-
/**
|
|
624
|
-
* Unsubscribe from updates for a resource URI.
|
|
625
|
-
* @param uri - Resource URI to unsubscribe from
|
|
626
|
-
*/
|
|
627
|
-
unsubscribe(uri: string): void;
|
|
628
|
-
/**
|
|
629
|
-
* Notify connected clients that a specific resource has been updated.
|
|
630
|
-
* Only emits for subscribed URIs.
|
|
631
|
-
* @param uri - URI of the updated resource
|
|
632
|
-
*/
|
|
633
|
-
notifyResourceUpdated(uri: string): void;
|
|
634
|
-
/**
|
|
635
|
-
* Notify connected clients that the tool list has changed.
|
|
636
|
-
*/
|
|
637
|
-
notifyToolsChanged(): void;
|
|
638
|
-
/**
|
|
639
|
-
* Notify connected clients that the resource list has changed.
|
|
640
|
-
*/
|
|
641
|
-
notifyResourcesChanged(): void;
|
|
642
|
-
/**
|
|
643
|
-
* Notify connected clients that the prompt list has changed.
|
|
644
|
-
*/
|
|
645
|
-
notifyPromptsChanged(): void;
|
|
646
|
-
/**
|
|
647
|
-
* Set the client-requested log level.
|
|
648
|
-
* Only log messages at or above this level will be forwarded.
|
|
649
|
-
* @param level - MCP log level string
|
|
650
|
-
*/
|
|
651
|
-
setLogLevel?(level: string): void;
|
|
652
|
-
/**
|
|
653
|
-
* Send a log message to connected clients.
|
|
654
|
-
* Filters by the client-requested log level threshold.
|
|
655
|
-
* No-op if no SDK server is bound or if the message is below the threshold.
|
|
656
|
-
*
|
|
657
|
-
* @param level - MCP log level for the message
|
|
658
|
-
* @param data - Log data (string, object, or any serializable value)
|
|
659
|
-
* @param loggerName - Optional logger name for client-side filtering
|
|
660
|
-
*/
|
|
661
|
-
sendLogMessage(level: McpLogLevel, data: unknown, loggerName?: string): void;
|
|
662
|
-
/**
|
|
663
|
-
* Bind the SDK server instance for notifications.
|
|
664
|
-
* Called internally by the transport layer.
|
|
665
|
-
* @param sdkServer - The MCP SDK Server instance
|
|
666
|
-
*/
|
|
667
|
-
bindSdkServer?(sdkServer: any): void;
|
|
668
|
-
/**
|
|
669
|
-
* Start the MCP server.
|
|
670
|
-
* Begins listening for client connections.
|
|
671
|
-
*/
|
|
672
|
-
start(): Promise<void>;
|
|
673
|
-
/**
|
|
674
|
-
* Stop the MCP server.
|
|
675
|
-
* Closes all connections and cleans up resources.
|
|
676
|
-
*/
|
|
677
|
-
stop(): Promise<void>;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Reporter for sending progress updates to clients.
|
|
681
|
-
*/
|
|
682
|
-
interface ProgressReporter {
|
|
683
|
-
/**
|
|
684
|
-
* Report progress for the current operation.
|
|
685
|
-
* @param progress - Current progress value
|
|
686
|
-
* @param total - Optional total value (for percentage calculation)
|
|
687
|
-
* @param message - Optional human-readable status message
|
|
688
|
-
*/
|
|
689
|
-
report(progress: number, total?: number, message?: string): void;
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* Extended handler context for MCP tools.
|
|
693
|
-
* Includes MCP-specific information in addition to standard HandlerContext.
|
|
694
|
-
*/
|
|
695
|
-
interface McpHandlerContext extends HandlerContext {
|
|
696
|
-
/** The name of the tool being invoked */
|
|
697
|
-
toolName?: string;
|
|
698
|
-
/** Progress reporter, present when client provides a progressToken */
|
|
699
|
-
progress?: ProgressReporter;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Adapt a handler with a domain error type for use with MCP tools.
|
|
703
|
-
*
|
|
704
|
-
* MCP tool definitions constrain `TError extends OutfitterError`. When your
|
|
705
|
-
* handler returns domain-specific errors that extend `Error` but not
|
|
706
|
-
* `OutfitterError`, use this function instead of an unsafe cast:
|
|
707
|
-
*
|
|
708
|
-
* ```typescript
|
|
709
|
-
* import { adaptHandler } from "@outfitter/mcp";
|
|
710
|
-
*
|
|
711
|
-
* const tool = defineTool({
|
|
712
|
-
* name: "my-tool",
|
|
713
|
-
* inputSchema: z.object({ id: z.string() }),
|
|
714
|
-
* handler: adaptHandler(myDomainHandler),
|
|
715
|
-
* });
|
|
716
|
-
* ```
|
|
717
|
-
*/
|
|
718
|
-
declare function adaptHandler<
|
|
719
|
-
TInput,
|
|
720
|
-
TOutput,
|
|
721
|
-
TError extends Error
|
|
722
|
-
>(handler: (input: TInput, ctx: HandlerContext) => Promise<Result<TOutput, TError>>): Handler<TInput, TOutput, OutfitterError>;
|
|
723
|
-
interface BuildMcpToolsOptions {
|
|
724
|
-
readonly includeSurfaces?: readonly ActionSurface[];
|
|
725
|
-
}
|
|
726
|
-
type ActionSource = ActionRegistry | readonly AnyActionSpec[];
|
|
727
|
-
declare function buildMcpTools(source: ActionSource, options?: BuildMcpToolsOptions): ToolDefinition<unknown, unknown>[];
|
|
728
|
-
import { HandlerContext as HandlerContext2, OutfitterError as OutfitterError2 } from "@outfitter/contracts";
|
|
729
|
-
import { Result as Result3 } from "@outfitter/contracts";
|
|
730
|
-
type DocsSection = "overview" | "tools" | "examples" | "schemas";
|
|
731
|
-
interface DocsToolInput {
|
|
732
|
-
section?: DocsSection | undefined;
|
|
733
|
-
}
|
|
734
|
-
interface DocsToolEntry {
|
|
735
|
-
name: string;
|
|
736
|
-
summary?: string;
|
|
737
|
-
examples?: Array<{
|
|
738
|
-
input: Record<string, unknown>;
|
|
739
|
-
description?: string;
|
|
740
|
-
}>;
|
|
741
|
-
}
|
|
742
|
-
interface DocsToolResponse {
|
|
743
|
-
overview?: string;
|
|
744
|
-
tools?: DocsToolEntry[];
|
|
745
|
-
examples?: Array<{
|
|
746
|
-
name?: string;
|
|
747
|
-
description?: string;
|
|
748
|
-
input?: Record<string, unknown>;
|
|
749
|
-
output?: unknown;
|
|
750
|
-
}>;
|
|
751
|
-
schemas?: Record<string, unknown>;
|
|
752
|
-
}
|
|
753
|
-
interface DocsToolOptions {
|
|
754
|
-
/** Optional override for the docs tool description. */
|
|
755
|
-
description?: string;
|
|
756
|
-
/** Static docs payload (used when getDocs is not provided). */
|
|
757
|
-
docs?: DocsToolResponse;
|
|
758
|
-
/** Dynamic docs provider. */
|
|
759
|
-
getDocs?: (section?: DocsSection) => DocsToolResponse | Promise<DocsToolResponse>;
|
|
760
|
-
}
|
|
761
|
-
declare function defineDocsTool(options?: DocsToolOptions): ToolDefinition<DocsToolInput, DocsToolResponse>;
|
|
762
|
-
type ConfigAction = "get" | "set" | "list";
|
|
763
|
-
interface ConfigToolInput {
|
|
764
|
-
action: ConfigAction;
|
|
765
|
-
key?: string | undefined;
|
|
766
|
-
value?: unknown | undefined;
|
|
767
|
-
}
|
|
768
|
-
interface ConfigToolResponse {
|
|
769
|
-
action: ConfigAction;
|
|
770
|
-
key?: string;
|
|
771
|
-
value?: unknown;
|
|
772
|
-
found?: boolean;
|
|
773
|
-
config?: Record<string, unknown>;
|
|
774
|
-
}
|
|
775
|
-
interface ConfigStore {
|
|
776
|
-
get(key: string): {
|
|
777
|
-
value: unknown;
|
|
778
|
-
found: boolean;
|
|
779
|
-
} | Promise<{
|
|
780
|
-
value: unknown;
|
|
781
|
-
found: boolean;
|
|
782
|
-
}>;
|
|
783
|
-
set(key: string, value: unknown): void | Promise<void>;
|
|
784
|
-
list(): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
785
|
-
}
|
|
786
|
-
interface ConfigToolOptions {
|
|
787
|
-
/** Optional override for the config tool description. */
|
|
788
|
-
description?: string;
|
|
789
|
-
/** Initial config values when using the default in-memory store. */
|
|
790
|
-
initial?: Record<string, unknown>;
|
|
791
|
-
/** Custom config store implementation. */
|
|
792
|
-
store?: ConfigStore;
|
|
793
|
-
}
|
|
794
|
-
declare function defineConfigTool(options?: ConfigToolOptions): ToolDefinition<ConfigToolInput, ConfigToolResponse>;
|
|
795
|
-
interface QueryToolInput {
|
|
796
|
-
q?: string | undefined;
|
|
797
|
-
query?: string | undefined;
|
|
798
|
-
limit?: number | undefined;
|
|
799
|
-
cursor?: string | undefined;
|
|
800
|
-
filters?: Record<string, unknown> | undefined;
|
|
801
|
-
}
|
|
802
|
-
interface QueryToolResponse<T = unknown> {
|
|
803
|
-
results: T[];
|
|
804
|
-
nextCursor?: string;
|
|
805
|
-
_meta?: Record<string, unknown>;
|
|
806
|
-
}
|
|
807
|
-
interface QueryToolOptions<T = unknown> {
|
|
808
|
-
/** Optional override for the query tool description. */
|
|
809
|
-
description?: string;
|
|
810
|
-
/** Custom query handler implementation. */
|
|
811
|
-
handler?: (input: NormalizedQueryInput, ctx: HandlerContext2) => Promise<Result3<QueryToolResponse<T>, OutfitterError2>>;
|
|
812
|
-
}
|
|
813
|
-
declare function defineQueryTool<T = unknown>(options?: QueryToolOptions<T>): ToolDefinition<QueryToolInput, QueryToolResponse<T>>;
|
|
814
|
-
interface CoreToolsOptions {
|
|
815
|
-
docs?: DocsToolOptions;
|
|
816
|
-
config?: ConfigToolOptions;
|
|
817
|
-
query?: QueryToolOptions;
|
|
818
|
-
}
|
|
819
|
-
type NormalizedQueryInput = Required<Pick<QueryToolInput, "q">> & Omit<QueryToolInput, "q">;
|
|
820
|
-
type CoreToolDefinition = ToolDefinition<DocsToolInput, DocsToolResponse> | ToolDefinition<ConfigToolInput, ConfigToolResponse> | ToolDefinition<QueryToolInput, QueryToolResponse>;
|
|
821
|
-
declare function createCoreTools(options?: CoreToolsOptions): CoreToolDefinition[];
|
|
822
|
-
import { JsonSchema, zodToJsonSchema } from "@outfitter/contracts/schema";
|
|
823
|
-
import { OutfitterError as OutfitterError3 } from "@outfitter/contracts";
|
|
824
|
-
/**
|
|
825
|
-
* Create an MCP server instance.
|
|
826
|
-
*
|
|
827
|
-
* The server provides:
|
|
828
|
-
* - Tool registration with Zod schema validation
|
|
829
|
-
* - Resource registration
|
|
830
|
-
* - Tool invocation with Result-based error handling
|
|
831
|
-
* - Automatic error translation from OutfitterError to McpError
|
|
832
|
-
*
|
|
833
|
-
* @param options - Server configuration options
|
|
834
|
-
* @returns Configured McpServer instance
|
|
835
|
-
*
|
|
836
|
-
* @example
|
|
837
|
-
* ```typescript
|
|
838
|
-
* const server = createMcpServer({
|
|
839
|
-
* name: "calculator",
|
|
840
|
-
* version: "1.0.0",
|
|
841
|
-
* logger: createLogger({ name: "mcp" }),
|
|
842
|
-
* });
|
|
843
|
-
*
|
|
844
|
-
* server.registerTool(defineTool({
|
|
845
|
-
* name: "add",
|
|
846
|
-
* description: "Add two numbers",
|
|
847
|
-
* inputSchema: z.object({ a: z.number(), b: z.number() }),
|
|
848
|
-
* handler: async (input) => Result.ok({ sum: input.a + input.b }),
|
|
849
|
-
* }));
|
|
850
|
-
*
|
|
851
|
-
* const result = await server.invokeTool("add", { a: 2, b: 3 });
|
|
852
|
-
* if (result.isOk()) {
|
|
853
|
-
* console.log(result.value.sum); // 5
|
|
854
|
-
* }
|
|
855
|
-
* ```
|
|
856
|
-
*/
|
|
857
|
-
declare function createMcpServer(options: McpServerOptions): McpServer;
|
|
858
|
-
/**
|
|
859
|
-
* Define a typed tool.
|
|
860
|
-
*
|
|
861
|
-
* This is a helper function that provides better type inference
|
|
862
|
-
* when creating tool definitions.
|
|
863
|
-
*
|
|
864
|
-
* @param definition - Tool definition object
|
|
865
|
-
* @returns The same tool definition with inferred types
|
|
866
|
-
*
|
|
867
|
-
* @example
|
|
868
|
-
* ```typescript
|
|
869
|
-
* const echoTool = defineTool({
|
|
870
|
-
* name: "echo",
|
|
871
|
-
* description: "Echo the input message",
|
|
872
|
-
* inputSchema: z.object({ message: z.string() }),
|
|
873
|
-
* handler: async (input, ctx) => {
|
|
874
|
-
* ctx.logger.debug("Echoing message");
|
|
875
|
-
* return Result.ok({ echo: input.message });
|
|
876
|
-
* },
|
|
877
|
-
* });
|
|
878
|
-
* ```
|
|
879
|
-
*/
|
|
880
|
-
declare function defineTool<
|
|
881
|
-
TInput,
|
|
882
|
-
TOutput,
|
|
883
|
-
TError extends OutfitterError3 = OutfitterError3
|
|
884
|
-
>(definition: ToolDefinition<TInput, TOutput, TError>): ToolDefinition<TInput, TOutput, TError>;
|
|
885
|
-
/**
|
|
886
|
-
* Define a resource.
|
|
887
|
-
*
|
|
888
|
-
* This is a helper function for creating resource definitions
|
|
889
|
-
* with consistent typing.
|
|
890
|
-
*
|
|
891
|
-
* @param definition - Resource definition object
|
|
892
|
-
* @returns The same resource definition
|
|
893
|
-
*
|
|
894
|
-
* @example
|
|
895
|
-
* ```typescript
|
|
896
|
-
* const configResource = defineResource({
|
|
897
|
-
* uri: "file:///etc/app/config.json",
|
|
898
|
-
* name: "Application Config",
|
|
899
|
-
* description: "Main configuration file",
|
|
900
|
-
* mimeType: "application/json",
|
|
901
|
-
* });
|
|
902
|
-
* ```
|
|
903
|
-
*/
|
|
904
|
-
declare function defineResource(definition: ResourceDefinition): ResourceDefinition;
|
|
905
|
-
/**
|
|
906
|
-
* Define a resource template.
|
|
907
|
-
*
|
|
908
|
-
* Helper function for creating resource template definitions
|
|
909
|
-
* with URI pattern matching.
|
|
910
|
-
*
|
|
911
|
-
* @param definition - Resource template definition object
|
|
912
|
-
* @returns The same resource template definition
|
|
913
|
-
*/
|
|
914
|
-
declare function defineResourceTemplate(definition: ResourceTemplateDefinition): ResourceTemplateDefinition;
|
|
915
|
-
/**
|
|
916
|
-
* Define a prompt.
|
|
917
|
-
*
|
|
918
|
-
* Helper function for creating prompt definitions
|
|
919
|
-
* with consistent typing.
|
|
920
|
-
*
|
|
921
|
-
* @param definition - Prompt definition object
|
|
922
|
-
* @returns The same prompt definition
|
|
923
|
-
*/
|
|
924
|
-
declare function definePrompt(definition: PromptDefinition): PromptDefinition;
|
|
925
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index";
|
|
926
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio";
|
|
927
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types";
|
|
928
|
-
type McpToolResponse = CallToolResult;
|
|
929
|
-
/**
|
|
930
|
-
* Wrap a handler success value into an MCP CallToolResult.
|
|
931
|
-
*
|
|
932
|
-
* If the value is already a valid McpToolResponse (has a `content` array),
|
|
933
|
-
* it is returned as-is. Otherwise it is wrapped in a text content block.
|
|
934
|
-
* Plain objects are also attached as `structuredContent` for SDK clients
|
|
935
|
-
* that support structured output.
|
|
936
|
-
*/
|
|
937
|
-
declare function wrapToolResult(value: unknown): McpToolResponse;
|
|
938
|
-
/**
|
|
939
|
-
* Wrap an error into an MCP CallToolResult with `isError: true`.
|
|
940
|
-
*
|
|
941
|
-
* Serializes the error (preserving `_tag`, `message`, `code`, `context` if
|
|
942
|
-
* present) and wraps it as a text content block.
|
|
943
|
-
*/
|
|
944
|
-
declare function wrapToolError(error: unknown): McpToolResponse;
|
|
945
|
-
/**
|
|
946
|
-
* Create an MCP SDK server from an Outfitter MCP server.
|
|
947
|
-
*/
|
|
948
|
-
declare function createSdkServer(server: McpServer): Server;
|
|
949
|
-
/**
|
|
950
|
-
* Connect an MCP server over stdio transport.
|
|
951
|
-
*/
|
|
952
|
-
declare function connectStdio(server: McpServer, transport?: StdioServerTransport): Promise<Server>;
|
|
1
|
+
import { McpToolResponse, connectStdio, createSdkServer, wrapToolError, wrapToolResult } from "./shared/@outfitter/mcp-7kcw2814.js";
|
|
2
|
+
import { createMcpServer, definePrompt, defineResource, defineResourceTemplate, defineTool } from "./shared/@outfitter/mcp-knq080yt.js";
|
|
3
|
+
import { BuildMcpToolsOptions, buildMcpTools } from "./shared/@outfitter/mcp-d8vs6vry.js";
|
|
4
|
+
import { ConfigAction, ConfigStore, ConfigToolInput, ConfigToolOptions, ConfigToolResponse, CoreToolsOptions, DocsSection, DocsToolEntry, DocsToolInput, DocsToolOptions, DocsToolResponse, QueryToolInput, QueryToolOptions, QueryToolResponse, createCoreTools, defineConfigTool, defineDocsTool, defineQueryTool } from "./shared/@outfitter/mcp-s6afm4ff.js";
|
|
5
|
+
import { BlobResourceContent, CompletionHandler, CompletionRef, CompletionResult, ContentAnnotations, InvokeToolOptions, McpError, McpHandlerContext, McpServer, McpServerOptions, ProgressReporter, PromptArgument, PromptDefinition, PromptHandler, PromptMessage, PromptMessageContent, PromptResult, ResourceContent, ResourceDefinition, ResourceReadHandler, ResourceTemplateDefinition, ResourceTemplateReadHandler, SerializedTool, TOOL_ANNOTATIONS, TextResourceContent, ToolAnnotations, ToolDefinition, adaptHandler } from "./shared/@outfitter/mcp-gqjg15f5.js";
|
|
6
|
+
import { McpLogLevel, mapLogLevelToMcp, shouldEmitLog } from "./shared/@outfitter/mcp-cqpyer9m.js";
|
|
7
|
+
import { JsonSchema, zodToJsonSchema } from "./shared/@outfitter/mcp-83zvbna8.js";
|
|
953
8
|
export { zodToJsonSchema, wrapToolResult, wrapToolError, shouldEmitLog, mapLogLevelToMcp, defineTool, defineResourceTemplate, defineResource, defineQueryTool, definePrompt, defineDocsTool, defineConfigTool, createSdkServer, createMcpServer, createCoreTools, connectStdio, buildMcpTools, adaptHandler, ToolDefinition, ToolAnnotations, TextResourceContent, TOOL_ANNOTATIONS, SerializedTool, ResourceTemplateReadHandler, ResourceTemplateDefinition, ResourceReadHandler, ResourceDefinition, ResourceContent, QueryToolResponse, QueryToolOptions, QueryToolInput, PromptResult, PromptMessageContent, PromptMessage, PromptHandler, PromptDefinition, PromptArgument, ProgressReporter, McpToolResponse, McpServerOptions, McpServer, McpLogLevel, McpHandlerContext, McpError, JsonSchema, InvokeToolOptions, DocsToolResponse, DocsToolOptions, DocsToolInput, DocsToolEntry, DocsSection, CoreToolsOptions, ContentAnnotations, ConfigToolResponse, ConfigToolOptions, ConfigToolInput, ConfigStore, ConfigAction, CompletionResult, CompletionRef, CompletionHandler, BuildMcpToolsOptions, BlobResourceContent };
|