@tabai/sdk 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/_shared/abi.d.ts.map +1 -1
- package/dist/_shared/abi.js +6 -3
- package/dist/_shared/abi.js.map +1 -1
- package/dist/_shared/chains.d.ts +4 -6
- package/dist/_shared/chains.d.ts.map +1 -1
- package/dist/_shared/chains.js +1 -2
- package/dist/_shared/chains.js.map +1 -1
- package/dist/_shared/keccak256.d.ts +6 -6
- package/dist/_shared/keccak256.js +6 -6
- package/dist/_shared/keccak256.js.map +1 -1
- package/dist/_shared/result.d.ts +5 -6
- package/dist/_shared/result.d.ts.map +1 -1
- package/dist/_shared/result.js +5 -6
- package/dist/_shared/result.js.map +1 -1
- package/dist/cli/client-config.d.ts +4 -5
- package/dist/cli/client-config.d.ts.map +1 -1
- package/dist/cli/client-config.js +4 -5
- package/dist/cli/client-config.js.map +1 -1
- package/dist/cli/connect.d.ts +1 -3
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +1 -3
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/doctor.d.ts +1 -3
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +1 -3
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/main.d.ts +1 -3
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +2 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/errors.d.ts +2 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -4
- package/dist/errors.js.map +1 -1
- package/dist/http/client-402.d.ts +11 -13
- package/dist/http/client-402.d.ts.map +1 -1
- package/dist/http/client-402.js +12 -14
- package/dist/http/client-402.js.map +1 -1
- package/dist/http/headers.d.ts +9 -11
- package/dist/http/headers.d.ts.map +1 -1
- package/dist/http/headers.js +9 -11
- package/dist/http/headers.js.map +1 -1
- package/dist/http/index.d.ts +0 -2
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +0 -2
- package/dist/http/index.js.map +1 -1
- package/dist/http/metering-claim.d.ts +0 -2
- package/dist/http/metering-claim.d.ts.map +1 -1
- package/dist/http/metering-claim.js +0 -2
- package/dist/http/metering-claim.js.map +1 -1
- package/dist/index.d.ts +15 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -12
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +1 -4
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +1 -4
- package/dist/logger.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/json-schema.d.ts +1 -3
- package/dist/mcp/json-schema.d.ts.map +1 -1
- package/dist/mcp/json-schema.js +1 -3
- package/dist/mcp/json-schema.js.map +1 -1
- package/dist/mcp/json.d.ts +0 -2
- package/dist/mcp/json.d.ts.map +1 -1
- package/dist/mcp/json.js +0 -2
- package/dist/mcp/json.js.map +1 -1
- package/dist/mcp/registry-client.d.ts +0 -2
- package/dist/mcp/registry-client.d.ts.map +1 -1
- package/dist/mcp/registry-client.js +3 -4
- package/dist/mcp/registry-client.js.map +1 -1
- package/dist/mcp/schemas.d.ts +10 -8
- package/dist/mcp/schemas.d.ts.map +1 -1
- package/dist/mcp/schemas.js +5 -7
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/server.d.ts +0 -2
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +4 -7
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/settings.d.ts +0 -2
- package/dist/mcp/settings.d.ts.map +1 -1
- package/dist/mcp/settings.js +0 -2
- package/dist/mcp/settings.js.map +1 -1
- package/dist/mcp/toolset.d.ts +2 -5
- package/dist/mcp/toolset.d.ts.map +1 -1
- package/dist/mcp/toolset.js +3 -6
- package/dist/mcp/toolset.js.map +1 -1
- package/dist/payments/config.d.ts +6 -8
- package/dist/payments/config.d.ts.map +1 -1
- package/dist/payments/config.js +5 -7
- package/dist/payments/config.js.map +1 -1
- package/dist/payments/index.d.ts +0 -2
- package/dist/payments/index.d.ts.map +1 -1
- package/dist/payments/index.js +0 -2
- package/dist/payments/index.js.map +1 -1
- package/dist/payments/registry.d.ts +11 -12
- package/dist/payments/registry.d.ts.map +1 -1
- package/dist/payments/registry.js +11 -12
- package/dist/payments/registry.js.map +1 -1
- package/dist/payments/strategy.d.ts +9 -5
- package/dist/payments/strategy.d.ts.map +1 -1
- package/dist/payments/strategy.js +9 -5
- package/dist/payments/strategy.js.map +1 -1
- package/dist/proxy/hooks.d.ts +3 -5
- package/dist/proxy/hooks.d.ts.map +1 -1
- package/dist/proxy/hooks.js +2 -4
- package/dist/proxy/hooks.js.map +1 -1
- package/dist/proxy/index.d.ts +2 -2
- package/dist/proxy/index.js +2 -2
- package/dist/proxy/index.js.map +1 -1
- package/dist/proxy/proxy.d.ts +3 -5
- package/dist/proxy/proxy.d.ts.map +1 -1
- package/dist/proxy/proxy.js +2 -4
- package/dist/proxy/proxy.js.map +1 -1
- package/dist/server/adapters/express.d.ts +0 -2
- package/dist/server/adapters/express.d.ts.map +1 -1
- package/dist/server/adapters/express.js +0 -2
- package/dist/server/adapters/express.js.map +1 -1
- package/dist/server/adapters/hono.d.ts +0 -2
- package/dist/server/adapters/hono.d.ts.map +1 -1
- package/dist/server/adapters/hono.js +0 -2
- package/dist/server/adapters/hono.js.map +1 -1
- package/dist/server/adapters/next.d.ts +0 -2
- package/dist/server/adapters/next.d.ts.map +1 -1
- package/dist/server/adapters/next.js +0 -2
- package/dist/server/adapters/next.js.map +1 -1
- package/dist/server/index.d.ts +5 -5
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/metering.d.ts +9 -11
- package/dist/server/metering.d.ts.map +1 -1
- package/dist/server/metering.js +6 -8
- package/dist/server/metering.js.map +1 -1
- package/dist/server/post-paid.d.ts +8 -10
- package/dist/server/post-paid.d.ts.map +1 -1
- package/dist/server/post-paid.js +7 -9
- package/dist/server/post-paid.js.map +1 -1
- package/dist/x402/client.d.ts +5 -6
- package/dist/x402/client.d.ts.map +1 -1
- package/dist/x402/client.js +6 -7
- package/dist/x402/client.js.map +1 -1
- package/dist/x402/server.d.ts +5 -5
- package/dist/x402/server.d.ts.map +1 -1
- package/dist/x402/server.js +2 -2
- package/dist/x402/server.js.map +1 -1
- package/dist/x402/wire.d.ts +1 -1
- package/dist/x402/wire.js +1 -1
- package/dist/x402/wire.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAErE,kGAAkG;AAClG,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,yBAAyB;AACzB,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,yEAAyE;AACzE,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAClD,6FAA6F;AAC7F,eAAO,MAAM,aAAa,+BAA+B,CAAC;AA2B1D;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,UA4B1B,CAAC;AAIF,eAAO,MAAM,kBAAkB,EAAE,gBAuBhC,CAAC;AA8FF,eAAO,MAAM,mBAAmB,EAAE,gBA2CjC,CAAC;AAIF,eAAO,MAAM,cAAc,EAAE,gBAiB5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAiD7B,CAAC;AAIF,eAAO,MAAM,gBAAgB,EAAE,gBAU9B,CAAC;AAmEF,eAAO,MAAM,iBAAiB,EAAE,gBAgB/B,CAAC;AAIF,eAAO,MAAM,gBAAgB,EAAE,gBAiB9B,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAoB/B,CAAC;AAIF,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE;QACpB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;QAC/B,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;QAClC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;QACjC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;KACjC,CAAC;CACH;AASD,eAAO,MAAM,SAAS,EAAE,SAAS,kBAAkB,EA+ClD,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,cAAc,UAAqC,CAAC;AAEjE,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,kBAAkB,GAAG,SACpB,CAAC"}
|
package/dist/mcp/schemas.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The four MCP tools, declared.
|
|
2
|
+
* The four MCP tools, declared.
|
|
3
3
|
*
|
|
4
4
|
* This file is the contract. A model reads these schemas to decide what to send
|
|
5
5
|
* and what it will get back, `tools/list` serves them verbatim, every tool
|
|
6
6
|
* validates its input against the schema here before doing any work, and the
|
|
7
|
-
*
|
|
7
|
+
* test suite validates every output against it. There is one declaration of
|
|
8
8
|
* each shape and it lives here, so the published contract and the enforced
|
|
9
9
|
* contract cannot drift apart.
|
|
10
10
|
*
|
|
@@ -27,12 +27,10 @@
|
|
|
27
27
|
* `tab_settle` additionally carry a required `ok` boolean, because those two
|
|
28
28
|
* change state and "did it happen" is the first thing a caller must read.
|
|
29
29
|
*
|
|
30
|
-
* `LIMIT_EXCEEDED` is the case
|
|
30
|
+
* `LIMIT_EXCEEDED` is the case that matters most: the Agent has no headroom
|
|
31
31
|
* for the Asset, so the tool answers `ok: false` with both `requiredBaseUnits`
|
|
32
32
|
* and `headroomBaseUnits` populated. That is the difference between a model that
|
|
33
|
-
* decides to settle and a model that guesses.
|
|
34
|
-
*
|
|
35
|
-
* Requirements: 21.5, 25.1, 25.2, 25.3, 25.4
|
|
33
|
+
* decides to settle and a model that guesses.
|
|
36
34
|
*/
|
|
37
35
|
/** A `uint256` in decimal, as a string. 78 digits is the ceiling; 39 covers every real amount. */
|
|
38
36
|
export const BASE_UNITS_PATTERN = "^[0-9]{1,39}$";
|
|
@@ -67,7 +65,7 @@ const nullableString = (description) => ({ type: ["string", "null"], description
|
|
|
67
65
|
/**
|
|
68
66
|
* The failure block every tool can return.
|
|
69
67
|
*
|
|
70
|
-
* `category` is the same
|
|
68
|
+
* `category` is the same nine-value vocabulary `../_shared/index.js` uses everywhere
|
|
71
69
|
* else, so a code path that maps a category to an HTTP status on one surface
|
|
72
70
|
* maps it the same way here. `requiredBaseUnits` and `headroomBaseUnits` are
|
|
73
71
|
* present only on `LIMIT_EXCEEDED`.
|
package/dist/mcp/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,kGAAkG;AAClG,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,yBAAyB;AACzB,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,CAAC;AACrD,yEAAyE;AACzE,MA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E,oBAAoB;QAC3B,WAAW,EACT,2KAA2K;QAC7K,WAAW,EAAE,gBAAgB;QAC7B,YAAY,EAAE,iBAAiB;QAC/B,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI;YACrB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF;CACF,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAkC,EAAE,CAC5E,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC","sourcesContent":["/**\n * The four MCP tools, declared. (R25.1, R25.2)\n *\n * This file is the contract. A model reads these schemas to decide what to send\n * and what it will get back, `tools/list` serves them verbatim, every tool\n * validates its input against the schema here before doing any work, and the\n * task 16.3 tests validate every output against it. There is one declaration of\n * each shape and it lives here, so the published contract and the enforced\n * contract cannot drift apart.\n *\n * ## Amounts are decimal strings, never numbers\n *\n * Every field whose name ends in `BaseUnits` is a string of digits matching\n * {@link BASE_UNITS_PATTERN}. A `uint256` does not survive a double: 2^53 base\n * units of a 6-decimal Asset is about 9 billion units of that Asset, which is\n * inside the range a Credit Limit can reach, and a rounded amount that still\n * looks plausible is the worst possible failure for a billing surface. JSON has\n * no integer type wide enough, so the wire form is a string and the boundary\n * converts.\n *\n * ## Failure is a value, not an exception\n *\n * Every output schema carries an optional `error` object of\n * `{ category, code, message }`. Nothing in this package throws across the MCP\n * boundary, so a tool that cannot do its job returns a schema-valid payload\n * whose `error` says why, and the model can act on it. `tab_call` and\n * `tab_settle` additionally carry a required `ok` boolean, because those two\n * change state and \"did it happen\" is the first thing a caller must read.\n *\n * `LIMIT_EXCEEDED` is the case the design singles out: the Agent has no headroom\n * for the Asset, so the tool answers `ok: false` with both `requiredBaseUnits`\n * and `headroomBaseUnits` populated. That is the difference between a model that\n * decides to settle and a model that guesses. (R21.5)\n *\n * Requirements: 21.5, 25.1, 25.2, 25.3, 25.4\n */\n\nimport type { JsonObjectSchema, JsonSchema } from \"./json-schema.js\";\n\n/** A `uint256` in decimal, as a string. 78 digits is the ceiling; 39 covers every real amount. */\nexport const BASE_UNITS_PATTERN = \"^[0-9]{1,39}$\";\n/** A 20-byte address. */\nexport const ADDRESS_PATTERN = \"^0x[a-fA-F0-9]{40}$\";\n/** A 32-byte word: a serviceId, a tool key, a tabId, a settlement id. */\nexport const WORD_PATTERN = \"^0x[a-fA-F0-9]{64}$\";\n/** An Asset named with its network: the decimal EVM chain id, a colon, the token address. */\nexport const ASSET_PATTERN = \"^[0-9]+:0x[a-fA-F0-9]{40}$\";\n\nconst baseUnits = (description: string): JsonSchema => ({\n type: \"string\",\n pattern: BASE_UNITS_PATTERN,\n description,\n});\n\n/**\n * An amount the source may be unable to serve.\n *\n * Null is \"this figure was withheld\", never \"zero\". The registry read API\n * withholds a Credit Limit it could not cross-check against `TabBook` rather\n * than serving an unchecked one, and a zero in its place would read as an Agent\n * with no credit -- the opposite of what a withheld figure means.\n */\nconst nullableBaseUnits = (description: string): JsonSchema => ({\n type: [\"string\", \"null\"],\n pattern: BASE_UNITS_PATTERN,\n description,\n});\n\nconst address = (description: string): JsonSchema => ({ type: \"string\", pattern: ADDRESS_PATTERN, description });\nconst word = (description: string): JsonSchema => ({ type: \"string\", pattern: WORD_PATTERN, description });\nconst assetRef = (description: string): JsonSchema => ({ type: \"string\", pattern: ASSET_PATTERN, description });\nconst nullableString = (description: string): JsonSchema => ({ type: [\"string\", \"null\"], description });\n\n/**\n * The failure block every tool can return.\n *\n * `category` is the same seven-value vocabulary `../_shared/index.js` uses everywhere\n * else, so a code path that maps a category to an HTTP status on one surface\n * maps it the same way here. `requiredBaseUnits` and `headroomBaseUnits` are\n * present only on `LIMIT_EXCEEDED`.\n */\nexport const ERROR_SCHEMA: JsonSchema = {\n type: \"object\",\n description: \"Why the call did not do what was asked. Absent when it did.\",\n properties: {\n category: {\n type: \"string\",\n enum: [\n \"VALIDATION\",\n \"AUTHORISATION\",\n \"NOT_FOUND\",\n \"LIMIT\",\n \"CHAIN\",\n \"UPSTREAM\",\n \"CONFLICT\",\n \"UNAVAILABLE\",\n \"INTERNAL\",\n ],\n description:\n \"The failure class, in the vocabulary the rest of Tab uses. VALIDATION and NOT_FOUND are the caller's to fix; LIMIT means the Credit Limit or the headroom is exhausted.\",\n },\n code: { type: \"string\", description: \"A stable machine-readable code, such as LIMIT_EXCEEDED.\" },\n message: { type: \"string\", description: \"One sentence a model or a person can act on.\" },\n retryable: { type: \"boolean\", description: \"Whether repeating the identical call could succeed.\" },\n requiredBaseUnits: baseUnits(\"LIMIT_EXCEEDED only: what the call needed, in Asset base units.\"),\n headroomBaseUnits: baseUnits(\"LIMIT_EXCEEDED only: what the Agent had, in Asset base units.\"),\n },\n required: [\"category\", \"code\", \"message\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_discover\n\nexport const TAB_DISCOVER_INPUT: JsonObjectSchema = {\n type: \"object\",\n description: \"Filters over the registered Services. Every field is optional; no filter lists everything.\",\n properties: {\n asset: assetRef(\n \"Keep only Services that accept this Asset, as `chainId:tokenAddress`, for example `143:0x7547...b603`.\",\n ),\n tier: {\n type: \"string\",\n enum: [\"curated\", \"permissionless\", \"any\"],\n default: \"any\",\n description:\n \"Curation tier. A Curated Service carries more Credit Limit weight; a Permissionless one is registered and unreviewed.\",\n },\n search: {\n type: \"string\",\n maxLength: 128,\n description: \"Case-insensitive substring matched against the Service name and its serviceId.\",\n },\n limit: { type: \"integer\", minimum: 1, maximum: 100, default: 25, description: \"How many Services to return.\" },\n },\n required: [],\n additionalProperties: false,\n};\n\nconst SERVICE_ASSET_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n chainId: { type: \"integer\", description: \"The EVM chain id: 143 is Monad Mainnet, 10143 is Monad Testnet.\" },\n address: address(\"The token contract on that chain.\"),\n symbol: nullableString(\"Null when this package ships no descriptor for the Asset.\"),\n decimals: { type: [\"integer\", \"null\"], description: \"Null when this package ships no descriptor for the Asset.\" },\n collectionAddress: {\n type: [\"string\", \"null\"],\n pattern: ADDRESS_PATTERN,\n description: \"Where the Service collects Settlements of this Asset. Null when no Tab Collection resolves.\",\n },\n curatedAsset: {\n type: \"boolean\",\n description:\n \"True when this package ships a descriptor for the pair, which is what supplies symbol and decimals. False means the Asset is accepted on chain but unknown here, so its symbol and decimals are null and a caller must not assume six decimals.\",\n },\n },\n required: [\"chainId\", \"address\", \"symbol\", \"decimals\", \"collectionAddress\", \"curatedAsset\"],\n additionalProperties: false,\n};\n\nconst SERVICE_TOOL_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n tool: word(\"The tool key: the tool name, left-aligned and zero-padded to 32 bytes.\"),\n toolName: nullableString(\"The ascii the tool key decodes to, when it decodes to printable ascii.\"),\n asset: assetRef(\"The Asset this price is denominated in.\"),\n priceBaseUnits: baseUnits(\"What one call costs, in Asset base units.\"),\n },\n required: [\"tool\", \"toolName\", \"asset\", \"priceBaseUnits\"],\n additionalProperties: false,\n};\n\nconst SERVICE_BOND_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n asset: assetRef(\"The Asset the stake is denominated in.\"),\n stakedBaseUnits: baseUnits(\"Total Bond staked for this Asset.\"),\n freeBaseUnits: baseUnits(\n \"Stake the Service can still withdraw. It is what caps the credit its history backs.\",\n ),\n },\n required: [\"asset\", \"stakedBaseUnits\", \"freeBaseUnits\"],\n additionalProperties: false,\n};\n\nconst PENDING_CHANGE_SCHEMA: JsonSchema = {\n type: [\"object\", \"null\"],\n description: \"The next queued registry change, or null when nothing is queued.\",\n properties: {\n changeId: word(\"The id the RegistryChangeQueued event reported.\"),\n kind: nullableString(\"Tier, SettlementWindow, ToolPrice, and so on.\"),\n etaIso: nullableString(\"When the timelock lets the change apply.\"),\n },\n required: [\"changeId\", \"kind\", \"etaIso\"],\n additionalProperties: false,\n};\n\nconst HUB_ENDPOINT_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n endpoint: { type: \"string\", description: \"The provider-relative path, for example `/get_current_weather`.\" },\n name: nullableString(\"The Hub's display name for the endpoint.\"),\n description: nullableString(\"What the endpoint does, as the Hub describes it.\"),\n priceType: {\n type: \"string\",\n description: \"How the Hub prices it: PER_CALL, PER_RESULT, PER_UNIT or PER_UNIT_MATRIX. Only PER_CALL has a fixed base-unit price.\",\n },\n priceUsd: nullableString(\"The Hub's decimal USD figure. The metered charge is this plus the fronting Service's margin.\"),\n priceBaseUnits: nullableBaseUnits(\"The USD figure as six-decimal base units, for PER_CALL only. Null otherwise.\"),\n networks: { type: \"array\", items: { type: \"string\" }, description: \"CAIP-2 networks the Hub takes payment on.\" },\n },\n required: [\"endpoint\", \"name\", \"description\", \"priceType\", \"priceUsd\", \"priceBaseUnits\", \"networks\"],\n additionalProperties: false,\n};\n\nconst SERVICE_HUB_SCHEMA: JsonSchema = {\n type: \"object\",\n description:\n \"The API Hub provider this Service fronts, when it fronts one. Each endpoint is called through the Service at `<endpoint>/hub/<prefix><endpoint path>`, paid upstream by the Service and metered onto the Agent's Open Tab for the upstream price plus the Service's margin.\",\n properties: {\n provider: { type: \"string\", description: \"The Hub provider slug.\" },\n prefix: { type: \"string\", description: \"The mount under the Service endpoint: `/hub/<prefix>`.\" },\n endpoints: { type: \"array\", items: HUB_ENDPOINT_SCHEMA },\n total: { type: \"integer\", description: \"How many endpoints the Hub lists for the provider.\" },\n error: ERROR_SCHEMA,\n },\n required: [\"provider\", \"prefix\", \"endpoints\", \"total\"],\n additionalProperties: false,\n};\n\nexport const TAB_DISCOVER_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n services: {\n type: \"array\",\n description: \"The matching Services. Empty on failure, with `error` populated.\",\n items: {\n type: \"object\",\n properties: {\n serviceId: word(\"The Service's 32-byte registry key.\"),\n name: nullableString(\"The ascii the serviceId decodes to, when it decodes to printable ascii.\"),\n endpoint: nullableString(\n \"Where tab_call sends requests. Null when nothing configured one: the chain records no endpoint, so it comes from tab.config or from the server options.\",\n ),\n tier: { type: \"string\", enum: [\"curated\", \"permissionless\", \"unknown\"] },\n settlementWindowSeconds: {\n type: \"integer\",\n description: \"How long after a Metered Delivery the Agent has to settle before the tab is delinquent.\",\n },\n assets: { type: \"array\", items: SERVICE_ASSET_SCHEMA },\n tools: { type: \"array\", items: SERVICE_TOOL_SCHEMA },\n bonds: { type: \"array\", items: SERVICE_BOND_SCHEMA },\n pendingChange: PENDING_CHANGE_SCHEMA,\n hub: SERVICE_HUB_SCHEMA,\n },\n required: [\n \"serviceId\",\n \"name\",\n \"endpoint\",\n \"tier\",\n \"settlementWindowSeconds\",\n \"assets\",\n \"tools\",\n \"bonds\",\n \"pendingChange\",\n ],\n additionalProperties: false,\n },\n },\n error: ERROR_SCHEMA,\n },\n required: [\"services\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_call\n\nexport const TAB_CALL_INPUT: JsonObjectSchema = {\n type: \"object\",\n description: \"Calls one tool on one Service. The call is metered onto the Agent's Open Tab and paid for later.\",\n properties: {\n serviceId: word(\"The Service to call, as reported by tab_discover.\"),\n tool: {\n type: \"string\",\n minLength: 1,\n maxLength: 128,\n description: \"The tool name, for example `quote.generate`. A 32-byte hex word is accepted too.\",\n },\n asset: assetRef(\"Which Asset to meter in. Defaults to the Service's only priced Asset when it has one.\"),\n arguments: { type: \"object\", description: \"The tool's own arguments, passed through untouched.\" },\n timeoutMs: { type: \"integer\", minimum: 1000, maximum: 120000, default: 30000 },\n },\n required: [\"serviceId\", \"tool\"],\n additionalProperties: false,\n};\n\nexport const TAB_CALL_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n ok: { type: \"boolean\", description: \"Whether the Service served the call and it was metered.\" },\n result: { description: \"Whatever the Service returned. Absent when ok is false.\" },\n charge: {\n type: \"object\",\n description: \"What this call cost. Present whenever the Service reported a charge block.\",\n properties: {\n amountBaseUnits: baseUnits(\"Charged when ok is true; required but not charged when ok is false.\"),\n asset: assetRef(\"The Asset the charge is denominated in.\"),\n tool: word(\"The tool key that was metered.\"),\n },\n required: [\"amountBaseUnits\", \"asset\", \"tool\"],\n additionalProperties: false,\n },\n tab: {\n type: \"object\",\n description: \"The Agent's position for this Asset, as the Service reported it on this response.\",\n properties: {\n openTabBaseUnits: baseUnits(\"What the Agent now owes for this Asset.\"),\n headroomBaseUnits: baseUnits(\"What the Agent may still spend before the Credit Limit binds.\"),\n creditLimitBaseUnits: baseUnits(\"The Credit Limit for this Asset, when the response carried one.\"),\n asset: assetRef(\"The Asset these figures are denominated in.\"),\n settlementDueIso: nullableString(\"When the Settlement Window closes on this tab.\"),\n },\n required: [\"openTabBaseUnits\", \"headroomBaseUnits\", \"asset\"],\n additionalProperties: false,\n },\n x402: {\n type: \"object\",\n description:\n \"Present when the Service refused the call on credit and it was prepaid through x402 instead, with the signer tab.config's `x402` factory built. Nothing landed on the Open Tab: the call was paid in full, once, by this transaction.\",\n properties: {\n txHash: { type: \"string\", description: \"The settlement transaction the facilitator broadcast. Empty when it reported none.\" },\n network: { type: \"string\", description: \"The CAIP-2 network it settled on, for example `eip155:10143`.\" },\n amountBaseUnits: baseUnits(\"What was paid, in atomic units of the asset.\"),\n asset: assetRef(\"The token the payment was made in.\"),\n payTo: address(\"Where the funds went: the Service's Collection address.\"),\n payer: address(\"Who signed: the x402 signer's address.\"),\n explorerUrl: nullableString(\"A link to the transaction on the configured explorer.\"),\n },\n required: [\"txHash\", \"network\", \"amountBaseUnits\", \"asset\", \"payTo\", \"payer\", \"explorerUrl\"],\n additionalProperties: false,\n },\n error: ERROR_SCHEMA,\n },\n required: [\"ok\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_status\n\nexport const TAB_STATUS_INPUT: JsonObjectSchema = {\n type: \"object\",\n description: \"The Agent's credit picture: what it owes, what it may still spend, and what has settled.\",\n properties: {\n agent: address(\"The Agent's Monad address. Defaults to the Agent this server is configured for.\"),\n asset: assetRef(\"Report only this Asset. Omitted reports every Asset the Agent has touched.\"),\n historyLimit: { type: \"integer\", minimum: 0, maximum: 200, default: 20 },\n },\n required: [],\n additionalProperties: false,\n};\n\nconst PER_ASSET_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n asset: assetRef(\"The Asset these figures are denominated in.\"),\n creditLimitBaseUnits: nullableBaseUnits(\n \"What this Agent may owe for this Asset at once. Null when the source withheld the figure because it could not cross-check it against TabBook.\",\n ),\n openTabBaseUnits: baseUnits(\"What it owes now.\"),\n prepaidBaseUnits: nullableBaseUnits(\n \"Credit paid in ahead of use, which is drawn on before the Credit Limit. Null when the source serves only cumulative settlement totals and no live balance.\",\n ),\n headroomBaseUnits: nullableBaseUnits(\"What it may still spend. Null whenever the Credit Limit is null.\"),\n delinquent: { type: \"boolean\", description: \"True while a Settlement Window has closed on an unsettled tab.\" },\n tabs: {\n type: \"array\",\n description: \"The tabs behind the figures, newest first, capped by historyLimit.\",\n items: {\n type: \"object\",\n properties: {\n tabId: {\n type: [\"string\", \"null\"],\n pattern: WORD_PATTERN,\n description:\n \"The tab's identity on TabBook. Null when the source reports the observation by Agent, Service and Asset without naming the tab.\",\n },\n serviceId: word(\"The Service the tab is with.\"),\n openBaseUnits: baseUnits(\n \"The Open Tab last observed on this tab. A lower bound: a Metered Delivery raises a tab without an indexed event, so the per-Asset figure above is the one to trust.\",\n ),\n dueIso: nullableString(\"When this tab's Settlement Window closes.\"),\n },\n required: [\"tabId\", \"serviceId\", \"openBaseUnits\", \"dueIso\"],\n additionalProperties: false,\n },\n },\n },\n required: [\n \"asset\",\n \"creditLimitBaseUnits\",\n \"openTabBaseUnits\",\n \"prepaidBaseUnits\",\n \"headroomBaseUnits\",\n \"delinquent\",\n \"tabs\",\n ],\n additionalProperties: false,\n};\n\nconst SETTLEMENT_SCHEMA: JsonSchema = {\n type: \"object\",\n description: \"A Settlement the Agent paid on Monad: the Asset moved to the Service and the Open Tab fell in one transaction.\",\n properties: {\n settlementId: word(\"The Settlement's identity, assigned by TabBook when it was applied.\"),\n txHash: word(\"The Monad transaction that paid it.\"),\n serviceId: word(\"The Service that was paid.\"),\n asset: assetRef(\"The Asset that was paid.\"),\n amountBaseUnits: baseUnits(\"How much was paid.\"),\n appliedBaseUnits: baseUnits(\"How much of it lowered the Open Tab.\"),\n prepaidBaseUnits: baseUnits(\"How much of it was banked as prepaid credit.\"),\n explorerUrl: nullableString(\"The transaction on the Monad explorer.\"),\n },\n required: [\"settlementId\", \"txHash\", \"serviceId\", \"asset\", \"amountBaseUnits\", \"appliedBaseUnits\", \"prepaidBaseUnits\", \"explorerUrl\"],\n additionalProperties: false,\n};\n\nexport const TAB_STATUS_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n agent: address(\"The Agent these figures are about.\"),\n indexedBlock: {\n type: [\"integer\", \"null\"],\n minimum: 0,\n description:\n \"The Monad block every figure is as at. A Settlement sent a moment ago sits in a later block and is not yet reflected; read again after the index passes it. Null when the index has never ticked.\",\n },\n perAsset: { type: \"array\", items: PER_ASSET_SCHEMA },\n settlements: { type: \"array\", items: SETTLEMENT_SCHEMA },\n error: ERROR_SCHEMA,\n },\n required: [\"agent\", \"indexedBlock\", \"perAsset\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_settle\n\nexport const TAB_SETTLE_INPUT: JsonObjectSchema = {\n type: \"object\",\n description:\n \"Pays down an Open Tab by calling TabSettlement.settle on Monad with the Agent's own key. This spends real funds unless dryRun is set.\",\n properties: {\n serviceId: word(\"The Service being paid.\"),\n asset: assetRef(\"The Asset to pay in, as `chainId:tokenAddress`.\"),\n amountBaseUnits: baseUnits(\"How much to pay, in Asset base units.\"),\n strategyId: { type: \"string\", maxLength: 64, description: \"Which registered payment strategy to settle through.\" },\n dryRun: {\n type: \"boolean\",\n default: false,\n description: \"Build and validate the Settlement, report what would be sent, and broadcast nothing.\",\n },\n },\n required: [\"serviceId\", \"asset\", \"amountBaseUnits\"],\n additionalProperties: false,\n};\n\nexport const TAB_SETTLE_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n ok: { type: \"boolean\", description: \"Whether the Settlement was sent, or would have been on a dry run.\" },\n dryRun: { type: \"boolean\", description: \"True when nothing was sent.\" },\n txHash: nullableString(\"The Monad transaction. Null on a dry run and on failure.\"),\n chainId: { type: [\"integer\", \"null\"] },\n amountBaseUnits: baseUnits(\"What was paid, echoed from the request.\"),\n settlementId: {\n type: [\"string\", \"null\"],\n pattern: WORD_PATTERN,\n description: \"The Settlement's identity from the receipt. Null on a dry run, and null when the receipt was not awaited.\",\n },\n appliedBaseUnits: nullableString(\"How much lowered the Open Tab, from the receipt.\"),\n prepaidBaseUnits: nullableString(\"How much was banked as prepaid credit, from the receipt.\"),\n explorerUrl: nullableString(\"The transaction on the Monad explorer.\"),\n error: ERROR_SCHEMA,\n },\n required: [\"ok\", \"dryRun\", \"amountBaseUnits\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- the declaration\n\n/** One tool as `tools/list` serves it. */\nexport interface TabToolDeclaration {\n readonly name: string;\n readonly title: string;\n readonly description: string;\n readonly inputSchema: JsonObjectSchema;\n readonly outputSchema: JsonObjectSchema;\n /** MCP behaviour hints. `tab_settle` is the only tool that is not read-only. */\n readonly annotations: {\n readonly readOnlyHint: boolean;\n readonly destructiveHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n };\n}\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true,\n} as const;\n\nexport const TAB_TOOLS: readonly TabToolDeclaration[] = [\n {\n name: \"tab_discover\",\n title: \"Discover Tab Services\",\n description:\n \"Lists Services registered on Monad, with the Assets each accepts, what each tool costs, and how much stake each has posted. Read-only and keyless. Start here: tab_call needs a serviceId from this list.\",\n inputSchema: TAB_DISCOVER_INPUT,\n outputSchema: TAB_DISCOVER_OUTPUT,\n annotations: READ_ONLY,\n },\n {\n name: \"tab_call\",\n title: \"Call a metered tool\",\n description:\n \"Calls a tool on a Service. Nothing is paid at call time: the charge lands on the Agent's Open Tab and is settled later with tab_settle. When the Agent has no headroom the call returns ok false with code LIMIT_EXCEEDED and both requiredBaseUnits and headroomBaseUnits, which is the signal to settle rather than retry. If tab.config declares an x402 signer and the Service offered x402 on that refusal, the call is prepaid instead and the output carries an x402 block naming the transaction.\",\n inputSchema: TAB_CALL_INPUT,\n outputSchema: TAB_CALL_OUTPUT,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n {\n name: \"tab_status\",\n title: \"Read the Agent's credit picture\",\n description:\n \"Reports the Agent's Credit Limit, Open Tab, prepaid credit and headroom per Asset, plus its recent Settlements. Read-only and keyless.\",\n inputSchema: TAB_STATUS_INPUT,\n outputSchema: TAB_STATUS_OUTPUT,\n annotations: READ_ONLY,\n },\n {\n name: \"tab_settle\",\n title: \"Settle an Open Tab\",\n description:\n \"Pays down an Open Tab by sending a Settlement on Monad with the Agent's own key. This spends real funds. Set dryRun to build and check the Settlement without sending it.\",\n inputSchema: TAB_SETTLE_INPUT,\n outputSchema: TAB_SETTLE_OUTPUT,\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n];\n\n/** The tool names, in the order `tools/list` serves them. */\nexport const TAB_TOOL_NAMES = TAB_TOOLS.map((tool) => tool.name);\n\nexport const tabToolByName = (name: string): TabToolDeclaration | undefined =>\n TAB_TOOLS.find((tool) => tool.name === name);\n"]}
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/mcp/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAIH,kGAAkG;AAClG,MAAM,CAAC,MAAM,kBAAkB,G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B;QAC7B,YAAY,EAAE,iBAAiB;QAC/B,WAAW,EAAE,SAAS;KACvB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EACT,2KAA2K;QAC7K,WAAW,EAAE,gBAAgB;QAC7B,YAAY,EAAE,iBAAiB;QAC/B,WAAW,EAAE;YACX,YAAY,EAAE,KAAK;YACnB,eAAe,EAAE,IAAI;YACrB,cAAc,EAAE,KAAK;YACrB,aAAa,EAAE,IAAI;SACpB;KACF;CACF,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAkC,EAAE,CAC5E,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC","sourcesContent":["/**\n * The four MCP tools, declared.\n *\n * This file is the contract. A model reads these schemas to decide what to send\n * and what it will get back, `tools/list` serves them verbatim, every tool\n * validates its input against the schema here before doing any work, and the\n * test suite validates every output against it. There is one declaration of\n * each shape and it lives here, so the published contract and the enforced\n * contract cannot drift apart.\n *\n * ## Amounts are decimal strings, never numbers\n *\n * Every field whose name ends in `BaseUnits` is a string of digits matching\n * {@link BASE_UNITS_PATTERN}. A `uint256` does not survive a double: 2^53 base\n * units of a 6-decimal Asset is about 9 billion units of that Asset, which is\n * inside the range a Credit Limit can reach, and a rounded amount that still\n * looks plausible is the worst possible failure for a billing surface. JSON has\n * no integer type wide enough, so the wire form is a string and the boundary\n * converts.\n *\n * ## Failure is a value, not an exception\n *\n * Every output schema carries an optional `error` object of\n * `{ category, code, message }`. Nothing in this package throws across the MCP\n * boundary, so a tool that cannot do its job returns a schema-valid payload\n * whose `error` says why, and the model can act on it. `tab_call` and\n * `tab_settle` additionally carry a required `ok` boolean, because those two\n * change state and \"did it happen\" is the first thing a caller must read.\n *\n * `LIMIT_EXCEEDED` is the case that matters most: the Agent has no headroom\n * for the Asset, so the tool answers `ok: false` with both `requiredBaseUnits`\n * and `headroomBaseUnits` populated. That is the difference between a model that\n * decides to settle and a model that guesses.\n */\n\nimport type { JsonObjectSchema, JsonSchema } from \"./json-schema.js\";\n\n/** A `uint256` in decimal, as a string. 78 digits is the ceiling; 39 covers every real amount. */\nexport const BASE_UNITS_PATTERN = \"^[0-9]{1,39}$\";\n/** A 20-byte address. */\nexport const ADDRESS_PATTERN = \"^0x[a-fA-F0-9]{40}$\";\n/** A 32-byte word: a serviceId, a tool key, a tabId, a settlement id. */\nexport const WORD_PATTERN = \"^0x[a-fA-F0-9]{64}$\";\n/** An Asset named with its network: the decimal EVM chain id, a colon, the token address. */\nexport const ASSET_PATTERN = \"^[0-9]+:0x[a-fA-F0-9]{40}$\";\n\nconst baseUnits = (description: string): JsonSchema => ({\n type: \"string\",\n pattern: BASE_UNITS_PATTERN,\n description,\n});\n\n/**\n * An amount the source may be unable to serve.\n *\n * Null is \"this figure was withheld\", never \"zero\". The registry read API\n * withholds a Credit Limit it could not cross-check against `TabBook` rather\n * than serving an unchecked one, and a zero in its place would read as an Agent\n * with no credit -- the opposite of what a withheld figure means.\n */\nconst nullableBaseUnits = (description: string): JsonSchema => ({\n type: [\"string\", \"null\"],\n pattern: BASE_UNITS_PATTERN,\n description,\n});\n\nconst address = (description: string): JsonSchema => ({ type: \"string\", pattern: ADDRESS_PATTERN, description });\nconst word = (description: string): JsonSchema => ({ type: \"string\", pattern: WORD_PATTERN, description });\nconst assetRef = (description: string): JsonSchema => ({ type: \"string\", pattern: ASSET_PATTERN, description });\nconst nullableString = (description: string): JsonSchema => ({ type: [\"string\", \"null\"], description });\n\n/**\n * The failure block every tool can return.\n *\n * `category` is the same nine-value vocabulary `../_shared/index.js` uses everywhere\n * else, so a code path that maps a category to an HTTP status on one surface\n * maps it the same way here. `requiredBaseUnits` and `headroomBaseUnits` are\n * present only on `LIMIT_EXCEEDED`.\n */\nexport const ERROR_SCHEMA: JsonSchema = {\n type: \"object\",\n description: \"Why the call did not do what was asked. Absent when it did.\",\n properties: {\n category: {\n type: \"string\",\n enum: [\n \"VALIDATION\",\n \"AUTHORISATION\",\n \"NOT_FOUND\",\n \"LIMIT\",\n \"CHAIN\",\n \"UPSTREAM\",\n \"CONFLICT\",\n \"UNAVAILABLE\",\n \"INTERNAL\",\n ],\n description:\n \"The failure class, in the vocabulary the rest of Tab uses. VALIDATION and NOT_FOUND are the caller's to fix; LIMIT means the Credit Limit or the headroom is exhausted.\",\n },\n code: { type: \"string\", description: \"A stable machine-readable code, such as LIMIT_EXCEEDED.\" },\n message: { type: \"string\", description: \"One sentence a model or a person can act on.\" },\n retryable: { type: \"boolean\", description: \"Whether repeating the identical call could succeed.\" },\n requiredBaseUnits: baseUnits(\"LIMIT_EXCEEDED only: what the call needed, in Asset base units.\"),\n headroomBaseUnits: baseUnits(\"LIMIT_EXCEEDED only: what the Agent had, in Asset base units.\"),\n },\n required: [\"category\", \"code\", \"message\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_discover\n\nexport const TAB_DISCOVER_INPUT: JsonObjectSchema = {\n type: \"object\",\n description: \"Filters over the registered Services. Every field is optional; no filter lists everything.\",\n properties: {\n asset: assetRef(\n \"Keep only Services that accept this Asset, as `chainId:tokenAddress`, for example `143:0x7547...b603`.\",\n ),\n tier: {\n type: \"string\",\n enum: [\"curated\", \"permissionless\", \"any\"],\n default: \"any\",\n description:\n \"Curation tier. A Curated Service carries more Credit Limit weight; a Permissionless one is registered and unreviewed.\",\n },\n search: {\n type: \"string\",\n maxLength: 128,\n description: \"Case-insensitive substring matched against the Service name and its serviceId.\",\n },\n limit: { type: \"integer\", minimum: 1, maximum: 100, default: 25, description: \"How many Services to return.\" },\n },\n required: [],\n additionalProperties: false,\n};\n\nconst SERVICE_ASSET_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n chainId: { type: \"integer\", description: \"The EVM chain id: 143 is Monad Mainnet, 10143 is Monad Testnet.\" },\n address: address(\"The token contract on that chain.\"),\n symbol: nullableString(\"Null when this package ships no descriptor for the Asset.\"),\n decimals: { type: [\"integer\", \"null\"], description: \"Null when this package ships no descriptor for the Asset.\" },\n collectionAddress: {\n type: [\"string\", \"null\"],\n pattern: ADDRESS_PATTERN,\n description: \"Where the Service collects Settlements of this Asset. Null when no Tab Collection resolves.\",\n },\n curatedAsset: {\n type: \"boolean\",\n description:\n \"True when this package ships a descriptor for the pair, which is what supplies symbol and decimals. False means the Asset is accepted on chain but unknown here, so its symbol and decimals are null and a caller must not assume six decimals.\",\n },\n },\n required: [\"chainId\", \"address\", \"symbol\", \"decimals\", \"collectionAddress\", \"curatedAsset\"],\n additionalProperties: false,\n};\n\nconst SERVICE_TOOL_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n tool: word(\"The tool key: the tool name, left-aligned and zero-padded to 32 bytes.\"),\n toolName: nullableString(\"The ascii the tool key decodes to, when it decodes to printable ascii.\"),\n asset: assetRef(\"The Asset this price is denominated in.\"),\n priceBaseUnits: baseUnits(\"What one call costs, in Asset base units.\"),\n },\n required: [\"tool\", \"toolName\", \"asset\", \"priceBaseUnits\"],\n additionalProperties: false,\n};\n\nconst SERVICE_BOND_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n asset: assetRef(\"The Asset the stake is denominated in.\"),\n stakedBaseUnits: baseUnits(\"Total Bond staked for this Asset.\"),\n freeBaseUnits: baseUnits(\n \"Stake the Service can still withdraw. It is what caps the credit its history backs.\",\n ),\n },\n required: [\"asset\", \"stakedBaseUnits\", \"freeBaseUnits\"],\n additionalProperties: false,\n};\n\nconst PENDING_CHANGE_SCHEMA: JsonSchema = {\n type: [\"object\", \"null\"],\n description: \"The next queued registry change, or null when nothing is queued.\",\n properties: {\n changeId: word(\"The id the RegistryChangeQueued event reported.\"),\n kind: nullableString(\"Tier, SettlementWindow, ToolPrice, and so on.\"),\n etaIso: nullableString(\"When the timelock lets the change apply.\"),\n },\n required: [\"changeId\", \"kind\", \"etaIso\"],\n additionalProperties: false,\n};\n\nconst HUB_ENDPOINT_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n endpoint: { type: \"string\", description: \"The provider-relative path, for example `/get_current_weather`.\" },\n name: nullableString(\"The Hub's display name for the endpoint.\"),\n description: nullableString(\"What the endpoint does, as the Hub describes it.\"),\n priceType: {\n type: \"string\",\n description: \"How the Hub prices it: PER_CALL, PER_RESULT, PER_UNIT or PER_UNIT_MATRIX. Only PER_CALL has a fixed base-unit price.\",\n },\n priceUsd: nullableString(\"The Hub's decimal USD figure. The metered charge is this plus the fronting Service's margin.\"),\n priceBaseUnits: nullableBaseUnits(\"The USD figure as six-decimal base units, for PER_CALL only. Null otherwise.\"),\n networks: { type: \"array\", items: { type: \"string\" }, description: \"CAIP-2 networks the Hub takes payment on.\" },\n },\n required: [\"endpoint\", \"name\", \"description\", \"priceType\", \"priceUsd\", \"priceBaseUnits\", \"networks\"],\n additionalProperties: false,\n};\n\nconst SERVICE_HUB_SCHEMA: JsonSchema = {\n type: \"object\",\n description:\n \"The API Hub provider this Service fronts, when it fronts one. Each endpoint is called through the Service at `<endpoint>/hub/<prefix><endpoint path>`, paid upstream by the Service and metered onto the Agent's Open Tab for the upstream price plus the Service's margin.\",\n properties: {\n provider: { type: \"string\", description: \"The Hub provider slug.\" },\n prefix: { type: \"string\", description: \"The mount under the Service endpoint: `/hub/<prefix>`.\" },\n endpoints: { type: \"array\", items: HUB_ENDPOINT_SCHEMA },\n total: { type: \"integer\", description: \"How many endpoints the Hub lists for the provider.\" },\n error: ERROR_SCHEMA,\n },\n required: [\"provider\", \"prefix\", \"endpoints\", \"total\"],\n additionalProperties: false,\n};\n\nexport const TAB_DISCOVER_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n services: {\n type: \"array\",\n description: \"The matching Services. Empty on failure, with `error` populated.\",\n items: {\n type: \"object\",\n properties: {\n serviceId: word(\"The Service's 32-byte registry key.\"),\n name: nullableString(\"The ascii the serviceId decodes to, when it decodes to printable ascii.\"),\n endpoint: nullableString(\n \"Where tab_call sends requests. Null when nothing configured one: the chain records no endpoint, so it comes from tab.config or from the server options.\",\n ),\n tier: { type: \"string\", enum: [\"curated\", \"permissionless\", \"unknown\"] },\n settlementWindowSeconds: {\n type: \"integer\",\n description: \"How long after a Metered Delivery the Agent has to settle before the tab is delinquent.\",\n },\n assets: { type: \"array\", items: SERVICE_ASSET_SCHEMA },\n tools: { type: \"array\", items: SERVICE_TOOL_SCHEMA },\n bonds: { type: \"array\", items: SERVICE_BOND_SCHEMA },\n pendingChange: PENDING_CHANGE_SCHEMA,\n hub: SERVICE_HUB_SCHEMA,\n },\n required: [\n \"serviceId\",\n \"name\",\n \"endpoint\",\n \"tier\",\n \"settlementWindowSeconds\",\n \"assets\",\n \"tools\",\n \"bonds\",\n \"pendingChange\",\n ],\n additionalProperties: false,\n },\n },\n error: ERROR_SCHEMA,\n },\n required: [\"services\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_call\n\nexport const TAB_CALL_INPUT: JsonObjectSchema = {\n type: \"object\",\n description: \"Calls one tool on one Service. The call is metered onto the Agent's Open Tab and paid for later.\",\n properties: {\n serviceId: word(\"The Service to call, as reported by tab_discover.\"),\n tool: {\n type: \"string\",\n minLength: 1,\n maxLength: 128,\n description: \"The tool name, for example `quote.generate`. A 32-byte hex word is accepted too.\",\n },\n asset: assetRef(\"Which Asset to meter in. Defaults to the Service's only priced Asset when it has one.\"),\n arguments: { type: \"object\", description: \"The tool's own arguments, passed through untouched.\" },\n timeoutMs: { type: \"integer\", minimum: 1000, maximum: 120000, default: 30000 },\n },\n required: [\"serviceId\", \"tool\"],\n additionalProperties: false,\n};\n\nexport const TAB_CALL_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n ok: { type: \"boolean\", description: \"Whether the Service served the call and it was metered.\" },\n result: { description: \"Whatever the Service returned. Absent when ok is false.\" },\n charge: {\n type: \"object\",\n description: \"What this call cost. Present whenever the Service reported a charge block.\",\n properties: {\n amountBaseUnits: baseUnits(\"Charged when ok is true; required but not charged when ok is false.\"),\n asset: assetRef(\"The Asset the charge is denominated in.\"),\n tool: word(\"The tool key that was metered.\"),\n },\n required: [\"amountBaseUnits\", \"asset\", \"tool\"],\n additionalProperties: false,\n },\n tab: {\n type: \"object\",\n description: \"The Agent's position for this Asset, as the Service reported it on this response.\",\n properties: {\n openTabBaseUnits: baseUnits(\"What the Agent now owes for this Asset.\"),\n headroomBaseUnits: baseUnits(\"What the Agent may still spend before the Credit Limit binds.\"),\n creditLimitBaseUnits: baseUnits(\"The Credit Limit for this Asset, when the response carried one.\"),\n asset: assetRef(\"The Asset these figures are denominated in.\"),\n settlementDueIso: nullableString(\"When the Settlement Window closes on this tab.\"),\n },\n required: [\"openTabBaseUnits\", \"headroomBaseUnits\", \"asset\"],\n additionalProperties: false,\n },\n x402: {\n type: \"object\",\n description:\n \"Present when the Service refused the call on credit and it was prepaid through x402 instead, with the signer tab.config's `x402` factory built. Nothing landed on the Open Tab: the call was paid in full, once, by this transaction.\",\n properties: {\n txHash: { type: \"string\", description: \"The settlement transaction the facilitator broadcast. Empty when it reported none.\" },\n network: { type: \"string\", description: \"The CAIP-2 network it settled on, for example `eip155:10143`.\" },\n amountBaseUnits: baseUnits(\"What was paid, in atomic units of the asset.\"),\n asset: assetRef(\"The token the payment was made in.\"),\n payTo: address(\"Where the funds went: the Service's Collection address.\"),\n payer: address(\"Who signed: the x402 signer's address.\"),\n explorerUrl: nullableString(\"A link to the transaction on the configured explorer.\"),\n },\n required: [\"txHash\", \"network\", \"amountBaseUnits\", \"asset\", \"payTo\", \"payer\", \"explorerUrl\"],\n additionalProperties: false,\n },\n error: ERROR_SCHEMA,\n },\n required: [\"ok\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_status\n\nexport const TAB_STATUS_INPUT: JsonObjectSchema = {\n type: \"object\",\n description: \"The Agent's credit picture: what it owes, what it may still spend, and what has settled.\",\n properties: {\n agent: address(\"The Agent's Monad address. Defaults to the Agent this server is configured for.\"),\n asset: assetRef(\"Report only this Asset. Omitted reports every Asset the Agent has touched.\"),\n historyLimit: { type: \"integer\", minimum: 0, maximum: 200, default: 20 },\n },\n required: [],\n additionalProperties: false,\n};\n\nconst PER_ASSET_SCHEMA: JsonSchema = {\n type: \"object\",\n properties: {\n asset: assetRef(\"The Asset these figures are denominated in.\"),\n creditLimitBaseUnits: nullableBaseUnits(\n \"What this Agent may owe for this Asset at once. Null when the source withheld the figure because it could not cross-check it against TabBook.\",\n ),\n openTabBaseUnits: baseUnits(\"What it owes now.\"),\n prepaidBaseUnits: nullableBaseUnits(\n \"Credit paid in ahead of use, which is drawn on before the Credit Limit. Null when the source serves only cumulative settlement totals and no live balance.\",\n ),\n headroomBaseUnits: nullableBaseUnits(\"What it may still spend. Null whenever the Credit Limit is null.\"),\n delinquent: { type: \"boolean\", description: \"True while a Settlement Window has closed on an unsettled tab.\" },\n tabs: {\n type: \"array\",\n description: \"The tabs behind the figures, newest first, capped by historyLimit.\",\n items: {\n type: \"object\",\n properties: {\n tabId: {\n type: [\"string\", \"null\"],\n pattern: WORD_PATTERN,\n description:\n \"The tab's identity on TabBook. Null when the source reports the observation by Agent, Service and Asset without naming the tab.\",\n },\n serviceId: word(\"The Service the tab is with.\"),\n openBaseUnits: baseUnits(\n \"The Open Tab last observed on this tab. A lower bound: a Metered Delivery raises a tab without an indexed event, so the per-Asset figure above is the one to trust.\",\n ),\n dueIso: nullableString(\"When this tab's Settlement Window closes.\"),\n },\n required: [\"tabId\", \"serviceId\", \"openBaseUnits\", \"dueIso\"],\n additionalProperties: false,\n },\n },\n },\n required: [\n \"asset\",\n \"creditLimitBaseUnits\",\n \"openTabBaseUnits\",\n \"prepaidBaseUnits\",\n \"headroomBaseUnits\",\n \"delinquent\",\n \"tabs\",\n ],\n additionalProperties: false,\n};\n\nconst SETTLEMENT_SCHEMA: JsonSchema = {\n type: \"object\",\n description: \"A Settlement the Agent paid on Monad: the Asset moved to the Service and the Open Tab fell in one transaction.\",\n properties: {\n settlementId: word(\"The Settlement's identity, assigned by TabBook when it was applied.\"),\n txHash: word(\"The Monad transaction that paid it.\"),\n serviceId: word(\"The Service that was paid.\"),\n asset: assetRef(\"The Asset that was paid.\"),\n amountBaseUnits: baseUnits(\"How much was paid.\"),\n appliedBaseUnits: baseUnits(\"How much of it lowered the Open Tab.\"),\n prepaidBaseUnits: baseUnits(\"How much of it was banked as prepaid credit.\"),\n explorerUrl: nullableString(\"The transaction on the Monad explorer.\"),\n },\n required: [\"settlementId\", \"txHash\", \"serviceId\", \"asset\", \"amountBaseUnits\", \"appliedBaseUnits\", \"prepaidBaseUnits\", \"explorerUrl\"],\n additionalProperties: false,\n};\n\nexport const TAB_STATUS_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n agent: address(\"The Agent these figures are about.\"),\n indexedBlock: {\n type: [\"integer\", \"null\"],\n minimum: 0,\n description:\n \"The Monad block every figure is as at. A Settlement sent a moment ago sits in a later block and is not yet reflected; read again after the index passes it. Null when the index has never ticked.\",\n },\n perAsset: { type: \"array\", items: PER_ASSET_SCHEMA },\n settlements: { type: \"array\", items: SETTLEMENT_SCHEMA },\n error: ERROR_SCHEMA,\n },\n required: [\"agent\", \"indexedBlock\", \"perAsset\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- tab_settle\n\nexport const TAB_SETTLE_INPUT: JsonObjectSchema = {\n type: \"object\",\n description:\n \"Pays down an Open Tab by calling TabSettlement.settle on Monad with the Agent's own key. This spends real funds unless dryRun is set.\",\n properties: {\n serviceId: word(\"The Service being paid.\"),\n asset: assetRef(\"The Asset to pay in, as `chainId:tokenAddress`.\"),\n amountBaseUnits: baseUnits(\"How much to pay, in Asset base units.\"),\n strategyId: { type: \"string\", maxLength: 64, description: \"Which registered payment strategy to settle through.\" },\n dryRun: {\n type: \"boolean\",\n default: false,\n description: \"Build and validate the Settlement, report what would be sent, and broadcast nothing.\",\n },\n },\n required: [\"serviceId\", \"asset\", \"amountBaseUnits\"],\n additionalProperties: false,\n};\n\nexport const TAB_SETTLE_OUTPUT: JsonObjectSchema = {\n type: \"object\",\n properties: {\n ok: { type: \"boolean\", description: \"Whether the Settlement was sent, or would have been on a dry run.\" },\n dryRun: { type: \"boolean\", description: \"True when nothing was sent.\" },\n txHash: nullableString(\"The Monad transaction. Null on a dry run and on failure.\"),\n chainId: { type: [\"integer\", \"null\"] },\n amountBaseUnits: baseUnits(\"What was paid, echoed from the request.\"),\n settlementId: {\n type: [\"string\", \"null\"],\n pattern: WORD_PATTERN,\n description: \"The Settlement's identity from the receipt. Null on a dry run, and null when the receipt was not awaited.\",\n },\n appliedBaseUnits: nullableString(\"How much lowered the Open Tab, from the receipt.\"),\n prepaidBaseUnits: nullableString(\"How much was banked as prepaid credit, from the receipt.\"),\n explorerUrl: nullableString(\"The transaction on the Monad explorer.\"),\n error: ERROR_SCHEMA,\n },\n required: [\"ok\", \"dryRun\", \"amountBaseUnits\"],\n additionalProperties: false,\n};\n\n// ---------------------------------------------------------------- the declaration\n\n/** One tool as `tools/list` serves it. */\nexport interface TabToolDeclaration {\n readonly name: string;\n readonly title: string;\n readonly description: string;\n readonly inputSchema: JsonObjectSchema;\n readonly outputSchema: JsonObjectSchema;\n /**\n * MCP behaviour hints. `tab_discover` and `tab_status` are read-only;\n * `tab_call` meters onto an Open Tab, and `tab_settle`, which spends funds,\n * is the one destructive tool.\n */\n readonly annotations: {\n readonly readOnlyHint: boolean;\n readonly destructiveHint: boolean;\n readonly idempotentHint: boolean;\n readonly openWorldHint: boolean;\n };\n}\n\nconst READ_ONLY = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true,\n} as const;\n\nexport const TAB_TOOLS: readonly TabToolDeclaration[] = [\n {\n name: \"tab_discover\",\n title: \"Discover Tab Services\",\n description:\n \"Lists Services registered on Monad, with the Assets each accepts, what each tool costs, and how much stake each has posted. Read-only and keyless. Start here: tab_call needs a serviceId from this list.\",\n inputSchema: TAB_DISCOVER_INPUT,\n outputSchema: TAB_DISCOVER_OUTPUT,\n annotations: READ_ONLY,\n },\n {\n name: \"tab_call\",\n title: \"Call a metered tool\",\n description:\n \"Calls a tool on a Service. Nothing is paid at call time: the charge lands on the Agent's Open Tab and is settled later with tab_settle. When the Agent has no headroom the call returns ok false with code LIMIT_EXCEEDED and both requiredBaseUnits and headroomBaseUnits, which is the signal to settle rather than retry. If tab.config declares an x402 signer and the Service offered x402 on that refusal, the call is prepaid instead and the output carries an x402 block naming the transaction.\",\n inputSchema: TAB_CALL_INPUT,\n outputSchema: TAB_CALL_OUTPUT,\n annotations: {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n {\n name: \"tab_status\",\n title: \"Read the Agent's credit picture\",\n description:\n \"Reports the Agent's Credit Limit, Open Tab, prepaid credit and headroom per Asset, plus its recent Settlements. Read-only and keyless.\",\n inputSchema: TAB_STATUS_INPUT,\n outputSchema: TAB_STATUS_OUTPUT,\n annotations: READ_ONLY,\n },\n {\n name: \"tab_settle\",\n title: \"Settle an Open Tab\",\n description:\n \"Pays down an Open Tab by sending a Settlement on Monad with the Agent's own key. This spends real funds. Set dryRun to build and check the Settlement without sending it.\",\n inputSchema: TAB_SETTLE_INPUT,\n outputSchema: TAB_SETTLE_OUTPUT,\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n },\n },\n];\n\n/** The tool names, in the order `tools/list` serves them. */\nexport const TAB_TOOL_NAMES = TAB_TOOLS.map((tool) => tool.name);\n\nexport const tabToolByName = (name: string): TabToolDeclaration | undefined =>\n TAB_TOOLS.find((tool) => tool.name === name);\n"]}
|
package/dist/mcp/server.d.ts
CHANGED
|
@@ -32,8 +32,6 @@
|
|
|
32
32
|
* payload as pretty JSON, because a client that predates structured output would
|
|
33
33
|
* otherwise see an empty result. `isError` is set when the payload reports a
|
|
34
34
|
* failure, so a model does not read an empty list as "nothing is registered".
|
|
35
|
-
*
|
|
36
|
-
* Requirements: 25.1, 25.2, 25.3
|
|
37
35
|
*/
|
|
38
36
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
39
37
|
import type { Result } from "../_shared/index.js";
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAInE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAM3C,OAAO,EAAyB,KAAK,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAsBjE,eAAO,MAAM,mBAAmB;;;CAAqD,CAAC;AAEtF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,MAK1B,CAAC;AAgBF,MAAM,WAAW,mBAAoB,SAAQ,qBAAqB;IAChE,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,oFAAoF;AACpF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,wDAAwD;IACxD,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,+EAA+E;IAC/E,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8EjG"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -32,8 +32,6 @@
|
|
|
32
32
|
* payload as pretty JSON, because a client that predates structured output would
|
|
33
33
|
* otherwise see an empty result. `isError` is set when the payload reports a
|
|
34
34
|
* failure, so a model does not read an empty list as "nothing is registered".
|
|
35
|
-
*
|
|
36
|
-
* Requirements: 25.1, 25.2, 25.3
|
|
37
35
|
*/
|
|
38
36
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
39
37
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -51,10 +49,9 @@ import { createTabToolset } from "./toolset.js";
|
|
|
51
49
|
* The name and version this server reports to a client.
|
|
52
50
|
*
|
|
53
51
|
* The version is read from the package rather than written here. A second copy
|
|
54
|
-
* of a version number
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* deciding whether it is talking to a build with a fix in it.
|
|
52
|
+
* of a version number goes stale on the next release without anything failing,
|
|
53
|
+
* and a client deciding whether it is talking to a build with a fix in it needs
|
|
54
|
+
* the real one.
|
|
58
55
|
*/
|
|
59
56
|
const PACKAGE_VERSION = (() => {
|
|
60
57
|
try {
|
|
@@ -62,7 +59,7 @@ const PACKAGE_VERSION = (() => {
|
|
|
62
59
|
}
|
|
63
60
|
catch {
|
|
64
61
|
// A bundler that inlines this module without the manifest beside it. Better a
|
|
65
|
-
// known-unknown than a number that
|
|
62
|
+
// known-unknown than a number that may be stale.
|
|
66
63
|
return "0.0.0";
|
|
67
64
|
}
|
|
68
65
|
})();
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEnG,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAA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I,CAAC,UAAU,EAAE,YAAY,EAAE,KAAK,IAAI,wCAAwC,EAAE;YACvF,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;YACvB,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC;SACtB,CAAC,CAAC;IACL,CAAC;IAED,+EAA+E;IAC/E,8EAA8E;IAC9E,4EAA4E;IAC5E,SAAS;IACT,MAAM,SAAS,GAAG,iBAAiB,CAAU,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,gBAAgB,CAAC,CAAC;IACpH,IAAI,CAAC,SAAS,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IACpC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,6FAA6F;AAC7F,SAAS,cAAc,CAAC,OAAgB;IACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,KAAc,EAAqC,EAAE,CACpE,KAAK,YAAY,KAAK;IACpB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;IAC9C,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC","sourcesContent":["/**\n * The MCP server: the protocol wiring, and nothing else.\n *\n * Every decision about what a tool does lives in `toolset.ts`. This file turns\n * that into an MCP server -- it answers `tools/list` with the declarations from\n * `schemas.ts` verbatim, routes `tools/call` to the toolset, and speaks over one\n * of two transports.\n *\n * ## Two transports, one default\n *\n * stdio is the default because it is what an MCP client launches: the client\n * spawns `npx -y @tabai/sdk mcp`, talks over the pipe, and there is no port to\n * choose, no address to bind, and nothing listening when the client is closed.\n * Streamable HTTP is the other supported transport and is chosen by configuring\n * a port, for the case the client is not the thing that launches the server -- a\n * shared deployment, or a client on another machine.\n *\n * Two rules follow from stdio being the default and neither is optional:\n *\n * - **stdout carries protocol frames and nothing else.** One stray `console.log`\n * corrupts the stream and the client drops the connection. Every log line this\n * server writes goes to stderr, which is why {@link stderrLogger} exists\n * rather than the package's `consoleLogger`.\n * - **A handler never throws.** The toolset returns a schema-valid payload on\n * every path, and the one `catch` here is a backstop for a bug in this file,\n * reported as a failed tool call rather than as a dropped transport.\n *\n * ## Results carry both forms\n *\n * Each call answers with `structuredContent` -- the payload, validated against\n * the tool's declared output schema -- and a `content` block holding the same\n * payload as pretty JSON, because a client that predates structured output would\n * otherwise see an empty result. `isError` is set when the payload reports a\n * failure, so a model does not read an empty list as \"nothing is registered\".\n *\n * Requirements: 25.1, 25.2, 25.3\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { Result } from \"../_shared/index.js\";\nimport { ok } from \"../_shared/index.js\";\n\nimport { fail } from \"../errors.js\";\nimport type { Logger } from \"../logger.js\";\nimport { createRequire } from \"node:module\";\n\nimport { validateJsonValue } from \"./json-schema.js\";\nimport { field, isRecord } from \"./json.js\";\nimport { TAB_TOOLS, tabToolByName } from \"./schemas.js\";\nimport { resolveTabMcpSettings, type TabMcpSettings, type TabMcpSettingsOptions } from \"./settings.js\";\nimport type { RegistryFetch } from \"./registry-client.js\";\nimport { createTabToolset, type TabToolset } from \"./toolset.js\";\n\n/**\n * The name and version this server reports to a client.\n *\n * The version is read from the package rather than written here. A second copy\n * of a version number is a copy that goes stale on the next release without\n * anything failing, and this one already had: the package shipped 0.1.3 while\n * every client was told 0.1.0, which is the wrong answer to give a client\n * deciding whether it is talking to a build with a fix in it.\n */\nconst PACKAGE_VERSION: string = (() => {\n try {\n return (\n createRequire(import.meta.url)(\"../../package.json\") as { version?: string }\n ).version ?? \"0.0.0\";\n } catch {\n // A bundler that inlines this module without the manifest beside it. Better a\n // known-unknown than a number that was true once.\n return \"0.0.0\";\n }\n})();\n\nexport const TAB_MCP_SERVER_INFO = { name: \"tab\", version: PACKAGE_VERSION } as const;\n\n/**\n * A logger that writes to stderr.\n *\n * The package default writes `info` and `debug` to stdout, which on the stdio\n * transport is the protocol stream. This is the same interface with every level\n * pointed at stderr, so a server can be logged without being corrupted.\n */\nexport const stderrLogger: Logger = {\n debug: (message, fields) => write(\"debug\", message, fields),\n info: (message, fields) => write(\"info\", message, fields),\n warn: (message, fields) => write(\"warn\", message, fields),\n error: (message, fields) => write(\"error\", message, fields),\n};\n\nfunction write(level: string, message: string, fields?: Record<string, unknown>): void {\n const suffix = fields === undefined ? \"\" : ` ${safeJson(fields)}`;\n process.stderr.write(`tab-mcp ${level}: ${message}${suffix}\\n`);\n}\n\n/** `JSON.stringify` that survives a `bigint` and a cycle, because a log line must not throw. */\nfunction safeJson(value: unknown): string {\n try {\n return JSON.stringify(value, (_key, entry) => (typeof entry === \"bigint\" ? `${entry.toString(10)}n` : entry)) ?? \"\";\n } catch {\n return \"[unserialisable]\";\n }\n}\n\nexport interface TabMcpServerOptions extends TabMcpSettingsOptions {\n /** Pre-resolved settings. Skips config and environment discovery entirely. */\n readonly settings?: TabMcpSettings;\n /** A toolset to route calls to. Built from the settings when absent. */\n readonly toolset?: TabToolset;\n /** Passed through to the toolset it builds. See `TabToolsetOptions`. */\n readonly registryFetch?: RegistryFetch;\n readonly logger?: Logger;\n}\n\n/** A built server, with the pieces a caller may want to reach past the protocol. */\nexport interface TabMcpServer {\n readonly server: Server;\n readonly toolset: TabToolset;\n readonly settings: TabMcpSettings;\n /** Serves on stdio until the client closes the pipe. */\n serveStdio(): Promise<Result<void>>;\n /** Serves streamable HTTP on `port`, and answers with the address it bound. */\n serveHttp(options: ServeHttpOptions): Promise<Result<ServingHttp>>;\n}\n\nexport interface ServeHttpOptions {\n readonly port: number;\n /** Defaults to `127.0.0.1`: a loopback bind, because this surface has no authentication. */\n readonly host?: string;\n /** Defaults to `/mcp`. */\n readonly endpoint?: string;\n}\n\nexport interface ServingHttp {\n readonly host: string;\n readonly port: number;\n readonly endpoint: string;\n close(): Promise<void>;\n}\n\n/**\n * Builds the server.\n *\n * Resolving settings is asynchronous because `tab.config` discovery is, which is\n * why this is a `Promise` rather than the total constructor the rest of the\n * package uses. It still cannot fail: a missing setting is reported by the tool\n * that needs it.\n */\nexport async function createTabMcpServer(options: TabMcpServerOptions = {}): Promise<TabMcpServer> {\n const logger = options.logger ?? stderrLogger;\n const settings = options.settings ?? (await resolveTabMcpSettings({ ...options, logger }));\n const toolset =\n options.toolset ??\n createTabToolset({\n settings,\n logger,\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.registryFetch === undefined ? {} : { registryFetch: options.registryFetch }),\n });\n\n const server = buildProtocolServer(toolset, logger);\n\n return {\n server,\n toolset,\n settings,\n\n async serveStdio() {\n try {\n await server.connect(new StdioServerTransport());\n logger.info(\"serving on stdio\", {\n tools: TAB_TOOLS.length,\n agent: settings.agent ?? null,\n registryUrl: settings.registryUrl ?? null,\n });\n return ok(undefined);\n } catch (error) {\n return fail(\"INTERNAL\", \"STDIO_TRANSPORT_FAILED\", \"the stdio transport could not be started\", {\n cause: causeOf(error),\n });\n }\n },\n\n async serveHttp(serve) {\n const host = serve.host ?? \"127.0.0.1\";\n const endpoint = serve.endpoint ?? \"/mcp\";\n try {\n const { createServer } = await import(\"node:http\");\n const http = createServer((req, res) => {\n const url = req.url ?? \"/\";\n if (!url.startsWith(endpoint)) {\n res.writeHead(404, { \"content-type\": \"application/json\" });\n res.end(\n safeJson({\n error: { category: \"NOT_FOUND\", code: \"ENDPOINT_UNKNOWN\", message: `this server serves MCP at ${endpoint}` },\n }),\n );\n return;\n }\n void handleStatelessRequest(req, res, toolset, logger);\n });\n\n await new Promise<void>((resolve, reject) => {\n http.once(\"error\", reject);\n http.listen(serve.port, host, () => resolve());\n });\n\n logger.info(\"serving streamable http\", { host, port: serve.port, endpoint });\n return ok({\n host,\n port: serve.port,\n endpoint,\n close: async () => {\n await new Promise<void>((resolve) => http.close(() => resolve()));\n },\n });\n } catch (error) {\n return fail(\n \"INTERNAL\",\n \"HTTP_TRANSPORT_FAILED\",\n `the streamable HTTP transport could not bind ${host}:${serve.port}`,\n { cause: causeOf(error) },\n );\n }\n },\n };\n}\n\n/**\n * One request, one server, one transport.\n *\n * This is the documented shape for stateless streamable HTTP and it is not a\n * detail: an MCP connection is a stateful protocol session, and a shared server\n * behind independent POSTs would carry one caller's initialisation into another\n * caller's request. Building a fresh pair per request costs a handful of\n * closures and makes the endpoint genuinely concurrent, which is the only reason\n * to serve HTTP at all rather than stdio.\n *\n * The toolset is shared, deliberately: it holds resolved settings and a memoised\n * strategy registry, neither of which belongs to a caller.\n */\nasync function handleStatelessRequest(\n req: IncomingMessage,\n res: ServerResponse,\n toolset: TabToolset,\n logger: Logger,\n): Promise<void> {\n const server = buildProtocolServer(toolset, logger);\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined,\n } as unknown as ConstructorParameters<typeof StreamableHTTPServerTransport>[0]);\n\n res.on(\"close\", () => {\n void transport.close();\n void server.close();\n });\n\n try {\n await server.connect(transport as unknown as Parameters<Server[\"connect\"]>[0]);\n await transport.handleRequest(req, res);\n } catch (error) {\n logger.error(\"streamable http request failed\", { reason: String(error) });\n if (!res.headersSent) {\n res.writeHead(500, { \"content-type\": \"application/json\" });\n res.end(\n safeJson({\n error: { category: \"INTERNAL\", code: \"REQUEST_FAILED\", message: \"the request could not be served\" },\n }),\n );\n }\n }\n}\n\n/** A protocol server wired to the toolset. One per stdio process, one per HTTP request. */\nfunction buildProtocolServer(toolset: TabToolset, logger: Logger): Server {\n const server = new Server(TAB_MCP_SERVER_INFO, { capabilities: { tools: {} } });\n\n server.setRequestHandler(ListToolsRequestSchema, () => ({\n tools: TAB_TOOLS.map((tool) => ({\n name: tool.name,\n title: tool.title,\n description: tool.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n annotations: { title: tool.title, ...tool.annotations },\n })),\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const name = request.params.name;\n const outcome = await runTool(toolset, name, request.params.arguments);\n if (!outcome.ok) {\n const payload = {\n category: outcome.error.category,\n code: outcome.error.code,\n message: outcome.error.message,\n retryable: outcome.error.retryable,\n };\n logger.warn(\"tool call refused\", { tool: name, code: outcome.error.code });\n return { content: [{ type: \"text\", text: safeJson(payload) }], isError: true };\n }\n\n const failed = reportsFailure(outcome.value);\n return {\n content: [{ type: \"text\", text: safeJson(outcome.value) }],\n structuredContent: outcome.value as Record<string, unknown>,\n ...(failed ? { isError: true } : {}),\n };\n });\n\n return server;\n}\n\n/** Runs one tool and validates its output against the schema that was published. */\nasync function runTool(toolset: TabToolset, name: string, args: unknown): Promise<Result<unknown>> {\n const declaration = tabToolByName(name);\n if (declaration === undefined) {\n return fail(\"NOT_FOUND\", \"TOOL_UNKNOWN\", `\\`${name}\\` is not a tool this server declares`, {\n details: { tool: name, declared: TAB_TOOLS.map((tool) => tool.name).join(\", \") },\n });\n }\n\n let payload: unknown;\n try {\n const invoked = await toolset.invoke(name, args);\n if (!invoked.ok) return invoked;\n payload = invoked.value;\n } catch (error) {\n // The toolset is written not to reach here. If it does, the bug is reported\n // as a failed call rather than as a dropped transport.\n return fail(\"INTERNAL\", \"TOOL_THREW\", `\\`${name}\\` threw instead of returning a result`, {\n details: { tool: name },\n cause: causeOf(error),\n });\n }\n\n // The published output schema is enforced on the way out, not just documented.\n // A payload that does not match is this package's bug, and a model told about\n // it is better served than a model handed a shape it was promised would not\n // occur.\n const validated = validateJsonValue<unknown>(declaration.outputSchema, payload, `${name} output`, \"OUTPUT_INVALID\");\n if (!validated.ok) return validated;\n return ok(payload);\n}\n\n/** Does a tool payload report a failure? `ok: false`, or an `error` block on a read tool. */\nfunction reportsFailure(payload: unknown): boolean {\n if (!isRecord(payload)) return false;\n if (field(payload, \"ok\") === false) return true;\n return isRecord(field(payload, \"error\"));\n}\n\nconst causeOf = (error: unknown): { code: string; message: string } =>\n error instanceof Error\n ? { code: error.name, message: error.message }\n : { code: \"UNKNOWN\", message: String(error) };\n"]}
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEnG,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAmD,MAAM,eAAe,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAmB,MAAM,cAAc,CAAC;AAEjE;;;;;;;GAOG;AACH,MAAM,eAAe,GAAW,CAAC,GAAG,EAAE;IACpC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OAAO,EAAE,GAAG,IAAI,SAAS,EAAE,gBAAgB,CAAC,CAAC;IACpH,IAAI,CAAC,SAAS,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IACpC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,6FAA6F;AAC7F,SAAS,cAAc,CAAC,OAAgB;IACtC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,IAAI,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,KAAc,EAAqC,EAAE,CACpE,KAAK,YAAY,KAAK;IACpB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;IAC9C,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC","sourcesContent":["/**\n * The MCP server: the protocol wiring, and nothing else.\n *\n * Every decision about what a tool does lives in `toolset.ts`. This file turns\n * that into an MCP server -- it answers `tools/list` with the declarations from\n * `schemas.ts` verbatim, routes `tools/call` to the toolset, and speaks over one\n * of two transports.\n *\n * ## Two transports, one default\n *\n * stdio is the default because it is what an MCP client launches: the client\n * spawns `npx -y @tabai/sdk mcp`, talks over the pipe, and there is no port to\n * choose, no address to bind, and nothing listening when the client is closed.\n * Streamable HTTP is the other supported transport and is chosen by configuring\n * a port, for the case the client is not the thing that launches the server -- a\n * shared deployment, or a client on another machine.\n *\n * Two rules follow from stdio being the default and neither is optional:\n *\n * - **stdout carries protocol frames and nothing else.** One stray `console.log`\n * corrupts the stream and the client drops the connection. Every log line this\n * server writes goes to stderr, which is why {@link stderrLogger} exists\n * rather than the package's `consoleLogger`.\n * - **A handler never throws.** The toolset returns a schema-valid payload on\n * every path, and the one `catch` here is a backstop for a bug in this file,\n * reported as a failed tool call rather than as a dropped transport.\n *\n * ## Results carry both forms\n *\n * Each call answers with `structuredContent` -- the payload, validated against\n * the tool's declared output schema -- and a `content` block holding the same\n * payload as pretty JSON, because a client that predates structured output would\n * otherwise see an empty result. `isError` is set when the payload reports a\n * failure, so a model does not read an empty list as \"nothing is registered\".\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { Result } from \"../_shared/index.js\";\nimport { ok } from \"../_shared/index.js\";\n\nimport { fail } from \"../errors.js\";\nimport type { Logger } from \"../logger.js\";\nimport { createRequire } from \"node:module\";\n\nimport { validateJsonValue } from \"./json-schema.js\";\nimport { field, isRecord } from \"./json.js\";\nimport { TAB_TOOLS, tabToolByName } from \"./schemas.js\";\nimport { resolveTabMcpSettings, type TabMcpSettings, type TabMcpSettingsOptions } from \"./settings.js\";\nimport type { RegistryFetch } from \"./registry-client.js\";\nimport { createTabToolset, type TabToolset } from \"./toolset.js\";\n\n/**\n * The name and version this server reports to a client.\n *\n * The version is read from the package rather than written here. A second copy\n * of a version number goes stale on the next release without anything failing,\n * and a client deciding whether it is talking to a build with a fix in it needs\n * the real one.\n */\nconst PACKAGE_VERSION: string = (() => {\n try {\n return (\n createRequire(import.meta.url)(\"../../package.json\") as { version?: string }\n ).version ?? \"0.0.0\";\n } catch {\n // A bundler that inlines this module without the manifest beside it. Better a\n // known-unknown than a number that may be stale.\n return \"0.0.0\";\n }\n})();\n\nexport const TAB_MCP_SERVER_INFO = { name: \"tab\", version: PACKAGE_VERSION } as const;\n\n/**\n * A logger that writes to stderr.\n *\n * The package default writes `info` and `debug` to stdout, which on the stdio\n * transport is the protocol stream. This is the same interface with every level\n * pointed at stderr, so a server can be logged without being corrupted.\n */\nexport const stderrLogger: Logger = {\n debug: (message, fields) => write(\"debug\", message, fields),\n info: (message, fields) => write(\"info\", message, fields),\n warn: (message, fields) => write(\"warn\", message, fields),\n error: (message, fields) => write(\"error\", message, fields),\n};\n\nfunction write(level: string, message: string, fields?: Record<string, unknown>): void {\n const suffix = fields === undefined ? \"\" : ` ${safeJson(fields)}`;\n process.stderr.write(`tab-mcp ${level}: ${message}${suffix}\\n`);\n}\n\n/** `JSON.stringify` that survives a `bigint` and a cycle, because a log line must not throw. */\nfunction safeJson(value: unknown): string {\n try {\n return JSON.stringify(value, (_key, entry) => (typeof entry === \"bigint\" ? `${entry.toString(10)}n` : entry)) ?? \"\";\n } catch {\n return \"[unserialisable]\";\n }\n}\n\nexport interface TabMcpServerOptions extends TabMcpSettingsOptions {\n /** Pre-resolved settings. Skips config and environment discovery entirely. */\n readonly settings?: TabMcpSettings;\n /** A toolset to route calls to. Built from the settings when absent. */\n readonly toolset?: TabToolset;\n /** Passed through to the toolset it builds. See `TabToolsetOptions`. */\n readonly registryFetch?: RegistryFetch;\n readonly logger?: Logger;\n}\n\n/** A built server, with the pieces a caller may want to reach past the protocol. */\nexport interface TabMcpServer {\n readonly server: Server;\n readonly toolset: TabToolset;\n readonly settings: TabMcpSettings;\n /** Serves on stdio until the client closes the pipe. */\n serveStdio(): Promise<Result<void>>;\n /** Serves streamable HTTP on `port`, and answers with the address it bound. */\n serveHttp(options: ServeHttpOptions): Promise<Result<ServingHttp>>;\n}\n\nexport interface ServeHttpOptions {\n readonly port: number;\n /** Defaults to `127.0.0.1`: a loopback bind, because this surface has no authentication. */\n readonly host?: string;\n /** Defaults to `/mcp`. */\n readonly endpoint?: string;\n}\n\nexport interface ServingHttp {\n readonly host: string;\n readonly port: number;\n readonly endpoint: string;\n close(): Promise<void>;\n}\n\n/**\n * Builds the server.\n *\n * Resolving settings is asynchronous because `tab.config` discovery is, which is\n * why this is a `Promise` rather than the total constructor the rest of the\n * package uses. It still cannot fail: a missing setting is reported by the tool\n * that needs it.\n */\nexport async function createTabMcpServer(options: TabMcpServerOptions = {}): Promise<TabMcpServer> {\n const logger = options.logger ?? stderrLogger;\n const settings = options.settings ?? (await resolveTabMcpSettings({ ...options, logger }));\n const toolset =\n options.toolset ??\n createTabToolset({\n settings,\n logger,\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n ...(options.registryFetch === undefined ? {} : { registryFetch: options.registryFetch }),\n });\n\n const server = buildProtocolServer(toolset, logger);\n\n return {\n server,\n toolset,\n settings,\n\n async serveStdio() {\n try {\n await server.connect(new StdioServerTransport());\n logger.info(\"serving on stdio\", {\n tools: TAB_TOOLS.length,\n agent: settings.agent ?? null,\n registryUrl: settings.registryUrl ?? null,\n });\n return ok(undefined);\n } catch (error) {\n return fail(\"INTERNAL\", \"STDIO_TRANSPORT_FAILED\", \"the stdio transport could not be started\", {\n cause: causeOf(error),\n });\n }\n },\n\n async serveHttp(serve) {\n const host = serve.host ?? \"127.0.0.1\";\n const endpoint = serve.endpoint ?? \"/mcp\";\n try {\n const { createServer } = await import(\"node:http\");\n const http = createServer((req, res) => {\n const url = req.url ?? \"/\";\n if (!url.startsWith(endpoint)) {\n res.writeHead(404, { \"content-type\": \"application/json\" });\n res.end(\n safeJson({\n error: { category: \"NOT_FOUND\", code: \"ENDPOINT_UNKNOWN\", message: `this server serves MCP at ${endpoint}` },\n }),\n );\n return;\n }\n void handleStatelessRequest(req, res, toolset, logger);\n });\n\n await new Promise<void>((resolve, reject) => {\n http.once(\"error\", reject);\n http.listen(serve.port, host, () => resolve());\n });\n\n logger.info(\"serving streamable http\", { host, port: serve.port, endpoint });\n return ok({\n host,\n port: serve.port,\n endpoint,\n close: async () => {\n await new Promise<void>((resolve) => http.close(() => resolve()));\n },\n });\n } catch (error) {\n return fail(\n \"INTERNAL\",\n \"HTTP_TRANSPORT_FAILED\",\n `the streamable HTTP transport could not bind ${host}:${serve.port}`,\n { cause: causeOf(error) },\n );\n }\n },\n };\n}\n\n/**\n * One request, one server, one transport.\n *\n * This is the documented shape for stateless streamable HTTP and it is not a\n * detail: an MCP connection is a stateful protocol session, and a shared server\n * behind independent POSTs would carry one caller's initialisation into another\n * caller's request. Building a fresh pair per request costs a handful of\n * closures and makes the endpoint genuinely concurrent, which is the only reason\n * to serve HTTP at all rather than stdio.\n *\n * The toolset is shared, deliberately: it holds resolved settings and a memoised\n * strategy registry, neither of which belongs to a caller.\n */\nasync function handleStatelessRequest(\n req: IncomingMessage,\n res: ServerResponse,\n toolset: TabToolset,\n logger: Logger,\n): Promise<void> {\n const server = buildProtocolServer(toolset, logger);\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined,\n } as unknown as ConstructorParameters<typeof StreamableHTTPServerTransport>[0]);\n\n res.on(\"close\", () => {\n void transport.close();\n void server.close();\n });\n\n try {\n await server.connect(transport as unknown as Parameters<Server[\"connect\"]>[0]);\n await transport.handleRequest(req, res);\n } catch (error) {\n logger.error(\"streamable http request failed\", { reason: String(error) });\n if (!res.headersSent) {\n res.writeHead(500, { \"content-type\": \"application/json\" });\n res.end(\n safeJson({\n error: { category: \"INTERNAL\", code: \"REQUEST_FAILED\", message: \"the request could not be served\" },\n }),\n );\n }\n }\n}\n\n/** A protocol server wired to the toolset. One per stdio process, one per HTTP request. */\nfunction buildProtocolServer(toolset: TabToolset, logger: Logger): Server {\n const server = new Server(TAB_MCP_SERVER_INFO, { capabilities: { tools: {} } });\n\n server.setRequestHandler(ListToolsRequestSchema, () => ({\n tools: TAB_TOOLS.map((tool) => ({\n name: tool.name,\n title: tool.title,\n description: tool.description,\n inputSchema: tool.inputSchema,\n outputSchema: tool.outputSchema,\n annotations: { title: tool.title, ...tool.annotations },\n })),\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const name = request.params.name;\n const outcome = await runTool(toolset, name, request.params.arguments);\n if (!outcome.ok) {\n const payload = {\n category: outcome.error.category,\n code: outcome.error.code,\n message: outcome.error.message,\n retryable: outcome.error.retryable,\n };\n logger.warn(\"tool call refused\", { tool: name, code: outcome.error.code });\n return { content: [{ type: \"text\", text: safeJson(payload) }], isError: true };\n }\n\n const failed = reportsFailure(outcome.value);\n return {\n content: [{ type: \"text\", text: safeJson(outcome.value) }],\n structuredContent: outcome.value as Record<string, unknown>,\n ...(failed ? { isError: true } : {}),\n };\n });\n\n return server;\n}\n\n/** Runs one tool and validates its output against the schema that was published. */\nasync function runTool(toolset: TabToolset, name: string, args: unknown): Promise<Result<unknown>> {\n const declaration = tabToolByName(name);\n if (declaration === undefined) {\n return fail(\"NOT_FOUND\", \"TOOL_UNKNOWN\", `\\`${name}\\` is not a tool this server declares`, {\n details: { tool: name, declared: TAB_TOOLS.map((tool) => tool.name).join(\", \") },\n });\n }\n\n let payload: unknown;\n try {\n const invoked = await toolset.invoke(name, args);\n if (!invoked.ok) return invoked;\n payload = invoked.value;\n } catch (error) {\n // The toolset is written not to reach here. If it does, the bug is reported\n // as a failed call rather than as a dropped transport.\n return fail(\"INTERNAL\", \"TOOL_THREW\", `\\`${name}\\` threw instead of returning a result`, {\n details: { tool: name },\n cause: causeOf(error),\n });\n }\n\n // The published output schema is enforced on the way out, not just documented.\n // A payload that does not match is this package's bug, and a model told about\n // it is better served than a model handed a shape it was promised would not\n // occur.\n const validated = validateJsonValue<unknown>(declaration.outputSchema, payload, `${name} output`, \"OUTPUT_INVALID\");\n if (!validated.ok) return validated;\n return ok(payload);\n}\n\n/** Does a tool payload report a failure? `ok: false`, or an `error` block on a read tool. */\nfunction reportsFailure(payload: unknown): boolean {\n if (!isRecord(payload)) return false;\n if (field(payload, \"ok\") === false) return true;\n return isRecord(field(payload, \"error\"));\n}\n\nconst causeOf = (error: unknown): { code: string; message: string } =>\n error instanceof Error\n ? { code: error.name, message: error.message }\n : { code: \"UNKNOWN\", message: String(error) };\n"]}
|
package/dist/mcp/settings.d.ts
CHANGED
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
* is signed, by the strategy that signs it, and never travels through a config
|
|
26
26
|
* file or an MCP client's `mcpServers` stanza. That is what makes `tab connect`
|
|
27
27
|
* safe to run against a file the client software rewrites.
|
|
28
|
-
*
|
|
29
|
-
* Requirements: 25.3, 25.5, 28.6
|
|
30
28
|
*/
|
|
31
29
|
import type { Address } from "../_shared/index.js";
|
|
32
30
|
import type { TabServiceEntry } from "../payments/config.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/mcp/settings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/mcp/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0FAA0F;IAC1F,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6DAA6D;IA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AAsB,qBAAqB,CACzC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,cAAc,CAAC,CA6HzB"}
|
package/dist/mcp/settings.js
CHANGED
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
* is signed, by the strategy that signs it, and never travels through a config
|
|
26
26
|
* file or an MCP client's `mcpServers` stanza. That is what makes `tab connect`
|
|
27
27
|
* safe to run against a file the client software rewrites.
|
|
28
|
-
*
|
|
29
|
-
* Requirements: 25.3, 25.5, 28.6
|
|
30
28
|
*/
|
|
31
29
|
import { CHAINS, TAB_HOSTED, isAddress, isMonadChainId } from "../_shared/index.js";
|
|
32
30
|
import { loadTabConfig } from "../payments/config.js";
|
package/dist/mcp/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/mcp/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG9E,OAAO,EAAE,aAAa,EAAkB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAe,MAAM,cAAc,CAAC;AAoD1D,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,iCAAiC,CAAC;AAEtE,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAEtC,MAAM,OAAO,GAAG,CAAC,KAAyB,EAAsB,EAAE;IAChE,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC3B,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,CAAC,GAAsB,EAA+C,EAAE;IACjG,MAA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AC3F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhG,OAAO;QACL,KAAK;QACL,WAAW;QACX,MAAM;QACN,OAAO;QACP,WAAW;QACX,QAAQ;QACR,UAAU;QACV,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Where the MCP server gets its settings, and the order it prefers them in.\n *\n * Three sources, most specific first:\n *\n * 1. the options handed to {@link resolveTabMcpSettings}, which is what a test\n * and an embedding host use;\n * 2. `tab.config.{ts,mts,mjs,js,cjs}`, discovered by walking up from the working\n * directory -- the mechanism this package already has for consumer\n * configuration, so the MCP surface adds no second one;\n * 3. the environment, which is what the `mcpServers` stanza `tab connect` writes\n * actually carries.\n *\n * Every environment variable read here is already declared in the tracked\n * `.env.example` contract. That is not incidental: the repository's environment\n * gate extracts every `process.env` read in the tree and fails the build when\n * one has no declaration, so a new name would be a new line in a contract this\n * surface has no business changing. The RPC endpoint is `MONAD_RPC_URL`, in the\n * stanza and here.\n *\n * ## No key is a setting\n *\n * Nothing in this module reads a private key and nothing returns one. The\n * settlement signing key is read from the environment at the moment a Settlement\n * is signed, by the strategy that signs it, and never travels through a config\n * file or an MCP client's `mcpServers` stanza. That is what makes `tab connect`\n * safe to run against a file the client software rewrites.\n *\n * Requirements: 25.3, 25.5, 28.6\n */\n\nimport type { Address } from \"../_shared/index.js\";\nimport { CHAINS, TAB_HOSTED, isAddress, isMonadChainId } from \"../_shared/index.js\";\n\nimport type { TabServiceEntry } from \"../payments/config.js\";\nimport { loadTabConfig, type TabConfig } from \"../payments/config.js\";\nimport { defaultLogger, type Logger } from \"../logger.js\";\nimport type { X402SignerFactory } from \"../x402/client.js\";\n\n/** The settings every tool reads. Each field is resolved or explicitly absent. */\nexport interface TabMcpSettings {\n /** Whose Open Tab a metered call lands on. Undefined until one is configured. */\n readonly agent: Address | undefined;\n /** Absolute base URL of the registry read API, or undefined when none is configured. */\n readonly registryUrl: string | undefined;\n /** The Monad JSON-RPC endpoint, used by `doctor` and by nothing that signs. */\n readonly rpcUrl: string | undefined;\n /** The EVM chain id every Asset is named against: 143 for Mainnet, 10143 for Testnet. */\n readonly chainId: number;\n /** Where a Monad transaction is linked. Always resolved; a default is fine for a link. */\n readonly explorerUrl: string;\n /** The endpoint directory, keyed by lower-case serviceId. */\n readonly services: readonly TabServiceEntry[];\n /** Which strategy `tab_settle` settles through when the call names none. */\n readonly strategyId: string | undefined;\n /**\n * The x402 signer factory, for `tab_call`'s prepaid fallback. Never called\n * while settings are resolved; only when a refused call carries an offer.\n */\n readonly x402: X402SignerFactory | undefined;\n /** Where each setting came from, so `doctor` can print it. */\n readonly sources: Readonly<Record<string, string>>;\n}\n\n/** Explicit settings, which beat both the config file and the environment. */\nexport interface TabMcpSettingsOptions {\n readonly agent?: string;\n readonly chainId?: number;\n readonly registryUrl?: string;\n /**\n * Whether the project's hosted read API and demo Service fill in what nothing\n * else names. Default true; `TAB_HOSTED_DEFAULTS=off` in the environment\n * turns them off as well.\n */\n readonly hostedDefaults?: boolean;\n readonly rpcUrl?: string;\n readonly explorerUrl?: string;\n readonly services?: readonly TabServiceEntry[];\n readonly strategyId?: string;\n readonly x402?: X402SignerFactory;\n /** Where the `tab.config` walk starts. Defaults to the working directory. */\n readonly cwd?: string;\n /** `false` skips config discovery entirely, which is what a hermetic test wants. */\n readonly config?: TabConfig | false;\n readonly env?: NodeJS.ProcessEnv;\n readonly logger?: Logger;\n}\n\n/** The public Monad Testnet explorer, used when nothing names one. */\nexport const DEFAULT_EXPLORER_URL = \"https://testnet.monadvision.com\";\n\n/** Monad Testnet, used when nothing names a chain. */\nexport const DEFAULT_CHAIN_ID = 10143;\n\nconst trimmed = (value: string | undefined): string | undefined => {\n const text = value?.trim();\n return text === undefined || text === \"\" ? undefined : text;\n};\n\n/**\n * The registry read API the environment names.\n *\n * `NEXT_PUBLIC_REGISTRY_API_URL` is the deployment's own name for this value and\n * is already in the environment contract, so it is what is read. When only\n * `REGISTRY_PORT` is set the read API is taken to be local, which is exactly the\n * developer case and saves a second variable that would say the same thing.\n */\nconst registryUrlFromEnv = (env: NodeJS.ProcessEnv): { url: string; source: string } | undefined => {\n const declared = trimmed(env[\"NEXT_PUBLIC_REGISTRY_API_URL\"]);\n if (declared !== undefined) return { url: declared, source: \"env NEXT_PUBLIC_REGISTRY_API_URL\" };\n const port = trimmed(env[\"REGISTRY_PORT\"]);\n if (port !== undefined && /^[0-9]{1,5}$/.test(port)) {\n return { url: `http://127.0.0.1:${port}`, source: \"env REGISTRY_PORT\" };\n }\n return undefined;\n};\n\n/** Keeps the first entry for each serviceId, so a more specific source wins. */\nfunction mergeServices(...groups: readonly (readonly TabServiceEntry[])[]): readonly TabServiceEntry[] {\n const byId = new Map<string, TabServiceEntry>();\n for (const group of groups) {\n for (const entry of group) {\n if (typeof entry?.serviceId !== \"string\" || typeof entry?.endpoint !== \"string\") continue;\n const key = entry.serviceId.toLowerCase();\n if (!byId.has(key)) byId.set(key, { ...entry, serviceId: key });\n }\n }\n return [...byId.values()];\n}\n\n/**\n * Resolves the settings, loading `tab.config` unless one was handed in.\n *\n * Never fails. A config file that cannot be imported is logged and skipped\n * rather than taking the server down: the tools each report their own missing\n * settings by name, which is a better message than a startup failure that names\n * a file the caller may not have known existed.\n */\nexport async function resolveTabMcpSettings(\n options: TabMcpSettingsOptions = {},\n): Promise<TabMcpSettings> {\n const env = options.env ?? process.env;\n const logger = options.logger ?? defaultLogger;\n const sources: Record<string, string> = {};\n\n let config: TabConfig = {};\n if (options.config === undefined) {\n const loaded = await loadTabConfig({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n registry: false,\n logger,\n });\n if (loaded.ok) {\n config = loaded.value.config;\n if (loaded.value.path !== undefined) sources[\"config\"] = loaded.value.path;\n } else {\n logger.warn(\"tab config could not be loaded; continuing without it\", {\n code: loaded.error.code,\n message: loaded.error.message,\n });\n }\n } else if (options.config !== false) {\n config = options.config;\n sources[\"config\"] = \"supplied\";\n }\n\n const pick = (\n key: string,\n explicit: string | undefined,\n fromConfig: string | undefined,\n fromEnv: { value: string; source: string } | undefined,\n ): string | undefined => {\n if (trimmed(explicit) !== undefined) {\n sources[key] = \"options\";\n return trimmed(explicit);\n }\n if (trimmed(fromConfig) !== undefined) {\n sources[key] = \"tab.config\";\n return trimmed(fromConfig);\n }\n if (fromEnv !== undefined) {\n sources[key] = fromEnv.source;\n return fromEnv.value;\n }\n return undefined;\n };\n\n const rawAgent = pick(\"agent\", options.agent, config.agent, undefined);\n const agent = rawAgent !== undefined && isAddress(rawAgent) ? (rawAgent.toLowerCase() as Address) : undefined;\n if (rawAgent !== undefined && agent === undefined) {\n logger.warn(\"the configured agent is not a 20-byte address and was ignored\", { agent: rawAgent });\n delete sources[\"agent\"];\n }\n\n const envRpc = trimmed(env[\"MONAD_RPC_URL\"]);\n const rpcUrl = pick(\n \"rpcUrl\",\n options.rpcUrl,\n undefined,\n envRpc === undefined ? undefined : { value: envRpc, source: \"env MONAD_RPC_URL\" },\n );\n\n const envChain = trimmed(env[\"MONAD_CHAIN_ID\"]);\n const chainIdText = pick(\n \"chainId\",\n options.chainId === undefined ? undefined : String(options.chainId),\n undefined,\n envChain === undefined ? undefined : { value: envChain, source: \"env MONAD_CHAIN_ID\" },\n );\n const chainId = chainIdText !== undefined && /^[0-9]+$/.test(chainIdText) ? Number(chainIdText) : DEFAULT_CHAIN_ID;\n\n /*\n What this project hosts on the chosen network: its read API and its demo\n Service. The lowest-priority source for both, so anything configured wins,\n and switched off with TAB_HOSTED_DEFAULTS=off for a setup that must reach\n nothing it did not name.\n */\n const hosted =\n options.hostedDefaults !== false && trimmed(env[\"TAB_HOSTED_DEFAULTS\"]) !== \"off\" && isMonadChainId(chainId)\n ? TAB_HOSTED[chainId]\n : undefined;\n\n const envRegistry = registryUrlFromEnv(env);\n let registryUrl = pick(\n \"registryUrl\",\n options.registryUrl,\n config.registryUrl,\n envRegistry === undefined ? undefined : { value: envRegistry.url, source: envRegistry.source },\n );\n if (registryUrl === undefined && hosted !== undefined) {\n registryUrl = hosted.registryUrl;\n sources[\"registryUrl\"] = \"default (the project's hosted read API)\";\n }\n\n const envExplorer = trimmed(env[\"MONAD_EXPLORER_URL\"]);\n const explorerUrl =\n pick(\n \"explorerUrl\",\n options.explorerUrl,\n undefined,\n envExplorer === undefined ? undefined : { value: envExplorer, source: \"env MONAD_EXPLORER_URL\" },\n ) ?? (isMonadChainId(chainId) ? CHAINS[chainId].explorerUrl : DEFAULT_EXPLORER_URL);\n\n const configured = mergeServices(options.services ?? [], config.services ?? []);\n if (configured.length > 0) sources[\"services\"] = options.services === undefined ? \"tab.config\" : \"options\";\n const services = hosted === undefined ? configured : mergeServices(configured, [hosted.demoService]);\n if (configured.length === 0 && services.length > 0) sources[\"services\"] = \"default (the project's hosted demo Service)\";\n\n const strategyId = trimmed(options.strategyId);\n if (strategyId !== undefined) sources[\"strategyId\"] = \"options\";\n\n const x402 = options.x402 ?? (typeof config.x402 === \"function\" ? config.x402 : undefined);\n if (x402 !== undefined) sources[\"x402\"] = options.x402 === undefined ? \"tab.config\" : \"options\";\n\n return {\n agent,\n registryUrl,\n rpcUrl,\n chainId,\n explorerUrl,\n services,\n strategyId,\n x402,\n sources,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/mcp/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG9E,OAAO,EAAE,aAAa,EAAkB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAe,MAAM,cAAc,CAAC;AAoD1D,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,iCAAiC,C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,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,UAAU,CAAC,GAAG,6CAA6C,CAAC;IAExH,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;IAEhE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3F,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IAEhG,OAAO;QACL,KAAK;QACL,WAAW;QACX,MAAM;QACN,OAAO;QACP,WAAW;QACX,QAAQ;QACR,UAAU;QACV,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Where the MCP server gets its settings, and the order it prefers them in.\n *\n * Three sources, most specific first:\n *\n * 1. the options handed to {@link resolveTabMcpSettings}, which is what a test\n * and an embedding host use;\n * 2. `tab.config.{ts,mts,mjs,js,cjs}`, discovered by walking up from the working\n * directory -- the mechanism this package already has for consumer\n * configuration, so the MCP surface adds no second one;\n * 3. the environment, which is what the `mcpServers` stanza `tab connect` writes\n * actually carries.\n *\n * Every environment variable read here is already declared in the tracked\n * `.env.example` contract. That is not incidental: the repository's environment\n * gate extracts every `process.env` read in the tree and fails the build when\n * one has no declaration, so a new name would be a new line in a contract this\n * surface has no business changing. The RPC endpoint is `MONAD_RPC_URL`, in the\n * stanza and here.\n *\n * ## No key is a setting\n *\n * Nothing in this module reads a private key and nothing returns one. The\n * settlement signing key is read from the environment at the moment a Settlement\n * is signed, by the strategy that signs it, and never travels through a config\n * file or an MCP client's `mcpServers` stanza. That is what makes `tab connect`\n * safe to run against a file the client software rewrites.\n */\n\nimport type { Address } from \"../_shared/index.js\";\nimport { CHAINS, TAB_HOSTED, isAddress, isMonadChainId } from \"../_shared/index.js\";\n\nimport type { TabServiceEntry } from \"../payments/config.js\";\nimport { loadTabConfig, type TabConfig } from \"../payments/config.js\";\nimport { defaultLogger, type Logger } from \"../logger.js\";\nimport type { X402SignerFactory } from \"../x402/client.js\";\n\n/** The settings every tool reads. Each field is resolved or explicitly absent. */\nexport interface TabMcpSettings {\n /** Whose Open Tab a metered call lands on. Undefined until one is configured. */\n readonly agent: Address | undefined;\n /** Absolute base URL of the registry read API, or undefined when none is configured. */\n readonly registryUrl: string | undefined;\n /** The Monad JSON-RPC endpoint, used by `doctor` and by nothing that signs. */\n readonly rpcUrl: string | undefined;\n /** The EVM chain id every Asset is named against: 143 for Mainnet, 10143 for Testnet. */\n readonly chainId: number;\n /** Where a Monad transaction is linked. Always resolved; a default is fine for a link. */\n readonly explorerUrl: string;\n /** The endpoint directory, keyed by lower-case serviceId. */\n readonly services: readonly TabServiceEntry[];\n /** Which strategy `tab_settle` settles through when the call names none. */\n readonly strategyId: string | undefined;\n /**\n * The x402 signer factory, for `tab_call`'s prepaid fallback. Never called\n * while settings are resolved; only when a refused call carries an offer.\n */\n readonly x402: X402SignerFactory | undefined;\n /** Where each setting came from, so `doctor` can print it. */\n readonly sources: Readonly<Record<string, string>>;\n}\n\n/** Explicit settings, which beat both the config file and the environment. */\nexport interface TabMcpSettingsOptions {\n readonly agent?: string;\n readonly chainId?: number;\n readonly registryUrl?: string;\n /**\n * Whether the project's hosted read API and demo Service fill in what nothing\n * else names. Default true; `TAB_HOSTED_DEFAULTS=off` in the environment\n * turns them off as well.\n */\n readonly hostedDefaults?: boolean;\n readonly rpcUrl?: string;\n readonly explorerUrl?: string;\n readonly services?: readonly TabServiceEntry[];\n readonly strategyId?: string;\n readonly x402?: X402SignerFactory;\n /** Where the `tab.config` walk starts. Defaults to the working directory. */\n readonly cwd?: string;\n /** `false` skips config discovery entirely, which is what a hermetic test wants. */\n readonly config?: TabConfig | false;\n readonly env?: NodeJS.ProcessEnv;\n readonly logger?: Logger;\n}\n\n/** The public Monad Testnet explorer, used when nothing names one. */\nexport const DEFAULT_EXPLORER_URL = \"https://testnet.monadvision.com\";\n\n/** Monad Testnet, used when nothing names a chain. */\nexport const DEFAULT_CHAIN_ID = 10143;\n\nconst trimmed = (value: string | undefined): string | undefined => {\n const text = value?.trim();\n return text === undefined || text === \"\" ? undefined : text;\n};\n\n/**\n * The registry read API the environment names.\n *\n * `NEXT_PUBLIC_REGISTRY_API_URL` is the deployment's own name for this value and\n * is already in the environment contract, so it is what is read. When only\n * `REGISTRY_PORT` is set the read API is taken to be local, which is exactly the\n * developer case and saves a second variable that would say the same thing.\n */\nconst registryUrlFromEnv = (env: NodeJS.ProcessEnv): { url: string; source: string } | undefined => {\n const declared = trimmed(env[\"NEXT_PUBLIC_REGISTRY_API_URL\"]);\n if (declared !== undefined) return { url: declared, source: \"env NEXT_PUBLIC_REGISTRY_API_URL\" };\n const port = trimmed(env[\"REGISTRY_PORT\"]);\n if (port !== undefined && /^[0-9]{1,5}$/.test(port)) {\n return { url: `http://127.0.0.1:${port}`, source: \"env REGISTRY_PORT\" };\n }\n return undefined;\n};\n\n/** Keeps the first entry for each serviceId, so a more specific source wins. */\nfunction mergeServices(...groups: readonly (readonly TabServiceEntry[])[]): readonly TabServiceEntry[] {\n const byId = new Map<string, TabServiceEntry>();\n for (const group of groups) {\n for (const entry of group) {\n if (typeof entry?.serviceId !== \"string\" || typeof entry?.endpoint !== \"string\") continue;\n const key = entry.serviceId.toLowerCase();\n if (!byId.has(key)) byId.set(key, { ...entry, serviceId: key });\n }\n }\n return [...byId.values()];\n}\n\n/**\n * Resolves the settings, loading `tab.config` unless one was handed in.\n *\n * Never fails. A config file that cannot be imported is logged and skipped\n * rather than taking the server down: the tools each report their own missing\n * settings by name, which is a better message than a startup failure that names\n * a file the caller may not have known existed.\n */\nexport async function resolveTabMcpSettings(\n options: TabMcpSettingsOptions = {},\n): Promise<TabMcpSettings> {\n const env = options.env ?? process.env;\n const logger = options.logger ?? defaultLogger;\n const sources: Record<string, string> = {};\n\n let config: TabConfig = {};\n if (options.config === undefined) {\n const loaded = await loadTabConfig({\n ...(options.cwd === undefined ? {} : { cwd: options.cwd }),\n registry: false,\n logger,\n });\n if (loaded.ok) {\n config = loaded.value.config;\n if (loaded.value.path !== undefined) sources[\"config\"] = loaded.value.path;\n } else {\n logger.warn(\"tab config could not be loaded; continuing without it\", {\n code: loaded.error.code,\n message: loaded.error.message,\n });\n }\n } else if (options.config !== false) {\n config = options.config;\n sources[\"config\"] = \"supplied\";\n }\n\n const pick = (\n key: string,\n explicit: string | undefined,\n fromConfig: string | undefined,\n fromEnv: { value: string; source: string } | undefined,\n ): string | undefined => {\n if (trimmed(explicit) !== undefined) {\n sources[key] = \"options\";\n return trimmed(explicit);\n }\n if (trimmed(fromConfig) !== undefined) {\n sources[key] = \"tab.config\";\n return trimmed(fromConfig);\n }\n if (fromEnv !== undefined) {\n sources[key] = fromEnv.source;\n return fromEnv.value;\n }\n return undefined;\n };\n\n const rawAgent = pick(\"agent\", options.agent, config.agent, undefined);\n const agent = rawAgent !== undefined && isAddress(rawAgent) ? (rawAgent.toLowerCase() as Address) : undefined;\n if (rawAgent !== undefined && agent === undefined) {\n logger.warn(\"the configured agent is not a 20-byte address and was ignored\", { agent: rawAgent });\n delete sources[\"agent\"];\n }\n\n const envRpc = trimmed(env[\"MONAD_RPC_URL\"]);\n const rpcUrl = pick(\n \"rpcUrl\",\n options.rpcUrl,\n undefined,\n envRpc === undefined ? undefined : { value: envRpc, source: \"env MONAD_RPC_URL\" },\n );\n\n const envChain = trimmed(env[\"MONAD_CHAIN_ID\"]);\n const chainIdText = pick(\n \"chainId\",\n options.chainId === undefined ? undefined : String(options.chainId),\n undefined,\n envChain === undefined ? undefined : { value: envChain, source: \"env MONAD_CHAIN_ID\" },\n );\n const chainId = chainIdText !== undefined && /^[0-9]+$/.test(chainIdText) ? Number(chainIdText) : DEFAULT_CHAIN_ID;\n\n /*\n What this project hosts on the chosen network: its read API and its demo\n Service. The lowest-priority source for both, so anything configured wins,\n and switched off with TAB_HOSTED_DEFAULTS=off for a setup that must reach\n nothing it did not name.\n */\n const hosted =\n options.hostedDefaults !== false && trimmed(env[\"TAB_HOSTED_DEFAULTS\"]) !== \"off\" && isMonadChainId(chainId)\n ? TAB_HOSTED[chainId]\n : undefined;\n\n const envRegistry = registryUrlFromEnv(env);\n let registryUrl = pick(\n \"registryUrl\",\n options.registryUrl,\n config.registryUrl,\n envRegistry === undefined ? undefined : { value: envRegistry.url, source: envRegistry.source },\n );\n if (registryUrl === undefined && hosted !== undefined) {\n registryUrl = hosted.registryUrl;\n sources[\"registryUrl\"] = \"default (the project's hosted read API)\";\n }\n\n const envExplorer = trimmed(env[\"MONAD_EXPLORER_URL\"]);\n const explorerUrl =\n pick(\n \"explorerUrl\",\n options.explorerUrl,\n undefined,\n envExplorer === undefined ? undefined : { value: envExplorer, source: \"env MONAD_EXPLORER_URL\" },\n ) ?? (isMonadChainId(chainId) ? CHAINS[chainId].explorerUrl : DEFAULT_EXPLORER_URL);\n\n const configured = mergeServices(options.services ?? [], config.services ?? []);\n if (configured.length > 0) sources[\"services\"] = options.services === undefined ? \"tab.config\" : \"options\";\n const services = hosted === undefined ? configured : mergeServices(configured, [hosted.demoService]);\n if (configured.length === 0 && services.length > 0) sources[\"services\"] = \"default (the project's hosted demo Service)\";\n\n const strategyId = trimmed(options.strategyId);\n if (strategyId !== undefined) sources[\"strategyId\"] = \"options\";\n\n const x402 = options.x402 ?? (typeof config.x402 === \"function\" ? config.x402 : undefined);\n if (x402 !== undefined) sources[\"x402\"] = options.x402 === undefined ? \"tab.config\" : \"options\";\n\n return {\n agent,\n registryUrl,\n rpcUrl,\n chainId,\n explorerUrl,\n services,\n strategyId,\n x402,\n sources,\n };\n}\n"]}
|
package/dist/mcp/toolset.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The MCP protocol wiring lives next door in `server.ts`. This file is the
|
|
5
5
|
* behaviour, and it is separate so the tools can be exercised without a
|
|
6
6
|
* transport: every test in `test/mcp-tools.test.mjs` calls these directly, which
|
|
7
|
-
* is what lets
|
|
7
|
+
* is what lets the suite validate every output against its declared schema
|
|
8
8
|
* without standing a server up.
|
|
9
9
|
*
|
|
10
10
|
* ## Nothing here throws, including into the transport
|
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
* the payload, and for `tab_call` and `tab_settle` it is `ok: false` beside it.
|
|
19
19
|
*
|
|
20
20
|
* `LIMIT_EXCEEDED` is the case that earns the discipline. An Agent out of
|
|
21
|
-
* headroom is not an error in the Agent, the Service, or the call
|
|
21
|
+
* headroom is not an error in the Agent, the Service, or the call: it is the
|
|
22
22
|
* credit facility working. The tool answers `ok: false` with
|
|
23
23
|
* `requiredBaseUnits` and `headroomBaseUnits` both filled in, so the model can
|
|
24
24
|
* settle the difference and call again instead of retrying into the same wall.
|
|
25
|
-
* (R21.5)
|
|
26
25
|
*
|
|
27
26
|
* ## Every input is validated against the schema that was published
|
|
28
27
|
*
|
|
@@ -30,8 +29,6 @@
|
|
|
30
29
|
* the declared defaults and {@link validateJsonValue} enforces the same document
|
|
31
30
|
* `tools/list` served, so a `limit` of 500 is refused with the same bound the
|
|
32
31
|
* model was shown.
|
|
33
|
-
*
|
|
34
|
-
* Requirements: 21.5, 25.1, 25.2, 25.3, 25.4
|
|
35
32
|
*/
|
|
36
33
|
import type { Result, TabError } from "../_shared/index.js";
|
|
37
34
|
import { type Tab402Fetch, type Tab402Response } from "../http/client-402.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolset.d.ts","sourceRoot":"","sources":["../../src/mcp/toolset.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"toolset.d.ts","sourceRoot":"","sources":["../../src/mcp/toolset.ts"],"names":[],"m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