@lunora/mcp 1.0.0-alpha.24 → 1.0.0-alpha.241

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.
Files changed (47) hide show
  1. package/LICENSE.md +120 -0
  2. package/README.md +200 -14
  3. package/dist/bin.mjs +4 -47
  4. package/dist/docs/index.d.mts +259 -0
  5. package/dist/docs/index.d.ts +259 -0
  6. package/dist/docs/index.mjs +1 -0
  7. package/dist/index.d.mts +84 -82
  8. package/dist/index.d.ts +84 -82
  9. package/dist/index.mjs +1 -5
  10. package/dist/node/index.d.mts +90 -0
  11. package/dist/node/index.d.ts +90 -0
  12. package/dist/node/index.mjs +1 -0
  13. package/dist/packem_shared/AGENT_RUN_INPUT_SCHEMA-hKbpa3Dg.mjs +1 -0
  14. package/dist/packem_shared/DEFAULT_DOCS_BASE_URL-CiHy_Dbz.mjs +4 -0
  15. package/dist/packem_shared/DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs +1 -0
  16. package/dist/packem_shared/DEFAULT_SEARCH_LIMIT-B8C5JM2y.mjs +3 -0
  17. package/dist/packem_shared/DOCS_SERVER_NAME-CUnLrk1a.mjs +1 -0
  18. package/dist/packem_shared/DOCS_URI_SCHEME-C35UQ5Fo.mjs +3 -0
  19. package/dist/packem_shared/LOCAL_SERVER_NAME-Bj3l_7WG.mjs +1 -0
  20. package/dist/packem_shared/OBSERVABILITY_TOOL_DEFINITIONS-mO4JuHgV.mjs +1 -0
  21. package/dist/packem_shared/READ_ONLY_TOOL_DEFINITIONS-CihHZdB6.mjs +1 -0
  22. package/dist/packem_shared/compose.d-BVnP3uAy.d.mts +111 -0
  23. package/dist/packem_shared/compose.d-BVnP3uAy.d.ts +111 -0
  24. package/dist/packem_shared/connectStdio-DYI-3vnF.mjs +1 -0
  25. package/dist/packem_shared/createAuthedMcpFetchHandler-D_SQpDhH.mjs +1 -0
  26. package/dist/packem_shared/createLunoraMcpServer-CQJIwdik.mjs +1 -0
  27. package/dist/packem_shared/createMcpFetchHandler-TkLzJUNn.mjs +1 -0
  28. package/dist/packem_shared/createPaidMcpServer-BH_mly77.mjs +1 -0
  29. package/dist/packem_shared/createToolServer-BtGuPyMU.mjs +1 -0
  30. package/dist/packem_shared/observability-tools-D4Z8dGS-.mjs +1 -0
  31. package/dist/packem_shared/promise-memo-OqVPWoUX.mjs +1 -0
  32. package/dist/packem_shared/serve-stateless.d-DD5arqFx.d.mts +45 -0
  33. package/dist/packem_shared/serve-stateless.d-DD5arqFx.d.ts +45 -0
  34. package/dist/packem_shared/server.d-D3rejkVc.d.mts +152 -0
  35. package/dist/packem_shared/server.d-DQgZyRkG.d.ts +152 -0
  36. package/dist/packem_shared/toDocsSearchHits-CBLmtWXt.mjs +1 -0
  37. package/dist/packem_shared/tool-call-Bs-QeKp6.mjs +1 -0
  38. package/dist/packem_shared/tools-BOfWz78m.mjs +2 -0
  39. package/dist/worker/index.d.mts +258 -0
  40. package/dist/worker/index.d.ts +258 -0
  41. package/dist/worker/index.mjs +1 -0
  42. package/package.json +26 -5
  43. package/dist/packem_shared/AGENT_RUN_INPUT_SCHEMA-DWobae3P.mjs +0 -168
  44. package/dist/packem_shared/READ_ONLY_TOOL_DEFINITIONS-CWb_wFd5.mjs +0 -204
  45. package/dist/packem_shared/connectStdio-bkJcaXYE.mjs +0 -76
  46. package/dist/packem_shared/createMcpFetchHandler-DfzBSLrm.mjs +0 -14
  47. package/dist/packem_shared/createPaidMcpServer-b-qp_aEF.mjs +0 -93
package/dist/index.d.mts CHANGED
@@ -1,83 +1,85 @@
1
- import { LunoraClient } from '@lunora/client';
2
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
1
+ export { A as AGENT_RUN_INPUT_SCHEMA, a as AGENT_STATUS_TOOL_NAME,
2
+ /**
3
+ * `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
4
+ * a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
5
+ * framework's *documentation* (credential-free, and safe to host publicly).
6
+ *
7
+ * The deployment server: It registers tools for introspecting a deployment
8
+ * (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
9
+ * (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
10
+ * writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
11
+ * `lunora_explain_error` — a credential-free read of the static error catalog
12
+ * (status, title, hint, matched solution) that needs no deployment at all. It also
13
+ * exposes the deployment's observability reads (`lunora_get_logs`,
14
+ * `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
15
+ * `lunora_get_migration_status`) when `allowObservability` (or the
16
+ * LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
17
+ * production user data, so they are omitted entirely without it. The server is
18
+ * read-only by default — the write tools are exposed only when `allowWrites`
19
+ * (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
20
+ * allowlisted against the deployment's discovered public functions. Past that
21
+ * gate the two write tools run a two-step confirmation handshake: the first
22
+ * call writes nothing and returns the proposed action plus a self-verifying
23
+ * `actionDigest`, and only a second call carrying `confirmed: true` and that
24
+ * digest executes (see `./write-confirmation`). It can also
25
+ * front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
26
+ * (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
27
+ * `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
28
+ * and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
29
+ * server remotely over Streamable HTTP with `createMcpFetchHandler` (a
30
+ * Workers-ready `Request` → `Response` handler), or build a server
31
+ * programmatically with `createLunoraMcpServer` and connect any transport.
32
+ *
33
+ * A remote endpoint is reachable by anyone who knows its URL, and the tools
34
+ * carry the deployment's admin bearer — so for a public deployment use
35
+ * `createAuthedMcpFetchHandler` instead, which mounts the same server behind
36
+ * better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
37
+ * and can scope tool exposure to the access token's own scopes.
38
+ */
39
+ type C as CallAgentToolOptions, type L as LunoraMcpServerOptions,
40
+ /**
41
+ * `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
42
+ * a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
43
+ * framework's *documentation* (credential-free, and safe to host publicly).
44
+ *
45
+ * The deployment server: It registers tools for introspecting a deployment
46
+ * (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
47
+ * (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
48
+ * writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
49
+ * `lunora_explain_error` — a credential-free read of the static error catalog
50
+ * (status, title, hint, matched solution) that needs no deployment at all. It also
51
+ * exposes the deployment's observability reads (`lunora_get_logs`,
52
+ * `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
53
+ * `lunora_get_migration_status`) when `allowObservability` (or the
54
+ * LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
55
+ * production user data, so they are omitted entirely without it. The server is
56
+ * read-only by default — the write tools are exposed only when `allowWrites`
57
+ * (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
58
+ * allowlisted against the deployment's discovered public functions. Past that
59
+ * gate the two write tools run a two-step confirmation handshake: the first
60
+ * call writes nothing and returns the proposed action plus a self-verifying
61
+ * `actionDigest`, and only a second call carrying `confirmed: true` and that
62
+ * digest executes (see `./write-confirmation`). It can also
63
+ * front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
64
+ * (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
65
+ * `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
66
+ * and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
67
+ * server remotely over Streamable HTTP with `createMcpFetchHandler` (a
68
+ * Workers-ready `Request` → `Response` handler), or build a server
69
+ * programmatically with `createLunoraMcpServer` and connect any transport.
70
+ *
71
+ * A remote endpoint is reachable by anyone who knows its URL, and the tools
72
+ * carry the deployment's admin bearer — so for a public deployment use
73
+ * `createAuthedMcpFetchHandler` instead, which mounts the same server behind
74
+ * better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
75
+ * and can scope tool exposure to the access token's own scopes.
76
+ */
77
+ type M as McpAgentExposure, b as agentToolDefinitions, c as callAgentTool, d as createLunoraMcpServer, p as parseAgentsEnv } from "./packem_shared/server.d-D3rejkVc.mjs";
78
+ export { type AuthedMcpFetchHandlerOptions, type AuthedMcpServerOptions, type McpAccessTokenClaims, type McpAuthProtect, type McpFetchHandlerOptions, OBSERVABILITY_TOOL_DEFINITIONS, type PaidMcpChargeConfig, type PaidMcpExecutionContext, type PaidMcpFetchHandler, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolHandler, WRITE_TOOL_DEFINITIONS, callTool, createAuthedMcpFetchHandler, createMcpFetchHandler, createPaidMcpServer, mcpTokenScopes, toolDefinitions } from "./worker/index.mjs";
79
+ export { type M as McpServerInfo, type a as McpTool, type T as ToolDefinition, type b as ToolInputSchema, type c as ToolResult, d as createToolServer } from "./packem_shared/compose.d-BVnP3uAy.mjs";
80
+ export { LOCAL_SERVER_NAME, type LocalDeployment, type LocalDeploymentSource, type LocalMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools } from "./node/index.mjs";
81
+ export { D as DEFAULT_MAX_REQUEST_BYTES, type M as McpFetchHandler, type S as ServeStatelessOptions, s as serveStateless } from "./packem_shared/serve-stateless.d-DD5arqFx.mjs";
82
+ import '@lunora/client';
83
+ import '@modelcontextprotocol/sdk/server/index.js';
84
+ import '@modelcontextprotocol/sdk/types.js';
3
85
  import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
4
- import { X402ChargeConfig, X402Price } from '@lunora/x402/charge';
5
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
- interface ToolInputSchema {
7
- properties: Record<string, unknown>;
8
- required?: ReadonlyArray<string>;
9
- type: "object";
10
- }
11
- interface ToolDefinition {
12
- description: string;
13
- inputSchema: ToolInputSchema;
14
- name: string;
15
- }
16
- interface ToolResult {
17
- content: {
18
- text: string;
19
- type: "text";
20
- }[];
21
- isError?: boolean;
22
- }
23
- declare const READ_ONLY_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
24
- declare const WRITE_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
25
- declare const toolDefinitions: (allowWrites: boolean) => ReadonlyArray<ToolDefinition>;
26
- declare const callTool: (client: LunoraClient, name: string, input: Record<string, unknown>, allowWrites?: boolean) => Promise<ToolResult>;
27
- interface McpAgentExposure {
28
- description: string;
29
- name: string;
30
- toolName?: string;
31
- }
32
- declare const AGENT_STATUS_TOOL_NAME = "lunora_agent_status";
33
- declare const AGENT_RUN_INPUT_SCHEMA: ToolInputSchema;
34
- declare const parseAgentsEnv: (raw: string | undefined) => McpAgentExposure[];
35
- declare const agentToolDefinitions: (exposures: ReadonlyArray<McpAgentExposure>, allowAgents: boolean) => ReadonlyArray<ToolDefinition>;
36
- interface CallAgentToolOptions {
37
- allowAgents: boolean;
38
- exposures: ReadonlyArray<McpAgentExposure>;
39
- maxWaitMs?: number;
40
- pollIntervalMs?: number;
41
- wait?: (ms: number) => Promise<void>;
42
- }
43
- declare const callAgentTool: (client: LunoraClient, name: string, input: Record<string, unknown>, options: CallAgentToolOptions) => Promise<ToolResult>;
44
- interface LunoraMcpServerOptions {
45
- agentMaxWaitMs?: number;
46
- agentPollIntervalMs?: number;
47
- agents?: ReadonlyArray<McpAgentExposure>;
48
- allowAgents?: boolean;
49
- allowWrites?: boolean;
50
- client?: LunoraClient;
51
- fetch?: typeof fetch;
52
- token?: string;
53
- url?: string;
54
- }
55
- declare const createLunoraMcpServer: (options: LunoraMcpServerOptions) => Server;
56
- declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
57
- type McpFetchHandler = (request: Request) => Promise<Response>;
58
- declare const createMcpFetchHandler: (options: LunoraMcpServerOptions) => McpFetchHandler;
59
- type ToolHandler = (arguments_: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
60
- interface RegisterToolOptions {
61
- annotations?: Tool["annotations"];
62
- description: string;
63
- inputSchema: ToolInputSchema;
64
- name: string;
65
- }
66
- interface RegisterPaidToolOptions extends RegisterToolOptions {
67
- price: X402Price;
68
- }
69
- type PaidMcpChargeConfig = Omit<X402ChargeConfig, "price">;
70
- interface PaidMcpServerConfig {
71
- charge: PaidMcpChargeConfig;
72
- serverInfo?: {
73
- name: string;
74
- version: string;
75
- };
76
- }
77
- interface PaidMcpServer {
78
- readonly fetchHandler: McpFetchHandler;
79
- paidTool: (options: RegisterPaidToolOptions, handler: ToolHandler) => void;
80
- tool: (options: RegisterToolOptions, handler: ToolHandler) => void;
81
- }
82
- declare const createPaidMcpServer: (config: PaidMcpServerConfig) => PaidMcpServer;
83
- export { AGENT_RUN_INPUT_SCHEMA, AGENT_STATUS_TOOL_NAME, type CallAgentToolOptions, type LunoraMcpServerOptions, type McpAgentExposure, type McpFetchHandler, type PaidMcpChargeConfig, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolDefinition, type ToolHandler, type ToolInputSchema, type ToolResult, WRITE_TOOL_DEFINITIONS, agentToolDefinitions, callAgentTool, callTool, connectStdio, createLunoraMcpServer, createMcpFetchHandler, createPaidMcpServer, parseAgentsEnv, toolDefinitions };
package/dist/index.d.ts CHANGED
@@ -1,83 +1,85 @@
1
- import { LunoraClient } from '@lunora/client';
2
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
1
+ export { A as AGENT_RUN_INPUT_SCHEMA, a as AGENT_STATUS_TOOL_NAME,
2
+ /**
3
+ * `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
4
+ * a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
5
+ * framework's *documentation* (credential-free, and safe to host publicly).
6
+ *
7
+ * The deployment server: It registers tools for introspecting a deployment
8
+ * (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
9
+ * (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
10
+ * writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
11
+ * `lunora_explain_error` — a credential-free read of the static error catalog
12
+ * (status, title, hint, matched solution) that needs no deployment at all. It also
13
+ * exposes the deployment's observability reads (`lunora_get_logs`,
14
+ * `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
15
+ * `lunora_get_migration_status`) when `allowObservability` (or the
16
+ * LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
17
+ * production user data, so they are omitted entirely without it. The server is
18
+ * read-only by default — the write tools are exposed only when `allowWrites`
19
+ * (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
20
+ * allowlisted against the deployment's discovered public functions. Past that
21
+ * gate the two write tools run a two-step confirmation handshake: the first
22
+ * call writes nothing and returns the proposed action plus a self-verifying
23
+ * `actionDigest`, and only a second call carrying `confirmed: true` and that
24
+ * digest executes (see `./write-confirmation`). It can also
25
+ * front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
26
+ * (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
27
+ * `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
28
+ * and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
29
+ * server remotely over Streamable HTTP with `createMcpFetchHandler` (a
30
+ * Workers-ready `Request` → `Response` handler), or build a server
31
+ * programmatically with `createLunoraMcpServer` and connect any transport.
32
+ *
33
+ * A remote endpoint is reachable by anyone who knows its URL, and the tools
34
+ * carry the deployment's admin bearer — so for a public deployment use
35
+ * `createAuthedMcpFetchHandler` instead, which mounts the same server behind
36
+ * better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
37
+ * and can scope tool exposure to the access token's own scopes.
38
+ */
39
+ type C as CallAgentToolOptions, type L as LunoraMcpServerOptions,
40
+ /**
41
+ * `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
42
+ * a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
43
+ * framework's *documentation* (credential-free, and safe to host publicly).
44
+ *
45
+ * The deployment server: It registers tools for introspecting a deployment
46
+ * (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
47
+ * (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
48
+ * writes are enabled), each backed by `LunoraClient` over HTTP RPC, plus
49
+ * `lunora_explain_error` — a credential-free read of the static error catalog
50
+ * (status, title, hint, matched solution) that needs no deployment at all. It also
51
+ * exposes the deployment's observability reads (`lunora_get_logs`,
52
+ * `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
53
+ * `lunora_get_migration_status`) when `allowObservability` (or the
54
+ * LUNORA_MCP_ALLOW_OBSERVABILITY env) is set — read-only, but they return
55
+ * production user data, so they are omitted entirely without it. The server is
56
+ * read-only by default — the write tools are exposed only when `allowWrites`
57
+ * (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
58
+ * allowlisted against the deployment's discovered public functions. Past that
59
+ * gate the two write tools run a two-step confirmation handshake: the first
60
+ * call writes nothing and returns the proposed action plus a self-verifying
61
+ * `actionDigest`, and only a second call carrying `confirmed: true` and that
62
+ * digest executes (see `./write-confirmation`). It can also
63
+ * front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
64
+ * (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
65
+ * `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
66
+ * and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
67
+ * server remotely over Streamable HTTP with `createMcpFetchHandler` (a
68
+ * Workers-ready `Request` → `Response` handler), or build a server
69
+ * programmatically with `createLunoraMcpServer` and connect any transport.
70
+ *
71
+ * A remote endpoint is reachable by anyone who knows its URL, and the tools
72
+ * carry the deployment's admin bearer — so for a public deployment use
73
+ * `createAuthedMcpFetchHandler` instead, which mounts the same server behind
74
+ * better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
75
+ * and can scope tool exposure to the access token's own scopes.
76
+ */
77
+ type M as McpAgentExposure, b as agentToolDefinitions, c as callAgentTool, d as createLunoraMcpServer, p as parseAgentsEnv } from "./packem_shared/server.d-DQgZyRkG.js";
78
+ export { type AuthedMcpFetchHandlerOptions, type AuthedMcpServerOptions, type McpAccessTokenClaims, type McpAuthProtect, type McpFetchHandlerOptions, OBSERVABILITY_TOOL_DEFINITIONS, type PaidMcpChargeConfig, type PaidMcpExecutionContext, type PaidMcpFetchHandler, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolHandler, WRITE_TOOL_DEFINITIONS, callTool, createAuthedMcpFetchHandler, createMcpFetchHandler, createPaidMcpServer, mcpTokenScopes, toolDefinitions } from "./worker/index.js";
79
+ export { type M as McpServerInfo, type a as McpTool, type T as ToolDefinition, type b as ToolInputSchema, type c as ToolResult, d as createToolServer } from "./packem_shared/compose.d-BVnP3uAy.js";
80
+ export { LOCAL_SERVER_NAME, type LocalDeployment, type LocalDeploymentSource, type LocalMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools } from "./node/index.js";
81
+ export { D as DEFAULT_MAX_REQUEST_BYTES, type M as McpFetchHandler, type S as ServeStatelessOptions, s as serveStateless } from "./packem_shared/serve-stateless.d-DD5arqFx.js";
82
+ import '@lunora/client';
83
+ import '@modelcontextprotocol/sdk/server/index.js';
84
+ import '@modelcontextprotocol/sdk/types.js';
3
85
  import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
4
- import { X402ChargeConfig, X402Price } from '@lunora/x402/charge';
5
- import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
- interface ToolInputSchema {
7
- properties: Record<string, unknown>;
8
- required?: ReadonlyArray<string>;
9
- type: "object";
10
- }
11
- interface ToolDefinition {
12
- description: string;
13
- inputSchema: ToolInputSchema;
14
- name: string;
15
- }
16
- interface ToolResult {
17
- content: {
18
- text: string;
19
- type: "text";
20
- }[];
21
- isError?: boolean;
22
- }
23
- declare const READ_ONLY_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
24
- declare const WRITE_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
25
- declare const toolDefinitions: (allowWrites: boolean) => ReadonlyArray<ToolDefinition>;
26
- declare const callTool: (client: LunoraClient, name: string, input: Record<string, unknown>, allowWrites?: boolean) => Promise<ToolResult>;
27
- interface McpAgentExposure {
28
- description: string;
29
- name: string;
30
- toolName?: string;
31
- }
32
- declare const AGENT_STATUS_TOOL_NAME = "lunora_agent_status";
33
- declare const AGENT_RUN_INPUT_SCHEMA: ToolInputSchema;
34
- declare const parseAgentsEnv: (raw: string | undefined) => McpAgentExposure[];
35
- declare const agentToolDefinitions: (exposures: ReadonlyArray<McpAgentExposure>, allowAgents: boolean) => ReadonlyArray<ToolDefinition>;
36
- interface CallAgentToolOptions {
37
- allowAgents: boolean;
38
- exposures: ReadonlyArray<McpAgentExposure>;
39
- maxWaitMs?: number;
40
- pollIntervalMs?: number;
41
- wait?: (ms: number) => Promise<void>;
42
- }
43
- declare const callAgentTool: (client: LunoraClient, name: string, input: Record<string, unknown>, options: CallAgentToolOptions) => Promise<ToolResult>;
44
- interface LunoraMcpServerOptions {
45
- agentMaxWaitMs?: number;
46
- agentPollIntervalMs?: number;
47
- agents?: ReadonlyArray<McpAgentExposure>;
48
- allowAgents?: boolean;
49
- allowWrites?: boolean;
50
- client?: LunoraClient;
51
- fetch?: typeof fetch;
52
- token?: string;
53
- url?: string;
54
- }
55
- declare const createLunoraMcpServer: (options: LunoraMcpServerOptions) => Server;
56
- declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
57
- type McpFetchHandler = (request: Request) => Promise<Response>;
58
- declare const createMcpFetchHandler: (options: LunoraMcpServerOptions) => McpFetchHandler;
59
- type ToolHandler = (arguments_: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
60
- interface RegisterToolOptions {
61
- annotations?: Tool["annotations"];
62
- description: string;
63
- inputSchema: ToolInputSchema;
64
- name: string;
65
- }
66
- interface RegisterPaidToolOptions extends RegisterToolOptions {
67
- price: X402Price;
68
- }
69
- type PaidMcpChargeConfig = Omit<X402ChargeConfig, "price">;
70
- interface PaidMcpServerConfig {
71
- charge: PaidMcpChargeConfig;
72
- serverInfo?: {
73
- name: string;
74
- version: string;
75
- };
76
- }
77
- interface PaidMcpServer {
78
- readonly fetchHandler: McpFetchHandler;
79
- paidTool: (options: RegisterPaidToolOptions, handler: ToolHandler) => void;
80
- tool: (options: RegisterToolOptions, handler: ToolHandler) => void;
81
- }
82
- declare const createPaidMcpServer: (config: PaidMcpServerConfig) => PaidMcpServer;
83
- export { AGENT_RUN_INPUT_SCHEMA, AGENT_STATUS_TOOL_NAME, type CallAgentToolOptions, type LunoraMcpServerOptions, type McpAgentExposure, type McpFetchHandler, type PaidMcpChargeConfig, type PaidMcpServer, type PaidMcpServerConfig, READ_ONLY_TOOL_DEFINITIONS, type RegisterPaidToolOptions, type RegisterToolOptions, type ToolDefinition, type ToolHandler, type ToolInputSchema, type ToolResult, WRITE_TOOL_DEFINITIONS, agentToolDefinitions, callAgentTool, callTool, connectStdio, createLunoraMcpServer, createMcpFetchHandler, createPaidMcpServer, parseAgentsEnv, toolDefinitions };
package/dist/index.mjs CHANGED
@@ -1,5 +1 @@
1
- export { AGENT_RUN_INPUT_SCHEMA, AGENT_STATUS_TOOL_NAME, agentToolDefinitions, callAgentTool, parseAgentsEnv } from './packem_shared/AGENT_RUN_INPUT_SCHEMA-DWobae3P.mjs';
2
- export { createMcpFetchHandler } from './packem_shared/createMcpFetchHandler-DfzBSLrm.mjs';
3
- export { createPaidMcpServer } from './packem_shared/createPaidMcpServer-b-qp_aEF.mjs';
4
- export { connectStdio, createLunoraMcpServer } from './packem_shared/connectStdio-bkJcaXYE.mjs';
5
- export { READ_ONLY_TOOL_DEFINITIONS, WRITE_TOOL_DEFINITIONS, callTool, toolDefinitions } from './packem_shared/READ_ONLY_TOOL_DEFINITIONS-CWb_wFd5.mjs';
1
+ import{AGENT_RUN_INPUT_SCHEMA as r,AGENT_STATUS_TOOL_NAME as t,agentToolDefinitions as a,callAgentTool as c,parseAgentsEnv as T}from"./packem_shared/AGENT_RUN_INPUT_SCHEMA-hKbpa3Dg.mjs";import{createAuthedMcpFetchHandler as S,mcpTokenScopes as _}from"./packem_shared/createAuthedMcpFetchHandler-D_SQpDhH.mjs";import{createToolServer as l}from"./packem_shared/createToolServer-BtGuPyMU.mjs";import{createMcpFetchHandler as n}from"./packem_shared/createMcpFetchHandler-TkLzJUNn.mjs";import{LOCAL_SERVER_NAME as A,NO_DEPLOYMENT_MESSAGE as N,connectLocalStdio as f,createLocalMcpServer as I,localTools as L}from"./packem_shared/LOCAL_SERVER_NAME-Bj3l_7WG.mjs";import{createPaidMcpServer as x}from"./packem_shared/createPaidMcpServer-BH_mly77.mjs";import{createLunoraMcpServer as i}from"./packem_shared/createLunoraMcpServer-CQJIwdik.mjs";import{default as R}from"./packem_shared/connectStdio-DYI-3vnF.mjs";import{R as v,W as F,c as U,t as Y}from"./packem_shared/tools-BOfWz78m.mjs";import{DEFAULT_MAX_REQUEST_BYTES as h,serveStateless as u}from"./packem_shared/DEFAULT_MAX_REQUEST_BYTES-CbbpkHRK.mjs";import{O as G}from"./packem_shared/observability-tools-D4Z8dGS-.mjs";export{r as AGENT_RUN_INPUT_SCHEMA,t as AGENT_STATUS_TOOL_NAME,h as DEFAULT_MAX_REQUEST_BYTES,A as LOCAL_SERVER_NAME,N as NO_DEPLOYMENT_MESSAGE,G as OBSERVABILITY_TOOL_DEFINITIONS,v as READ_ONLY_TOOL_DEFINITIONS,F as WRITE_TOOL_DEFINITIONS,a as agentToolDefinitions,c as callAgentTool,U as callTool,f as connectLocalStdio,R as connectStdio,S as createAuthedMcpFetchHandler,I as createLocalMcpServer,i as createLunoraMcpServer,n as createMcpFetchHandler,x as createPaidMcpServer,l as createToolServer,L as localTools,_ as mcpTokenScopes,T as parseAgentsEnv,u as serveStateless,Y as toolDefinitions};
@@ -0,0 +1,90 @@
1
+ import { LunoraClient } from '@lunora/client';
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { a as McpTool } from "../packem_shared/compose.d-BVnP3uAy.mjs";
4
+ import { L as LunoraMcpServerOptions } from "../packem_shared/server.d-D3rejkVc.mjs";
5
+ export { d as createLunoraMcpServer } from "../packem_shared/server.d-D3rejkVc.mjs";
6
+ /** A Lunora deployment the tools dispatch against. */
7
+ interface LocalDeployment {
8
+ token?: string;
9
+ url: string;
10
+ }
11
+ /**
12
+ * Where the deployment comes from: a fixed value, or a function consulted on
13
+ * every tool call.
14
+ *
15
+ * The resolver form exists because an editor spawns this server when the
16
+ * project opens — routinely *before* `lunora dev` is running, and it keeps the
17
+ * process alive across every restart afterwards. A URL captured once at startup
18
+ * would therefore be absent for the entire first session and stale after the
19
+ * first restart.
20
+ */
21
+ type LocalDeploymentSource = (() => LocalDeployment | undefined) | LocalDeployment;
22
+ interface LocalMcpServerOptions {
23
+ /**
24
+ * Expose the deployment write tools (`lunora_run_mutation` /
25
+ * `lunora_run_action`). Defaults to `false` — the same fail-closed default
26
+ * as the remote server. Locally the blast radius is dev data rather than
27
+ * production, but a mutation is still a side effect an agent should be
28
+ * granted deliberately.
29
+ */
30
+ allowWrites?: boolean;
31
+ /**
32
+ * The Lunora deployment (usually the running dev server) to expose. Omit to
33
+ * leave the deployment tools out entirely.
34
+ */
35
+ deployment?: LocalDeploymentSource;
36
+ /** Docs site origin backing the documentation tools; `false` omits them. */
37
+ docs?: false | {
38
+ baseUrl?: string;
39
+ };
40
+ /** Extra tools to compose in, e.g. the CLI's local dev-server tools. */
41
+ extraTools?: ReadonlyArray<McpTool>;
42
+ /** `fetch` implementation; defaults to the ambient global. */
43
+ fetch?: typeof fetch;
44
+ /** Version reported in the MCP handshake — the host CLI's, not this package's. */
45
+ version?: string;
46
+ }
47
+ /** Server identity advertised in the MCP `initialize` handshake. */
48
+ declare const LOCAL_SERVER_NAME = "lunora";
49
+ /** Shown when a deployment tool is called and no dev server can be found. */
50
+ declare const NO_DEPLOYMENT_MESSAGE = "no Lunora dev server is running for this project — start one with `lunora dev`, then call this tool again (call lunora_dev_status to check).";
51
+ /**
52
+ * Assemble the tool list, in the order it is advertised: docs first (the
53
+ * surface that always works), then the caller's extras, then the error catalog
54
+ * (compiled in, so it needs no deployment either), then the deployment tools.
55
+ * Order also decides precedence — `createToolServer` keeps the first
56
+ * registration of a duplicated name.
57
+ *
58
+ * `clientFor` is the shared client cache built once by
59
+ * {@link createLocalMcpServer} and threaded into both the tool and resource
60
+ * surfaces. Exported (and called directly by tests) without going through
61
+ * `createLocalMcpServer`, so a caller that omits it gets a private,
62
+ * call-scoped cache — same shape as before this surface was shared, just
63
+ * without the cross-surface sharing that only matters once a resource
64
+ * surface exists alongside it.
65
+ */
66
+ declare const localTools: (options: LocalMcpServerOptions, clientFor?: (deployment: LocalDeployment) => LunoraClient) => ReadonlyArray<McpTool>;
67
+ /** Build the composed local server without connecting a transport. */
68
+ declare const createLocalMcpServer: (options?: LocalMcpServerOptions) => Server;
69
+ /**
70
+ * Build the composed local server and connect it over stdio — the transport an
71
+ * MCP client uses when it spawns `lunora mcp serve`. Resolves once connected;
72
+ * the process then stays alive serving requests.
73
+ */
74
+ declare const connectLocalStdio: (options?: LocalMcpServerOptions) => Promise<Server>;
75
+ /**
76
+ * Build the server and connect it over stdio — the transport MCP clients use
77
+ * when they spawn the `lunora-mcp` binary. Resolves once the transport is
78
+ * connected; the process then stays alive serving requests.
79
+ *
80
+ * Lives apart from `server.ts` so the Worker entry's module graph never pulls
81
+ * in the stdio transport (and its `node:process` import).
82
+ */
83
+ declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
84
+ export { LOCAL_SERVER_NAME,
85
+ /** Node-only entry: the stdio transport and the local/deployment servers. */
86
+ type LocalDeployment,
87
+ /** Node-only entry: the stdio transport and the local/deployment servers. */
88
+ type LocalDeploymentSource,
89
+ /** Node-only entry: the stdio transport and the local/deployment servers. */
90
+ type LocalMcpServerOptions, type LunoraMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools };
@@ -0,0 +1,90 @@
1
+ import { LunoraClient } from '@lunora/client';
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { a as McpTool } from "../packem_shared/compose.d-BVnP3uAy.js";
4
+ import { L as LunoraMcpServerOptions } from "../packem_shared/server.d-DQgZyRkG.js";
5
+ export { d as createLunoraMcpServer } from "../packem_shared/server.d-DQgZyRkG.js";
6
+ /** A Lunora deployment the tools dispatch against. */
7
+ interface LocalDeployment {
8
+ token?: string;
9
+ url: string;
10
+ }
11
+ /**
12
+ * Where the deployment comes from: a fixed value, or a function consulted on
13
+ * every tool call.
14
+ *
15
+ * The resolver form exists because an editor spawns this server when the
16
+ * project opens — routinely *before* `lunora dev` is running, and it keeps the
17
+ * process alive across every restart afterwards. A URL captured once at startup
18
+ * would therefore be absent for the entire first session and stale after the
19
+ * first restart.
20
+ */
21
+ type LocalDeploymentSource = (() => LocalDeployment | undefined) | LocalDeployment;
22
+ interface LocalMcpServerOptions {
23
+ /**
24
+ * Expose the deployment write tools (`lunora_run_mutation` /
25
+ * `lunora_run_action`). Defaults to `false` — the same fail-closed default
26
+ * as the remote server. Locally the blast radius is dev data rather than
27
+ * production, but a mutation is still a side effect an agent should be
28
+ * granted deliberately.
29
+ */
30
+ allowWrites?: boolean;
31
+ /**
32
+ * The Lunora deployment (usually the running dev server) to expose. Omit to
33
+ * leave the deployment tools out entirely.
34
+ */
35
+ deployment?: LocalDeploymentSource;
36
+ /** Docs site origin backing the documentation tools; `false` omits them. */
37
+ docs?: false | {
38
+ baseUrl?: string;
39
+ };
40
+ /** Extra tools to compose in, e.g. the CLI's local dev-server tools. */
41
+ extraTools?: ReadonlyArray<McpTool>;
42
+ /** `fetch` implementation; defaults to the ambient global. */
43
+ fetch?: typeof fetch;
44
+ /** Version reported in the MCP handshake — the host CLI's, not this package's. */
45
+ version?: string;
46
+ }
47
+ /** Server identity advertised in the MCP `initialize` handshake. */
48
+ declare const LOCAL_SERVER_NAME = "lunora";
49
+ /** Shown when a deployment tool is called and no dev server can be found. */
50
+ declare const NO_DEPLOYMENT_MESSAGE = "no Lunora dev server is running for this project — start one with `lunora dev`, then call this tool again (call lunora_dev_status to check).";
51
+ /**
52
+ * Assemble the tool list, in the order it is advertised: docs first (the
53
+ * surface that always works), then the caller's extras, then the error catalog
54
+ * (compiled in, so it needs no deployment either), then the deployment tools.
55
+ * Order also decides precedence — `createToolServer` keeps the first
56
+ * registration of a duplicated name.
57
+ *
58
+ * `clientFor` is the shared client cache built once by
59
+ * {@link createLocalMcpServer} and threaded into both the tool and resource
60
+ * surfaces. Exported (and called directly by tests) without going through
61
+ * `createLocalMcpServer`, so a caller that omits it gets a private,
62
+ * call-scoped cache — same shape as before this surface was shared, just
63
+ * without the cross-surface sharing that only matters once a resource
64
+ * surface exists alongside it.
65
+ */
66
+ declare const localTools: (options: LocalMcpServerOptions, clientFor?: (deployment: LocalDeployment) => LunoraClient) => ReadonlyArray<McpTool>;
67
+ /** Build the composed local server without connecting a transport. */
68
+ declare const createLocalMcpServer: (options?: LocalMcpServerOptions) => Server;
69
+ /**
70
+ * Build the composed local server and connect it over stdio — the transport an
71
+ * MCP client uses when it spawns `lunora mcp serve`. Resolves once connected;
72
+ * the process then stays alive serving requests.
73
+ */
74
+ declare const connectLocalStdio: (options?: LocalMcpServerOptions) => Promise<Server>;
75
+ /**
76
+ * Build the server and connect it over stdio — the transport MCP clients use
77
+ * when they spawn the `lunora-mcp` binary. Resolves once the transport is
78
+ * connected; the process then stays alive serving requests.
79
+ *
80
+ * Lives apart from `server.ts` so the Worker entry's module graph never pulls
81
+ * in the stdio transport (and its `node:process` import).
82
+ */
83
+ declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
84
+ export { LOCAL_SERVER_NAME,
85
+ /** Node-only entry: the stdio transport and the local/deployment servers. */
86
+ type LocalDeployment,
87
+ /** Node-only entry: the stdio transport and the local/deployment servers. */
88
+ type LocalDeploymentSource,
89
+ /** Node-only entry: the stdio transport and the local/deployment servers. */
90
+ type LocalMcpServerOptions, type LunoraMcpServerOptions, NO_DEPLOYMENT_MESSAGE, connectLocalStdio, connectStdio, createLocalMcpServer, localTools };
@@ -0,0 +1 @@
1
+ import{LOCAL_SERVER_NAME as r,NO_DEPLOYMENT_MESSAGE as c,connectLocalStdio as t,createLocalMcpServer as a,localTools as E}from"../packem_shared/LOCAL_SERVER_NAME-Bj3l_7WG.mjs";import{createLunoraMcpServer as l}from"../packem_shared/createLunoraMcpServer-CQJIwdik.mjs";import{default as n}from"../packem_shared/connectStdio-DYI-3vnF.mjs";export{r as LOCAL_SERVER_NAME,c as NO_DEPLOYMENT_MESSAGE,t as connectLocalStdio,n as connectStdio,a as createLocalMcpServer,l as createLunoraMcpServer,E as localTools};
@@ -0,0 +1 @@
1
+ const b="agents:agentRun",T="agents:agentThread",H="agents:agentMessages",p="lunora_agent_status",_=new Set(["awaiting_input","cancelled","error","idle"]),O=6e4,x=600,P={properties:{prompt:{description:"The task or message for the agent.",type:"string"},threadKey:{description:"Reuse to continue a conversation; omit to start a new thread.",type:"string"},title:{description:"Optional thread title (first run only).",type:"string"}},required:["prompt"],type:"object"},U={properties:{threadKey:{description:"The thread key returned by an agent tool call.",type:"string"}},required:["threadKey"],type:"object"},g=t=>t.toolName??`agent_${t.name}`,C=t=>{if(t===void 0)return[];const n=[];for(const e of t.split(";")){const r=e.trim();if(r.length===0)continue;const o=r.indexOf(":");if(o<=0)continue;const a=r.slice(0,o).trim(),s=r.slice(o+1).trim();a.length===0||s.length===0||n.push({description:s,name:a})}return n},L={destructiveHint:!1,idempotentHint:!0,openWorldHint:!0,readOnlyHint:!0},K=(t,n)=>n!==!0||t.length===0?[]:[...t.map(r=>({annotations:{destructiveHint:!0,idempotentHint:!1,openWorldHint:!0,readOnlyHint:!1,title:`Run the ${r.name} agent (starts a durable run)`},description:`${r.description} Starts a durable agent run and returns its final answer.`,inputSchema:P,name:g(r)})),{annotations:{...L,title:"Check a durable agent run"},description:"Check the status of a durable agent run (and its answer if finished) by its threadKey.",inputSchema:U,name:p}],G=(t,n)=>t===p||n.some(e=>g(e)===t),R=()=>`mcp-${crypto.randomUUID()}`,d=t=>({__lunoraRef:t}),k=async t=>{await new Promise(n=>{setTimeout(n,t)})},c=t=>({content:[{text:JSON.stringify(t,void 0,2),type:"text"}]}),i=t=>({content:[{text:t,type:"text"}],isError:!0}),l=(t,n)=>{const e=t[n];return typeof e=="string"&&e.length>0?e:void 0},A=t=>{for(let n=t.length-1;n>=0;n-=1){const e=t[n],r=e?.toolCalls,o=Array.isArray(r)&&r.length>0;if(e?.role==="assistant"&&!o)return typeof e.content=="string"?e.content:""}return""},w=t=>t!==null&&typeof t=="object"&&typeof t.status=="string"?t.status:"unknown",S=async(t,n,e,r)=>{const o=await t.query(d(H),{key:n});if(e==="error"){const a=r!==null&&typeof r=="object"?r.error:void 0;return c({error:typeof a=="string"?a:"the agent run failed",status:e,threadKey:n})}return c(e==="awaiting_input"?{hint:"This run is paused on a human-in-the-loop tool approval. Approve or reject it in the app that owns the agent; MCP cannot supply the input. Poll lunora_agent_status with this threadKey afterwards.",status:e,text:A(o),threadKey:n}:{status:e,text:A(o),threadKey:n})},I=async(t,n)=>{const e=l(n,"threadKey");if(e===void 0)return i('"threadKey" is required and must be a non-empty string');const r=await t.query(d(T),{key:e}),o=w(r);return _.has(o)?S(t,e,o,r):c({status:o==="unknown"?"running":o,threadKey:e})},q=async(t,n,e,r)=>{try{if(r.allowAgents!==!0)return i(`tool "${n}" is disabled: agent tools are off. Enable them with the LUNORA_MCP_ALLOW_AGENTS env var.`);if(n===p)return await I(t,e);const o=r.exposures.find(u=>g(u)===n);if(o===void 0)return i(`agent tool "${n}" is not exposed by this MCP server`);const a=l(e,"prompt");if(a===void 0)return i('"prompt" is required and must be a non-empty string');const s=l(e,"threadKey")??R(),h=l(e,"title"),{id:E}=await t.mutation(d(b),{agent:o.name,input:a,threadKey:s,...h===void 0?{}:{title:h}}),f=r.pollIntervalMs??x,N=r.maxWaitMs??O,v=r.wait??k,M=Math.max(1,Math.ceil(N/f));for(let u=0;u<M;u+=1){const y=await t.query(d(T),{key:s}),m=w(y);if(_.has(m))return await S(t,s,m,y);await v(f)}return c({hint:"call lunora_agent_status with this threadKey to poll for the answer",runId:E,status:"running",threadKey:s})}catch(o){const a=o instanceof Error?o.message:String(o);return i(a)}};export{P as AGENT_RUN_INPUT_SCHEMA,p as AGENT_STATUS_TOOL_NAME,K as agentToolDefinitions,q as callAgentTool,A as finalAnswer,G as isAgentToolName,C as parseAgentsEnv};
@@ -0,0 +1,4 @@
1
+ import{toDocsSearchHits as h}from"./toDocsSearchHits-CBLmtWXt.mjs";const f="https://lunora.sh",u=1e4,m=t=>t.endsWith("/")?t.slice(0,-1):t,p="\\",g=(t,n,i)=>{for(let s=i;s<t.length;s+=1)if(t[s]===n&&t[s-1]!==p)return s;return-1},d=t=>t.replaceAll(String.raw`\[`,"[").replaceAll(String.raw`\]`,"]").replaceAll(String.raw`\(`,"(").replaceAll(String.raw`\)`,")"),S=t=>{const n=t.trim();if(!n.startsWith("- ["))return;const i=n.lastIndexOf("](");if(i===-1)return;const s=g(n,")",i+2);if(s===-1)return;const o=d(n.slice(3,i).trim()),c=d(n.slice(i+2,s).trim());if(o.length===0||c.length===0)return;const e=n.slice(s+1).trim(),r=e.startsWith(":")?e.slice(1).trim():"";return r.length>0?{description:r,title:o,url:c}:{title:o,url:c}},x=t=>{if(!t.endsWith(")"))return t;const n=t.lastIndexOf(" (");if(n===-1)return t;const i=t.slice(n+2,-1);return i.startsWith("/")||i.startsWith("http")?t.slice(0,n).trim():t},y=(t,n)=>{for(const i of t.split(`
2
+ `)){if(i.startsWith("# "))return x(i.slice(2).trim());if(i.trim().length>0)break}return n},b=t=>{if(!t.startsWith("# "))return t;const n=t.indexOf(`
3
+ `);return n===-1?"":t.slice(n+1).trimStart()},A=(t={})=>{const n=m(t.baseUrl??f),i=t.fetch??globalThis.fetch,s=t.timeoutMs??u,o=async e=>{try{const r=await i(`${n}${e}`,{headers:{accept:"text/plain, application/json"},signal:AbortSignal.timeout(s)});return r.ok?{body:await r.text()}:{missing:!0}}catch(r){return{unreachable:r instanceof Error?r.message:String(r)}}},c=(e,r)=>{if("unreachable"in e)throw new Error(`could not reach the documentation site at ${n}${r}: ${e.unreachable}`);return"missing"in e?void 0:e.body};return{getPage:async e=>{const r=c(await o(`/llms.mdx${e}`),`/llms.mdx${e}`);if(!(r===void 0||r.trim().length===0))return{content:b(r),title:y(r,e),url:e}},listPages:async()=>{const e=c(await o("/llms.txt"),"/llms.txt");if(e===void 0)return[];const r=[];for(const l of e.split(`
4
+ `)){const a=S(l);a!==void 0&&r.push(a)}return r},search:async e=>{const r=`/api/search?query=${encodeURIComponent(e)}`,l=c(await o(r),r);if(l===void 0)return[];let a;try{a=JSON.parse(l)}catch{return[]}return Array.isArray(a)?h(a):[]}}};export{f as DEFAULT_DOCS_BASE_URL,A as createRemoteDocsIndex,S as parseIndexLine};
@@ -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};
@@ -0,0 +1,3 @@
1
+ const T=10,A=50,h="docs";const _={properties:{limit:{description:`Maximum hits to return (default ${String(10)}, max ${String(50)})`,type:"number"},query:{description:'Search terms, e.g. "shardBy" or "optimistic updates"',type:"string"}},required:["query"],type:"object"},m={properties:{url:{description:'Site-relative page URL from a search hit, e.g. "/docs/sharding"',type:"string"}},required:["url"],type:"object"},g={properties:{},type:"object"},s={destructiveHint:!1,idempotentHint:!0,openWorldHint:!0,readOnlyHint:!0},u={annotations:{...s,title:"Search the Lunora documentation"},description:"Search the Lunora documentation and return matching pages and sections. Use this before writing Lunora code (schema, queries, mutations, actions, sharding, .global(), client hooks) so the answer reflects the framework's current API rather than a guess. Follow a hit with lunora_get_doc to read the full page.",inputSchema:_,name:"lunora_search_docs"},l={annotations:{...s,title:"Read a Lunora documentation page"},description:"Return one Lunora documentation page in full, as Markdown. Takes the `url` of a lunora_search_docs hit or a lunora_list_docs entry.",inputSchema:m,name:"lunora_get_doc"},d={annotations:{...s,title:"List the Lunora documentation pages"},description:"List every Lunora documentation page with its title and description. Prefer lunora_search_docs when you know what you're looking for.",inputSchema:g,name:"lunora_list_docs"},L=[u,l,d],r=n=>({content:[{text:JSON.stringify(n,void 0,2),type:"text"}]}),p=n=>({content:[{text:n,type:"text"}],isError:!0}),a=512,c=(n,t)=>{const e=n[t];if(typeof e!="string"||e.trim().length===0)throw new TypeError(`"${t}" is required and must be a non-empty string`);if(e.length>a)throw new RangeError(`"${t}" must be at most ${String(a)} characters`);return e.trim()},f=n=>{const t=typeof n=="string"?Number(n):n;return typeof t!="number"||!Number.isFinite(t)?10:Math.min(50,Math.max(1,Math.floor(t)))},S=(n,t)=>{let e;try{e=decodeURIComponent(n)}catch{throw new RangeError(`"url" contains a malformed percent-escape: ${t}`)}if(e.includes("%")||e.includes("\\"))throw new RangeError(`"url" must not contain ".." or encoded segments: ${t}`);for(const o of e.split("/"))if(o===".."||o===".")throw new RangeError(`"url" must not contain ".." or encoded segments: ${t}`)},E=n=>{let t=n.trim().replaceAll("\\","/");if(t.startsWith("http://")||t.startsWith("https://")){const e=t.slice(t.indexOf("//")+2),o=e.indexOf("/");t=o===-1?"/":e.slice(o)}for(const e of["?","#"]){const o=t.indexOf(e);o!==-1&&(t=t.slice(0,o))}for(;t.endsWith("/")&&t.length>1;)t=t.slice(0,-1);return t.startsWith("/")||(t=t.startsWith("docs/")?`/${t}`:`/${h}/${t}`),S(t,n),t},y=n=>[{definition:u,handle:async t=>{const e=c(t,"query"),o=f(t.limit),i=(await n.search(e)).slice(0,o);return i.length===0?r({hits:[],note:`no documentation matched "${e}" — try fewer or more general terms, or lunora_list_docs to browse`}):r({hits:i})}},{definition:l,handle:async t=>{const e=E(c(t,"url")),o=await n.getPage(e);return o===void 0?p(`documentation page not found: ${e}. Use lunora_search_docs or lunora_list_docs to find a valid url.`):{content:[{text:`# ${o.title} (${o.url})
2
+
3
+ ${o.content}`,type:"text"}]}}},{definition:d,handle:async()=>{const t=await n.listPages();return t.length>500?r({note:`showing the first ${String(500)} of ${String(t.length)} pages — use lunora_search_docs to find the rest`,pages:t.slice(0,500)}):r(t)}}];export{T as DEFAULT_SEARCH_LIMIT,L as DOCS_TOOL_DEFINITIONS,A as MAX_SEARCH_LIMIT,y as docsTools,E as normalizeDocUrl};
@@ -0,0 +1 @@
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-C35UQ5Fo.mjs";import{docsTools as c}from"./DEFAULT_SEARCH_LIMIT-B8C5JM2y.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};
@@ -0,0 +1,3 @@
1
+ import{normalizeDocUrl as s}from"./DEFAULT_SEARCH_LIMIT-B8C5JM2y.mjs";const e="lunora-docs:",n=t=>`${e}${t}`,c=t=>t.startsWith(e)?t.slice(e.length):void 0,d=t=>({list:async()=>(await t.listPages()).map(o=>({...o.description===void 0?{}:{description:o.description},mimeType:"text/markdown",name:o.title,uri:n(o.url)})),read:async i=>{const o=c(i);if(o===void 0)return;const r=await t.getPage(s(o));return r===void 0?void 0:{mimeType:"text/markdown",text:`# ${r.title} (${r.url})
2
+
3
+ ${r.content}`}}});export{e as DOCS_URI_SCHEME,d as docsResources,c as fromDocsUri,n as toDocsUri};
@@ -0,0 +1 @@
1
+ import{LunoraClient as f}from"@lunora/client";import{StdioServerTransport as m}from"@modelcontextprotocol/sdk/server/stdio.js";import{e as p}from"./promise-memo-OqVPWoUX.mjs";import{createToolServer as v}from"./createToolServer-BtGuPyMU.mjs";import{createRemoteDocsIndex as h}from"./DEFAULT_DOCS_BASE_URL-CiHy_Dbz.mjs";import{docsResources as E}from"./DOCS_URI_SCHEME-C35UQ5Fo.mjs";import{docsTools as y}from"./DEFAULT_SEARCH_LIMIT-B8C5JM2y.mjs";import{E as R,a as O,t as T,b as _,c as S}from"./tools-BOfWz78m.mjs";const l=e=>e.docs===!1?void 0:h({...e.docs?.baseUrl===void 0?{}:{baseUrl:e.docs.baseUrl},...e.fetch===void 0?{}:{fetch:e.fetch}}),P="lunora",C="no Lunora dev server is running for this project — start one with `lunora dev`, then call this tool again (call lunora_dev_status to check).",g=8,d=e=>{const n=new Map;return t=>{const r=JSON.stringify([t.url,t.token??""]),c=n.get(r);if(c!==void 0)return c;const o=new f({fetch:e,url:t.url});return t.token!==void 0&&t.token.length>0&&o.setAuthToken(t.token),p(n,g),n.set(r,o),o}},i=e=>e?.token!==void 0&&e.token.length>0,A=(e,n,t)=>{const r=typeof e=="function"?e:()=>e;return T(n,i(r())).filter(c=>!_.has(c.name)).map(c=>({definition:c,handle:async o=>{const s=r();return s===void 0?{content:[{text:C,type:"text"}],isError:!0}:S(t(s),c.name,o,n,i(s))}}))},I=()=>R.map(e=>({definition:e,handle:n=>Promise.resolve(O(e.name,n))})),N="lunora-spec:openrpc",k="lunora-spec:openapi",a=[{description:"The deployment's generated OpenRPC 1.x document — every RPC function's path, kind, and argument schema in one read, instead of list_functions plus one get_function_schema call per function.",fetch:async e=>e.fetchOpenRpc(),name:"OpenRPC specification",uri:N},{description:"The deployment's generated OpenAPI 3.1 document.",fetch:async e=>e.fetchOpenApi(),name:"OpenAPI specification",uri:k}],w=(e,n)=>{const t=typeof e=="function"?e:()=>e,r=async c=>{const o=t();if(o!==void 0)try{return await c.fetch(n(o))}catch{return}};return{list:async()=>(await Promise.all(a.map(async o=>await r(o)===void 0?void 0:{description:o.description,mimeType:"application/json",name:o.name,uri:o.uri}))).filter(o=>o!==void 0),read:async c=>{const o=a.find(u=>u.uri===c);if(o===void 0)return;const s=await r(o);return s===void 0?void 0:{mimeType:"application/json",text:JSON.stringify(s,void 0,2)}}}},x=e=>({list:async()=>(await Promise.all(e.map(async t=>t.list()))).flat(),read:async n=>{for(const t of e){const r=await t.read(n);if(r!==void 0)return r}}}),L=(e,n)=>{const t=[],r=l(e);return r!==void 0&&t.push(...y(r)),t.push(...e.extraTools??[],...I()),e.deployment!==void 0&&t.push(...A(e.deployment,e.allowWrites??!1,n??d(e.fetch))),t},U=(e={})=>{const n=l(e),t=[];n!==void 0&&t.push(E(n));const r=d(e.fetch);return e.deployment!==void 0&&t.push(w(e.deployment,r)),v({name:P,version:e.version??"0.0.0"},L(e,r),t.length===0?void 0:x(t))},H=async(e={})=>{const n=U(e);return await n.connect(new m),n};export{P as LOCAL_SERVER_NAME,C as NO_DEPLOYMENT_MESSAGE,k as OPENAPI_RESOURCE_URI,N as OPENRPC_RESOURCE_URI,H as connectLocalStdio,U as createLocalMcpServer,L as localTools};
@@ -0,0 +1 @@
1
+ import{D as T,M as a,O as L,b as s,c as _}from"./observability-tools-D4Z8dGS-.mjs";export{T as DEFAULT_LIMIT,a as MAX_LIMIT,L as OBSERVABILITY_TOOL_DEFINITIONS,s as OBSERVABILITY_TOOL_NAMES,_ as callObservabilityTool};
@@ -0,0 +1 @@
1
+ import{D as T,O as E,R as _,e as s,S as o,W as a,d as S,c as D,s as N,t as A}from"./tools-BOfWz78m.mjs";import{O as L}from"./observability-tools-D4Z8dGS-.mjs";export{T as DATA_READ_SCOPE,E as OBSERVABILITY_SCOPE,L as OBSERVABILITY_TOOL_DEFINITIONS,_ as READ_ONLY_TOOL_DEFINITIONS,s as ROW_READ_TOOL_DEFINITIONS,o as SCOPED_GATES,a as WRITE_TOOL_DEFINITIONS,S as WRITE_TOOL_NAMES,D as callTool,N as scopeForTool,A as toolDefinitions};