@lunora/mcp 1.0.0-alpha.107 → 1.0.0-alpha.109

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.
@@ -1,4 +1,4 @@
1
- import { M as McpResourceProvider, a as McpFetchHandler, T as ToolDefinition, b as McpTool } from "../packem_shared/serve-stateless.d-C_y-E_zk.mjs";
1
+ import { M as McpResourceProvider, a as McpFetchHandler, T as ToolDefinition, b as McpTool } from "../packem_shared/serve-stateless.d-CKsbI0fP.mjs";
2
2
  export type {
3
3
  /**
4
4
  * `@lunora/mcp/docs` — the documentation tool surface: `lunora_search_docs`,
@@ -49,7 +49,7 @@ c as McpResourceSummary,
49
49
  * (`createToolServer`) is exported from the package root, so a consumer using
50
50
  * both entries gets one implementation rather than two copies.
51
51
  */
52
- d as McpServerInfo, e as ToolInputSchema, f as ToolResult } from "../packem_shared/serve-stateless.d-C_y-E_zk.mjs";
52
+ d as McpServerInfo, e as ToolInputSchema, f as ToolResult } from "../packem_shared/serve-stateless.d-CKsbI0fP.mjs";
53
53
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
54
54
  import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
55
55
  /**
@@ -135,7 +135,12 @@ declare const DOCS_SERVER_NAME = "lunora-docs";
135
135
  interface DocsMcpServerOptions {
136
136
  /** The documentation source the tools read. */
137
137
  index: DocsIndex;
138
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES`, re-exported at the foot of this module. */
138
+ /**
139
+ * Largest accepted request body, in bytes — enforced while the body streams
140
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
141
+ * (re-exported at the foot of this module), which a value that is not a
142
+ * non-negative safe integer also falls back to.
143
+ */
139
144
  maxRequestBytes?: number;
140
145
  /**
141
146
  * Version reported in the handshake. Defaults to `"0.0.0"` — a docs site
@@ -1,4 +1,4 @@
1
- import { M as McpResourceProvider, a as McpFetchHandler, T as ToolDefinition, b as McpTool } from "../packem_shared/serve-stateless.d-C_y-E_zk.js";
1
+ import { M as McpResourceProvider, a as McpFetchHandler, T as ToolDefinition, b as McpTool } from "../packem_shared/serve-stateless.d-CKsbI0fP.js";
2
2
  export type {
3
3
  /**
4
4
  * `@lunora/mcp/docs` — the documentation tool surface: `lunora_search_docs`,
@@ -49,7 +49,7 @@ c as McpResourceSummary,
49
49
  * (`createToolServer`) is exported from the package root, so a consumer using
50
50
  * both entries gets one implementation rather than two copies.
51
51
  */
52
- d as McpServerInfo, e as ToolInputSchema, f as ToolResult } from "../packem_shared/serve-stateless.d-C_y-E_zk.js";
52
+ d as McpServerInfo, e as ToolInputSchema, f as ToolResult } from "../packem_shared/serve-stateless.d-CKsbI0fP.js";
53
53
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
54
54
  import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
55
55
  /**
@@ -135,7 +135,12 @@ declare const DOCS_SERVER_NAME = "lunora-docs";
135
135
  interface DocsMcpServerOptions {
136
136
  /** The documentation source the tools read. */
137
137
  index: DocsIndex;
138
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES`, re-exported at the foot of this module. */
138
+ /**
139
+ * Largest accepted request body, in bytes — enforced while the body streams
140
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
141
+ * (re-exported at the foot of this module), which a value that is not a
142
+ * non-negative safe integer also falls back to.
143
+ */
139
144
  maxRequestBytes?: number;
140
145
  /**
141
146
  * Version reported in the handshake. Defaults to `"0.0.0"` — a docs site
@@ -1 +1 @@
1
- import{toDocsSearchHits as e}from"../packem_shared/toDocsSearchHits-CBLmtWXt.mjs";import{DEFAULT_DOCS_BASE_URL as D,createRemoteDocsIndex as t}from"../packem_shared/DEFAULT_DOCS_BASE_URL-CZ3fVsSc.mjs";import{DOCS_URI_SCHEME as s,docsResources as S,fromDocsUri as E,toDocsUri as I}from"../packem_shared/DOCS_URI_SCHEME-CFANc3vr.mjs";import{DOCS_SERVER_NAME as R,createDocsMcpFetchHandler as p,createDocsMcpServer as A}from"../packem_shared/DOCS_SERVER_NAME-DmmgZtad.mjs";import{DEFAULT_SEARCH_LIMIT as M,DOCS_TOOL_DEFINITIONS as O,MAX_SEARCH_LIMIT as T,docsTools as U,normalizeDocUrl as a}from"../packem_shared/DEFAULT_SEARCH_LIMIT-BqSYN5vr.mjs";export{D as DEFAULT_DOCS_BASE_URL,M as DEFAULT_SEARCH_LIMIT,R as DOCS_SERVER_NAME,O as DOCS_TOOL_DEFINITIONS,s as DOCS_URI_SCHEME,T as MAX_SEARCH_LIMIT,p as createDocsMcpFetchHandler,A as createDocsMcpServer,t as createRemoteDocsIndex,S as docsResources,U as docsTools,E as fromDocsUri,a as normalizeDocUrl,e as toDocsSearchHits,I as toDocsUri};
1
+ import{toDocsSearchHits as e}from"../packem_shared/toDocsSearchHits-CBLmtWXt.mjs";import{DEFAULT_DOCS_BASE_URL as D,createRemoteDocsIndex as t}from"../packem_shared/DEFAULT_DOCS_BASE_URL-CZ3fVsSc.mjs";import{DOCS_URI_SCHEME as s,docsResources as S,fromDocsUri as E,toDocsUri as I}from"../packem_shared/DOCS_URI_SCHEME-CFANc3vr.mjs";import{DOCS_SERVER_NAME as R,createDocsMcpFetchHandler as p,createDocsMcpServer as A}from"../packem_shared/DOCS_SERVER_NAME-GSrAnODG.mjs";import{DEFAULT_SEARCH_LIMIT as M,DOCS_TOOL_DEFINITIONS as O,MAX_SEARCH_LIMIT as T,docsTools as U,normalizeDocUrl as a}from"../packem_shared/DEFAULT_SEARCH_LIMIT-BqSYN5vr.mjs";export{D as DEFAULT_DOCS_BASE_URL,M as DEFAULT_SEARCH_LIMIT,R as DOCS_SERVER_NAME,O as DOCS_TOOL_DEFINITIONS,s as DOCS_URI_SCHEME,T as MAX_SEARCH_LIMIT,p as createDocsMcpFetchHandler,A as createDocsMcpServer,t as createRemoteDocsIndex,S as docsResources,U as docsTools,E as fromDocsUri,a as normalizeDocUrl,e as toDocsSearchHits,I as toDocsUri};
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LunoraClient } from '@lunora/client';
2
- import { T as ToolDefinition, f as ToolResult, e as ToolInputSchema, a as McpFetchHandler, b as McpTool } from "./packem_shared/serve-stateless.d-C_y-E_zk.mjs";
3
- export { D as DEFAULT_MAX_REQUEST_BYTES, type d as McpServerInfo, type S as ServeStatelessOptions, g as createToolServer, s as serveStateless } from "./packem_shared/serve-stateless.d-C_y-E_zk.mjs";
2
+ import { T as ToolDefinition, f as ToolResult, e as ToolInputSchema, a as McpFetchHandler, b as McpTool } from "./packem_shared/serve-stateless.d-CKsbI0fP.mjs";
3
+ export { D as DEFAULT_MAX_REQUEST_BYTES, type d as McpServerInfo, type S as ServeStatelessOptions, g as createToolServer, s as serveStateless } from "./packem_shared/serve-stateless.d-CKsbI0fP.mjs";
4
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
5
  import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
6
  import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
@@ -215,7 +215,12 @@ type McpAuthProtect = (handler: (request: Request, claims: McpAccessTokenClaims)
215
215
  /** Server options, or a function deriving them from the request's verified claims. */
216
216
  type AuthedMcpServerOptions = ((claims: McpAccessTokenClaims) => LunoraMcpServerOptions | Promise<LunoraMcpServerOptions>) | LunoraMcpServerOptions;
217
217
  interface AuthedMcpFetchHandlerOptions {
218
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES` (128 KiB). */
218
+ /**
219
+ * Largest accepted request body, in bytes — enforced while the body streams
220
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
221
+ * (128 KiB), which a value that is not a non-negative safe integer also
222
+ * falls back to.
223
+ */
219
224
  maxRequestBytes?: number;
220
225
  /**
221
226
  * The OAuth gate to mount the MCP server behind. Pass
@@ -259,7 +264,12 @@ declare const mcpTokenScopes: (claims: McpAccessTokenClaims) => ReadonlySet<stri
259
264
  declare const createAuthedMcpFetchHandler: (options: AuthedMcpFetchHandlerOptions) => McpFetchHandler;
260
265
  /** {@link createMcpFetchHandler} options: the server's, plus this transport's body limit. */
261
266
  interface McpFetchHandlerOptions extends LunoraMcpServerOptions {
262
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES` (128 KiB). */
267
+ /**
268
+ * Largest accepted request body, in bytes — enforced while the body streams
269
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
270
+ * (128 KiB), which a value that is not a non-negative safe integer also
271
+ * falls back to.
272
+ */
263
273
  maxRequestBytes?: number;
264
274
  }
265
275
  /**
@@ -395,7 +405,12 @@ type PaidMcpChargeConfig = X402ChargeSettings;
395
405
  interface PaidMcpServerConfig {
396
406
  /** The worker-level x402 charge config; each paid tool supplies only its own `price`. */
397
407
  charge: PaidMcpChargeConfig;
398
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES` (128 KiB). */
408
+ /**
409
+ * Largest accepted request body, in bytes — enforced while the body streams
410
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
411
+ * (128 KiB), which a value that is not a non-negative safe integer also
412
+ * falls back to.
413
+ */
399
414
  maxRequestBytes?: number;
400
415
  /** Name/version advertised in the MCP `initialize` handshake. Defaults to `lunora-paid-mcp`. */
401
416
  serverInfo?: {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { LunoraClient } from '@lunora/client';
2
- import { T as ToolDefinition, f as ToolResult, e as ToolInputSchema, a as McpFetchHandler, b as McpTool } from "./packem_shared/serve-stateless.d-C_y-E_zk.js";
3
- export { D as DEFAULT_MAX_REQUEST_BYTES, type d as McpServerInfo, type S as ServeStatelessOptions, g as createToolServer, s as serveStateless } from "./packem_shared/serve-stateless.d-C_y-E_zk.js";
2
+ import { T as ToolDefinition, f as ToolResult, e as ToolInputSchema, a as McpFetchHandler, b as McpTool } from "./packem_shared/serve-stateless.d-CKsbI0fP.js";
3
+ export { D as DEFAULT_MAX_REQUEST_BYTES, type d as McpServerInfo, type S as ServeStatelessOptions, g as createToolServer, s as serveStateless } from "./packem_shared/serve-stateless.d-CKsbI0fP.js";
4
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
5
  import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
6
  import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
@@ -215,7 +215,12 @@ type McpAuthProtect = (handler: (request: Request, claims: McpAccessTokenClaims)
215
215
  /** Server options, or a function deriving them from the request's verified claims. */
216
216
  type AuthedMcpServerOptions = ((claims: McpAccessTokenClaims) => LunoraMcpServerOptions | Promise<LunoraMcpServerOptions>) | LunoraMcpServerOptions;
217
217
  interface AuthedMcpFetchHandlerOptions {
218
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES` (128 KiB). */
218
+ /**
219
+ * Largest accepted request body, in bytes — enforced while the body streams
220
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
221
+ * (128 KiB), which a value that is not a non-negative safe integer also
222
+ * falls back to.
223
+ */
219
224
  maxRequestBytes?: number;
220
225
  /**
221
226
  * The OAuth gate to mount the MCP server behind. Pass
@@ -259,7 +264,12 @@ declare const mcpTokenScopes: (claims: McpAccessTokenClaims) => ReadonlySet<stri
259
264
  declare const createAuthedMcpFetchHandler: (options: AuthedMcpFetchHandlerOptions) => McpFetchHandler;
260
265
  /** {@link createMcpFetchHandler} options: the server's, plus this transport's body limit. */
261
266
  interface McpFetchHandlerOptions extends LunoraMcpServerOptions {
262
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES` (128 KiB). */
267
+ /**
268
+ * Largest accepted request body, in bytes — enforced while the body streams
269
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
270
+ * (128 KiB), which a value that is not a non-negative safe integer also
271
+ * falls back to.
272
+ */
263
273
  maxRequestBytes?: number;
264
274
  }
265
275
  /**
@@ -395,7 +405,12 @@ type PaidMcpChargeConfig = X402ChargeSettings;
395
405
  interface PaidMcpServerConfig {
396
406
  /** The worker-level x402 charge config; each paid tool supplies only its own `price`. */
397
407
  charge: PaidMcpChargeConfig;
398
- /** Largest accepted request body, in bytes. Defaults to `DEFAULT_MAX_REQUEST_BYTES` (128 KiB). */
408
+ /**
409
+ * Largest accepted request body, in bytes — enforced while the body streams
410
+ * in, not after it is buffered. Defaults to `DEFAULT_MAX_REQUEST_BYTES`
411
+ * (128 KiB), which a value that is not a non-negative safe integer also
412
+ * falls back to.
413
+ */
399
414
  maxRequestBytes?: number;
400
415
  /** Name/version advertised in the MCP `initialize` handshake. Defaults to `lunora-paid-mcp`. */
401
416
  serverInfo?: {
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{AGENT_RUN_INPUT_SCHEMA as r,AGENT_STATUS_TOOL_NAME as t,agentToolDefinitions as c,callAgentTool as T,parseAgentsEnv as E}from"./packem_shared/AGENT_RUN_INPUT_SCHEMA-hKbpa3Dg.mjs";import{createAuthedMcpFetchHandler as _,mcpTokenScopes as a}from"./packem_shared/createAuthedMcpFetchHandler-CmVUae-x.mjs";import{createToolServer as l}from"./packem_shared/createToolServer-BtGuPyMU.mjs";import{createMcpFetchHandler as n}from"./packem_shared/createMcpFetchHandler-BJKPn555.mjs";import{LOCAL_SERVER_NAME as N,NO_DEPLOYMENT_MESSAGE as I,connectLocalStdio as L,createLocalMcpServer as f,localTools as m}from"./packem_shared/LOCAL_SERVER_NAME-Do7MU6Kd.mjs";import{createPaidMcpServer as s}from"./packem_shared/createPaidMcpServer-CQrzMUhI.mjs";import{connectStdio as i,createLunoraMcpServer as D}from"./packem_shared/connectStdio-BBtfW4UB.mjs";import{READ_ONLY_TOOL_DEFINITIONS as d,WRITE_TOOL_DEFINITIONS as v,callTool as F,toolDefinitions as U}from"./packem_shared/READ_ONLY_TOOL_DEFINITIONS-_aG40yWx.mjs";import{DEFAULT_MAX_REQUEST_BYTES as g,serveStateless as h}from"./packem_shared/DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";import{O as G}from"./packem_shared/observability-tools-B-g9Y9IT.mjs";export{r as AGENT_RUN_INPUT_SCHEMA,t as AGENT_STATUS_TOOL_NAME,g as DEFAULT_MAX_REQUEST_BYTES,N as LOCAL_SERVER_NAME,I as NO_DEPLOYMENT_MESSAGE,G as OBSERVABILITY_TOOL_DEFINITIONS,d as READ_ONLY_TOOL_DEFINITIONS,v as WRITE_TOOL_DEFINITIONS,c as agentToolDefinitions,T as callAgentTool,F as callTool,L as connectLocalStdio,i as connectStdio,_ as createAuthedMcpFetchHandler,f as createLocalMcpServer,D as createLunoraMcpServer,n as createMcpFetchHandler,s as createPaidMcpServer,l as createToolServer,m as localTools,a as mcpTokenScopes,E as parseAgentsEnv,h as serveStateless,U as toolDefinitions};
1
+ import{AGENT_RUN_INPUT_SCHEMA as r,AGENT_STATUS_TOOL_NAME as t,agentToolDefinitions as c,callAgentTool as T,parseAgentsEnv as E}from"./packem_shared/AGENT_RUN_INPUT_SCHEMA-hKbpa3Dg.mjs";import{createAuthedMcpFetchHandler as _,mcpTokenScopes as a}from"./packem_shared/createAuthedMcpFetchHandler-DwOzAueC.mjs";import{createToolServer as l}from"./packem_shared/createToolServer-BtGuPyMU.mjs";import{createMcpFetchHandler as n}from"./packem_shared/createMcpFetchHandler-DSK2X9Hd.mjs";import{LOCAL_SERVER_NAME as N,NO_DEPLOYMENT_MESSAGE as I,connectLocalStdio as L,createLocalMcpServer as f,localTools as m}from"./packem_shared/LOCAL_SERVER_NAME-Do7MU6Kd.mjs";import{createPaidMcpServer as s}from"./packem_shared/createPaidMcpServer-BIBKMtxs.mjs";import{connectStdio as i,createLunoraMcpServer as D}from"./packem_shared/connectStdio-BBtfW4UB.mjs";import{READ_ONLY_TOOL_DEFINITIONS as d,WRITE_TOOL_DEFINITIONS as v,callTool as F,toolDefinitions as U}from"./packem_shared/READ_ONLY_TOOL_DEFINITIONS-_aG40yWx.mjs";import{DEFAULT_MAX_REQUEST_BYTES as g,serveStateless as h}from"./packem_shared/DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{O as G}from"./packem_shared/observability-tools-B-g9Y9IT.mjs";export{r as AGENT_RUN_INPUT_SCHEMA,t as AGENT_STATUS_TOOL_NAME,g as DEFAULT_MAX_REQUEST_BYTES,N as LOCAL_SERVER_NAME,I as NO_DEPLOYMENT_MESSAGE,G as OBSERVABILITY_TOOL_DEFINITIONS,d as READ_ONLY_TOOL_DEFINITIONS,v as WRITE_TOOL_DEFINITIONS,c as agentToolDefinitions,T as callAgentTool,F as callTool,L as connectLocalStdio,i as connectStdio,_ as createAuthedMcpFetchHandler,f as createLocalMcpServer,D as createLunoraMcpServer,n as createMcpFetchHandler,s as createPaidMcpServer,l as createToolServer,m as localTools,a as mcpTokenScopes,E as parseAgentsEnv,h as serveStateless,U as toolDefinitions};
@@ -0,0 +1 @@
1
+ import{WebStandardStreamableHTTPServerTransport as y}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";const u=128*1024,p=e=>e!==void 0&&Number.isSafeInteger(e)&&e>=0?e:u,l=async(e,t)=>{if(!e.body)return"";const r=e.body.getReader(),s=new TextDecoder;let n=0,o="";for(;;){const{done:i,value:a}=await r.read();if(i)break;if(a){if(n+=a.byteLength,n>t){r.cancel().catch(()=>{});return}o+=s.decode(a,{stream:!0})}}return o+s.decode()},d=(e,t,r)=>Response.json({error:{code:t,message:r},id:null,jsonrpc:"2.0"},{status:e}),c=()=>d(400,-32600,"batched requests are not supported: send one JSON-RPC message per request"),f=async(e,t)=>{if(e.method!=="POST")return{parsedBody:void 0};const r=p(t),s={response:d(413,-32600,`request body exceeds ${String(r)} bytes`)},n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>r)return s;const o=await l(e,r);if(o===void 0)return s;try{return{parsedBody:JSON.parse(o)}}catch{return{response:d(400,-32700,"parse error: body is not valid JSON")}}},b=async(e,t)=>{if(e.method!=="POST")return{parsedBody:t?.parsedBody};if(t?.parsedBody!==void 0)return Array.isArray(t.parsedBody)?{response:c()}:{parsedBody:t.parsedBody};const r=await f(e,t?.maxRequestBytes);return"response"in r?r:Array.isArray(r.parsedBody)?{response:c()}:r},B=async(e,t,r)=>{const s=await b(t,r);if("response"in s)return s.response;const n=new y({enableJsonResponse:!0,sessionIdGenerator:void 0});try{return await e.connect(n),await n.handleRequest(t,{authInfo:r?.authInfo,parsedBody:s.parsedBody})}finally{n.close().catch(()=>{}),e.close().catch(()=>{})}};export{u as DEFAULT_MAX_REQUEST_BYTES,f as readScreenedBody,B as serveStateless};
@@ -1 +1 @@
1
- import{createToolServer as o}from"./createToolServer-BtGuPyMU.mjs";import{serveStateless as s}from"./DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";import{DEFAULT_MAX_REQUEST_BYTES as i}from"./DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";import{docsResources as t}from"./DOCS_URI_SCHEME-CFANc3vr.mjs";import{docsTools as c}from"./DEFAULT_SEARCH_LIMIT-BqSYN5vr.mjs";const m="lunora-docs",n=e=>({name:m,version:e??"0.0.0"}),a=e=>o(n(e.version),c(e.index),t(e.index)),v=e=>r=>s(a(e),r,{maxRequestBytes:e.maxRequestBytes});export{i as DEFAULT_MAX_REQUEST_BYTES,m as DOCS_SERVER_NAME,v as createDocsMcpFetchHandler,a as createDocsMcpServer};
1
+ import{createToolServer as o}from"./createToolServer-BtGuPyMU.mjs";import{serveStateless as s}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{DEFAULT_MAX_REQUEST_BYTES as i}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{docsResources as t}from"./DOCS_URI_SCHEME-CFANc3vr.mjs";import{docsTools as c}from"./DEFAULT_SEARCH_LIMIT-BqSYN5vr.mjs";const m="lunora-docs",n=e=>({name:m,version:e??"0.0.0"}),a=e=>o(n(e.version),c(e.index),t(e.index)),v=e=>r=>s(a(e),r,{maxRequestBytes:e.maxRequestBytes});export{i as DEFAULT_MAX_REQUEST_BYTES,m as DOCS_SERVER_NAME,v as createDocsMcpFetchHandler,a as createDocsMcpServer};
@@ -1 +1 @@
1
- import{serveStateless as n}from"./DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";import{resolveClient as a,createLunoraMcpServer as o}from"./connectStdio-BBtfW4UB.mjs";const f=e=>typeof e.scope!="string"?new Set:new Set(e.scope.split(" ").filter(r=>r!=="")),l=e=>{const r=typeof e.server=="function"?void 0:a(e.server);return e.protect(async(t,s)=>{const c=typeof e.server=="function"?await e.server(s):{...e.server,client:r};return await n(o(c),t,{maxRequestBytes:e.maxRequestBytes})})};export{l as createAuthedMcpFetchHandler,f as mcpTokenScopes};
1
+ import{serveStateless as n}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{resolveClient as a,createLunoraMcpServer as o}from"./connectStdio-BBtfW4UB.mjs";const f=e=>typeof e.scope!="string"?new Set:new Set(e.scope.split(" ").filter(r=>r!=="")),l=e=>{const r=typeof e.server=="function"?void 0:a(e.server);return e.protect(async(t,s)=>{const c=typeof e.server=="function"?await e.server(s):{...e.server,client:r};return await n(o(c),t,{maxRequestBytes:e.maxRequestBytes})})};export{l as createAuthedMcpFetchHandler,f as mcpTokenScopes};
@@ -1 +1 @@
1
- import{serveStateless as c}from"./DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";import{DEFAULT_MAX_REQUEST_BYTES as u}from"./DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";import{resolveClient as s,createLunoraMcpServer as a}from"./connectStdio-BBtfW4UB.mjs";const l=e=>{const r=s(e);return t=>c(a({...e,client:r}),t,{maxRequestBytes:e.maxRequestBytes})};export{u as DEFAULT_MAX_REQUEST_BYTES,l as createMcpFetchHandler,c as serveStateless};
1
+ import{serveStateless as c}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{DEFAULT_MAX_REQUEST_BYTES as u}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{resolveClient as s,createLunoraMcpServer as a}from"./connectStdio-BBtfW4UB.mjs";const l=e=>{const r=s(e);return t=>c(a({...e,client:r}),t,{maxRequestBytes:e.maxRequestBytes})};export{u as DEFAULT_MAX_REQUEST_BYTES,l as createMcpFetchHandler,c as serveStateless};
@@ -1 +1 @@
1
- import{LunoraError as y}from"@lunora/errors";import{Server as g}from"@modelcontextprotocol/sdk/server/index.js";import{ListToolsRequestSchema as E,CallToolRequestSchema as x}from"@modelcontextprotocol/sdk/types.js";import{readScreenedBody as T,serveStateless as B}from"./DEFAULT_MAX_REQUEST_BYTES-B8WntTxM.mjs";const M=(t,o,a,c)=>{const l=t.get(o);if(l!==void 0)return l;const i=a().catch(u=>{throw t.get(o)===i&&t.delete(o),u});return t.set(o,i),i},C=async()=>{try{return(await import("@lunora/x402/charge")).createChargeMiddleware}catch(t){throw new y("INTERNAL",`paid MCP tools need the optional peer "@lunora/x402" — install it alongside @lunora/mcp to charge for tools (${t instanceof Error?t.message:String(t)})`)}},A={name:"lunora-paid-mcp",version:"0.0.0"},L="tools/call",v=t=>{if(typeof t!="object"||t===null)return;const{method:o,params:a}=t;if(o!==L||typeof a!="object"||a===null)return;const{name:c}=a;return typeof c=="string"?c:void 0},q=()=>Response.json({error:"A JSON-RPC batch may not reference a paid MCP tool; send paid tools/call requests individually."},{status:400}),I=t=>{const o=new Map,a=new Map,c=new Map,l=t.serverInfo??A,i=(e,r,s)=>{if(o.has(e.name))throw new y("BAD_REQUEST",`MCP tool "${e.name}" is already registered.`);const n={description:e.description,inputSchema:e.inputSchema,name:e.name};e.annotations!==void 0&&(n.annotations=e.annotations),o.set(e.name,{definition:n,handler:r}),s!==void 0&&a.set(e.name,s)},u=()=>{const e=new g(l,{capabilities:{tools:{}}});return e.setRequestHandler(E,()=>({tools:[...o.values()].map(r=>r.definition)})),e.setRequestHandler(x,async r=>{const s=o.get(r.params.name);if(s===void 0)return{content:[{text:`unknown tool: ${r.params.name}`,type:"text"}],isError:!0};try{return await s.handler(r.params.arguments??{})}catch(n){return{content:[{text:n instanceof Error?n.message:String(n),type:"text"}],isError:!0}}}),e},w=(e,r)=>M(c,e,async()=>(await C())({...t.charge,price:r},{resource:e}));return{fetchHandler:async(e,r,s)=>{const n=await T(e.clone(),t.maxRequestBytes);if("response"in n)return n.response;const{parsedBody:d}=n,p=()=>B(u(),e,d===void 0?{maxRequestBytes:t.maxRequestBytes}:{maxRequestBytes:t.maxRequestBytes,parsedBody:d});if(Array.isArray(d))return d.some(f=>a.has(v(f)??""))?q():p();const m=v(d),h=m===void 0?void 0:a.get(m);if(m===void 0||h===void 0)return p();const R=await w(m,h),S=typeof s?.waitUntil=="function"?{waitUntil:f=>{s.waitUntil?.(f)}}:void 0;return R.handle(e,p,S)},paidTool:(e,r)=>{i(e,r,e.price)},tool:(e,r)=>{i(e,r)}}};export{I as createPaidMcpServer};
1
+ import{LunoraError as y}from"@lunora/errors";import{Server as g}from"@modelcontextprotocol/sdk/server/index.js";import{ListToolsRequestSchema as E,CallToolRequestSchema as x}from"@modelcontextprotocol/sdk/types.js";import{readScreenedBody as T,serveStateless as B}from"./DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";const M=(t,o,a,c)=>{const l=t.get(o);if(l!==void 0)return l;const i=a().catch(u=>{throw t.get(o)===i&&t.delete(o),u});return t.set(o,i),i},C=async()=>{try{return(await import("@lunora/x402/charge")).createChargeMiddleware}catch(t){throw new y("INTERNAL",`paid MCP tools need the optional peer "@lunora/x402" — install it alongside @lunora/mcp to charge for tools (${t instanceof Error?t.message:String(t)})`)}},A={name:"lunora-paid-mcp",version:"0.0.0"},L="tools/call",v=t=>{if(typeof t!="object"||t===null)return;const{method:o,params:a}=t;if(o!==L||typeof a!="object"||a===null)return;const{name:c}=a;return typeof c=="string"?c:void 0},q=()=>Response.json({error:"A JSON-RPC batch may not reference a paid MCP tool; send paid tools/call requests individually."},{status:400}),I=t=>{const o=new Map,a=new Map,c=new Map,l=t.serverInfo??A,i=(e,r,s)=>{if(o.has(e.name))throw new y("BAD_REQUEST",`MCP tool "${e.name}" is already registered.`);const n={description:e.description,inputSchema:e.inputSchema,name:e.name};e.annotations!==void 0&&(n.annotations=e.annotations),o.set(e.name,{definition:n,handler:r}),s!==void 0&&a.set(e.name,s)},u=()=>{const e=new g(l,{capabilities:{tools:{}}});return e.setRequestHandler(E,()=>({tools:[...o.values()].map(r=>r.definition)})),e.setRequestHandler(x,async r=>{const s=o.get(r.params.name);if(s===void 0)return{content:[{text:`unknown tool: ${r.params.name}`,type:"text"}],isError:!0};try{return await s.handler(r.params.arguments??{})}catch(n){return{content:[{text:n instanceof Error?n.message:String(n),type:"text"}],isError:!0}}}),e},w=(e,r)=>M(c,e,async()=>(await C())({...t.charge,price:r},{resource:e}));return{fetchHandler:async(e,r,s)=>{const n=await T(e.clone(),t.maxRequestBytes);if("response"in n)return n.response;const{parsedBody:d}=n,p=()=>B(u(),e,d===void 0?{maxRequestBytes:t.maxRequestBytes}:{maxRequestBytes:t.maxRequestBytes,parsedBody:d});if(Array.isArray(d))return d.some(f=>a.has(v(f)??""))?q():p();const m=v(d),h=m===void 0?void 0:a.get(m);if(m===void 0||h===void 0)return p();const R=await w(m,h),S=typeof s?.waitUntil=="function"?{waitUntil:f=>{s.waitUntil?.(f)}}:void 0;return R.handle(e,p,S)},paidTool:(e,r)=>{i(e,r,e.price)},tool:(e,r)=>{i(e,r)}}};export{I as createPaidMcpServer};
@@ -119,7 +119,12 @@ type McpFetchHandler = (request: Request) => Promise<Response>;
119
119
  declare const DEFAULT_MAX_REQUEST_BYTES: number;
120
120
  /** What {@link serveStateless} accepts on top of the transport's own options. */
121
121
  interface ServeStatelessOptions extends HandleRequestOptions {
122
- /** Largest accepted request body, in bytes. Defaults to {@link DEFAULT_MAX_REQUEST_BYTES}. */
122
+ /**
123
+ * Largest accepted request body, in bytes — enforced while the body streams
124
+ * in, not after it is buffered. Defaults to
125
+ * {@link DEFAULT_MAX_REQUEST_BYTES}, which a value that is not a
126
+ * non-negative safe integer also falls back to (see `resolveLimit`).
127
+ */
123
128
  maxRequestBytes?: number;
124
129
  }
125
130
  /**
@@ -119,7 +119,12 @@ type McpFetchHandler = (request: Request) => Promise<Response>;
119
119
  declare const DEFAULT_MAX_REQUEST_BYTES: number;
120
120
  /** What {@link serveStateless} accepts on top of the transport's own options. */
121
121
  interface ServeStatelessOptions extends HandleRequestOptions {
122
- /** Largest accepted request body, in bytes. Defaults to {@link DEFAULT_MAX_REQUEST_BYTES}. */
122
+ /**
123
+ * Largest accepted request body, in bytes — enforced while the body streams
124
+ * in, not after it is buffered. Defaults to
125
+ * {@link DEFAULT_MAX_REQUEST_BYTES}, which a value that is not a
126
+ * non-negative safe integer also falls back to (see `resolveLimit`).
127
+ */
123
128
  maxRequestBytes?: number;
124
129
  }
125
130
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/mcp",
3
- "version": "1.0.0-alpha.107",
3
+ "version": "1.0.0-alpha.109",
4
4
  "description": "Model Context Protocol server exposing a Lunora deployment to AI agents",
5
5
  "keywords": [
6
6
  "ai-agents",
@@ -53,7 +53,7 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@lunora/client": "1.0.0-alpha.73",
56
+ "@lunora/client": "1.0.0-alpha.74",
57
57
  "@lunora/errors": "1.0.0-alpha.30",
58
58
  "@lunora/shard-engine": "1.0.0-alpha.54",
59
59
  "@modelcontextprotocol/sdk": "^1.30.0"
@@ -1 +0,0 @@
1
- import{WebStandardStreamableHTTPServerTransport as c}from"@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";const y=128*1024,i=e=>new TextEncoder().encode(e).length,o=(e,s,r)=>Response.json({error:{code:s,message:r},id:null,jsonrpc:"2.0"},{status:e}),d=()=>o(400,-32600,"batched requests are not supported: send one JSON-RPC message per request"),p=async(e,s)=>{if(e.method!=="POST")return{parsedBody:void 0};const r=s??y,t={response:o(413,-32600,`request body exceeds ${String(r)} bytes`)},n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>r)return t;const a=await e.text();if(i(a)>r)return t;try{return{parsedBody:JSON.parse(a)}}catch{return{response:o(400,-32700,"parse error: body is not valid JSON")}}},u=async(e,s)=>{if(e.method!=="POST")return{parsedBody:s?.parsedBody};if(s?.parsedBody!==void 0)return Array.isArray(s.parsedBody)?{response:d()}:{parsedBody:s.parsedBody};const r=await p(e,s?.maxRequestBytes);return"response"in r?r:Array.isArray(r.parsedBody)?{response:d()}:r},l=async(e,s,r)=>{const t=await u(s,r);if("response"in t)return t.response;const n=new c({enableJsonResponse:!0,sessionIdGenerator:void 0});try{return await e.connect(n),await n.handleRequest(s,{authInfo:r?.authInfo,parsedBody:t.parsedBody})}finally{n.close().catch(()=>{}),e.close().catch(()=>{})}};export{y as DEFAULT_MAX_REQUEST_BYTES,p as readScreenedBody,l as serveStateless};