@outfitter/mcp 0.3.0 → 0.4.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/README.md CHANGED
@@ -56,14 +56,82 @@ Creates an MCP server instance.
56
56
  interface McpServerOptions {
57
57
  name: string; // Server name for MCP handshake
58
58
  version: string; // Server version (semver)
59
- logger?: Logger; // Optional structured logger
59
+ logger?: Logger; // Optional structured logger (BYO)
60
60
  defaultLogLevel?: McpLogLevel | null; // Default log forwarding level
61
61
  }
62
62
 
63
63
  const server = createMcpServer({
64
64
  name: "my-server",
65
65
  version: "1.0.0",
66
- logger: createLogger({ name: "mcp" }),
66
+ });
67
+
68
+ // If `logger` is omitted, Outfitter logger factory defaults are used.
69
+ ```
70
+
71
+ ### Bring Your Own Logger (BYO)
72
+
73
+ `createMcpServer` accepts any logger implementing the shared `Logger` contract.
74
+ This lets you use the default Outfitter backend or a custom backend adapter.
75
+
76
+ #### Outfitter factory backend
77
+
78
+ ```typescript
79
+ import { createOutfitterLoggerFactory } from "@outfitter/logging";
80
+
81
+ const loggerFactory = createOutfitterLoggerFactory();
82
+ const server = createMcpServer({
83
+ name: "my-server",
84
+ version: "1.0.0",
85
+ logger: loggerFactory.createLogger({
86
+ name: "mcp",
87
+ context: { surface: "mcp" },
88
+ }),
89
+ });
90
+ ```
91
+
92
+ #### Custom adapter backend
93
+
94
+ ```typescript
95
+ import {
96
+ createLoggerFactory,
97
+ type Logger,
98
+ type LoggerAdapter,
99
+ } from "@outfitter/contracts";
100
+
101
+ type BackendOptions = { write: (line: string) => void };
102
+
103
+ const adapter: LoggerAdapter<BackendOptions> = {
104
+ createLogger(config) {
105
+ const write = config.backend?.write ?? (() => {});
106
+ const createMethod = (level: string): Logger["info"] =>
107
+ ((message: string) => {
108
+ write(`[${level}] ${config.name}: ${message}`);
109
+ }) as Logger["info"];
110
+
111
+ return {
112
+ trace: createMethod("trace"),
113
+ debug: createMethod("debug"),
114
+ info: createMethod("info"),
115
+ warn: createMethod("warn"),
116
+ error: createMethod("error"),
117
+ fatal: createMethod("fatal"),
118
+ child: (childContext) =>
119
+ adapter.createLogger({
120
+ ...config,
121
+ context: { ...(config.context ?? {}), ...childContext },
122
+ }),
123
+ };
124
+ },
125
+ };
126
+
127
+ const loggerFactory = createLoggerFactory(adapter);
128
+ const server = createMcpServer({
129
+ name: "my-server",
130
+ version: "1.0.0",
131
+ logger: loggerFactory.createLogger({
132
+ name: "mcp",
133
+ backend: { write: (line) => console.log(line) },
134
+ }),
67
135
  });
68
136
  ```
69
137
 
@@ -122,7 +190,7 @@ const getUserTool = defineTool({
122
190
  handler: async (input, ctx) => {
123
191
  const user = await db.users.find(input.userId);
124
192
  if (!user) {
125
- return Result.err(new NotFoundError("user", input.userId));
193
+ return Result.err(NotFoundError.create("user", input.userId));
126
194
  }
127
195
  return Result.ok(user);
128
196
  },
@@ -291,8 +359,74 @@ for (const tool of coreTools) {
291
359
  }
292
360
  ```
293
361
 
362
+ ## Tool Annotations
363
+
364
+ Use `TOOL_ANNOTATIONS` presets to declare tool behavior hints without manually specifying all four booleans:
365
+
366
+ ```typescript
367
+ import { defineTool, TOOL_ANNOTATIONS } from "@outfitter/mcp";
368
+
369
+ // Use a preset directly
370
+ const listTool = defineTool({
371
+ name: "list-items",
372
+ description: "List all items",
373
+ inputSchema: z.object({}),
374
+ annotations: TOOL_ANNOTATIONS.readOnly,
375
+ handler: async (input, ctx) => { /* ... */ },
376
+ });
377
+
378
+ // Spread and override for edge cases
379
+ const searchTool = defineTool({
380
+ name: "search",
381
+ description: "Search external APIs",
382
+ inputSchema: z.object({ q: z.string() }),
383
+ annotations: { ...TOOL_ANNOTATIONS.readOnly, openWorldHint: true },
384
+ handler: async (input, ctx) => { /* ... */ },
385
+ });
386
+ ```
387
+
388
+ | Preset | readOnly | destructive | idempotent | openWorld |
389
+ |--------|----------|-------------|------------|-----------|
390
+ | `readOnly` | true | false | true | false |
391
+ | `write` | false | false | false | false |
392
+ | `writeIdempotent` | false | false | true | false |
393
+ | `destructive` | false | true | true | false |
394
+ | `openWorld` | false | false | false | true |
395
+
396
+ For multi-action tools, use the most conservative union of hints. Per-action annotations are an MCP spec limitation.
397
+
398
+ ### adaptHandler
399
+
400
+ When your handler returns domain errors that extend `Error` but not `OutfitterError`, use `adaptHandler` instead of an unsafe cast:
401
+
402
+ ```typescript
403
+ import { adaptHandler, defineTool } from "@outfitter/mcp";
404
+
405
+ const tool = defineTool({
406
+ name: "my-tool",
407
+ inputSchema: z.object({ id: z.string() }),
408
+ handler: adaptHandler(myDomainHandler),
409
+ });
410
+ ```
411
+
294
412
  ## Transport Helpers
295
413
 
414
+ ### wrapToolResult / wrapToolError
415
+
416
+ Format handler output as MCP tool responses. Useful when building custom transport layers or testing:
417
+
418
+ ```typescript
419
+ import { wrapToolResult, wrapToolError } from "@outfitter/mcp";
420
+
421
+ // Wrap a plain value as MCP tool content
422
+ const response = wrapToolResult({ count: 42 });
423
+ // { content: [{ type: "text", text: '{"count":42}' }] }
424
+
425
+ // Wrap an error with isError flag
426
+ const errorResponse = wrapToolError(new Error("not found"));
427
+ // { content: [{ type: "text", text: "not found" }], isError: true }
428
+ ```
429
+
296
430
  ### connectStdio
297
431
 
298
432
  Connect server to stdio transport for Claude Desktop integration.
@@ -393,6 +527,10 @@ Config location:
393
527
  - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
394
528
  - Linux: `~/.config/claude/claude_desktop_config.json`
395
529
 
530
+ ## Upgrading
531
+
532
+ Run `outfitter update --guide` for version-specific migration instructions, or check the [migration docs](https://github.com/outfitter-dev/outfitter/tree/main/plugins/outfitter/shared/migrations) for detailed upgrade steps.
533
+
396
534
  ## Related Packages
397
535
 
398
536
  - [@outfitter/contracts](../contracts/README.md) — Result types and error taxonomy
@@ -0,0 +1,4 @@
1
+ import { BuildMcpToolsOptions, buildMcpTools } from "./shared/@outfitter/mcp-a0cgfsnw";
2
+ import "./shared/@outfitter/mcp-h2twz77x";
3
+ import "./shared/@outfitter/mcp-cqpyer9m";
4
+ export { buildMcpTools, BuildMcpToolsOptions };
@@ -0,0 +1,11 @@
1
+ // @bun
2
+ import {
3
+ buildMcpTools
4
+ } from "./shared/@outfitter/mcp-9whem1wr.js";
5
+ import"./shared/@outfitter/mcp-k8r6kefr.js";
6
+ import"./shared/@outfitter/mcp-fjtxsa0x.js";
7
+ import"./shared/@outfitter/mcp-9m5hs2z0.js";
8
+ import"./shared/@outfitter/mcp-f91wbr49.js";
9
+ export {
10
+ buildMcpTools
11
+ };
@@ -0,0 +1,4 @@
1
+ import { ConfigAction, ConfigStore, ConfigToolInput, ConfigToolOptions, ConfigToolResponse, CoreToolDefinition, CoreToolsOptions, DocsSection, DocsToolEntry, DocsToolInput, DocsToolOptions, DocsToolResponse, NormalizedQueryInput, QueryToolInput, QueryToolOptions, QueryToolResponse, createCoreTools, defineConfigTool, defineDocsTool, defineQueryTool } from "./shared/@outfitter/mcp-dwd800vf";
2
+ import "./shared/@outfitter/mcp-h2twz77x";
3
+ import "./shared/@outfitter/mcp-cqpyer9m";
4
+ export { defineQueryTool, defineDocsTool, defineConfigTool, createCoreTools, QueryToolResponse, QueryToolOptions, QueryToolInput, NormalizedQueryInput, DocsToolResponse, DocsToolOptions, DocsToolInput, DocsToolEntry, DocsSection, CoreToolsOptions, CoreToolDefinition, ConfigToolResponse, ConfigToolOptions, ConfigToolInput, ConfigStore, ConfigAction };
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ import {
3
+ createCoreTools,
4
+ defineConfigTool,
5
+ defineDocsTool,
6
+ defineQueryTool
7
+ } from "./shared/@outfitter/mcp-zv3ej45k.js";
8
+ export {
9
+ defineQueryTool,
10
+ defineDocsTool,
11
+ defineConfigTool,
12
+ createCoreTools
13
+ };
package/dist/index.d.ts CHANGED
@@ -54,7 +54,7 @@ interface McpServerOptions {
54
54
  version: string;
55
55
  /**
56
56
  * Optional logger instance for server logging.
57
- * If not provided, a no-op logger is used.
57
+ * If not provided, the server uses the Outfitter logger factory defaults.
58
58
  */
59
59
  logger?: Logger;
60
60
  /**
@@ -90,6 +90,57 @@ interface ToolAnnotations {
90
90
  openWorldHint?: boolean;
91
91
  }
92
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
+ /**
93
144
  * Definition of an MCP tool that can be invoked by clients.
94
145
  *
95
146
  * Tools are the primary way clients interact with MCP servers.
@@ -647,6 +698,28 @@ interface McpHandlerContext extends HandlerContext {
647
698
  /** Progress reporter, present when client provides a progressToken */
648
699
  progress?: ProgressReporter;
649
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>;
650
723
  interface BuildMcpToolsOptions {
651
724
  readonly includeSurfaces?: readonly ActionSurface[];
652
725
  }
@@ -912,6 +985,22 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio";
912
985
  import { CallToolResult } from "@modelcontextprotocol/sdk/types";
913
986
  type McpToolResponse = CallToolResult;
914
987
  /**
988
+ * Wrap a handler success value into an MCP CallToolResult.
989
+ *
990
+ * If the value is already a valid McpToolResponse (has a `content` array),
991
+ * it is returned as-is. Otherwise it is wrapped in a text content block.
992
+ * Plain objects are also attached as `structuredContent` for SDK clients
993
+ * that support structured output.
994
+ */
995
+ declare function wrapToolResult(value: unknown): McpToolResponse;
996
+ /**
997
+ * Wrap an error into an MCP CallToolResult with `isError: true`.
998
+ *
999
+ * Serializes the error (preserving `_tag`, `message`, `code`, `context` if
1000
+ * present) and wraps it as a text content block.
1001
+ */
1002
+ declare function wrapToolError(error: unknown): McpToolResponse;
1003
+ /**
915
1004
  * Create an MCP SDK server from an Outfitter MCP server.
916
1005
  */
917
1006
  declare function createSdkServer(server: McpServer): Server;
@@ -919,4 +1008,4 @@ declare function createSdkServer(server: McpServer): Server;
919
1008
  * Connect an MCP server over stdio transport.
920
1009
  */
921
1010
  declare function connectStdio(server: McpServer, transport?: StdioServerTransport): Promise<Server>;
922
- export { zodToJsonSchema, shouldEmitLog, mapLogLevelToMcp, defineTool, defineResourceTemplate, defineResource, defineQueryTool, definePrompt, defineDocsTool, defineConfigTool, createSdkServer, createMcpServer, createCoreTools, connectStdio, buildMcpTools, ToolDefinition, ToolAnnotations, TextResourceContent, 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 };
1011
+ 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 };
package/dist/index.js CHANGED
@@ -4,6 +4,10 @@ import { DEFAULT_REGISTRY_SURFACES } from "@outfitter/contracts";
4
4
  // src/server.ts
5
5
  import { getEnvironment, getEnvironmentDefaults } from "@outfitter/config";
6
6
  import { generateRequestId, Result } from "@outfitter/contracts";
7
+ import {
8
+ createOutfitterLoggerFactory,
9
+ createPrettyFormatter
10
+ } from "@outfitter/logging";
7
11
 
8
12
  // src/logging.ts
9
13
  var MCP_LEVEL_ORDER = [
@@ -384,24 +388,48 @@ import {
384
388
  } from "@outfitter/contracts";
385
389
  import { TaggedError } from "@outfitter/contracts";
386
390
  var TaggedError2 = TaggedErrorImpl;
391
+ var TOOL_ANNOTATIONS = {
392
+ readOnly: {
393
+ readOnlyHint: true,
394
+ destructiveHint: false,
395
+ idempotentHint: true,
396
+ openWorldHint: false
397
+ },
398
+ write: {
399
+ readOnlyHint: false,
400
+ destructiveHint: false,
401
+ idempotentHint: false,
402
+ openWorldHint: false
403
+ },
404
+ writeIdempotent: {
405
+ readOnlyHint: false,
406
+ destructiveHint: false,
407
+ idempotentHint: true,
408
+ openWorldHint: false
409
+ },
410
+ destructive: {
411
+ readOnlyHint: false,
412
+ destructiveHint: true,
413
+ idempotentHint: true,
414
+ openWorldHint: false
415
+ },
416
+ openWorld: {
417
+ readOnlyHint: false,
418
+ destructiveHint: false,
419
+ idempotentHint: false,
420
+ openWorldHint: true
421
+ }
422
+ };
387
423
  var McpErrorBase = TaggedError2("McpError")();
388
424
 
389
425
  class McpError extends McpErrorBase {
390
426
  category = "internal";
391
427
  }
428
+ function adaptHandler(handler) {
429
+ return handler;
430
+ }
392
431
 
393
432
  // src/server.ts
394
- function createNoOpLogger() {
395
- return {
396
- trace: (..._args) => {},
397
- debug: (..._args) => {},
398
- info: (..._args) => {},
399
- warn: (..._args) => {},
400
- error: (..._args) => {},
401
- fatal: (..._args) => {},
402
- child: () => createNoOpLogger()
403
- };
404
- }
405
433
  var VALID_MCP_LOG_LEVELS = new Set([
406
434
  "debug",
407
435
  "info",
@@ -418,6 +446,21 @@ var DEFAULTS_TO_MCP = {
418
446
  warn: "warning",
419
447
  error: "error"
420
448
  };
449
+ function createDefaultMcpSink() {
450
+ const formatter = createPrettyFormatter({ colors: false });
451
+ return {
452
+ formatter,
453
+ write(record, formatted) {
454
+ const serialized = formatted ?? formatter.format(record);
455
+ const line = serialized.endsWith(`
456
+ `) ? serialized : `${serialized}
457
+ `;
458
+ if (typeof process !== "undefined" && process.stderr?.write) {
459
+ process.stderr.write(line);
460
+ }
461
+ }
462
+ };
463
+ }
421
464
  function resolveDefaultLogLevel(options) {
422
465
  const envLogLevel = process.env["OUTFITTER_LOG_LEVEL"];
423
466
  if (envLogLevel !== undefined && VALID_MCP_LOG_LEVELS.has(envLogLevel)) {
@@ -438,7 +481,16 @@ function resolveDefaultLogLevel(options) {
438
481
  }
439
482
  function createMcpServer(options) {
440
483
  const { name, version, logger: providedLogger } = options;
441
- const logger = providedLogger ?? createNoOpLogger();
484
+ let loggerFactory = null;
485
+ const logger = providedLogger ?? (() => {
486
+ loggerFactory = createOutfitterLoggerFactory({
487
+ defaults: { sinks: [createDefaultMcpSink()] }
488
+ });
489
+ return loggerFactory.createLogger({
490
+ name: "mcp",
491
+ context: { serverName: name, serverVersion: version, surface: "mcp" }
492
+ });
493
+ })();
442
494
  const tools = new Map;
443
495
  const resources = new Map;
444
496
  const resourceTemplates = new Map;
@@ -848,6 +900,9 @@ function createMcpServer(options) {
848
900
  },
849
901
  async stop() {
850
902
  logger.info("MCP server stopping", { name, version });
903
+ if (loggerFactory !== null) {
904
+ await loggerFactory.flush();
905
+ }
851
906
  }
852
907
  };
853
908
  return server;
@@ -1131,16 +1186,12 @@ function toSdkError(error) {
1131
1186
  }
1132
1187
  function createSdkServer(server) {
1133
1188
  const capabilities = {
1134
- tools: { listChanged: true }
1189
+ tools: { listChanged: true },
1190
+ resources: { listChanged: true, subscribe: true },
1191
+ prompts: { listChanged: true },
1192
+ completions: {},
1193
+ logging: {}
1135
1194
  };
1136
- if (server.getResources().length > 0 || server.getResourceTemplates().length > 0) {
1137
- capabilities["resources"] = { listChanged: true, subscribe: true };
1138
- }
1139
- if (server.getPrompts().length > 0) {
1140
- capabilities["prompts"] = { listChanged: true };
1141
- }
1142
- capabilities["completions"] = {};
1143
- capabilities["logging"] = {};
1144
1195
  const sdkServer = new Server({ name: server.name, version: server.version }, { capabilities });
1145
1196
  sdkServer.setRequestHandler(ListToolsRequestSchema, async () => ({
1146
1197
  tools: server.getTools()
@@ -1222,6 +1273,8 @@ async function connectStdio(server, transport = new StdioServerTransport) {
1222
1273
  }
1223
1274
  export {
1224
1275
  zodToJsonSchema,
1276
+ wrapToolResult,
1277
+ wrapToolError,
1225
1278
  shouldEmitLog,
1226
1279
  mapLogLevelToMcp,
1227
1280
  defineTool,
@@ -1236,5 +1289,7 @@ export {
1236
1289
  createCoreTools,
1237
1290
  connectStdio,
1238
1291
  buildMcpTools,
1292
+ adaptHandler,
1293
+ TOOL_ANNOTATIONS,
1239
1294
  McpError
1240
1295
  };
@@ -0,0 +1,2 @@
1
+ import { McpLogLevel, mapLogLevelToMcp, shouldEmitLog } from "./shared/@outfitter/mcp-cqpyer9m";
2
+ export { shouldEmitLog, mapLogLevelToMcp, McpLogLevel };
@@ -0,0 +1,9 @@
1
+ // @bun
2
+ import {
3
+ mapLogLevelToMcp,
4
+ shouldEmitLog
5
+ } from "./shared/@outfitter/mcp-fjtxsa0x.js";
6
+ export {
7
+ shouldEmitLog,
8
+ mapLogLevelToMcp
9
+ };
@@ -0,0 +1,2 @@
1
+ import { JsonSchema, zodToJsonSchema } from "./shared/@outfitter/mcp-s80bqcsb";
2
+ export { zodToJsonSchema, JsonSchema };
package/dist/schema.js ADDED
@@ -0,0 +1,7 @@
1
+ // @bun
2
+ import {
3
+ zodToJsonSchema
4
+ } from "./shared/@outfitter/mcp-f91wbr49.js";
5
+ export {
6
+ zodToJsonSchema
7
+ };
@@ -0,0 +1,4 @@
1
+ import { createMcpServer, definePrompt, defineResource, defineResourceTemplate, defineTool } from "./shared/@outfitter/mcp-2vqyt1fj";
2
+ import "./shared/@outfitter/mcp-h2twz77x";
3
+ import "./shared/@outfitter/mcp-cqpyer9m";
4
+ export { defineTool, defineResourceTemplate, defineResource, definePrompt, createMcpServer };
package/dist/server.js ADDED
@@ -0,0 +1,18 @@
1
+ // @bun
2
+ import {
3
+ createMcpServer,
4
+ definePrompt,
5
+ defineResource,
6
+ defineResourceTemplate,
7
+ defineTool
8
+ } from "./shared/@outfitter/mcp-k8r6kefr.js";
9
+ import"./shared/@outfitter/mcp-fjtxsa0x.js";
10
+ import"./shared/@outfitter/mcp-9m5hs2z0.js";
11
+ import"./shared/@outfitter/mcp-f91wbr49.js";
12
+ export {
13
+ defineTool,
14
+ defineResourceTemplate,
15
+ defineResource,
16
+ definePrompt,
17
+ createMcpServer
18
+ };
@@ -0,0 +1,104 @@
1
+ import { McpServer, McpServerOptions, PromptDefinition, ResourceDefinition, ResourceTemplateDefinition, ToolDefinition } from "./mcp-h2twz77x";
2
+ import { OutfitterError } from "@outfitter/contracts";
3
+ /**
4
+ * Create an MCP server instance.
5
+ *
6
+ * The server provides:
7
+ * - Tool registration with Zod schema validation
8
+ * - Resource registration
9
+ * - Tool invocation with Result-based error handling
10
+ * - Automatic error translation from OutfitterError to McpError
11
+ *
12
+ * @param options - Server configuration options
13
+ * @returns Configured McpServer instance
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const server = createMcpServer({
18
+ * name: "calculator",
19
+ * version: "1.0.0",
20
+ * logger: createLogger({ name: "mcp" }),
21
+ * });
22
+ *
23
+ * server.registerTool(defineTool({
24
+ * name: "add",
25
+ * description: "Add two numbers",
26
+ * inputSchema: z.object({ a: z.number(), b: z.number() }),
27
+ * handler: async (input) => Result.ok({ sum: input.a + input.b }),
28
+ * }));
29
+ *
30
+ * const result = await server.invokeTool("add", { a: 2, b: 3 });
31
+ * if (result.isOk()) {
32
+ * console.log(result.value.sum); // 5
33
+ * }
34
+ * ```
35
+ */
36
+ declare function createMcpServer(options: McpServerOptions): McpServer;
37
+ /**
38
+ * Define a typed tool.
39
+ *
40
+ * This is a helper function that provides better type inference
41
+ * when creating tool definitions.
42
+ *
43
+ * @param definition - Tool definition object
44
+ * @returns The same tool definition with inferred types
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const echoTool = defineTool({
49
+ * name: "echo",
50
+ * description: "Echo the input message",
51
+ * inputSchema: z.object({ message: z.string() }),
52
+ * handler: async (input, ctx) => {
53
+ * ctx.logger.debug("Echoing message");
54
+ * return Result.ok({ echo: input.message });
55
+ * },
56
+ * });
57
+ * ```
58
+ */
59
+ declare function defineTool<
60
+ TInput,
61
+ TOutput,
62
+ TError extends OutfitterError = OutfitterError
63
+ >(definition: ToolDefinition<TInput, TOutput, TError>): ToolDefinition<TInput, TOutput, TError>;
64
+ /**
65
+ * Define a resource.
66
+ *
67
+ * This is a helper function for creating resource definitions
68
+ * with consistent typing.
69
+ *
70
+ * @param definition - Resource definition object
71
+ * @returns The same resource definition
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const configResource = defineResource({
76
+ * uri: "file:///etc/app/config.json",
77
+ * name: "Application Config",
78
+ * description: "Main configuration file",
79
+ * mimeType: "application/json",
80
+ * });
81
+ * ```
82
+ */
83
+ declare function defineResource(definition: ResourceDefinition): ResourceDefinition;
84
+ /**
85
+ * Define a resource template.
86
+ *
87
+ * Helper function for creating resource template definitions
88
+ * with URI pattern matching.
89
+ *
90
+ * @param definition - Resource template definition object
91
+ * @returns The same resource template definition
92
+ */
93
+ declare function defineResourceTemplate(definition: ResourceTemplateDefinition): ResourceTemplateDefinition;
94
+ /**
95
+ * Define a prompt.
96
+ *
97
+ * Helper function for creating prompt definitions
98
+ * with consistent typing.
99
+ *
100
+ * @param definition - Prompt definition object
101
+ * @returns The same prompt definition
102
+ */
103
+ declare function definePrompt(definition: PromptDefinition): PromptDefinition;
104
+ export { createMcpServer, defineTool, defineResource, defineResourceTemplate, definePrompt };