somamcp 1.3.4 → 1.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
@@ -476,6 +476,13 @@ createServer({
476
476
  **Transport**
477
477
 
478
478
  - Types: `TransportConfig`, `HttpStreamConfig` (accepts `cors`, `stateless`, `eventStore`, `sslCert` / `sslKey` / `sslCa`, plus `port` / `host` / `endpoint` / `enableJsonResponse`)
479
+ - `streamKeepalive` on `ServerConfig` — `{ enabled, intervalMs }`, written onto an in-flight tool call's own
480
+ response stream so a proxy does not close it as idle during a long, silent call. **Pair it with
481
+ `httpStream.stateless`**: a transport-level ping needs the standing server-to-client stream that stateless
482
+ does not have, so this is the only keepalive left. It sits on `ServerConfig` rather than `HttpStreamConfig`
483
+ because the backend builds its server before `start()` sees the transport. Ignored by the edge backend.
484
+ Leave `httpStream.enableJsonResponse` **off**: in JSON-response mode the MCP SDK skips the SSE write for
485
+ request-related notifications, so the keepalive is accepted, costs an interval timer, and does nothing.
479
486
 
480
487
  **Introspection**
481
488
 
@@ -1,2 +1,2 @@
1
- import { a as BackendSession, i as BackendFactory, n as BackendAdapter, r as BackendEvents, t as createFastMCPBackend } from "../index-pl2m5zH7.js";
1
+ import { a as BackendSession, i as BackendFactory, n as BackendAdapter, r as BackendEvents, t as createFastMCPBackend } from "../index-CSy9en2A.js";
2
2
  export { type BackendAdapter, type BackendEvents, type BackendFactory, type BackendSession, createFastMCPBackend };
@@ -1 +1 @@
1
- import{t as e}from"../backend-CA7j4YCF.js";export{e as createFastMCPBackend};
1
+ import{t as e}from"../backend-Dd0n_9Ai.js";export{e as createFastMCPBackend};
@@ -0,0 +1 @@
1
+ import{FastMCP as e,ServerState as t}from"fastmcp";const n=e=>{switch(e){case t.Running:return`running`;case t.Error:return`error`;default:return`stopped`}},r=(t,r)=>{let i={...r,authenticate:t.authenticate,instructions:t.instructions,logger:t.logger,name:t.name,...t.streamKeepalive?{streamKeepalive:t.streamKeepalive}:{},version:t.version},a=new e(i);return{get serverState(){return n(a.serverState)},get sessions(){return a.sessions.map(e=>({sessionId:e.sessionId}))},addPrompt:e=>{a.addPrompt(e)},addResource:e=>{a.addResource(e)},addResourceTemplate:(...e)=>{a.addResourceTemplate(...e)},addTool:e=>{a.addTool(e)},fetch:async e=>a.getApp().fetch(e),getApp:()=>a.getApp(),on:(e,t)=>{a.on(e,t)},removePrompt:e=>a.removePrompt(e),removeResource:e=>a.removeResource(e),removeTool:e=>a.removeTool(e),start:async e=>{if(!e){await a.start();return}e.transportType===`httpStream`?await a.start({httpStream:e.httpStream,transportType:`httpStream`}):await a.start({transportType:`stdio`})},stop:()=>a.stop()}};export{r as t};
package/dist/edge.d.ts CHANGED
@@ -191,6 +191,37 @@ type ServerConfig<T extends SessionAuth = SessionAuth> = {
191
191
  instructions?: string;
192
192
  logger?: Logger;
193
193
  name: string;
194
+ /**
195
+ * Periodic writes onto an in-flight tool call's own response stream, so a proxy or load
196
+ * balancer does not close the connection as idle while a long-running tool produces no
197
+ * output — a large document read, say.
198
+ *
199
+ * This is the only keepalive that survives `httpStream.stateless`. A transport-level ping
200
+ * needs the standing server-to-client stream, and stateless has none; these travel on the
201
+ * request's own stream instead. If you set `stateless` and have anything with an idle
202
+ * timeout in front of you, you want this too.
203
+ *
204
+ * Set at construction rather than on `httpStream`, because the backend builds its server
205
+ * before `start()` ever sees the transport config.
206
+ *
207
+ * Honoured by the fastmcp backend. The edge backend ignores it — Workers and Deno Deploy
208
+ * terminate the connection themselves, so there is nothing for somamcp to keep alive.
209
+ */
210
+ streamKeepalive?: {
211
+ /** Whether to write keepalives. Opt-in. */
212
+ enabled?: boolean;
213
+ /**
214
+ * Gap between keepalives. Keep it comfortably under the shortest idle timeout on the
215
+ * path — an AWS ALB defaults to 60s. Defaults to 20s in the fastmcp backend.
216
+ */
217
+ intervalMs?: number;
218
+ /**
219
+ * Level reported on the keepalive notification. Defaults to `debug` in the fastmcp
220
+ * backend, which is usually what you want — these fire every interval, for the whole
221
+ * length of every long call.
222
+ */
223
+ logLevel?: "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning";
224
+ };
194
225
  version: `${number}.${number}.${number}`;
195
226
  };
196
227
  /**
@@ -164,6 +164,37 @@ type ServerConfig<T extends SessionAuth = SessionAuth> = {
164
164
  instructions?: string;
165
165
  logger?: Logger;
166
166
  name: string;
167
+ /**
168
+ * Periodic writes onto an in-flight tool call's own response stream, so a proxy or load
169
+ * balancer does not close the connection as idle while a long-running tool produces no
170
+ * output — a large document read, say.
171
+ *
172
+ * This is the only keepalive that survives `httpStream.stateless`. A transport-level ping
173
+ * needs the standing server-to-client stream, and stateless has none; these travel on the
174
+ * request's own stream instead. If you set `stateless` and have anything with an idle
175
+ * timeout in front of you, you want this too.
176
+ *
177
+ * Set at construction rather than on `httpStream`, because the backend builds its server
178
+ * before `start()` ever sees the transport config.
179
+ *
180
+ * Honoured by the fastmcp backend. The edge backend ignores it — Workers and Deno Deploy
181
+ * terminate the connection themselves, so there is nothing for somamcp to keep alive.
182
+ */
183
+ streamKeepalive?: {
184
+ /** Whether to write keepalives. Opt-in. */
185
+ enabled?: boolean;
186
+ /**
187
+ * Gap between keepalives. Keep it comfortably under the shortest idle timeout on the
188
+ * path — an AWS ALB defaults to 60s. Defaults to 20s in the fastmcp backend.
189
+ */
190
+ intervalMs?: number;
191
+ /**
192
+ * Level reported on the keepalive notification. Defaults to `debug` in the fastmcp
193
+ * backend, which is usually what you want — these fire every interval, for the whole
194
+ * length of every long call.
195
+ */
196
+ logLevel?: "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning";
197
+ };
167
198
  version: `${number}.${number}.${number}`;
168
199
  };
169
200
  /**
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ToolAnnotations, C as ResourceLink, D as SessionAuth, E as ServerStatus, O as TextContent, S as ResourceContent, T as SchemaParams, _ as Progress, a as BackendSession, b as PromptResult, c as ServerConfig, d as Completion, f as Content, g as InferSchemaOutput, h as ImageContent, i as BackendFactory, j as UserError, k as Tool, l as TransportConfig, m as Context, n as BackendAdapter, o as HttpStreamConfig, p as ContentResult, s as Logger, t as createFastMCPBackend, u as AudioContent, v as Prompt, w as ResourceResult, x as Resource, y as PromptArgument } from "./index-pl2m5zH7.js";
1
+ import { A as ToolAnnotations, C as ResourceLink, D as SessionAuth, E as ServerStatus, O as TextContent, S as ResourceContent, T as SchemaParams, _ as Progress, a as BackendSession, b as PromptResult, c as ServerConfig, d as Completion, f as Content, g as InferSchemaOutput, h as ImageContent, i as BackendFactory, j as UserError, k as Tool, l as TransportConfig, m as Context, n as BackendAdapter, o as HttpStreamConfig, p as ContentResult, s as Logger, t as createFastMCPBackend, u as AudioContent, v as Prompt, w as ResourceResult, x as Resource, y as PromptArgument } from "./index-CSy9en2A.js";
2
2
  import { Option } from "functype";
3
3
  import { DirectLogger, DirectLogger as DirectLogger$1 } from "functype-log";
4
4
  import { z } from "zod";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{t as e}from"./backend-CA7j4YCF.js";import{Map as t,Option as n,Ref as r,Set as i,Try as a,Tuple as o}from"functype";import{Client as s}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as c}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{appendFile as l,mkdir as u,readFile as d}from"node:fs/promises";import{dirname as f,extname as p}from"node:path";import{createDirectConsoleLogger as m}from"functype-log";import{z as h}from"zod";const g=e=>e.json({error:`Unauthorized`},401),_=({authenticate:e,onUnauthorized:t})=>{let r=t??g;return async(t,i)=>{if(!e)return r(t);let o=n(t.env).flatMap(e=>n(e.incoming)).orElse(t.req.raw);if((await a.fromPromise(e(o))).isFailure())return r(t);await i()}},v=(e,t)=>typeof e.get==`function`?n(e.get(t)):n.none(),y=(e,t,r)=>{let i=e;return n(i[t]??i[r]).map(e=>Array.isArray(e)?e[0]??``:e)},b=(e,t,r)=>v(e,t).fold(()=>y(e,t,r),e=>n(e)),x=e=>n(e).flatMap(e=>n(e.headers)),S=(e,t)=>{let n=t.toLowerCase();return x(e).flatMap(e=>b(e,n,t)).orUndefined()},C=(e,t,n)=>{t.forEach(t=>{switch(t.protected&&e.use(t.path,_({authenticate:n})),t.type){case`static`:e.get(t.path,e=>e.body(t.content,{headers:{"Content-Type":t.contentType}}));break;case`dynamic`:e.get(t.path,e=>t.handler(e))}})},w=(e,t,n)=>({handler:()=>{let r=e(),i=t(),a=n(),o=T(r,i,a);return new Response(o,{headers:{"Content-Type":`text/html; charset=utf-8`}})},path:`/dashboard`,protected:!0,type:`dynamic`}),T=(e,t,n)=>`<!DOCTYPE html>
1
+ import{t as e}from"./backend-Dd0n_9Ai.js";import{Map as t,Option as n,Ref as r,Set as i,Try as a,Tuple as o}from"functype";import{Client as s}from"@modelcontextprotocol/sdk/client/index.js";import{StreamableHTTPClientTransport as c}from"@modelcontextprotocol/sdk/client/streamableHttp.js";import{appendFile as l,mkdir as u,readFile as d}from"node:fs/promises";import{dirname as f,extname as p}from"node:path";import{createDirectConsoleLogger as m}from"functype-log";import{z as h}from"zod";const g=e=>e.json({error:`Unauthorized`},401),_=({authenticate:e,onUnauthorized:t})=>{let r=t??g;return async(t,i)=>{if(!e)return r(t);let o=n(t.env).flatMap(e=>n(e.incoming)).orElse(t.req.raw);if((await a.fromPromise(e(o))).isFailure())return r(t);await i()}},v=(e,t)=>typeof e.get==`function`?n(e.get(t)):n.none(),y=(e,t,r)=>{let i=e;return n(i[t]??i[r]).map(e=>Array.isArray(e)?e[0]??``:e)},b=(e,t,r)=>v(e,t).fold(()=>y(e,t,r),e=>n(e)),x=e=>n(e).flatMap(e=>n(e.headers)),S=(e,t)=>{let n=t.toLowerCase();return x(e).flatMap(e=>b(e,n,t)).orUndefined()},C=(e,t,n)=>{t.forEach(t=>{switch(t.protected&&e.use(t.path,_({authenticate:n})),t.type){case`static`:e.get(t.path,e=>e.body(t.content,{headers:{"Content-Type":t.contentType}}));break;case`dynamic`:e.get(t.path,e=>t.handler(e))}})},w=(e,t,n)=>({handler:()=>{let r=e(),i=t(),a=n(),o=T(r,i,a);return new Response(o,{headers:{"Content-Type":`text/html; charset=utf-8`}})},path:`/dashboard`,protected:!0,type:`dynamic`}),T=(e,t,n)=>`<!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="UTF-8">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "somamcp",
3
- "version": "1.3.4",
3
+ "version": "1.4.0",
4
4
  "description": "Framework for building MCP servers with telemetry, introspection, and backend abstraction",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1 +0,0 @@
1
- import{FastMCP as e,ServerState as t}from"fastmcp";const n=e=>{switch(e){case t.Running:return`running`;case t.Error:return`error`;default:return`stopped`}},r=(t,r)=>{let i={...r,authenticate:t.authenticate,instructions:t.instructions,logger:t.logger,name:t.name,version:t.version},a=new e(i);return{get serverState(){return n(a.serverState)},get sessions(){return a.sessions.map(e=>({sessionId:e.sessionId}))},addPrompt:e=>{a.addPrompt(e)},addResource:e=>{a.addResource(e)},addResourceTemplate:(...e)=>{a.addResourceTemplate(...e)},addTool:e=>{a.addTool(e)},fetch:async e=>a.getApp().fetch(e),getApp:()=>a.getApp(),on:(e,t)=>{a.on(e,t)},removePrompt:e=>a.removePrompt(e),removeResource:e=>a.removeResource(e),removeTool:e=>a.removeTool(e),start:async e=>{if(!e){await a.start();return}e.transportType===`httpStream`?await a.start({httpStream:e.httpStream,transportType:`httpStream`}):await a.start({transportType:`stdio`})},stop:()=>a.stop()}};export{r as t};