@absolutejs/mcp 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.14.0 — 2026-09-11
10
+
11
+ ### Added
12
+
13
+ - **Add explicit credit-budget envelopes for durable prepaid MCP work**
14
+
9
15
  ## 0.13.0 — 2026-09-11
10
16
 
11
17
  ### Added
package/README.md CHANGED
@@ -423,3 +423,7 @@ deployments can route discovery through `@absolutejs/egress`.
423
423
 
424
424
  Business Source License 1.1 — see [LICENSE](./LICENSE). Converts to Apache 2.0
425
425
  on the Change Date.
426
+
427
+ ### Budgeted prepaid work
428
+
429
+ `budgetedMcpTool({ tool, execute })` adds a stable work ID, an explicit maximum-credit budget, and a `paid_access` commerce requirement. The executor must bind the account and use durable claims and settlement (for example `@absolutejs/billing/credit-work`). Only wrap tools whose effects and metering finish inside the execution scope. Deferred jobs need a durable budget handoff. Task-required, authorization-mapped, and already commerce-tagged tools are rejected rather than silently changing their enforcement contracts.
package/changelog.json CHANGED
@@ -2,6 +2,16 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/mcp",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "added",
9
+ "summary": "Add explicit credit-budget envelopes for durable prepaid MCP work"
10
+ }
11
+ ],
12
+ "date": "2026-09-11",
13
+ "version": "0.14.0"
14
+ },
5
15
  {
6
16
  "changes": [
7
17
  {
package/dist/index.js CHANGED
@@ -1964,12 +1964,50 @@ var createPostgresMcpSessionStore = ({
1964
1964
  }
1965
1965
  };
1966
1966
  };
1967
+ // src/budgetedTool.ts
1968
+ var budgetedMcpTool = (options) => {
1969
+ const { tool } = options;
1970
+ if (tool.authorization || tool.commerce || tool.coaz || tool.taskSupport === "required")
1971
+ throw new Error("Budget wrapping needs an ordinary tool; preserve its authorization and commerce contract separately");
1972
+ return {
1973
+ ...tool,
1974
+ annotations: { ...tool.annotations, readOnlyHint: false },
1975
+ outputSchema: undefined,
1976
+ commerce: { action: "paid_access", categories: ["usage_credits"] },
1977
+ taskSupport: "forbidden",
1978
+ description: `${tool.description}
1979
+ Provide a stable requestId and the maximum service credits this work may charge. Retry with the same ID and exact input to retrieve existing work; never invent a new ID to retry an uncertain effect.`,
1980
+ inputSchema: {
1981
+ type: "object",
1982
+ additionalProperties: false,
1983
+ required: ["requestId", "maxCredits", "input"],
1984
+ properties: {
1985
+ requestId: { type: "string", minLength: 1, maxLength: 128 },
1986
+ maxCredits: {
1987
+ type: "integer",
1988
+ minimum: 1,
1989
+ maximum: Number.MAX_SAFE_INTEGER
1990
+ },
1991
+ input: tool.inputSchema
1992
+ }
1993
+ },
1994
+ handler: async (args, context) => {
1995
+ if (args === null || typeof args !== "object" || Array.isArray(args))
1996
+ throw new Error("Invalid credit work request");
1997
+ const { requestId, maxCredits, input } = args;
1998
+ if (typeof requestId !== "string" || !requestId || requestId.length > 128 || typeof maxCredits !== "number" || !Number.isSafeInteger(maxCredits) || maxCredits < 1 || !("input" in args))
1999
+ throw new Error("A request ID, positive credit budget, and input are required");
2000
+ return options.execute({ requestId, maxCredits, input }, async () => tool.handler(input, context));
2001
+ }
2002
+ };
2003
+ };
1967
2004
  export {
1968
2005
  COMMERCE_POLICY_SOURCES,
1969
2006
  COMMERCE_POLICY_VERSION,
1970
2007
  FEEDBACK_INSTRUCTIONS,
1971
2008
  MCP_LATEST_PROTOCOL_VERSION,
1972
2009
  McpClientError,
2010
+ budgetedMcpTool,
1973
2011
  createCreditBalanceTool,
1974
2012
  createMcpAuthorizationRequest,
1975
2013
  createMcpClient,
package/dist/manifest.js CHANGED
@@ -2861,9 +2861,7 @@ var manifest = defineManifest()({
2861
2861
  tagline: "Let AI assistants connect to your site and use its tools."
2862
2862
  },
2863
2863
  requires: {
2864
- peers: [
2865
- { name: "elysia", range: "^2.0.0-beta.6", reason: "plugin host" }
2866
- ]
2864
+ peers: [{ name: "elysia", range: "^2.0.0-beta.6", reason: "plugin host" }]
2867
2865
  },
2868
2866
  settings: Type.Object({
2869
2867
  instructions: Type.Optional(Type.String({
@@ -0,0 +1,13 @@
1
+ import type { McpTool, McpToolReturn } from "./types";
2
+ export type McpCreditWorkRequest = {
3
+ requestId: string;
4
+ maxCredits: number;
5
+ input: unknown;
6
+ };
7
+ /** Wrap a synchronous tool with an explicit per-work credit budget. The executor
8
+ * must bind the caller, claim durable work, track usage, and persist its result.
9
+ * Do not wrap deferred jobs without transferring their budget to the worker. */
10
+ export declare const budgetedMcpTool: (options: {
11
+ tool: McpTool;
12
+ execute: (request: McpCreditWorkRequest, run: () => Promise<McpToolReturn>) => Promise<McpToolReturn>;
13
+ }) => McpTool;
@@ -44,3 +44,4 @@ export { createPostgresMcpSessionStore, createPostgresMcpTaskStore, mcpPostgresS
44
44
  export type { McpAgencyOptions, McpAudioContent, McpElicitAnswer, McpElicitationRequest, McpElicitBus, McpElicitResult, McpFormElicitationRequest, McpSessionStore, McpAuthResult, McpCallGate, McpCallMeta, McpContent, McpImageContent, McpPromptArgument, McpPromptDefinition, McpPrompts, McpResource, McpResourceLink, McpResources, McpServerConfig, McpServerInfo, McpTextContent, McpTask, McpTaskStatus, McpTaskStore, McpTasksOptions, McpTool, McpToolAnnotations, McpToolCallContext, McpToolContext, McpToolRegistry, McpToolResult, McpToolReturn, McpUrlElicitationRequest, } from "./types";
45
45
  export * from "./commerce";
46
46
  export { createCreditBalanceTool, type McpCreditBalance } from "./creditStatus";
47
+ export { budgetedMcpTool, type McpCreditWorkRequest } from "./budgetedTool";
package/package.json CHANGED
@@ -72,5 +72,5 @@
72
72
  "prepublishOnly": "bun run check:package"
73
73
  },
74
74
  "types": "./dist/src/index.d.ts",
75
- "version": "0.13.0"
75
+ "version": "0.14.0"
76
76
  }