@outfitter/mcp 0.3.0 → 0.4.1

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.
@@ -0,0 +1,8 @@
1
+ import { ToolDefinition } from "./mcp-h2twz77x";
2
+ import { ActionRegistry, ActionSurface, AnyActionSpec } from "@outfitter/contracts";
3
+ interface BuildMcpToolsOptions {
4
+ readonly includeSurfaces?: readonly ActionSurface[];
5
+ }
6
+ type ActionSource = ActionRegistry | readonly AnyActionSpec[];
7
+ declare function buildMcpTools(source: ActionSource, options?: BuildMcpToolsOptions): ToolDefinition<unknown, unknown>[];
8
+ export { BuildMcpToolsOptions, buildMcpTools };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @outfitter/mcp - Logging Bridge
3
+ *
4
+ * Maps Outfitter log levels to MCP log levels for
5
+ * server-to-client log message notifications.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * MCP log levels as defined in the MCP specification.
11
+ * Ordered from least to most severe.
12
+ */
13
+ type McpLogLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
14
+ /**
15
+ * Outfitter log levels.
16
+ */
17
+ type OutfitterLogLevel = "trace" | "debug" | "info" | "warn" | "error" | "fatal";
18
+ /**
19
+ * Map an Outfitter log level to the corresponding MCP log level.
20
+ */
21
+ declare function mapLogLevelToMcp(level: OutfitterLogLevel): McpLogLevel;
22
+ /**
23
+ * Check whether a message at the given level should be emitted
24
+ * based on the client-requested threshold.
25
+ */
26
+ declare function shouldEmitLog(messageLevel: McpLogLevel, threshold: McpLogLevel): boolean;
27
+ export { McpLogLevel, mapLogLevelToMcp, shouldEmitLog };
@@ -0,0 +1,96 @@
1
+ import { ToolDefinition } from "./mcp-h2twz77x";
2
+ import { HandlerContext, OutfitterError } from "@outfitter/contracts";
3
+ import { Result } from "@outfitter/contracts";
4
+ type DocsSection = "overview" | "tools" | "examples" | "schemas";
5
+ interface DocsToolInput {
6
+ section?: DocsSection | undefined;
7
+ }
8
+ interface DocsToolEntry {
9
+ name: string;
10
+ summary?: string;
11
+ examples?: Array<{
12
+ input: Record<string, unknown>;
13
+ description?: string;
14
+ }>;
15
+ }
16
+ interface DocsToolResponse {
17
+ overview?: string;
18
+ tools?: DocsToolEntry[];
19
+ examples?: Array<{
20
+ name?: string;
21
+ description?: string;
22
+ input?: Record<string, unknown>;
23
+ output?: unknown;
24
+ }>;
25
+ schemas?: Record<string, unknown>;
26
+ }
27
+ interface DocsToolOptions {
28
+ /** Optional override for the docs tool description. */
29
+ description?: string;
30
+ /** Static docs payload (used when getDocs is not provided). */
31
+ docs?: DocsToolResponse;
32
+ /** Dynamic docs provider. */
33
+ getDocs?: (section?: DocsSection) => DocsToolResponse | Promise<DocsToolResponse>;
34
+ }
35
+ declare function defineDocsTool(options?: DocsToolOptions): ToolDefinition<DocsToolInput, DocsToolResponse>;
36
+ type ConfigAction = "get" | "set" | "list";
37
+ interface ConfigToolInput {
38
+ action: ConfigAction;
39
+ key?: string | undefined;
40
+ value?: unknown | undefined;
41
+ }
42
+ interface ConfigToolResponse {
43
+ action: ConfigAction;
44
+ key?: string;
45
+ value?: unknown;
46
+ found?: boolean;
47
+ config?: Record<string, unknown>;
48
+ }
49
+ interface ConfigStore {
50
+ get(key: string): {
51
+ value: unknown;
52
+ found: boolean;
53
+ } | Promise<{
54
+ value: unknown;
55
+ found: boolean;
56
+ }>;
57
+ set(key: string, value: unknown): void | Promise<void>;
58
+ list(): Record<string, unknown> | Promise<Record<string, unknown>>;
59
+ }
60
+ interface ConfigToolOptions {
61
+ /** Optional override for the config tool description. */
62
+ description?: string;
63
+ /** Initial config values when using the default in-memory store. */
64
+ initial?: Record<string, unknown>;
65
+ /** Custom config store implementation. */
66
+ store?: ConfigStore;
67
+ }
68
+ declare function defineConfigTool(options?: ConfigToolOptions): ToolDefinition<ConfigToolInput, ConfigToolResponse>;
69
+ interface QueryToolInput {
70
+ q?: string | undefined;
71
+ query?: string | undefined;
72
+ limit?: number | undefined;
73
+ cursor?: string | undefined;
74
+ filters?: Record<string, unknown> | undefined;
75
+ }
76
+ interface QueryToolResponse<T = unknown> {
77
+ results: T[];
78
+ nextCursor?: string;
79
+ _meta?: Record<string, unknown>;
80
+ }
81
+ interface QueryToolOptions<T = unknown> {
82
+ /** Optional override for the query tool description. */
83
+ description?: string;
84
+ /** Custom query handler implementation. */
85
+ handler?: (input: NormalizedQueryInput, ctx: HandlerContext) => Promise<Result<QueryToolResponse<T>, OutfitterError>>;
86
+ }
87
+ declare function defineQueryTool<T = unknown>(options?: QueryToolOptions<T>): ToolDefinition<QueryToolInput, QueryToolResponse<T>>;
88
+ interface CoreToolsOptions {
89
+ docs?: DocsToolOptions;
90
+ config?: ConfigToolOptions;
91
+ query?: QueryToolOptions;
92
+ }
93
+ type NormalizedQueryInput = Required<Pick<QueryToolInput, "q">> & Omit<QueryToolInput, "q">;
94
+ type CoreToolDefinition = ToolDefinition<DocsToolInput, DocsToolResponse> | ToolDefinition<ConfigToolInput, ConfigToolResponse> | ToolDefinition<QueryToolInput, QueryToolResponse>;
95
+ declare function createCoreTools(options?: CoreToolsOptions): CoreToolDefinition[];
96
+ export { DocsSection, DocsToolInput, DocsToolEntry, DocsToolResponse, DocsToolOptions, defineDocsTool, ConfigAction, ConfigToolInput, ConfigToolResponse, ConfigStore, ConfigToolOptions, defineConfigTool, QueryToolInput, QueryToolResponse, QueryToolOptions, defineQueryTool, CoreToolsOptions, NormalizedQueryInput, CoreToolDefinition, createCoreTools };
@@ -0,0 +1,36 @@
1
+ // @bun
2
+ // packages/mcp/src/logging.ts
3
+ var MCP_LEVEL_ORDER = [
4
+ "debug",
5
+ "info",
6
+ "notice",
7
+ "warning",
8
+ "error",
9
+ "critical",
10
+ "alert",
11
+ "emergency"
12
+ ];
13
+ function mapLogLevelToMcp(level) {
14
+ switch (level) {
15
+ case "trace":
16
+ case "debug":
17
+ return "debug";
18
+ case "info":
19
+ return "info";
20
+ case "warn":
21
+ return "warning";
22
+ case "error":
23
+ return "error";
24
+ case "fatal":
25
+ return "emergency";
26
+ default: {
27
+ const _exhaustiveCheck = level;
28
+ return _exhaustiveCheck;
29
+ }
30
+ }
31
+ }
32
+ function shouldEmitLog(messageLevel, threshold) {
33
+ return MCP_LEVEL_ORDER.indexOf(messageLevel) >= MCP_LEVEL_ORDER.indexOf(threshold);
34
+ }
35
+
36
+ export { mapLogLevelToMcp, shouldEmitLog };