@trinaryex/mcp 3.3.1
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 +146 -0
- package/dist/capture.d.ts +38 -0
- package/dist/capture.js +58 -0
- package/dist/capture.js.map +1 -0
- package/dist/context.d.ts +25 -0
- package/dist/context.js +44 -0
- package/dist/context.js.map +1 -0
- package/dist/env.d.ts +27 -0
- package/dist/env.js +40 -0
- package/dist/env.js.map +1 -0
- package/dist/http.d.ts +5 -0
- package/dist/http.js +120 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/logging.d.ts +10 -0
- package/dist/logging.js +43 -0
- package/dist/logging.js.map +1 -0
- package/dist/prepare.d.ts +71 -0
- package/dist/prepare.js +79 -0
- package/dist/prepare.js.map +1 -0
- package/dist/registry.d.ts +18 -0
- package/dist/registry.js +24 -0
- package/dist/registry.js.map +1 -0
- package/dist/result.d.ts +16 -0
- package/dist/result.js +32 -0
- package/dist/result.js.map +1 -0
- package/dist/schemas.d.ts +31 -0
- package/dist/schemas.js +37 -0
- package/dist/schemas.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.js +41 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/prepare.d.ts +2 -0
- package/dist/tools/prepare.js +297 -0
- package/dist/tools/prepare.js.map +1 -0
- package/dist/tools/read.d.ts +7 -0
- package/dist/tools/read.js +152 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/types.d.ts +20 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +20 -0
- package/dist/version.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ClientWithCoreApi } from '@mysten/sui/client';
|
|
2
|
+
import type { Transaction } from '@mysten/sui/transactions';
|
|
3
|
+
/**
|
|
4
|
+
* A prepared, unsigned transaction. This is the whole output contract of every
|
|
5
|
+
* `prepare_*` tool: bytes the caller can sponsor, sign and submit, plus the
|
|
6
|
+
* declared intent those bytes are meant to be checked against.
|
|
7
|
+
*
|
|
8
|
+
* Callers MUST verify before signing: decode `txKindBytes`, confirm the Move
|
|
9
|
+
* call targets equal `intent.targets`, bound the spend against
|
|
10
|
+
* `intent.worstCaseSpend`, and dry-run. Never blind-sign.
|
|
11
|
+
*/
|
|
12
|
+
export interface PreparedTransaction {
|
|
13
|
+
/** Base64 BCS `TransactionKind`, built with `onlyTransactionKind: true`. */
|
|
14
|
+
txKindBytes: string;
|
|
15
|
+
/** Address the transaction was built for; only this key can sign it. */
|
|
16
|
+
sender: string;
|
|
17
|
+
intent: PreparedIntent;
|
|
18
|
+
/**
|
|
19
|
+
* Owned/shared objects the build pinned, with the versions it resolved.
|
|
20
|
+
* Staleness lives here: sign promptly, and never hold two prepared
|
|
21
|
+
* transactions over the same owned objects.
|
|
22
|
+
*/
|
|
23
|
+
pinnedObjects: PinnedObject[];
|
|
24
|
+
/** Epoch-ms the bytes were built, for freshness checks. */
|
|
25
|
+
builtAtMs: number;
|
|
26
|
+
/** Guidance echoed to the model so the constraint travels with the data. */
|
|
27
|
+
notes: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface PreparedIntent {
|
|
30
|
+
/** Stable action name, matching the tool that produced it. */
|
|
31
|
+
action: string;
|
|
32
|
+
/**
|
|
33
|
+
* Every Move call target in the built transaction, in command order.
|
|
34
|
+
* Extracted from the transaction itself — not reconstructed — so the
|
|
35
|
+
* caller's allowlist check is checking the real bytes.
|
|
36
|
+
*/
|
|
37
|
+
targets: string[];
|
|
38
|
+
/** Worst-case funds the transaction can move out of the sender's control. */
|
|
39
|
+
worstCaseSpend?: WorstCaseSpend;
|
|
40
|
+
/** Action-specific, human- and machine-readable parameters. */
|
|
41
|
+
params: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export interface WorstCaseSpend {
|
|
44
|
+
/** Coin type or asset id, e.g. a CRED coin type or an item asset id. */
|
|
45
|
+
asset: string;
|
|
46
|
+
/** Integer base units, as a decimal string. */
|
|
47
|
+
amount: string;
|
|
48
|
+
kind: 'currency' | 'item';
|
|
49
|
+
}
|
|
50
|
+
export interface PinnedObject {
|
|
51
|
+
objectId: string;
|
|
52
|
+
version: string | null;
|
|
53
|
+
kind: 'owned' | 'shared' | 'receiving';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Pull every Move call target out of a built transaction, in command order.
|
|
57
|
+
* Returns `<package>::<module>::<function>` strings.
|
|
58
|
+
*
|
|
59
|
+
* Package ids are NORMALIZED to full 32-byte form by the builder (`0x2`
|
|
60
|
+
* becomes `0x000…002`). Callers allowlisting these targets must normalize
|
|
61
|
+
* their expected ids the same way or the comparison will never match.
|
|
62
|
+
*/
|
|
63
|
+
export declare function extractTargets(tx: Transaction): string[];
|
|
64
|
+
/** Pull the object inputs a build pinned, with resolved versions. */
|
|
65
|
+
export declare function extractPinnedObjects(tx: Transaction): PinnedObject[];
|
|
66
|
+
/**
|
|
67
|
+
* Serialize a built transaction into the prepare contract. Builds with
|
|
68
|
+
* `onlyTransactionKind: true` — no gas data, no sender signature — which is
|
|
69
|
+
* exactly the shape a gas station expects for sponsorship.
|
|
70
|
+
*/
|
|
71
|
+
export declare function toPrepared(tx: Transaction, sender: string, client: ClientWithCoreApi, intent: Omit<PreparedIntent, 'targets'>, extraNotes?: string[]): Promise<PreparedTransaction>;
|
package/dist/prepare.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pull every Move call target out of a built transaction, in command order.
|
|
3
|
+
* Returns `<package>::<module>::<function>` strings.
|
|
4
|
+
*
|
|
5
|
+
* Package ids are NORMALIZED to full 32-byte form by the builder (`0x2`
|
|
6
|
+
* becomes `0x000…002`). Callers allowlisting these targets must normalize
|
|
7
|
+
* their expected ids the same way or the comparison will never match.
|
|
8
|
+
*/
|
|
9
|
+
export function extractTargets(tx) {
|
|
10
|
+
const data = tx.getData();
|
|
11
|
+
const targets = [];
|
|
12
|
+
for (const command of data.commands ?? []) {
|
|
13
|
+
const call = command?.MoveCall;
|
|
14
|
+
if (!call)
|
|
15
|
+
continue;
|
|
16
|
+
const pkg = call.package ?? '?';
|
|
17
|
+
const mod = call.module ?? '?';
|
|
18
|
+
const fn = call.function ?? '?';
|
|
19
|
+
targets.push(`${pkg}::${mod}::${fn}`);
|
|
20
|
+
}
|
|
21
|
+
return targets;
|
|
22
|
+
}
|
|
23
|
+
/** Pull the object inputs a build pinned, with resolved versions. */
|
|
24
|
+
export function extractPinnedObjects(tx) {
|
|
25
|
+
const data = tx.getData();
|
|
26
|
+
const pinned = [];
|
|
27
|
+
for (const input of data.inputs ?? []) {
|
|
28
|
+
const object = input?.Object;
|
|
29
|
+
if (!object)
|
|
30
|
+
continue;
|
|
31
|
+
const owned = object.ImmOrOwnedObject;
|
|
32
|
+
const shared = object.SharedObject;
|
|
33
|
+
const receiving = object.Receiving;
|
|
34
|
+
if (owned) {
|
|
35
|
+
pinned.push({
|
|
36
|
+
objectId: owned.objectId,
|
|
37
|
+
version: owned.version != null ? String(owned.version) : null,
|
|
38
|
+
kind: 'owned',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else if (shared) {
|
|
42
|
+
pinned.push({
|
|
43
|
+
objectId: shared.objectId,
|
|
44
|
+
version: shared.initialSharedVersion != null
|
|
45
|
+
? String(shared.initialSharedVersion)
|
|
46
|
+
: null,
|
|
47
|
+
kind: 'shared',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (receiving) {
|
|
51
|
+
pinned.push({
|
|
52
|
+
objectId: receiving.objectId,
|
|
53
|
+
version: receiving.version != null ? String(receiving.version) : null,
|
|
54
|
+
kind: 'receiving',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return pinned;
|
|
59
|
+
}
|
|
60
|
+
const VERIFY_NOTE = 'Verify before signing: decode txKindBytes, assert its Move call targets equal intent.targets, bound the spend against intent.worstCaseSpend, then dry-run.';
|
|
61
|
+
const STALENESS_NOTE = 'Sign promptly. pinnedObjects records the object versions this build resolved; holding two prepared transactions over the same owned objects risks equivocation.';
|
|
62
|
+
/**
|
|
63
|
+
* Serialize a built transaction into the prepare contract. Builds with
|
|
64
|
+
* `onlyTransactionKind: true` — no gas data, no sender signature — which is
|
|
65
|
+
* exactly the shape a gas station expects for sponsorship.
|
|
66
|
+
*/
|
|
67
|
+
export async function toPrepared(tx, sender, client, intent, extraNotes = []) {
|
|
68
|
+
tx.setSender(sender);
|
|
69
|
+
const bytes = await tx.build({ client, onlyTransactionKind: true });
|
|
70
|
+
return {
|
|
71
|
+
txKindBytes: Buffer.from(bytes).toString('base64'),
|
|
72
|
+
sender,
|
|
73
|
+
intent: { ...intent, targets: extractTargets(tx) },
|
|
74
|
+
pinnedObjects: extractPinnedObjects(tx),
|
|
75
|
+
builtAtMs: Date.now(),
|
|
76
|
+
notes: [VERIFY_NOTE, STALENESS_NOTE, ...extraNotes],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../src/prepare.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolDef } from './tools/types.js';
|
|
2
|
+
import type { ServerMode } from './env.js';
|
|
3
|
+
/** Every tool this server can expose, in a stable order. */
|
|
4
|
+
export declare const ALL_TOOLS: ToolDef[];
|
|
5
|
+
/**
|
|
6
|
+
* SDK client methods deliberately not exposed as tools, with the reason.
|
|
7
|
+
*
|
|
8
|
+
* The parity test walks the SDK's public client surface and fails on anything
|
|
9
|
+
* that is neither wrapped by a tool nor listed here — so dropping a method is
|
|
10
|
+
* always a conscious, reviewed act.
|
|
11
|
+
*/
|
|
12
|
+
export declare const EXCLUDED_SDK_PATHS: Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Tools for a given server mode. `read` mode never even registers the prepare
|
|
15
|
+
* tools, so a read-only deployment is read-only by construction and its
|
|
16
|
+
* `tools/list` says so.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toolsForMode(mode: ServerMode): ToolDef[];
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { prepareTools } from './tools/prepare.js';
|
|
2
|
+
import { readTools } from './tools/read.js';
|
|
3
|
+
/** Every tool this server can expose, in a stable order. */
|
|
4
|
+
export const ALL_TOOLS = [...readTools, ...prepareTools];
|
|
5
|
+
/**
|
|
6
|
+
* SDK client methods deliberately not exposed as tools, with the reason.
|
|
7
|
+
*
|
|
8
|
+
* The parity test walks the SDK's public client surface and fails on anything
|
|
9
|
+
* that is neither wrapped by a tool nor listed here — so dropping a method is
|
|
10
|
+
* always a conscious, reviewed act.
|
|
11
|
+
*/
|
|
12
|
+
export const EXCLUDED_SDK_PATHS = {
|
|
13
|
+
'market.resolvePool': 'Internal plumbing — pool ids are resolved inside the tools that need them.',
|
|
14
|
+
'balances.currency': 'Wallet CRED balance is a plain Sui coin read; account_balances_at_hub covers the trading-account view.',
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Tools for a given server mode. `read` mode never even registers the prepare
|
|
18
|
+
* tools, so a read-only deployment is read-only by construction and its
|
|
19
|
+
* `tools/list` says so.
|
|
20
|
+
*/
|
|
21
|
+
export function toolsForMode(mode) {
|
|
22
|
+
return mode === 'read' ? readTools : ALL_TOOLS;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAc,CAAC,GAAG,SAAS,EAAE,GAAG,YAAY,CAAC,CAAA;AAEnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD,oBAAoB,EAClB,4EAA4E;IAC9E,mBAAmB,EACjB,wGAAwG;CAC3G,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAAgB;IAC3C,OAAO,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;AAChD,CAAC"}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Serialize any SDK value to JSON text, with u64-ish values as strings. */
|
|
2
|
+
export declare function toJsonText(value: unknown): string;
|
|
3
|
+
export interface ToolResponse {
|
|
4
|
+
content: {
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}[];
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Wrap a value as a successful MCP tool result. */
|
|
11
|
+
export declare function ok(value: unknown): ToolResponse;
|
|
12
|
+
/**
|
|
13
|
+
* Wrap an error as an MCP tool result. Tool-level failures are returned as
|
|
14
|
+
* results (not protocol errors) so the model can read and react to them.
|
|
15
|
+
*/
|
|
16
|
+
export declare function fail(error: unknown): ToolResponse;
|
package/dist/result.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** JSON replacer that renders bigints as decimal strings. */
|
|
2
|
+
function bigintSafe(_key, value) {
|
|
3
|
+
return typeof value === 'bigint' ? value.toString() : value;
|
|
4
|
+
}
|
|
5
|
+
/** Serialize any SDK value to JSON text, with u64-ish values as strings. */
|
|
6
|
+
export function toJsonText(value) {
|
|
7
|
+
return JSON.stringify(value, bigintSafe, 2);
|
|
8
|
+
}
|
|
9
|
+
/** Wrap a value as a successful MCP tool result. */
|
|
10
|
+
export function ok(value) {
|
|
11
|
+
return { content: [{ type: 'text', text: toJsonText(value) }] };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wrap an error as an MCP tool result. Tool-level failures are returned as
|
|
15
|
+
* results (not protocol errors) so the model can read and react to them.
|
|
16
|
+
*/
|
|
17
|
+
export function fail(error) {
|
|
18
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
19
|
+
const code = error && typeof error === 'object' && 'code' in error
|
|
20
|
+
? String(error.code)
|
|
21
|
+
: undefined;
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: 'text',
|
|
26
|
+
text: toJsonText({ error: message, ...(code ? { code } : {}) }),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
isError: true,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../src/result.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,SAAS,UAAU,CAAC,IAAY,EAAE,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;AAC7D,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAA;AAC7C,CAAC;AAOD,oDAAoD;AACpD,MAAM,UAAU,EAAE,CAAC,KAAc;IAC/B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,IAAI,CAAC,KAAc;IACjC,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACtE,MAAM,IAAI,GACR,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK;QACnD,CAAC,CAAC,MAAM,CAAE,KAA2B,CAAC,IAAI,CAAC;QAC3C,CAAC,CAAC,SAAS,CAAA;IACf,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;aAChE;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Input primitives for tool schemas.
|
|
4
|
+
*
|
|
5
|
+
* u64-ish values cross the MCP boundary as decimal strings — JSON has no
|
|
6
|
+
* bigint, and silently truncating an order price through a double is not an
|
|
7
|
+
* acceptable failure mode. This mirrors the relay-api convention.
|
|
8
|
+
*/
|
|
9
|
+
export declare const u64: z.ZodString;
|
|
10
|
+
export declare const suiAddress: z.ZodString;
|
|
11
|
+
export declare const objectId: z.ZodString;
|
|
12
|
+
export declare const orderSide: z.ZodEnum<{
|
|
13
|
+
buy: "buy";
|
|
14
|
+
sell: "sell";
|
|
15
|
+
}>;
|
|
16
|
+
/** The address a prepared transaction is built for. Only its key can sign. */
|
|
17
|
+
export declare const senderShape: {
|
|
18
|
+
sender: z.ZodString;
|
|
19
|
+
};
|
|
20
|
+
export declare const hubAssetShape: {
|
|
21
|
+
storageUnitId: z.ZodString;
|
|
22
|
+
assetId: z.ZodString;
|
|
23
|
+
};
|
|
24
|
+
export declare const pagingShape: {
|
|
25
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
27
|
+
};
|
|
28
|
+
/** Parse a decimal string into a bigint after zod has validated its shape. */
|
|
29
|
+
export declare function big(value: string): bigint;
|
|
30
|
+
/** Parse an optional decimal string into an optional bigint. */
|
|
31
|
+
export declare function bigOpt(value: string | undefined): bigint | undefined;
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Input primitives for tool schemas.
|
|
4
|
+
*
|
|
5
|
+
* u64-ish values cross the MCP boundary as decimal strings — JSON has no
|
|
6
|
+
* bigint, and silently truncating an order price through a double is not an
|
|
7
|
+
* acceptable failure mode. This mirrors the relay-api convention.
|
|
8
|
+
*/
|
|
9
|
+
export const u64 = z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^\d+$/, 'expected a non-negative integer as a decimal string');
|
|
12
|
+
export const suiAddress = z
|
|
13
|
+
.string()
|
|
14
|
+
.regex(/^0x[0-9a-fA-F]{1,64}$/, 'expected a 0x-prefixed Sui address');
|
|
15
|
+
export const objectId = suiAddress;
|
|
16
|
+
export const orderSide = z.enum(['buy', 'sell']);
|
|
17
|
+
/** The address a prepared transaction is built for. Only its key can sign. */
|
|
18
|
+
export const senderShape = {
|
|
19
|
+
sender: suiAddress.describe('Sui address the transaction is built for; only this address can sign the result.'),
|
|
20
|
+
};
|
|
21
|
+
export const hubAssetShape = {
|
|
22
|
+
storageUnitId: objectId.describe('Trade hub / storage unit object id.'),
|
|
23
|
+
assetId: z.string().describe('EVE Frontier item asset id, e.g. "70810".'),
|
|
24
|
+
};
|
|
25
|
+
export const pagingShape = {
|
|
26
|
+
limit: z.number().int().positive().max(200).optional(),
|
|
27
|
+
cursor: z.string().optional(),
|
|
28
|
+
};
|
|
29
|
+
/** Parse a decimal string into a bigint after zod has validated its shape. */
|
|
30
|
+
export function big(value) {
|
|
31
|
+
return BigInt(value);
|
|
32
|
+
}
|
|
33
|
+
/** Parse an optional decimal string into an optional bigint. */
|
|
34
|
+
export function bigOpt(value) {
|
|
35
|
+
return value === undefined ? undefined : BigInt(value);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC;KACjB,MAAM,EAAE;KACR,KAAK,CAAC,OAAO,EAAE,qDAAqD,CAAC,CAAA;AAExE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,EAAE;KACR,KAAK,CAAC,uBAAuB,EAAE,oCAAoC,CAAC,CAAA;AAEvE,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAA;AAElC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;AAEhD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,MAAM,EAAE,UAAU,CAAC,QAAQ,CACzB,kFAAkF,CACnF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IACvE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;CAC1E,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IACtD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAA;AAED,8EAA8E;AAC9E,MAAM,UAAU,GAAG,CAAC,KAAa;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,MAAM,CAAC,KAAyB;IAC9C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACxD,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { RequestContext } from './context.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build an MCP server bound to one request's context.
|
|
5
|
+
*
|
|
6
|
+
* In stateless HTTP mode a server instance is created per request, so the
|
|
7
|
+
* caller's credentials live in this closure and nowhere else — there is no
|
|
8
|
+
* shared registry a second tenant could read them out of.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createServer(ctx: RequestContext): McpServer;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { fail } from './result.js';
|
|
3
|
+
import { toolsForMode } from './registry.js';
|
|
4
|
+
import { packageVersion } from './version.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build an MCP server bound to one request's context.
|
|
7
|
+
*
|
|
8
|
+
* In stateless HTTP mode a server instance is created per request, so the
|
|
9
|
+
* caller's credentials live in this closure and nowhere else — there is no
|
|
10
|
+
* shared registry a second tenant could read them out of.
|
|
11
|
+
*/
|
|
12
|
+
export function createServer(ctx) {
|
|
13
|
+
const server = new McpServer({
|
|
14
|
+
name: '@trinaryex/mcp',
|
|
15
|
+
version: packageVersion(),
|
|
16
|
+
});
|
|
17
|
+
for (const tool of toolsForMode(ctx.config.mode)) {
|
|
18
|
+
server.registerTool(tool.name, {
|
|
19
|
+
title: tool.title,
|
|
20
|
+
description: tool.description,
|
|
21
|
+
inputSchema: tool.inputShape,
|
|
22
|
+
annotations: {
|
|
23
|
+
title: tool.title,
|
|
24
|
+
// Both kinds are read-only with respect to the world: prepare tools
|
|
25
|
+
// build bytes and submit nothing. The act boundary lives in the
|
|
26
|
+
// caller, at signing time.
|
|
27
|
+
readOnlyHint: true,
|
|
28
|
+
openWorldHint: true,
|
|
29
|
+
},
|
|
30
|
+
}, async (args) => {
|
|
31
|
+
try {
|
|
32
|
+
return (await tool.handler(ctx, args));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return fail(e);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return server;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAEnE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,GAAmB;IAC9C,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,cAAc,EAAE;KAC1B,CAAC,CAAA;IAEF,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,YAAY,CACjB,IAAI,CAAC,IAAI,EACT;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,UAAU;YAC5B,WAAW,EAAE;gBACX,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,oEAAoE;gBACpE,gEAAgE;gBAChE,2BAA2B;gBAC3B,YAAY,EAAE,IAAI;gBAClB,aAAa,EAAE,IAAI;aACpB;SACF,EACD,KAAK,EAAE,IAAS,EAAE,EAAE;YAClB,IAAI,CAAC;gBACH,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAQ,CAAA;YAC/C,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,IAAI,CAAC,CAAC,CAAQ,CAAA;YACvB,CAAC;QACH,CAAC,CACF,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|