@veyanet/mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/LICENSE +21 -0
- package/README.md +502 -0
- package/SECURITY.md +72 -0
- package/assets/logo.png +0 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +441 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +444 -0
- package/dist/index.js.map +1 -0
- package/docs/ARCHITECTURE.md +77 -0
- package/docs/AUTHENTICATION.md +76 -0
- package/docs/CONFIGURATION.md +88 -0
- package/docs/DEPLOYMENT.md +119 -0
- package/docs/NETWORK_PIN.md +51 -0
- package/docs/QUICKSTART.md +111 -0
- package/docs/README.md +54 -0
- package/docs/SDK_BRIDGE.md +67 -0
- package/docs/TOOLS.md +148 -0
- package/docs/TRANSPORT.md +91 -0
- package/docs/VERIFICATION.md +81 -0
- package/package.json +69 -0
- package/src/auth.ts +24 -0
- package/src/cli.ts +6 -0
- package/src/config.test.ts +44 -0
- package/src/config.ts +49 -0
- package/src/http.ts +143 -0
- package/src/index.ts +9 -0
- package/src/sdk.ts +36 -0
- package/src/server.ts +23 -0
- package/src/tools/public.ts +113 -0
- package/src/tools/write.ts +120 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { MCP_SERVICE_NAME, MCP_SERVICE_VERSION, type McpServiceConfig } from "../config.js";
|
|
4
|
+
import { createReadClient } from "../sdk.js";
|
|
5
|
+
|
|
6
|
+
export function registerPublicTools(server: McpServer, cfg: McpServiceConfig): void {
|
|
7
|
+
server.tool(
|
|
8
|
+
"veya_describe",
|
|
9
|
+
"Honesty card: what this MCP is (AES sealed elsewhere, testnet 46630, not FHE/mainnet)",
|
|
10
|
+
{},
|
|
11
|
+
async () => ({
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: "text",
|
|
15
|
+
text: JSON.stringify(
|
|
16
|
+
{
|
|
17
|
+
name: MCP_SERVICE_NAME,
|
|
18
|
+
version: MCP_SERVICE_VERSION,
|
|
19
|
+
publicUrl: cfg.publicMcpUrl,
|
|
20
|
+
settlement: {
|
|
21
|
+
network: "Robinhood Chain testnet",
|
|
22
|
+
chainId: cfg.chainId,
|
|
23
|
+
contract: cfg.contractAddress,
|
|
24
|
+
explorer: cfg.explorerUrl,
|
|
25
|
+
rpc: cfg.rpcUrl,
|
|
26
|
+
},
|
|
27
|
+
productApi: cfg.apiUrl,
|
|
28
|
+
sealed: "AES-256-GCM sealed-node (not FHE; TFHE is Phase 4)",
|
|
29
|
+
mainnet: "Not a VEYA settlement claim (Phase 3)",
|
|
30
|
+
writes: "Require Authorization: Bearer <MCP_API_KEY> when enabled on the server",
|
|
31
|
+
stdioSibling: "Local stdio MCP remains at veya-anchor/packages/mcp (operators)",
|
|
32
|
+
},
|
|
33
|
+
null,
|
|
34
|
+
2,
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
server.tool(
|
|
42
|
+
"veya_ping_chain",
|
|
43
|
+
"Ping Robinhood Chain RPC — chain id, block, contract",
|
|
44
|
+
{},
|
|
45
|
+
async () => {
|
|
46
|
+
const client = createReadClient(cfg);
|
|
47
|
+
const ping = await client.pingChain();
|
|
48
|
+
return {
|
|
49
|
+
content: [
|
|
50
|
+
{
|
|
51
|
+
type: "text",
|
|
52
|
+
text: JSON.stringify(
|
|
53
|
+
{
|
|
54
|
+
...ping,
|
|
55
|
+
chainId: ping.chainId.toString(),
|
|
56
|
+
expectedChainId: cfg.chainId,
|
|
57
|
+
config: client.describe(),
|
|
58
|
+
},
|
|
59
|
+
null,
|
|
60
|
+
2,
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
server.tool(
|
|
69
|
+
"veya_hash_blake3",
|
|
70
|
+
"Compute BLAKE3 hex digest (commitment helper)",
|
|
71
|
+
{ data: z.string().min(1) },
|
|
72
|
+
async ({ data }) => {
|
|
73
|
+
const client = createReadClient(cfg);
|
|
74
|
+
const hash = await client.hashBlake3(data);
|
|
75
|
+
return {
|
|
76
|
+
content: [{ type: "text", text: JSON.stringify({ hash }, null, 2) }],
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
server.tool(
|
|
82
|
+
"veya_verify_transaction",
|
|
83
|
+
"Verify a Veya.sol commitment from a Robinhood Chain tx hash",
|
|
84
|
+
{ txHash: z.string().min(66) },
|
|
85
|
+
async ({ txHash }) => {
|
|
86
|
+
const client = createReadClient(cfg);
|
|
87
|
+
const result = await client.verifyTransaction(txHash);
|
|
88
|
+
return {
|
|
89
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
server.tool(
|
|
95
|
+
"veya_api_health",
|
|
96
|
+
"Probe the public VEYA API /health (api.veyanet.tech) — honest degraded when fleet down",
|
|
97
|
+
{},
|
|
98
|
+
async () => {
|
|
99
|
+
const res = await fetch(`${cfg.apiUrl}/health`, {
|
|
100
|
+
signal: AbortSignal.timeout(8000),
|
|
101
|
+
});
|
|
102
|
+
const body = await res.json().catch(() => ({}));
|
|
103
|
+
return {
|
|
104
|
+
content: [
|
|
105
|
+
{
|
|
106
|
+
type: "text",
|
|
107
|
+
text: JSON.stringify({ httpStatus: res.status, body }, null, 2),
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { McpServiceConfig } from "../config.js";
|
|
4
|
+
import { writesEnabled } from "../config.js";
|
|
5
|
+
import { assertWriteAuthorized } from "../auth.js";
|
|
6
|
+
import { createWriteClient, parseHexBytes } from "../sdk.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Write tools are registered only when MCP_API_KEY + relayer key exist.
|
|
10
|
+
* Callers must still pass Authorization: Bearer on the HTTP request;
|
|
11
|
+
* bearer is read from request AsyncLocalStorage.
|
|
12
|
+
*/
|
|
13
|
+
export function registerWriteTools(
|
|
14
|
+
server: McpServer,
|
|
15
|
+
cfg: McpServiceConfig,
|
|
16
|
+
getBearer: () => string | null,
|
|
17
|
+
): void {
|
|
18
|
+
if (!writesEnabled(cfg)) {
|
|
19
|
+
server.tool(
|
|
20
|
+
"veya_writes_status",
|
|
21
|
+
"Reports that on-chain write tools are disabled on this server",
|
|
22
|
+
{},
|
|
23
|
+
async () => ({
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: "text",
|
|
27
|
+
text: JSON.stringify({
|
|
28
|
+
writesEnabled: false,
|
|
29
|
+
reason: "Set MCP_API_KEY and VEYA_RELAYER_PRIVATE_KEY to enable write tools",
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function requireAuth(): void {
|
|
39
|
+
assertWriteAuthorized(cfg, getBearer());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
server.tool(
|
|
43
|
+
"veya_store_commitment",
|
|
44
|
+
"Write a 32-byte commitment to Veya.sol (requires MCP_API_KEY). Use content Use stamps prefer product-site + API.",
|
|
45
|
+
{
|
|
46
|
+
environmentUuidHex: z.string().min(32),
|
|
47
|
+
commitmentHex: z.string().min(64),
|
|
48
|
+
},
|
|
49
|
+
async ({ environmentUuidHex, commitmentHex }) => {
|
|
50
|
+
requireAuth();
|
|
51
|
+
const client = createWriteClient(cfg);
|
|
52
|
+
const txHash = await client.requireEvm().storeCommitment(
|
|
53
|
+
parseHexBytes(environmentUuidHex, 16),
|
|
54
|
+
parseHexBytes(commitmentHex, 32),
|
|
55
|
+
);
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: "text",
|
|
60
|
+
text: JSON.stringify({ txHash, explorer: client.explorerFor(txHash) }, null, 2),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
server.tool(
|
|
68
|
+
"veya_attest_execution",
|
|
69
|
+
"attestExecution on Veya.sol with ML-DSA bytes (requires MCP_API_KEY)",
|
|
70
|
+
{
|
|
71
|
+
environmentUuidHex: z.string().min(32),
|
|
72
|
+
blake3HashHex: z.string().min(64),
|
|
73
|
+
mldsaSigHex: z.string().min(8),
|
|
74
|
+
},
|
|
75
|
+
async ({ environmentUuidHex, blake3HashHex, mldsaSigHex }) => {
|
|
76
|
+
requireAuth();
|
|
77
|
+
const client = createWriteClient(cfg);
|
|
78
|
+
const txHash = await client.requireEvm().attestExecution(
|
|
79
|
+
parseHexBytes(environmentUuidHex, 16),
|
|
80
|
+
parseHexBytes(blake3HashHex, 32),
|
|
81
|
+
parseHexBytes(mldsaSigHex),
|
|
82
|
+
);
|
|
83
|
+
return {
|
|
84
|
+
content: [
|
|
85
|
+
{
|
|
86
|
+
type: "text",
|
|
87
|
+
text: JSON.stringify({ txHash, explorer: client.explorerFor(txHash) }, null, 2),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
server.tool(
|
|
95
|
+
"veya_register_environment",
|
|
96
|
+
"registerEnvironment on Veya.sol (requires MCP_API_KEY)",
|
|
97
|
+
{
|
|
98
|
+
environmentUuidHex: z.string().min(32),
|
|
99
|
+
pqPubkeyHashHex: z.string().min(64),
|
|
100
|
+
envType: z.number().int().min(0).max(10).default(0),
|
|
101
|
+
},
|
|
102
|
+
async ({ environmentUuidHex, pqPubkeyHashHex, envType }) => {
|
|
103
|
+
requireAuth();
|
|
104
|
+
const client = createWriteClient(cfg);
|
|
105
|
+
const txHash = await client.requireEvm().registerEnvironment(
|
|
106
|
+
parseHexBytes(environmentUuidHex, 16),
|
|
107
|
+
parseHexBytes(pqPubkeyHashHex, 32),
|
|
108
|
+
envType,
|
|
109
|
+
);
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: "text",
|
|
114
|
+
text: JSON.stringify({ txHash, explorer: client.explorerFor(txHash) }, null, 2),
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
}
|