@casys/mcp-server 0.18.0 → 0.20.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.
@@ -27,6 +27,31 @@ export type EnvFn = (key: string) => string | undefined;
27
27
  */
28
28
  export type ReadTextFileFn = (path: string) => Promise<string | null>;
29
29
 
30
+ /** Write a UTF-8 text file. */
31
+ export type WriteTextFileFn = (
32
+ path: string,
33
+ content: string,
34
+ opts?: { mode?: number },
35
+ ) => Promise<void>;
36
+
37
+ /** Create a directory. */
38
+ export type MkdirFn = (
39
+ path: string,
40
+ opts?: { recursive?: boolean; mode?: number },
41
+ ) => Promise<void>;
42
+
43
+ /**
44
+ * Remove a file or empty directory.
45
+ * Does nothing if the path does not exist.
46
+ */
47
+ export type RemoveFn = (path: string) => Promise<void>;
48
+
49
+ /**
50
+ * Read directory entry names.
51
+ * Returns [] if the directory does not exist.
52
+ */
53
+ export type ReadDirFn = (path: string) => Promise<string[]>;
54
+
30
55
  // ─── HTTP Server ─────────────────────────────────────────
31
56
 
32
57
  /** Fetch-style request handler (Web standard) */
@@ -37,6 +62,8 @@ export interface ServeOptions {
37
62
  port: number;
38
63
  hostname?: string;
39
64
  onListen?: (info: { hostname: string; port: number }) => void;
65
+ /** Optional bind/startup error channel. */
66
+ onError?: (err: Error) => void;
40
67
  /** Maximum request body size in bytes (optional, adapter-specific). */
41
68
  maxBodyBytes?: number | null;
42
69
  }
@@ -79,12 +106,25 @@ export type UnrefTimerFn = (id: number) => void;
79
106
  * @example
80
107
  * ```typescript
81
108
  * // At the bottom of runtime.ts / runtime.node.ts:
82
- * export const _port = { env, readTextFile, serve, unrefTimer } satisfies RuntimePort;
109
+ * export const _port = {
110
+ * env,
111
+ * readTextFile,
112
+ * writeTextFile,
113
+ * mkdir,
114
+ * remove,
115
+ * readDir,
116
+ * serve,
117
+ * unrefTimer,
118
+ * } satisfies RuntimePort;
83
119
  * ```
84
120
  */
85
121
  export interface RuntimePort {
86
122
  env: EnvFn;
87
123
  readTextFile: ReadTextFileFn;
124
+ writeTextFile: WriteTextFileFn;
125
+ mkdir: MkdirFn;
126
+ remove: RemoveFn;
127
+ readDir: ReadDirFn;
88
128
  serve: ServeFn;
89
129
  unrefTimer: UnrefTimerFn;
90
130
  }
@@ -24,6 +24,8 @@ import type {
24
24
  * - Promise-based async/await API
25
25
  * - Support for both Anthropic and OpenAI sampling
26
26
  *
27
+ * @deprecated Deprecated (MCP 2026-07-28). Removal after 2027-07-28. Prefer the explicit handle-based pattern.
28
+ *
27
29
  * @example
28
30
  * ```typescript
29
31
  * const bridge = new SamplingBridge(samplingClient);
package/src/types.ts CHANGED
@@ -75,7 +75,10 @@ export interface McpAppOptions {
75
75
  */
76
76
  validateSchema?: boolean;
77
77
 
78
- /** Enable sampling support for agentic tools (default: false) */
78
+ /**
79
+ * Enable sampling support for agentic tools (default: false)
80
+ * @deprecated Deprecated (MCP 2026-07-28). Removal after 2027-07-28. Prefer the explicit handle-based pattern.
81
+ */
79
82
  enableSampling?: boolean;
80
83
 
81
84
  /**
@@ -84,7 +87,10 @@ export interface McpAppOptions {
84
87
  */
85
88
  instructions?: string;
86
89
 
87
- /** Sampling client implementation (required if enableSampling is true) */
90
+ /**
91
+ * Sampling client implementation (required if enableSampling is true)
92
+ * @deprecated Deprecated (MCP 2026-07-28). Removal after 2027-07-28. Prefer the explicit handle-based pattern.
93
+ */
88
94
  samplingClient?: SamplingClient;
89
95
 
90
96
  /** Custom logger function (default: console.error) */
@@ -132,6 +138,22 @@ export interface McpAppOptions {
132
138
  * that discovers child servers after the stdio handshake).
133
139
  */
134
140
  expectResources?: boolean;
141
+
142
+ /**
143
+ * HTTP transport mode (Track A — spec 2026-07-28).
144
+ *
145
+ * - `"stateful"` (DEFAULT): legacy session-based transport, retro-compatible
146
+ * with spec 2025-06-18. Requires an `initialize` handshake before any
147
+ * other method; emits and validates `Mcp-Session-Id` headers.
148
+ * - `"stateless"`: per-request transport, spec 2026-07-28. No handshake, no
149
+ * `Mcp-Session-Id`. `protocolVersion` is read from
150
+ * `params._meta["io.modelcontextprotocol/protocolVersion"]` on every
151
+ * request. `GET /mcp` returns 405 (Track B will replace the SSE channel).
152
+ *
153
+ * Default: `"stateful"`.
154
+ */
155
+ // Track A — transport mode, défaut "stateful"
156
+ transport?: "stateful" | "stateless";
135
157
  }
136
158
 
137
159
  // ============================================
@@ -481,6 +503,8 @@ export type ToolErrorMapper = (
481
503
  /**
482
504
  * Sampling client interface for bidirectional LLM delegation
483
505
  * Compatible with the agentic sampling protocol (SEP-1577)
506
+ *
507
+ * @deprecated Deprecated (MCP 2026-07-28). Removal after 2027-07-28. Prefer the explicit handle-based pattern.
484
508
  */
485
509
  export interface SamplingClient {
486
510
  /**
@@ -494,6 +518,8 @@ export interface SamplingClient {
494
518
  /**
495
519
  * Parameters for sampling request
496
520
  * Compatible with MCP sampling protocol
521
+ *
522
+ * @deprecated Deprecated (MCP 2026-07-28). Removal after 2027-07-28. Prefer the explicit handle-based pattern.
497
523
  */
498
524
  export interface SamplingParams {
499
525
  messages: Array<{ role: "user" | "assistant"; content: string }>;
@@ -515,6 +541,8 @@ export interface SamplingParams {
515
541
  /**
516
542
  * Result from sampling request
517
543
  * Compatible with MCP sampling protocol
544
+ *
545
+ * @deprecated Deprecated (MCP 2026-07-28). Removal after 2027-07-28. Prefer the explicit handle-based pattern.
518
546
  */
519
547
  export interface SamplingResult {
520
548
  content: Array<{