@lunora/mcp 1.0.0-alpha.9 → 1.0.0-alpha.91

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 (30) hide show
  1. package/LICENSE.md +126 -0
  2. package/README.md +139 -9
  3. package/dist/bin.mjs +3 -35
  4. package/dist/docs/index.d.mts +253 -0
  5. package/dist/docs/index.d.ts +253 -0
  6. package/dist/docs/index.mjs +1 -0
  7. package/dist/index.d.mts +434 -14
  8. package/dist/index.d.ts +434 -14
  9. package/dist/index.mjs +1 -2
  10. package/dist/packem_shared/AGENT_RUN_INPUT_SCHEMA-DRSY74ed.mjs +1 -0
  11. package/dist/packem_shared/DEFAULT_DOCS_BASE_URL-CZ3fVsSc.mjs +4 -0
  12. package/dist/packem_shared/DEFAULT_SEARCH_LIMIT-V7pCZ1wt.mjs +3 -0
  13. package/dist/packem_shared/DOCS_SERVER_NAME-BNYVF715.mjs +1 -0
  14. package/dist/packem_shared/DOCS_URI_SCHEME-CFANc3vr.mjs +3 -0
  15. package/dist/packem_shared/LOCAL_SERVER_NAME-CisKTqzv.mjs +1 -0
  16. package/dist/packem_shared/OBSERVABILITY_TOOL_DEFINITIONS-KrCukPbu.mjs +1 -0
  17. package/dist/packem_shared/READ_ONLY_TOOL_DEFINITIONS-DGexf3Tn.mjs +1 -0
  18. package/dist/packem_shared/connectStdio-BCeI0Wqu.mjs +1 -0
  19. package/dist/packem_shared/createAuthedMcpFetchHandler-BUoCjrxu.mjs +1 -0
  20. package/dist/packem_shared/createMcpFetchHandler-TKDnZTGs.mjs +1 -0
  21. package/dist/packem_shared/createPaidMcpServer-DyNwdCq2.mjs +1 -0
  22. package/dist/packem_shared/createToolServer-BtGuPyMU.mjs +1 -0
  23. package/dist/packem_shared/observability-tools-Ce0YK58T.mjs +1 -0
  24. package/dist/packem_shared/serve-stateless.d-B_q8q39X.d.mts +133 -0
  25. package/dist/packem_shared/serve-stateless.d-B_q8q39X.d.ts +133 -0
  26. package/dist/packem_shared/serveStateless-Db7J3pAO.mjs +1 -0
  27. package/dist/packem_shared/toDocsSearchHits-CBLmtWXt.mjs +1 -0
  28. package/package.json +17 -3
  29. package/dist/packem_shared/TOOL_DEFINITIONS-Dpiu38ji.mjs +0 -112
  30. package/dist/packem_shared/connectStdio-C_mvQBs2.mjs +0 -64
package/dist/index.d.mts CHANGED
@@ -1,30 +1,450 @@
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-B_q8q39X.mjs";
3
+ export { type d as McpServerInfo, g as createToolServer, s as serveStateless } from "./packem_shared/serve-stateless.d-B_q8q39X.mjs";
2
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
6
+ import '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js';
7
+ /**
8
+ * The observability tools. Descriptions say WHEN to call the tool, not just
9
+ * what it returns — an agent picking between five similar reads needs the
10
+ * trigger, and it pays for these strings on every turn.
11
+ */
12
+ declare const OBSERVABILITY_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
13
+ /** The read-only tool surface: introspection + query. Always exposed. */
14
+ declare const READ_ONLY_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
15
+ /** The write tool surface (mutations + actions). Exposed ONLY when writes are enabled. */
16
+ declare const WRITE_TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
17
+ /**
18
+ * The tools this server advertises, in three tiers:
19
+ *
20
+ * - the read-only surface, always exposed;
21
+ * - the observability surface, exposed only when an admin token resolved —
22
+ * read-only, but it surfaces production logs and grouped errors, so an
23
+ * unauthenticated server must not even advertise that it exists;
24
+ * - the write surface, exposed only when `allowWrites` is set.
25
+ *
26
+ * Both gates OMIT rather than refuse: an AI agent can't invoke what it can't
27
+ * see. Dispatch re-checks both in {@link callTool}, so the guarantee does not
28
+ * depend on a client honouring the advertised list.
29
+ */
30
+ declare const toolDefinitions: (allowWrites: boolean, hasAdminToken?: boolean) => ReadonlyArray<ToolDefinition>;
31
+ /**
32
+ * Dispatch a tool call against `client`. Unknown tools and thrown errors are
33
+ * returned as `isError` results (rather than rejections) so the calling model
34
+ * sees the failure as tool output, per the MCP convention.
35
+ *
36
+ * `allowWrites` gates the mutation/action tools and `hasAdminToken` gates the
37
+ * observability tools: when either is false a call to the gated tool is refused
38
+ * even if the client somehow names it, so both guarantees hold at dispatch, not
39
+ * just in the advertised tool list.
40
+ */
41
+ declare const callTool: (client: LunoraClient, name: string, input: Record<string, unknown>, allowWrites?: boolean, hasAdminToken?: boolean) => Promise<ToolResult>;
42
+ /**
43
+ * Agent exposure for the MCP server: a durable `@lunora/agent` run fronted as an
44
+ * MCP tool an external agent can call. The capability boundary is the MCP-server
45
+ * process + its token, so WHICH agents are exposed is config on the server (like
46
+ * `allowWrites`), not on `defineAgent` — keeping `@lunora/agent` codegen
47
+ * byte-identical.
48
+ */
49
+ interface McpAgentExposure {
50
+ /** What the agent does — shown to the calling model, which decides from it. */
51
+ description: string;
52
+ /** The agent's export name (its `ctx.agents.<name>` / `AGENT_<NAME>` binding). */
53
+ name: string;
54
+ /** Override the model-facing tool name (default `agent_<name>`). */
55
+ toolName?: string;
56
+ }
57
+ /** The generic status/poll tool advertised alongside the per-agent tools. */
58
+ declare const AGENT_STATUS_TOOL_NAME = "lunora_agent_status";
59
+ /**
60
+ * The uniform input schema every agent tool advertises. Agents share ONE run
61
+ * input (`@lunora/agent` has no per-agent validator), so there is nothing to
62
+ * derive per agent — a single static schema is reused for every agent tool.
63
+ */
64
+ declare const AGENT_RUN_INPUT_SCHEMA: ToolInputSchema;
65
+ /**
66
+ * Parse `LUNORA_MCP_AGENTS` — a `;`-separated list of `name:description` pairs,
67
+ * e.g. `"support:Handles support questions;billing:Billing help"`. The
68
+ * description may itself contain colons (only the FIRST colon splits). Blank
69
+ * entries and entries with an empty name/description are skipped.
70
+ */
71
+ declare const parseAgentsEnv: (raw: string | undefined) => McpAgentExposure[];
72
+ /**
73
+ * The tools this module advertises. Fail-closed: only the boolean `true` opts
74
+ * in (an env-plumbed caller could pass a truthy string), and the tools appear
75
+ * ONLY when at least one agent is exposed — so an agent-free or non-opted-in
76
+ * server never lists them.
77
+ */
78
+ declare const agentToolDefinitions: (exposures: ReadonlyArray<McpAgentExposure>, allowAgents: boolean) => ReadonlyArray<ToolDefinition>;
79
+ /** Options threaded into a single agent tool dispatch. */
80
+ interface CallAgentToolOptions {
81
+ /** Opt-in gate — must be exactly `true` or the call is refused fail-closed. */
82
+ allowAgents: boolean;
83
+ /** The exposures advertised by this server. */
84
+ exposures: ReadonlyArray<McpAgentExposure>;
85
+ /** Wall-clock budget a single call awaits before returning a pending result. */
86
+ maxWaitMs?: number;
87
+ /** Delay between thread-status polls. */
88
+ pollIntervalMs?: number;
89
+ /** Test seam replacing the between-poll wait; production uses a real timer. */
90
+ wait?: (ms: number) => Promise<void>;
91
+ }
92
+ /**
93
+ * Dispatch an agent tool call: start a durable run via `agents:agentRun`, then
94
+ * await-with-timeout — poll `agents:agentThread` until terminal (returning the
95
+ * final answer from `agents:agentMessages`) or, on budget exhaustion, return a
96
+ * NON-error pending payload the caller resumes with `lunora_agent_status`.
97
+ *
98
+ * Fail-closed: refused at dispatch unless `allowAgents === true`, mirroring the
99
+ * `allowWrites` guard — starting a run is a side effect and must not ride the
100
+ * read-only default.
101
+ */
102
+ declare const callAgentTool: (client: LunoraClient, name: string, input: Record<string, unknown>, options: CallAgentToolOptions) => Promise<ToolResult>;
3
103
  interface LunoraMcpServerOptions {
104
+ /** Wall-clock budget a single agent tool call awaits before returning a pending result. */
105
+ agentMaxWaitMs?: number;
106
+ /** Delay between agent thread-status polls. */
107
+ agentPollIntervalMs?: number;
108
+ /** The agents this server fronts as MCP tools (see `allowAgents`). */
109
+ agents?: ReadonlyArray<McpAgentExposure>;
110
+ /**
111
+ * Expose the per-agent tools (`agent_<name>` + the generic
112
+ * `lunora_agent_status`). Defaults to `false`, mirroring `allowWrites`:
113
+ * starting a durable agent run is a side effect, so the agent tools are
114
+ * omitted from the advertised list AND refused at dispatch unless explicitly
115
+ * opted in. Only takes effect together with a non-empty `agents` list.
116
+ */
117
+ allowAgents?: boolean;
118
+ /**
119
+ * Expose the write tools (`lunora_run_mutation` / `lunora_run_action`).
120
+ * Defaults to `false`: the server is READ-ONLY unless explicitly opted in,
121
+ * so a prompt-injected or misaligned agent can't mutate the deployment with
122
+ * the configured token. When false the write tools are omitted from the
123
+ * advertised tool list AND refused at dispatch.
124
+ */
125
+ allowWrites?: boolean;
126
+ /**
127
+ * Pre-built client (test injection). When omitted a `LunoraClient` is
128
+ * created from `url`/`token`/`fetch`.
129
+ */
4
130
  client?: LunoraClient;
131
+ /** `fetch` implementation; defaults to the ambient global. */
5
132
  fetch?: typeof fetch;
133
+ /**
134
+ * Bearer token sent on every RPC. This must be the deployment's **admin
135
+ * bearer**: the introspection/allowlist path every tool depends on
136
+ * (`lunora_list_functions`, `lunora_list_tables`, and the `assertRunnable`
137
+ * precheck that runs before every `run` tool) hits admin-gated
138
+ * `/_lunora/admin/*` routes, so no scoped/app token works today — it would
139
+ * 403 (`ADMIN_FORBIDDEN`) on the first tool call. The read-only guarantee is
140
+ * therefore NOT enforced by the token's scope; it is enforced in-process via
141
+ * `allowWrites: false` (the default), which omits the write tools from the
142
+ * advertised list and refuses them at dispatch.
143
+ *
144
+ * Its presence is also what gates the observability tools (logs, Issues,
145
+ * advisories, query insights, migration status): without a token they are
146
+ * omitted from `ListTools` and refused at dispatch.
147
+ */
6
148
  token?: string;
149
+ /** Base URL of the deployed Lunora Worker. Required unless `client` is given. */
7
150
  url?: string;
8
151
  }
152
+ /**
153
+ * Build an MCP `Server` whose tools talk to a Lunora deployment. The server is
154
+ * transport-agnostic — call `.connect(transport)` yourself, or use
155
+ * `connectStdio` for the common stdio case.
156
+ *
157
+ * Tool calls are dispatched through `callTool`, which the deployment reaches
158
+ * over HTTP RPC. No WebSocket is opened (the tools never subscribe), so this is
159
+ * safe to run as a short-lived stdio process.
160
+ */
9
161
  declare const createLunoraMcpServer: (options: LunoraMcpServerOptions) => Server;
162
+ /**
163
+ * Build the server and connect it over stdio — the transport MCP clients use
164
+ * when they spawn the `lunora-mcp` binary. Resolves once the transport is
165
+ * connected; the process then stays alive serving requests.
166
+ */
10
167
  declare const connectStdio: (options: LunoraMcpServerOptions) => Promise<Server>;
11
- interface ToolInputSchema {
12
- properties: Record<string, unknown>;
13
- required?: ReadonlyArray<string>;
14
- type: "object";
168
+ /**
169
+ * The verified access-token payload better-auth hands a protected handler.
170
+ *
171
+ * A JWT payload is an open bag of claims, so this is deliberately an index
172
+ * signature with the two entries this module reads named. It is structurally
173
+ * satisfied by `jose`'s `JWTPayload`, which is what better-auth passes.
174
+ */
175
+ interface McpAccessTokenClaims {
176
+ readonly [claim: string]: unknown;
177
+ /** Space-delimited granted scopes (RFC 6749 §3.3). */
178
+ readonly scope?: unknown;
179
+ /** Subject — the user the token was issued for. */
180
+ readonly sub?: string;
181
+ }
182
+ /**
183
+ * The MCP auth gate: wraps a claims-aware handler into a plain fetch handler.
184
+ *
185
+ * Declared structurally here rather than imported from `@better-auth/mcp`,
186
+ * following the same rule `./paid` follows for `@lunora/x402`: a type import
187
+ * from a package this one does not depend on puts that package's `.d.ts` into
188
+ * the build graph, and a consumer that never installs it never builds it
189
+ * either — so the dts bundler looks for a `dist/` that does not exist and fails
190
+ * the build. Structural typing costs nothing here because this module never
191
+ * inspects the gate; it only applies it.
192
+ *
193
+ * Both better-auth entry points partially apply to this shape:
194
+ * `(handler) => requireMcpAuth(auth, handler, opts)` and
195
+ * `(handler) => createMcpProtectedRequestHandler(options, handler)`.
196
+ */
197
+ type McpAuthProtect = (handler: (request: Request, claims: McpAccessTokenClaims) => Promise<Response>) => McpFetchHandler;
198
+ /** Server options, or a function deriving them from the request's verified claims. */
199
+ type AuthedMcpServerOptions = ((claims: McpAccessTokenClaims) => LunoraMcpServerOptions | Promise<LunoraMcpServerOptions>) | LunoraMcpServerOptions;
200
+ interface AuthedMcpFetchHandlerOptions {
201
+ /**
202
+ * The OAuth gate to mount the MCP server behind. Pass
203
+ * `(handler) => requireMcpAuth(auth, handler, opts)` from
204
+ * `@lunora/auth/plugins`.
205
+ */
206
+ protect: McpAuthProtect;
207
+ /**
208
+ * The Lunora MCP server to serve once a request is authorized — either a
209
+ * fixed options object, or a function of the verified token claims so tool
210
+ * exposure can follow the scopes the token actually carries.
211
+ */
212
+ server: AuthedMcpServerOptions;
213
+ }
214
+ /**
215
+ * Parse an access token's `scope` claim into a set.
216
+ *
217
+ * RFC 6749 §3.3 makes `scope` a space-delimited string, and better-auth issues
218
+ * it that way; anything else (absent, or a non-string an extension wrote)
219
+ * yields an empty set rather than throwing, so a scope check on a malformed
220
+ * token denies instead of crashing the tool call.
221
+ */
222
+ declare const mcpTokenScopes: (claims: McpAccessTokenClaims) => ReadonlySet<string>;
223
+ /**
224
+ * Build an OAuth-protected stateless Streamable-HTTP fetch handler for a Lunora
225
+ * MCP server.
226
+ *
227
+ * Unauthenticated requests never reach the MCP server at all: `protect` answers
228
+ * them with the RFC 9728 `WWW-Authenticate` challenge that starts the client's
229
+ * authorization flow. An authorized request builds a fresh proxy server from
230
+ * `server` (resolved against the verified claims) and serves it through
231
+ * {@link serveStateless}, exactly as the unprotected `createMcpFetchHandler`
232
+ * does — the transport behaviour is identical, only the gate is new.
233
+ */
234
+ declare const createAuthedMcpFetchHandler: (options: AuthedMcpFetchHandlerOptions) => McpFetchHandler;
235
+ /**
236
+ * Build a stateless Streamable-HTTP fetch handler for a Lunora MCP server. Each
237
+ * invocation constructs a fresh proxy server and serves the request through
238
+ * {@link serveStateless}.
239
+ */
240
+ declare const createMcpFetchHandler: (options: LunoraMcpServerOptions) => McpFetchHandler;
241
+ /** A Lunora deployment the tools dispatch against. */
242
+ interface LocalDeployment {
243
+ token?: string;
244
+ url: string;
245
+ }
246
+ /**
247
+ * Where the deployment comes from: a fixed value, or a function consulted on
248
+ * every tool call.
249
+ *
250
+ * The resolver form exists because an editor spawns this server when the
251
+ * project opens — routinely *before* `lunora dev` is running, and it keeps the
252
+ * process alive across every restart afterwards. A URL captured once at startup
253
+ * would therefore be absent for the entire first session and stale after the
254
+ * first restart.
255
+ */
256
+ type LocalDeploymentSource = (() => LocalDeployment | undefined) | LocalDeployment;
257
+ interface LocalMcpServerOptions {
258
+ /**
259
+ * Expose the deployment write tools (`lunora_run_mutation` /
260
+ * `lunora_run_action`). Defaults to `false` — the same fail-closed default
261
+ * as the remote server. Locally the blast radius is dev data rather than
262
+ * production, but a mutation is still a side effect an agent should be
263
+ * granted deliberately.
264
+ */
265
+ allowWrites?: boolean;
266
+ /**
267
+ * The Lunora deployment (usually the running dev server) to expose. Omit to
268
+ * leave the deployment tools out entirely.
269
+ */
270
+ deployment?: LocalDeploymentSource;
271
+ /** Docs site origin backing the documentation tools; `false` omits them. */
272
+ docs?: false | {
273
+ baseUrl?: string;
274
+ };
275
+ /** Extra tools to compose in, e.g. the CLI's local dev-server tools. */
276
+ extraTools?: ReadonlyArray<McpTool>;
277
+ /** `fetch` implementation; defaults to the ambient global. */
278
+ fetch?: typeof fetch;
279
+ /** Version reported in the MCP handshake — the host CLI's, not this package's. */
280
+ version?: string;
15
281
  }
16
- interface ToolDefinition {
282
+ /** Server identity advertised in the MCP `initialize` handshake. */
283
+ declare const LOCAL_SERVER_NAME = "lunora";
284
+ /** Shown when a deployment tool is called and no dev server can be found. */
285
+ 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).";
286
+ /**
287
+ * Assemble the tool list, in the order it is advertised: docs first (the
288
+ * surface that always works), then the caller's extras, then the deployment
289
+ * tools. Order also decides precedence — `createToolServer` keeps the first
290
+ * registration of a duplicated name.
291
+ *
292
+ * `clientFor` is the shared client cache built once by
293
+ * {@link createLocalMcpServer} and threaded into both the tool and resource
294
+ * surfaces. Exported (and called directly by tests) without going through
295
+ * `createLocalMcpServer`, so a caller that omits it gets a private,
296
+ * call-scoped cache — same shape as before this surface was shared, just
297
+ * without the cross-surface sharing that only matters once a resource
298
+ * surface exists alongside it.
299
+ */
300
+ declare const localTools: (options: LocalMcpServerOptions, clientFor?: (deployment: LocalDeployment) => LunoraClient) => ReadonlyArray<McpTool>;
301
+ /** Build the composed local server without connecting a transport. */
302
+ declare const createLocalMcpServer: (options?: LocalMcpServerOptions) => Server;
303
+ /**
304
+ * Build the composed local server and connect it over stdio — the transport an
305
+ * MCP client uses when it spawns `lunora mcp serve`. Resolves once connected;
306
+ * the process then stays alive serving requests.
307
+ */
308
+ declare const connectLocalStdio: (options?: LocalMcpServerOptions) => Promise<Server>;
309
+ /** A tool handler: receives the call's `arguments` bag, returns an MCP tool result. */
310
+ /**
311
+ * The x402 vocabulary this module needs, declared here rather than imported.
312
+ *
313
+ * The x402 package is an optional peer, and a type import from its `charge`
314
+ * entry puts its `.d.ts` back into this package's build graph:
315
+ * a consumer that never installs x402 never builds it either, so the dts bundler
316
+ * looks for a `dist/` that does not exist and fails. That is not hypothetical —
317
+ * it broke the docs site build, which runs a filtered build over the docs app and its dependency closure
318
+ * and therefore never builds x402.
319
+ *
320
+ * Declaring them locally is safe because this module never *inspects* a charge
321
+ * config; it forwards it whole to `createChargeMiddleware`. The index signature
322
+ * keeps a real charge config assignable as x402 grows fields.
323
+ */
324
+ /** Mirrors x402's `X402Price` — a decimal string like `"$0.05"`, or a number. */
325
+ type X402Price = number | string;
326
+ /** Mirrors x402's charge config with the per-tool price omitted. */
327
+ interface X402ChargeSettings {
328
+ /** Network this resource settles on. */
329
+ readonly network: string;
330
+ /** Everything else x402 accepts, forwarded untouched. */
331
+ readonly [key: string]: unknown;
332
+ /** Payout wallet(s), per network family. */
333
+ readonly recipient: {
334
+ readonly evm?: string;
335
+ readonly svm?: string;
336
+ };
337
+ }
338
+ type ToolHandler = (arguments_: Record<string, unknown>) => Promise<ToolResult> | ToolResult;
339
+ /** Registration shape for a free tool. */
340
+ interface RegisterToolOptions {
341
+ /** Optional MCP tool annotations (`readOnlyHint`, `title`, …). */
342
+ annotations?: Tool["annotations"];
343
+ /** Human/model-facing description of what the tool does. */
17
344
  description: string;
345
+ /** JSON-Schema object describing the tool's arguments. */
18
346
  inputSchema: ToolInputSchema;
347
+ /** Unique tool name (the MCP `tools/call` `name`). */
19
348
  name: string;
20
349
  }
21
- interface ToolResult {
22
- content: {
23
- text: string;
24
- type: "text";
25
- }[];
26
- isError?: boolean;
350
+ /** Registration shape for a paid tool: a {@link RegisterToolOptions} plus its USD price. */
351
+ interface RegisterPaidToolOptions extends RegisterToolOptions {
352
+ /** USD price per call (e.g. `"$0.05"`), charged via x402 before dispatch. */
353
+ price: X402Price;
354
+ }
355
+ /** x402 settlement vocabulary shared by every paid tool (network, recipient, facilitator); price is per-tool. */
356
+ type PaidMcpChargeConfig = X402ChargeSettings;
357
+ /** Config for `createPaidMcpServer`. */
358
+ interface PaidMcpServerConfig {
359
+ /** The worker-level x402 charge config; each paid tool supplies only its own `price`. */
360
+ charge: PaidMcpChargeConfig;
361
+ /** Name/version advertised in the MCP `initialize` handshake. Defaults to `lunora-paid-mcp`. */
362
+ serverInfo?: {
363
+ name: string;
364
+ version: string;
365
+ };
366
+ }
367
+ /** A paid MCP server: register free/paid tools, then serve over Streamable HTTP. */
368
+ interface PaidMcpServer {
369
+ /** The Streamable-HTTP fetch handler; gates each paid `tools/call` behind x402. */
370
+ readonly fetchHandler: McpFetchHandler;
371
+ /** Register a **paid** tool: its dispatch runs the x402 charge middleware first. */
372
+ paidTool: (options: RegisterPaidToolOptions, handler: ToolHandler) => void;
373
+ /** Register a **free** tool (coexists with paid tools on the same server). */
374
+ tool: (options: RegisterToolOptions, handler: ToolHandler) => void;
27
375
  }
28
- declare const TOOL_DEFINITIONS: ReadonlyArray<ToolDefinition>;
29
- declare const callTool: (client: LunoraClient, name: string, input: Record<string, unknown>) => Promise<ToolResult>;
30
- export { type LunoraMcpServerOptions, TOOL_DEFINITIONS, type ToolDefinition, type ToolInputSchema, type ToolResult, callTool, connectStdio, createLunoraMcpServer };
376
+ /**
377
+ * Create a paid MCP server. Register free tools with `tool()` and priced tools
378
+ * with `paidTool()` (they coexist), then serve `fetchHandler` over HTTP.
379
+ *
380
+ * The server is **stateless**: `fetchHandler` builds a fresh `Server` per
381
+ * request (reading the live tool registry), so tools registered before the
382
+ * first request are all visible. Each priced tool memoises one initialised
383
+ * `ChargeMiddleware` (keyed by tool name, baking that tool's price and naming
384
+ * the tool as the challenge `resource`); a failed init is not cached, so a
385
+ * transient facilitator outage retries on the next call.
386
+ */
387
+ declare const createPaidMcpServer: (config: PaidMcpServerConfig) => PaidMcpServer;
388
+ export { AGENT_RUN_INPUT_SCHEMA, AGENT_STATUS_TOOL_NAME, type AuthedMcpFetchHandlerOptions, type AuthedMcpServerOptions,
389
+ /**
390
+ * `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
391
+ * a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
392
+ * framework's *documentation* (credential-free, and safe to host publicly).
393
+ *
394
+ * The deployment server: It registers tools for introspecting a deployment
395
+ * (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
396
+ * (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
397
+ * writes are enabled), each backed by `LunoraClient` over HTTP RPC. It also
398
+ * exposes the deployment's observability reads (`lunora_get_logs`,
399
+ * `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
400
+ * `lunora_get_migration_status`) whenever an admin token resolved — read-only,
401
+ * but privileged, so they are omitted entirely without one. The server is
402
+ * read-only by default — the write tools are exposed only when `allowWrites`
403
+ * (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
404
+ * allowlisted against the deployment's discovered public functions. It can also
405
+ * front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
406
+ * (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
407
+ * `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
408
+ * and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
409
+ * server remotely over Streamable HTTP with `createMcpFetchHandler` (a
410
+ * Workers-ready `Request` → `Response` handler), or build a server
411
+ * programmatically with `createLunoraMcpServer` and connect any transport.
412
+ *
413
+ * A remote endpoint is reachable by anyone who knows its URL, and the tools
414
+ * carry the deployment's admin bearer — so for a public deployment use
415
+ * `createAuthedMcpFetchHandler` instead, which mounts the same server behind
416
+ * better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
417
+ * and can scope tool exposure to the access token's own scopes.
418
+ */
419
+ type CallAgentToolOptions, LOCAL_SERVER_NAME, type LocalDeployment, type LocalDeploymentSource, type LocalMcpServerOptions, type LunoraMcpServerOptions, type McpAccessTokenClaims,
420
+ /**
421
+ * `@lunora/mcp` — Model Context Protocol servers for Lunora. This entry exposes
422
+ * a *deployment* to AI agents; the `@lunora/mcp/docs` subpath exposes the
423
+ * framework's *documentation* (credential-free, and safe to host publicly).
424
+ *
425
+ * The deployment server: It registers tools for introspecting a deployment
426
+ * (`lunora_list_functions`, `lunora_list_tables`) and invoking its functions
427
+ * (`lunora_run_query`, plus `lunora_run_mutation` and `lunora_run_action` when
428
+ * writes are enabled), each backed by `LunoraClient` over HTTP RPC. It also
429
+ * exposes the deployment's observability reads (`lunora_get_logs`,
430
+ * `lunora_get_issues`, `lunora_get_advisories`, `lunora_get_query_insights`,
431
+ * `lunora_get_migration_status`) whenever an admin token resolved — read-only,
432
+ * but privileged, so they are omitted entirely without one. The server is
433
+ * read-only by default — the write tools are exposed only when `allowWrites`
434
+ * (or the `LUNORA_MCP_ALLOW_WRITES` env) is set, and every run tool is
435
+ * allowlisted against the deployment's discovered public functions. It can also
436
+ * front durable `@lunora/agent` runs as `agent_<name>` tools when `allowAgents`
437
+ * (or `LUNORA_MCP_ALLOW_AGENTS` + `LUNORA_MCP_AGENTS`) is set. Run the
438
+ * `lunora-mcp` binary (configured via the `LUNORA_URL`, `LUNORA_ADMIN_TOKEN`,
439
+ * and `LUNORA_MCP_ALLOW_WRITES` env vars) for the stdio transport, serve the
440
+ * server remotely over Streamable HTTP with `createMcpFetchHandler` (a
441
+ * Workers-ready `Request` → `Response` handler), or build a server
442
+ * programmatically with `createLunoraMcpServer` and connect any transport.
443
+ *
444
+ * A remote endpoint is reachable by anyone who knows its URL, and the tools
445
+ * carry the deployment's admin bearer — so for a public deployment use
446
+ * `createAuthedMcpFetchHandler` instead, which mounts the same server behind
447
+ * better-auth's MCP OAuth gate (`requireMcpAuth` from `@lunora/auth/plugins`)
448
+ * and can scope tool exposure to the access token's own scopes.
449
+ */
450
+ type McpAgentExposure, type McpAuthProtect, type McpFetchHandler, type McpTool, NO_DEPLOYMENT_MESSAGE, OBSERVABILITY_TOOL_DEFINITIONS, 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, connectLocalStdio, connectStdio, createAuthedMcpFetchHandler, createLocalMcpServer, createLunoraMcpServer, createMcpFetchHandler, createPaidMcpServer, localTools, mcpTokenScopes, parseAgentsEnv, toolDefinitions };