@outfitter/mcp 0.4.3 → 0.5.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.
Files changed (44) hide show
  1. package/README.md +92 -0
  2. package/dist/actions.d.ts +7 -2
  3. package/dist/actions.js +35 -9
  4. package/dist/core-tools.d.ts +7 -2
  5. package/dist/index.d.ts +12 -6
  6. package/dist/index.js +1 -0
  7. package/dist/internal/content-types.d.ts +2 -0
  8. package/dist/internal/content-types.js +1 -0
  9. package/dist/internal/log-config.d.ts +24 -0
  10. package/dist/internal/log-config.js +13 -0
  11. package/dist/internal/prompt-types.d.ts +3 -0
  12. package/dist/internal/prompt-types.js +1 -0
  13. package/dist/internal/resource-types.d.ts +4 -0
  14. package/dist/internal/resource-types.js +1 -0
  15. package/dist/internal/server-types.d.ts +7 -0
  16. package/dist/internal/server-types.js +20 -0
  17. package/dist/internal/tool-types.d.ts +2 -0
  18. package/dist/{shared/@outfitter/mcp-9m5hs2z0.js → internal/tool-types.js} +4 -16
  19. package/dist/internal/uri-template.d.ts +8 -0
  20. package/dist/internal/uri-template.js +7 -0
  21. package/dist/progress.d.ts +2 -0
  22. package/dist/progress.js +7 -0
  23. package/dist/server.d.ts +7 -2
  24. package/dist/server.js +5 -2
  25. package/dist/shared/@outfitter/{mcp-knq080yt.d.ts → mcp-3hxaatj9.d.ts} +37 -6
  26. package/dist/shared/@outfitter/{mcp-s6afm4ff.d.ts → mcp-4s22693j.d.ts} +1 -1
  27. package/dist/shared/@outfitter/mcp-7btcghjj.d.ts +304 -0
  28. package/dist/shared/@outfitter/mcp-9ry52yg3.d.ts +187 -0
  29. package/dist/shared/@outfitter/mcp-dgwj3jna.d.ts +103 -0
  30. package/dist/shared/@outfitter/{mcp-d8vs6vry.d.ts → mcp-f67dnr72.d.ts} +1 -1
  31. package/dist/shared/@outfitter/mcp-knc1gq0g.d.ts +130 -0
  32. package/dist/shared/@outfitter/mcp-n9vzcp37.js +55 -0
  33. package/dist/shared/@outfitter/mcp-q5hr7227.d.ts +24 -0
  34. package/dist/shared/@outfitter/mcp-q70dtfj6.js +53 -0
  35. package/dist/shared/@outfitter/mcp-r27vbpc1.d.ts +45 -0
  36. package/dist/shared/@outfitter/mcp-s2vnhzav.js +2 -0
  37. package/dist/shared/@outfitter/{mcp-7kcw2814.d.ts → mcp-yf0w5cgh.d.ts} +1 -1
  38. package/dist/shared/@outfitter/{mcp-b502y16n.js → mcp-yf1n85e9.js} +76 -116
  39. package/dist/shared/@outfitter/mcp-zt2s3r38.js +33 -0
  40. package/dist/transport.d.ts +7 -2
  41. package/dist/types.d.ts +7 -2
  42. package/dist/types.js +1 -1
  43. package/package.json +26 -20
  44. package/dist/shared/@outfitter/mcp-gqjg15f5.d.ts +0 -669
@@ -0,0 +1,304 @@
1
+ import { SerializedTool, ToolDefinition } from "./mcp-knc1gq0g.js";
2
+ import { ResourceContent, ResourceDefinition, ResourceTemplateDefinition } from "./mcp-9ry52yg3.js";
3
+ import { CompletionRef, CompletionResult, PromptArgument, PromptDefinition, PromptResult } from "./mcp-dgwj3jna.js";
4
+ import { McpLogLevel } from "./mcp-cqpyer9m.js";
5
+ import { Handler, HandlerContext, Logger, OutfitterError, Result, TaggedErrorClass } from "@outfitter/contracts";
6
+ import { Result as Result2 } from "@outfitter/contracts";
7
+ import { TaggedError } from "@outfitter/contracts";
8
+ /**
9
+ * Configuration options for creating an MCP server.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const options: McpServerOptions = {
14
+ * name: "my-mcp-server",
15
+ * version: "1.0.0",
16
+ * logger: createLogger({ name: "mcp" }),
17
+ * };
18
+ *
19
+ * const server = createMcpServer(options);
20
+ * ```
21
+ */
22
+ interface McpServerOptions {
23
+ /**
24
+ * Default MCP log level for client-facing log forwarding.
25
+ *
26
+ * Precedence (highest wins):
27
+ * 1. `OUTFITTER_LOG_LEVEL` environment variable
28
+ * 2. This option
29
+ * 3. Environment profile (`OUTFITTER_ENV`)
30
+ * 4. `null` (no forwarding until client opts in)
31
+ *
32
+ * Set to `null` to explicitly disable forwarding regardless of environment.
33
+ * The MCP client can always override via `logging/setLevel`.
34
+ */
35
+ defaultLogLevel?: McpLogLevel | null;
36
+ /**
37
+ * Optional logger instance for server logging.
38
+ * If not provided, the server uses the Outfitter logger factory defaults.
39
+ */
40
+ logger?: Logger;
41
+ /**
42
+ * Server name, used in MCP protocol handshake.
43
+ * Should be a short, descriptive identifier.
44
+ */
45
+ name: string;
46
+ /**
47
+ * Server version (semver format recommended).
48
+ * Sent to clients during initialization.
49
+ */
50
+ version: string;
51
+ }
52
+ declare const McpErrorBase: TaggedErrorClass<"McpError", {
53
+ message: string;
54
+ code: number;
55
+ context?: Record<string, unknown>;
56
+ }>;
57
+ /**
58
+ * MCP-specific error with JSON-RPC error code.
59
+ *
60
+ * Used when tool invocations fail or when there are protocol-level errors.
61
+ * Follows the JSON-RPC 2.0 error object format.
62
+ *
63
+ * Standard error codes:
64
+ * - `-32700`: Parse error
65
+ * - `-32600`: Invalid request
66
+ * - `-32601`: Method not found
67
+ * - `-32602`: Invalid params
68
+ * - `-32603`: Internal error
69
+ * - `-32000` to `-32099`: Server errors (reserved)
70
+ *
71
+ * @example
72
+ * ```typescript
73
+ * const error = new McpError({
74
+ * message: "Tool not found: unknown-tool",
75
+ * code: -32601,
76
+ * context: { tool: "unknown-tool" },
77
+ * });
78
+ * ```
79
+ */
80
+ declare class McpError extends McpErrorBase {
81
+ /** Error category for Outfitter error taxonomy compatibility */
82
+ readonly category: "internal";
83
+ }
84
+ /**
85
+ * Options for invoking a tool.
86
+ */
87
+ interface InvokeToolOptions {
88
+ /** Progress token from client for tracking progress */
89
+ progressToken?: string | number;
90
+ /** Custom request ID (auto-generated if not provided) */
91
+ requestId?: string;
92
+ /** Abort signal for cancellation */
93
+ signal?: AbortSignal;
94
+ }
95
+ /**
96
+ * MCP Server instance.
97
+ *
98
+ * Provides methods for registering tools and resources, and for
99
+ * starting/stopping the server.
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const server = createMcpServer({
104
+ * name: "my-server",
105
+ * version: "1.0.0",
106
+ * });
107
+ *
108
+ * server.registerTool(myTool);
109
+ * server.registerResource(myResource);
110
+ *
111
+ * await server.start();
112
+ * ```
113
+ */
114
+ interface McpServer {
115
+ /**
116
+ * Bind the SDK server instance for notifications.
117
+ * Called internally by the transport layer.
118
+ * @param sdkServer - The MCP SDK Server instance
119
+ */
120
+ bindSdkServer?(sdkServer: any): void;
121
+ /**
122
+ * Complete an argument value.
123
+ * @param ref - Reference to the prompt or resource template
124
+ * @param argumentName - Name of the argument to complete
125
+ * @param value - Current value to complete
126
+ * @returns Result with completion values or McpError
127
+ */
128
+ complete(ref: CompletionRef, argumentName: string, value: string): Promise<Result<CompletionResult, InstanceType<typeof McpError>>>;
129
+ /**
130
+ * Get a specific prompt's messages.
131
+ * @param name - Prompt name
132
+ * @param args - Prompt arguments
133
+ * @returns Result with prompt result or McpError
134
+ */
135
+ getPrompt(name: string, args: Record<string, string | undefined>): Promise<Result<PromptResult, InstanceType<typeof McpError>>>;
136
+ /**
137
+ * Get all registered prompts.
138
+ * @returns Array of prompt definitions (without handlers)
139
+ */
140
+ getPrompts(): Array<{
141
+ name: string;
142
+ description?: string;
143
+ arguments: PromptArgument[];
144
+ }>;
145
+ /**
146
+ * Get all registered resources.
147
+ * @returns Array of resource definitions
148
+ */
149
+ getResources(): ResourceDefinition[];
150
+ /**
151
+ * Get all registered resource templates.
152
+ * @returns Array of resource template definitions
153
+ */
154
+ getResourceTemplates(): ResourceTemplateDefinition[];
155
+ /**
156
+ * Get all registered tools.
157
+ * @returns Array of serialized tool information
158
+ */
159
+ getTools(): SerializedTool[];
160
+ /**
161
+ * Invoke a tool by name.
162
+ * @param name - Tool name
163
+ * @param input - Tool input (will be validated)
164
+ * @param options - Optional invocation options
165
+ * @returns Result with tool output or McpError
166
+ */
167
+ invokeTool<T = unknown>(name: string, input: unknown, options?: InvokeToolOptions): Promise<Result<T, InstanceType<typeof McpError>>>;
168
+ /** Server name */
169
+ readonly name: string;
170
+ /**
171
+ * Notify connected clients that the prompt list has changed.
172
+ */
173
+ notifyPromptsChanged(): void;
174
+ /**
175
+ * Notify connected clients that the resource list has changed.
176
+ */
177
+ notifyResourcesChanged(): void;
178
+ /**
179
+ * Notify connected clients that a specific resource has been updated.
180
+ * Only emits for subscribed URIs.
181
+ * @param uri - URI of the updated resource
182
+ */
183
+ notifyResourceUpdated(uri: string): void;
184
+ /**
185
+ * Notify connected clients that the tool list has changed.
186
+ */
187
+ notifyToolsChanged(): void;
188
+ /**
189
+ * Read a resource by URI.
190
+ * @param uri - Resource URI
191
+ * @returns Result with resource content or McpError
192
+ */
193
+ readResource(uri: string): Promise<Result<ResourceContent[], InstanceType<typeof McpError>>>;
194
+ /**
195
+ * Register a prompt with the server.
196
+ * @param prompt - Prompt definition to register
197
+ */
198
+ registerPrompt(prompt: PromptDefinition): void;
199
+ /**
200
+ * Register a resource with the server.
201
+ * @param resource - Resource definition to register
202
+ */
203
+ registerResource(resource: ResourceDefinition): void;
204
+ /**
205
+ * Register a resource template with the server.
206
+ * @param template - Resource template definition to register
207
+ */
208
+ registerResourceTemplate(template: ResourceTemplateDefinition): void;
209
+ /**
210
+ * Register a tool with the server.
211
+ * @param tool - Tool definition to register
212
+ */
213
+ registerTool<
214
+ TInput,
215
+ TOutput,
216
+ TError extends OutfitterError
217
+ >(tool: ToolDefinition<TInput, TOutput, TError>): void;
218
+ /**
219
+ * Send a log message to connected clients.
220
+ * Filters by the client-requested log level threshold.
221
+ * No-op if no SDK server is bound or if the message is below the threshold.
222
+ *
223
+ * @param level - MCP log level for the message
224
+ * @param data - Log data (string, object, or any serializable value)
225
+ * @param loggerName - Optional logger name for client-side filtering
226
+ */
227
+ sendLogMessage(level: McpLogLevel, data: unknown, loggerName?: string): void;
228
+ /**
229
+ * Set the client-requested log level.
230
+ * Only log messages at or above this level will be forwarded.
231
+ * @param level - MCP log level string
232
+ */
233
+ setLogLevel?(level: string): void;
234
+ /**
235
+ * Start the MCP server.
236
+ * Begins listening for client connections.
237
+ */
238
+ start(): Promise<void>;
239
+ /**
240
+ * Stop the MCP server.
241
+ * Closes all connections and cleans up resources.
242
+ */
243
+ stop(): Promise<void>;
244
+ /**
245
+ * Subscribe to updates for a resource URI.
246
+ * @param uri - Resource URI to subscribe to
247
+ */
248
+ subscribe(uri: string): void;
249
+ /**
250
+ * Unsubscribe from updates for a resource URI.
251
+ * @param uri - Resource URI to unsubscribe from
252
+ */
253
+ unsubscribe(uri: string): void;
254
+ /** Server version */
255
+ readonly version: string;
256
+ }
257
+ type HandlerProgress = HandlerContext extends {
258
+ progress?: infer P;
259
+ } ? P : never;
260
+ type LegacyProgressReporter = {
261
+ report(progress: number, total?: number, message?: string): void;
262
+ };
263
+ /**
264
+ * Backward-compatible progress reporter type.
265
+ *
266
+ * - When `HandlerContext.progress` exists (streaming branches), this becomes
267
+ * `ProgressCallback & { report(...) }`.
268
+ * - When it does not exist (older branches), this falls back to
269
+ * `{ report(...) }`.
270
+ */
271
+ type ProgressReporter = [HandlerProgress] extends [never] ? LegacyProgressReporter : NonNullable<HandlerProgress> & LegacyProgressReporter;
272
+ /**
273
+ * Extended handler context for MCP tools.
274
+ * Includes MCP-specific information in addition to standard HandlerContext.
275
+ */
276
+ interface McpHandlerContext extends Omit<HandlerContext, "progress"> {
277
+ /** Progress reporter, present when client provides a progressToken */
278
+ progress?: ProgressReporter;
279
+ /** The name of the tool being invoked */
280
+ toolName?: string;
281
+ }
282
+ /**
283
+ * Adapt a handler with a domain error type for use with MCP tools.
284
+ *
285
+ * MCP tool definitions constrain `TError extends OutfitterError`. When your
286
+ * handler returns domain-specific errors that extend `Error` but not
287
+ * `OutfitterError`, use this function instead of an unsafe cast:
288
+ *
289
+ * ```typescript
290
+ * import { adaptHandler } from "@outfitter/mcp";
291
+ *
292
+ * const tool = defineTool({
293
+ * name: "my-tool",
294
+ * inputSchema: z.object({ id: z.string() }),
295
+ * handler: adaptHandler(myDomainHandler),
296
+ * });
297
+ * ```
298
+ */
299
+ declare function adaptHandler<
300
+ TInput,
301
+ TOutput,
302
+ TError extends Error
303
+ >(handler: (input: TInput, ctx: HandlerContext) => Promise<Result<TOutput, TError>>): Handler<TInput, TOutput, OutfitterError>;
304
+ export { McpServerOptions, McpError, InvokeToolOptions, McpServer, ProgressReporter, McpHandlerContext, adaptHandler, Result2 as Result, TaggedError };
@@ -0,0 +1,187 @@
1
+ import { CompletionHandler } from "./mcp-dgwj3jna.js";
2
+ import { ContentAnnotations } from "./mcp-q5hr7227.js";
3
+ import { HandlerContext, OutfitterError, Result } from "@outfitter/contracts";
4
+ import { z } from "zod";
5
+ /**
6
+ * Text content returned from a resource read.
7
+ */
8
+ interface TextResourceContent {
9
+ /** Optional content annotations */
10
+ annotations?: ContentAnnotations;
11
+ /** Optional MIME type */
12
+ mimeType?: string;
13
+ /** Text content */
14
+ text: string;
15
+ /** Resource URI */
16
+ uri: string;
17
+ }
18
+ /**
19
+ * Binary (base64-encoded) content returned from a resource read.
20
+ */
21
+ interface BlobResourceContent {
22
+ /** Optional content annotations */
23
+ annotations?: ContentAnnotations;
24
+ /** Base64-encoded binary content */
25
+ blob: string;
26
+ /** Optional MIME type */
27
+ mimeType?: string;
28
+ /** Resource URI */
29
+ uri: string;
30
+ }
31
+ /**
32
+ * Content returned from reading a resource.
33
+ */
34
+ type ResourceContent = TextResourceContent | BlobResourceContent;
35
+ /**
36
+ * Handler for reading a resource's content.
37
+ *
38
+ * @param uri - The resource URI being read
39
+ * @param ctx - Handler context with logger and requestId
40
+ * @returns Array of resource content items
41
+ */
42
+ type ResourceReadHandler = (uri: string, ctx: HandlerContext) => Promise<Result<ResourceContent[], OutfitterError>>;
43
+ /**
44
+ * Definition of an MCP resource that can be read by clients.
45
+ *
46
+ * Resources represent data that clients can access, such as files,
47
+ * database records, or API responses.
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const configResource: ResourceDefinition = {
52
+ * uri: "file:///etc/app/config.json",
53
+ * name: "Application Config",
54
+ * description: "Main application configuration file",
55
+ * mimeType: "application/json",
56
+ * handler: async (uri, ctx) => {
57
+ * const content = await readFile(uri);
58
+ * return Result.ok([{ uri, text: content }]);
59
+ * },
60
+ * };
61
+ * ```
62
+ */
63
+ interface ResourceDefinition {
64
+ /**
65
+ * Optional description of the resource.
66
+ * Provides additional context about the resource contents.
67
+ */
68
+ description?: string;
69
+ /**
70
+ * Optional handler for reading the resource content.
71
+ * If not provided, the resource is metadata-only.
72
+ */
73
+ handler?: ResourceReadHandler;
74
+ /**
75
+ * Optional MIME type of the resource content.
76
+ * Helps clients understand how to process the resource.
77
+ */
78
+ mimeType?: string;
79
+ /**
80
+ * Human-readable resource name.
81
+ * Displayed to users in resource listings.
82
+ */
83
+ name: string;
84
+ /**
85
+ * Unique resource URI.
86
+ * Must be a valid URI (file://, https://, custom://, etc.).
87
+ */
88
+ uri: string;
89
+ }
90
+ /**
91
+ * Handler for reading a resource template's content.
92
+ *
93
+ * @param uri - The matched URI
94
+ * @param variables - Extracted template variables
95
+ * @param ctx - Handler context
96
+ */
97
+ type ResourceTemplateReadHandler = (uri: string, variables: Record<string, string>, ctx: HandlerContext) => Promise<Result<ResourceContent[], OutfitterError>>;
98
+ /**
99
+ * Definition of an MCP resource template with URI pattern matching.
100
+ *
101
+ * Templates use RFC 6570 Level 1 URI templates (e.g., `{param}`)
102
+ * to match and extract variables from URIs.
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const userTemplate: ResourceTemplateDefinition = {
107
+ * uriTemplate: "db:///users/{userId}/profile",
108
+ * name: "User Profile",
109
+ * handler: async (uri, variables) => {
110
+ * const profile = await getProfile(variables.userId);
111
+ * return Result.ok([{ uri, text: JSON.stringify(profile) }]);
112
+ * },
113
+ * };
114
+ * ```
115
+ */
116
+ interface ResourceTemplateDefinition {
117
+ /** Optional completion handlers keyed by parameter name. */
118
+ complete?: Record<string, CompletionHandler>;
119
+ /** Optional description. */
120
+ description?: string;
121
+ /** Handler for reading matched resources. */
122
+ handler: ResourceTemplateReadHandler;
123
+ /** Optional MIME type. */
124
+ mimeType?: string;
125
+ /** Human-readable name for the template. */
126
+ name: string;
127
+ /** URI template with `{param}` placeholders (RFC 6570 Level 1). */
128
+ uriTemplate: string;
129
+ }
130
+ /**
131
+ * Handler for reading a typed resource template's content.
132
+ *
133
+ * @param uri - The matched URI
134
+ * @param params - Validated and parsed template parameters (typed via Zod schema)
135
+ * @param ctx - Handler context
136
+ */
137
+ type TypedResourceTemplateReadHandler<TParams> = (uri: string, params: TParams, ctx: HandlerContext) => Promise<Result<ResourceContent[], OutfitterError>>;
138
+ /**
139
+ * Typed definition of an MCP resource template with Zod schema validation.
140
+ *
141
+ * Parallel to `ToolDefinition` — the `paramSchema` validates URI template
142
+ * variables before handler invocation, providing type-safe parameters
143
+ * and automatic coercion (e.g., string → number via `z.coerce.number()`).
144
+ *
145
+ * @typeParam TParams - The validated parameter type (inferred from Zod schema)
146
+ *
147
+ * @example
148
+ * ```typescript
149
+ * const userTemplate = defineResourceTemplate({
150
+ * uriTemplate: "db:///users/{userId}/posts/{postId}",
151
+ * name: "User Post",
152
+ * paramSchema: z.object({
153
+ * userId: z.string().min(1),
154
+ * postId: z.coerce.number().int().positive(),
155
+ * }),
156
+ * handler: async (uri, params, ctx) => {
157
+ * // params is { userId: string; postId: number } — validated and coerced
158
+ * const post = await getPost(params.userId, params.postId);
159
+ * return Result.ok([{ uri, text: JSON.stringify(post) }]);
160
+ * },
161
+ * });
162
+ * ```
163
+ */
164
+ interface TypedResourceTemplateDefinition<TParams> {
165
+ /** Optional completion handlers keyed by parameter name. */
166
+ complete?: Record<string, CompletionHandler>;
167
+ /** Optional description. */
168
+ description?: string;
169
+ /**
170
+ * Handler for reading matched resources.
171
+ * Receives validated and coerced parameters (typed via `paramSchema`).
172
+ */
173
+ handler: TypedResourceTemplateReadHandler<TParams>;
174
+ /** Optional MIME type. */
175
+ mimeType?: string;
176
+ /** Human-readable name for the template. */
177
+ name: string;
178
+ /**
179
+ * Zod schema for validating and parsing URI template parameters.
180
+ * Variables extracted from the URI template are validated against this schema
181
+ * before being passed to the handler. Supports coercion (e.g., `z.coerce.number()`).
182
+ */
183
+ paramSchema: z.ZodType<TParams>;
184
+ /** URI template with `{param}` placeholders (RFC 6570 Level 1). */
185
+ uriTemplate: string;
186
+ }
187
+ export { TextResourceContent, BlobResourceContent, ResourceContent, ResourceReadHandler, ResourceDefinition, ResourceTemplateReadHandler, ResourceTemplateDefinition, TypedResourceTemplateReadHandler, TypedResourceTemplateDefinition };
@@ -0,0 +1,103 @@
1
+ import { ContentAnnotations } from "./mcp-q5hr7227.js";
2
+ import { OutfitterError, Result } from "@outfitter/contracts";
3
+ /**
4
+ * Result of a completion request.
5
+ */
6
+ interface CompletionResult {
7
+ /** Whether there are more values */
8
+ hasMore?: boolean;
9
+ /** Total number of available values (for pagination) */
10
+ total?: number;
11
+ /** Completion values */
12
+ values: string[];
13
+ }
14
+ /**
15
+ * Handler for generating completions.
16
+ */
17
+ type CompletionHandler = (value: string) => Promise<CompletionResult>;
18
+ /**
19
+ * Reference to a prompt or resource for completion.
20
+ */
21
+ type CompletionRef = {
22
+ type: "ref/prompt";
23
+ name: string;
24
+ } | {
25
+ type: "ref/resource";
26
+ uri: string;
27
+ };
28
+ /**
29
+ * Argument definition for a prompt.
30
+ */
31
+ interface PromptArgument {
32
+ /** Optional completion handler for this argument */
33
+ complete?: CompletionHandler;
34
+ /** Human-readable description */
35
+ description?: string;
36
+ /** Argument name */
37
+ name: string;
38
+ /** Whether this argument is required */
39
+ required?: boolean;
40
+ }
41
+ /**
42
+ * Content block within a prompt message.
43
+ */
44
+ interface PromptMessageContent {
45
+ /** Optional content annotations */
46
+ annotations?: ContentAnnotations;
47
+ /** Text content */
48
+ text: string;
49
+ /** Content type */
50
+ type: "text";
51
+ }
52
+ /**
53
+ * A message in a prompt response.
54
+ */
55
+ interface PromptMessage {
56
+ /** Message content */
57
+ content: PromptMessageContent;
58
+ /** Message role */
59
+ role: "user" | "assistant";
60
+ }
61
+ /**
62
+ * Result returned from getting a prompt.
63
+ */
64
+ interface PromptResult {
65
+ /** Optional description override */
66
+ description?: string;
67
+ /** Prompt messages */
68
+ messages: PromptMessage[];
69
+ }
70
+ /**
71
+ * Handler for generating prompt messages.
72
+ */
73
+ type PromptHandler = (args: Record<string, string | undefined>) => Promise<Result<PromptResult, OutfitterError>>;
74
+ /**
75
+ * Definition of an MCP prompt.
76
+ *
77
+ * Prompts are reusable templates that generate messages for LLMs.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const reviewPrompt: PromptDefinition = {
82
+ * name: "code-review",
83
+ * description: "Review code changes",
84
+ * arguments: [
85
+ * { name: "language", description: "Programming language", required: true },
86
+ * ],
87
+ * handler: async (args) => Result.ok({
88
+ * messages: [{ role: "user", content: { type: "text", text: `Review this ${args.language} code` } }],
89
+ * }),
90
+ * };
91
+ * ```
92
+ */
93
+ interface PromptDefinition {
94
+ /** Prompt arguments */
95
+ arguments: PromptArgument[];
96
+ /** Human-readable description */
97
+ description?: string;
98
+ /** Handler to generate messages */
99
+ handler: PromptHandler;
100
+ /** Unique prompt name */
101
+ name: string;
102
+ }
103
+ export { CompletionResult, CompletionHandler, CompletionRef, PromptArgument, PromptMessageContent, PromptMessage, PromptResult, PromptHandler, PromptDefinition };
@@ -1,4 +1,4 @@
1
- import { ToolDefinition } from "./mcp-gqjg15f5.js";
1
+ import { ToolDefinition } from "./mcp-knc1gq0g.js";
2
2
  import { ActionRegistry, ActionSurface, AnyActionSpec } from "@outfitter/contracts";
3
3
  interface BuildMcpToolsOptions {
4
4
  readonly includeSurfaces?: readonly ActionSurface[];