@treza/mcp 0.1.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/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # @treza/mcp
2
+
3
+ [![npm version](https://badge.fury.io/js/%40treza%2Fmcp.svg)](https://badge.fury.io/js/%40treza%2Fmcp)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Model Context Protocol (MCP) server for Treza Enclaves. Lets AI agents manage hardware-isolated TEEs, verify cryptographic attestations, and interact with the Treza platform — all through natural tool calls.
7
+
8
+ ## Quick Start
9
+
10
+ ### With Claude Desktop / Cursor / Any MCP Client
11
+
12
+ Add to your MCP configuration:
13
+
14
+ ```json
15
+ {
16
+ "mcpServers": {
17
+ "treza": {
18
+ "command": "npx",
19
+ "args": ["@treza/mcp"],
20
+ "env": {
21
+ "TREZA_BASE_URL": "https://app.trezalabs.com"
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ ### As a Standalone Server
29
+
30
+ ```bash
31
+ npm install -g @treza/mcp
32
+ treza-mcp
33
+ ```
34
+
35
+ ## Environment Variables
36
+
37
+ | Variable | Default | Description |
38
+ |---|---|---|
39
+ | `TREZA_BASE_URL` | `https://app.trezalabs.com` | Treza Platform API URL |
40
+ | `TREZA_TIMEOUT` | `30000` | Request timeout in milliseconds |
41
+
42
+ ## Available Tools
43
+
44
+ ### Enclave Management
45
+
46
+ | Tool | Description |
47
+ |---|---|
48
+ | `treza_list_enclaves` | List all enclaves owned by a wallet address |
49
+ | `treza_get_enclave` | Get detailed info about a specific enclave |
50
+ | `treza_create_enclave` | Create a new AWS Nitro Enclave with hardware-isolated TEE |
51
+ | `treza_update_enclave` | Update enclave name, description, or config |
52
+ | `treza_delete_enclave` | Permanently delete a terminated enclave |
53
+ | `treza_enclave_action` | Pause, resume, or terminate an enclave |
54
+ | `treza_get_enclave_logs` | Retrieve logs filtered by source type |
55
+
56
+ ### Attestation & Verification
57
+
58
+ | Tool | Description |
59
+ |---|---|
60
+ | `treza_get_attestation` | Get attestation document with PCR measurements and certificate chain |
61
+ | `treza_verify_attestation` | Full cryptographic verification with compliance checks (SOC2, HIPAA, FIPS) |
62
+ | `treza_get_verification_status` | Quick trust level check |
63
+
64
+ ### Platform
65
+
66
+ | Tool | Description |
67
+ |---|---|
68
+ | `treza_list_providers` | List available enclave providers and regions |
69
+ | `treza_get_provider` | Get provider details and config schema |
70
+ | `treza_list_tasks` | List scheduled tasks |
71
+ | `treza_create_task` | Create a cron-scheduled task in an enclave |
72
+ | `treza_list_api_keys` | List scoped API keys |
73
+ | `treza_create_api_key` | Create a new API key with specific permissions |
74
+
75
+ ## MCP Resources
76
+
77
+ The server also exposes browsable resources that give agents ambient context:
78
+
79
+ | Resource URI | Description |
80
+ |---|---|
81
+ | `treza://enclaves/{walletAddress}` | All enclaves for a wallet |
82
+ | `treza://enclaves/{enclaveId}/details` | Full enclave details |
83
+ | `treza://enclaves/{enclaveId}/attestation` | Attestation document |
84
+ | `treza://enclaves/{enclaveId}/verification` | Verification status |
85
+
86
+ ## Example Agent Interactions
87
+
88
+ An AI agent using the Treza MCP server can:
89
+
90
+ ```
91
+ "Create me a Nitro Enclave in us-west-2 for my trading bot"
92
+ → treza_create_enclave
93
+
94
+ "Is my enclave verified? What's the trust level?"
95
+ → treza_verify_attestation
96
+
97
+ "Show me the last 20 error logs from my enclave"
98
+ → treza_get_enclave_logs
99
+
100
+ "Pause my enclave to save costs while I'm not using it"
101
+ → treza_enclave_action (pause)
102
+ ```
103
+
104
+ ## Architecture
105
+
106
+ ```
107
+ AI Agent (Claude, Cursor, etc.)
108
+
109
+
110
+ ┌──────────────┐
111
+ │ @treza/mcp │ ← MCP Server (this package)
112
+ │ 16 tools │
113
+ │ 4 resources │
114
+ └──────┬───────┘
115
+ │ HTTP
116
+
117
+ ┌──────────────────┐
118
+ │ Treza Platform │ ← https://app.trezalabs.com
119
+ │ REST API │
120
+ └──────┬───────────┘
121
+
122
+
123
+ ┌──────────────────┐
124
+ │ AWS Nitro │ ← Hardware-isolated TEEs
125
+ │ Enclaves │
126
+ └──────────────────┘
127
+ ```
128
+
129
+ ## Development
130
+
131
+ ```bash
132
+ git clone https://github.com/treza-labs/treza-sdk.git
133
+ cd treza-sdk/packages/mcp
134
+ npm install
135
+ npm run build
136
+ npm start
137
+ ```
138
+
139
+ ## Related
140
+
141
+ - [@treza/sdk](https://www.npmjs.com/package/@treza/sdk) — Core SDK
142
+ - [Treza Platform](https://app.trezalabs.com) — Web dashboard
143
+ - [OpenAPI Spec](https://app.trezalabs.com/.well-known/openapi.json) — Full API schema
144
+ - [Agent Manifest](https://app.trezalabs.com/.well-known/ai-plugin.json) — Machine-readable capabilities
145
+
146
+ ## License
147
+
148
+ MIT
@@ -0,0 +1,10 @@
1
+ import { TrezaClient } from './treza-client';
2
+ type ToolResult = {
3
+ content: Array<{
4
+ type: 'text';
5
+ text: string;
6
+ }>;
7
+ isError?: boolean;
8
+ };
9
+ export declare function handleToolCall(client: TrezaClient, toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
10
+ export {};
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleToolCall = handleToolCall;
4
+ const tools_1 = require("./tools");
5
+ function ok(data) {
6
+ return {
7
+ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
8
+ };
9
+ }
10
+ function err(message) {
11
+ return {
12
+ content: [{ type: 'text', text: JSON.stringify({ error: message }) }],
13
+ isError: true,
14
+ };
15
+ }
16
+ async function handleToolCall(client, toolName, args) {
17
+ try {
18
+ switch (toolName) {
19
+ // ── Enclave Management ──────────────────────────────────────────
20
+ case 'treza_list_enclaves': {
21
+ const { walletAddress } = tools_1.listEnclavesSchema.parse(args);
22
+ const enclaves = await client.getEnclaves(walletAddress);
23
+ return ok({
24
+ count: enclaves.length,
25
+ enclaves: enclaves.map((e) => ({
26
+ id: e.id,
27
+ name: e.name,
28
+ status: e.status,
29
+ region: e.region,
30
+ description: e.description,
31
+ createdAt: e.createdAt,
32
+ })),
33
+ });
34
+ }
35
+ case 'treza_get_enclave': {
36
+ const { enclaveId } = tools_1.getEnclaveSchema.parse(args);
37
+ const enclave = await client.getEnclave(enclaveId);
38
+ return ok(enclave);
39
+ }
40
+ case 'treza_create_enclave': {
41
+ const params = tools_1.createEnclaveSchema.parse(args);
42
+ const providerConfig = {};
43
+ if (params.dockerImage)
44
+ providerConfig.dockerImage = params.dockerImage;
45
+ if (params.cpuCount)
46
+ providerConfig.cpuCount = params.cpuCount;
47
+ if (params.memoryMiB)
48
+ providerConfig.memoryMiB = params.memoryMiB;
49
+ if (params.workloadType)
50
+ providerConfig.workloadType = params.workloadType;
51
+ if (params.exposePorts)
52
+ providerConfig.exposePorts = params.exposePorts;
53
+ if (params.enableDebug !== undefined)
54
+ providerConfig.enableDebug = params.enableDebug;
55
+ const enclave = await client.createEnclave({
56
+ name: params.name,
57
+ description: params.description,
58
+ region: params.region,
59
+ walletAddress: params.walletAddress,
60
+ providerId: params.providerId,
61
+ providerConfig: Object.keys(providerConfig).length > 0 ? providerConfig : undefined,
62
+ });
63
+ return ok({
64
+ message: `Enclave "${enclave.name}" created. Deployment in progress (typically 2-5 minutes).`,
65
+ enclave,
66
+ });
67
+ }
68
+ case 'treza_update_enclave': {
69
+ const params = tools_1.updateEnclaveSchema.parse(args);
70
+ const enclave = await client.updateEnclave(params);
71
+ return ok(enclave);
72
+ }
73
+ case 'treza_delete_enclave': {
74
+ const { enclaveId, walletAddress } = tools_1.deleteEnclaveSchema.parse(args);
75
+ const message = await client.deleteEnclave(enclaveId, walletAddress);
76
+ return ok({ message });
77
+ }
78
+ case 'treza_enclave_action': {
79
+ const { enclaveId, action, walletAddress } = tools_1.enclaveActionSchema.parse(args);
80
+ const result = await client.performEnclaveAction({
81
+ id: enclaveId,
82
+ action,
83
+ walletAddress,
84
+ });
85
+ return ok(result);
86
+ }
87
+ case 'treza_get_enclave_logs': {
88
+ const { enclaveId, logType, limit } = tools_1.getEnclaveLogsSchema.parse(args);
89
+ const logs = await client.getEnclaveLogs(enclaveId, logType, limit);
90
+ return ok(logs);
91
+ }
92
+ // ── Attestation ─────────────────────────────────────────────────
93
+ case 'treza_get_attestation': {
94
+ const { enclaveId } = tools_1.getAttestationSchema.parse(args);
95
+ const attestation = await client.getAttestation(enclaveId);
96
+ return ok(attestation);
97
+ }
98
+ case 'treza_verify_attestation': {
99
+ const { enclaveId, nonce, challenge } = tools_1.verifyAttestationSchema.parse(args);
100
+ const result = await client.verifyAttestation(enclaveId, {
101
+ ...(nonce && { nonce }),
102
+ ...(challenge && { challenge }),
103
+ });
104
+ return ok(result);
105
+ }
106
+ case 'treza_get_verification_status': {
107
+ const { enclaveId } = tools_1.getVerificationStatusSchema.parse(args);
108
+ const status = await client.getVerificationStatus(enclaveId);
109
+ return ok(status);
110
+ }
111
+ // ── Providers ───────────────────────────────────────────────────
112
+ case 'treza_list_providers': {
113
+ tools_1.listProvidersSchema.parse(args);
114
+ const providers = await client.getProviders();
115
+ return ok(providers);
116
+ }
117
+ case 'treza_get_provider': {
118
+ const { providerId } = tools_1.getProviderSchema.parse(args);
119
+ const provider = await client.getProvider(providerId);
120
+ return ok(provider);
121
+ }
122
+ // ── Tasks ───────────────────────────────────────────────────────
123
+ case 'treza_list_tasks': {
124
+ const { walletAddress } = tools_1.listTasksSchema.parse(args);
125
+ const tasks = await client.getTasks(walletAddress);
126
+ return ok({ count: tasks.length, tasks });
127
+ }
128
+ case 'treza_create_task': {
129
+ const params = tools_1.createTaskSchema.parse(args);
130
+ const task = await client.createTask(params);
131
+ return ok(task);
132
+ }
133
+ // ── API Keys ────────────────────────────────────────────────────
134
+ case 'treza_list_api_keys': {
135
+ const { walletAddress } = tools_1.listApiKeysSchema.parse(args);
136
+ const apiKeys = await client.getApiKeys(walletAddress);
137
+ return ok({
138
+ count: apiKeys.length,
139
+ apiKeys: apiKeys.map((k) => ({
140
+ id: k.id,
141
+ name: k.name,
142
+ status: k.status,
143
+ permissions: k.permissions,
144
+ createdAt: k.createdAt,
145
+ lastUsed: k.lastUsed,
146
+ })),
147
+ });
148
+ }
149
+ case 'treza_create_api_key': {
150
+ const params = tools_1.createApiKeySchema.parse(args);
151
+ const apiKey = await client.createApiKey(params);
152
+ return ok({
153
+ message: 'API key created. Store the key securely — it will not be shown again.',
154
+ apiKey,
155
+ });
156
+ }
157
+ default:
158
+ return err(`Unknown tool: ${toolName}`);
159
+ }
160
+ }
161
+ catch (error) {
162
+ const message = error instanceof Error ? error.message : String(error);
163
+ return err(message);
164
+ }
165
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
+ const treza_client_1 = require("./treza-client");
7
+ const tools_1 = require("./tools");
8
+ const handlers_1 = require("./handlers");
9
+ const resources_1 = require("./resources");
10
+ const TREZA_BASE_URL = process.env.TREZA_BASE_URL || 'https://app.trezalabs.com';
11
+ const TREZA_TIMEOUT = parseInt(process.env.TREZA_TIMEOUT || '30000', 10);
12
+ const client = new treza_client_1.TrezaClient({
13
+ baseUrl: TREZA_BASE_URL,
14
+ timeout: TREZA_TIMEOUT,
15
+ });
16
+ const server = new mcp_js_1.McpServer({
17
+ name: 'treza-enclaves',
18
+ version: '0.1.0',
19
+ });
20
+ // ─── Register Tools ─────────────────────────────────────────────────────────
21
+ for (const tool of tools_1.TOOL_DEFINITIONS) {
22
+ const shape = tool.schema.shape;
23
+ server.tool(tool.name, tool.description, shape, async (args) => (0, handlers_1.handleToolCall)(client, tool.name, args));
24
+ }
25
+ // ─── Register Resource Templates ────────────────────────────────────────────
26
+ for (const template of resources_1.RESOURCE_TEMPLATES) {
27
+ server.resource(template.name, template.uriTemplate, { description: template.description, mimeType: template.mimeType }, async (uri) => ({
28
+ contents: [
29
+ {
30
+ uri: uri.href,
31
+ mimeType: template.mimeType,
32
+ text: await (0, resources_1.handleResourceRead)(client, uri.href),
33
+ },
34
+ ],
35
+ }));
36
+ }
37
+ // ─── Start ──────────────────────────────────────────────────────────────────
38
+ async function main() {
39
+ const transport = new stdio_js_1.StdioServerTransport();
40
+ await server.connect(transport);
41
+ console.error(`Treza MCP server running (API: ${TREZA_BASE_URL})`);
42
+ }
43
+ main().catch((error) => {
44
+ console.error('Failed to start Treza MCP server:', error);
45
+ process.exit(1);
46
+ });
@@ -0,0 +1,20 @@
1
+ import { TrezaClient } from './treza-client';
2
+ /**
3
+ * MCP Resources expose Treza data as browsable context that AI agents
4
+ * can read without invoking a tool. This gives agents ambient awareness
5
+ * of enclave state.
6
+ */
7
+ export interface ResourceDefinition {
8
+ uri: string;
9
+ name: string;
10
+ description: string;
11
+ mimeType: string;
12
+ }
13
+ export interface ResourceTemplateDefinition {
14
+ uriTemplate: string;
15
+ name: string;
16
+ description: string;
17
+ mimeType: string;
18
+ }
19
+ export declare const RESOURCE_TEMPLATES: ResourceTemplateDefinition[];
20
+ export declare function handleResourceRead(client: TrezaClient, uri: string): Promise<string>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESOURCE_TEMPLATES = void 0;
4
+ exports.handleResourceRead = handleResourceRead;
5
+ exports.RESOURCE_TEMPLATES = [
6
+ {
7
+ uriTemplate: 'treza://enclaves/{walletAddress}',
8
+ name: 'Wallet Enclaves',
9
+ description: 'All enclaves owned by a wallet address, including status and configuration',
10
+ mimeType: 'application/json',
11
+ },
12
+ {
13
+ uriTemplate: 'treza://enclaves/{enclaveId}/details',
14
+ name: 'Enclave Details',
15
+ description: 'Full details for a specific enclave including provider config and GitHub connection',
16
+ mimeType: 'application/json',
17
+ },
18
+ {
19
+ uriTemplate: 'treza://enclaves/{enclaveId}/attestation',
20
+ name: 'Enclave Attestation',
21
+ description: 'Attestation document with PCR measurements, certificate chain, and verification status',
22
+ mimeType: 'application/json',
23
+ },
24
+ {
25
+ uriTemplate: 'treza://enclaves/{enclaveId}/verification',
26
+ name: 'Verification Status',
27
+ description: 'Quick verification status and trust level for an enclave',
28
+ mimeType: 'application/json',
29
+ },
30
+ ];
31
+ async function handleResourceRead(client, uri) {
32
+ const url = new URL(uri);
33
+ const pathParts = url.pathname.replace(/^\/+/, '').split('/');
34
+ // treza://enclaves/{walletAddress}
35
+ if (url.host === 'enclaves' && pathParts.length === 1 && pathParts[0] !== '') {
36
+ const walletAddress = pathParts[0];
37
+ const enclaves = await client.getEnclaves(walletAddress);
38
+ return JSON.stringify({ count: enclaves.length, enclaves }, null, 2);
39
+ }
40
+ // treza://enclaves/{enclaveId}/details
41
+ if (url.host === 'enclaves' && pathParts.length === 2 && pathParts[1] === 'details') {
42
+ const enclaveId = pathParts[0];
43
+ const enclave = await client.getEnclave(enclaveId);
44
+ return JSON.stringify(enclave, null, 2);
45
+ }
46
+ // treza://enclaves/{enclaveId}/attestation
47
+ if (url.host === 'enclaves' && pathParts.length === 2 && pathParts[1] === 'attestation') {
48
+ const enclaveId = pathParts[0];
49
+ const attestation = await client.getAttestation(enclaveId);
50
+ return JSON.stringify(attestation, null, 2);
51
+ }
52
+ // treza://enclaves/{enclaveId}/verification
53
+ if (url.host === 'enclaves' && pathParts.length === 2 && pathParts[1] === 'verification') {
54
+ const enclaveId = pathParts[0];
55
+ const status = await client.getVerificationStatus(enclaveId);
56
+ return JSON.stringify(status, null, 2);
57
+ }
58
+ throw new Error(`Unknown resource URI: ${uri}`);
59
+ }
@@ -0,0 +1,195 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Zod schemas and metadata for all MCP tools exposed by the Treza server.
4
+ * Each tool maps to a TrezaClient SDK method.
5
+ */
6
+ export declare const listEnclavesSchema: z.ZodObject<{
7
+ walletAddress: z.ZodString;
8
+ }, "strip", z.ZodTypeAny, {
9
+ walletAddress: string;
10
+ }, {
11
+ walletAddress: string;
12
+ }>;
13
+ export declare const getEnclaveSchema: z.ZodObject<{
14
+ enclaveId: z.ZodString;
15
+ }, "strip", z.ZodTypeAny, {
16
+ enclaveId: string;
17
+ }, {
18
+ enclaveId: string;
19
+ }>;
20
+ export declare const createEnclaveSchema: z.ZodObject<{
21
+ name: z.ZodString;
22
+ description: z.ZodString;
23
+ region: z.ZodString;
24
+ walletAddress: z.ZodString;
25
+ providerId: z.ZodDefault<z.ZodString>;
26
+ dockerImage: z.ZodOptional<z.ZodString>;
27
+ cpuCount: z.ZodOptional<z.ZodEnum<["2", "4", "8", "16"]>>;
28
+ memoryMiB: z.ZodOptional<z.ZodEnum<["1024", "2048", "4096", "8192", "16384"]>>;
29
+ workloadType: z.ZodOptional<z.ZodEnum<["batch", "service", "daemon"]>>;
30
+ exposePorts: z.ZodOptional<z.ZodString>;
31
+ enableDebug: z.ZodOptional<z.ZodBoolean>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ walletAddress: string;
34
+ name: string;
35
+ description: string;
36
+ region: string;
37
+ providerId: string;
38
+ dockerImage?: string | undefined;
39
+ cpuCount?: "2" | "4" | "8" | "16" | undefined;
40
+ memoryMiB?: "1024" | "2048" | "4096" | "8192" | "16384" | undefined;
41
+ workloadType?: "batch" | "service" | "daemon" | undefined;
42
+ exposePorts?: string | undefined;
43
+ enableDebug?: boolean | undefined;
44
+ }, {
45
+ walletAddress: string;
46
+ name: string;
47
+ description: string;
48
+ region: string;
49
+ providerId?: string | undefined;
50
+ dockerImage?: string | undefined;
51
+ cpuCount?: "2" | "4" | "8" | "16" | undefined;
52
+ memoryMiB?: "1024" | "2048" | "4096" | "8192" | "16384" | undefined;
53
+ workloadType?: "batch" | "service" | "daemon" | undefined;
54
+ exposePorts?: string | undefined;
55
+ enableDebug?: boolean | undefined;
56
+ }>;
57
+ export declare const updateEnclaveSchema: z.ZodObject<{
58
+ id: z.ZodString;
59
+ walletAddress: z.ZodString;
60
+ name: z.ZodOptional<z.ZodString>;
61
+ description: z.ZodOptional<z.ZodString>;
62
+ }, "strip", z.ZodTypeAny, {
63
+ walletAddress: string;
64
+ id: string;
65
+ name?: string | undefined;
66
+ description?: string | undefined;
67
+ }, {
68
+ walletAddress: string;
69
+ id: string;
70
+ name?: string | undefined;
71
+ description?: string | undefined;
72
+ }>;
73
+ export declare const deleteEnclaveSchema: z.ZodObject<{
74
+ enclaveId: z.ZodString;
75
+ walletAddress: z.ZodString;
76
+ }, "strip", z.ZodTypeAny, {
77
+ walletAddress: string;
78
+ enclaveId: string;
79
+ }, {
80
+ walletAddress: string;
81
+ enclaveId: string;
82
+ }>;
83
+ export declare const enclaveActionSchema: z.ZodObject<{
84
+ enclaveId: z.ZodString;
85
+ action: z.ZodEnum<["pause", "resume", "terminate"]>;
86
+ walletAddress: z.ZodString;
87
+ }, "strip", z.ZodTypeAny, {
88
+ action: "pause" | "resume" | "terminate";
89
+ walletAddress: string;
90
+ enclaveId: string;
91
+ }, {
92
+ action: "pause" | "resume" | "terminate";
93
+ walletAddress: string;
94
+ enclaveId: string;
95
+ }>;
96
+ export declare const getEnclaveLogsSchema: z.ZodObject<{
97
+ enclaveId: z.ZodString;
98
+ logType: z.ZodDefault<z.ZodEnum<["all", "ecs", "stepfunctions", "lambda", "application", "errors"]>>;
99
+ limit: z.ZodDefault<z.ZodNumber>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ enclaveId: string;
102
+ logType: "all" | "ecs" | "stepfunctions" | "lambda" | "application" | "errors";
103
+ limit: number;
104
+ }, {
105
+ enclaveId: string;
106
+ logType?: "all" | "ecs" | "stepfunctions" | "lambda" | "application" | "errors" | undefined;
107
+ limit?: number | undefined;
108
+ }>;
109
+ export declare const getAttestationSchema: z.ZodObject<{
110
+ enclaveId: z.ZodString;
111
+ }, "strip", z.ZodTypeAny, {
112
+ enclaveId: string;
113
+ }, {
114
+ enclaveId: string;
115
+ }>;
116
+ export declare const verifyAttestationSchema: z.ZodObject<{
117
+ enclaveId: z.ZodString;
118
+ nonce: z.ZodOptional<z.ZodString>;
119
+ challenge: z.ZodOptional<z.ZodString>;
120
+ }, "strip", z.ZodTypeAny, {
121
+ enclaveId: string;
122
+ nonce?: string | undefined;
123
+ challenge?: string | undefined;
124
+ }, {
125
+ enclaveId: string;
126
+ nonce?: string | undefined;
127
+ challenge?: string | undefined;
128
+ }>;
129
+ export declare const getVerificationStatusSchema: z.ZodObject<{
130
+ enclaveId: z.ZodString;
131
+ }, "strip", z.ZodTypeAny, {
132
+ enclaveId: string;
133
+ }, {
134
+ enclaveId: string;
135
+ }>;
136
+ export declare const listProvidersSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
137
+ export declare const getProviderSchema: z.ZodObject<{
138
+ providerId: z.ZodString;
139
+ }, "strip", z.ZodTypeAny, {
140
+ providerId: string;
141
+ }, {
142
+ providerId: string;
143
+ }>;
144
+ export declare const listTasksSchema: z.ZodObject<{
145
+ walletAddress: z.ZodString;
146
+ }, "strip", z.ZodTypeAny, {
147
+ walletAddress: string;
148
+ }, {
149
+ walletAddress: string;
150
+ }>;
151
+ export declare const createTaskSchema: z.ZodObject<{
152
+ name: z.ZodString;
153
+ description: z.ZodString;
154
+ enclaveId: z.ZodString;
155
+ schedule: z.ZodString;
156
+ walletAddress: z.ZodString;
157
+ }, "strip", z.ZodTypeAny, {
158
+ walletAddress: string;
159
+ enclaveId: string;
160
+ name: string;
161
+ description: string;
162
+ schedule: string;
163
+ }, {
164
+ walletAddress: string;
165
+ enclaveId: string;
166
+ name: string;
167
+ description: string;
168
+ schedule: string;
169
+ }>;
170
+ export declare const listApiKeysSchema: z.ZodObject<{
171
+ walletAddress: z.ZodString;
172
+ }, "strip", z.ZodTypeAny, {
173
+ walletAddress: string;
174
+ }, {
175
+ walletAddress: string;
176
+ }>;
177
+ export declare const createApiKeySchema: z.ZodObject<{
178
+ name: z.ZodString;
179
+ permissions: z.ZodArray<z.ZodEnum<["enclaves:read", "enclaves:write", "tasks:read", "tasks:write", "logs:read"]>, "many">;
180
+ walletAddress: z.ZodString;
181
+ }, "strip", z.ZodTypeAny, {
182
+ walletAddress: string;
183
+ name: string;
184
+ permissions: ("enclaves:read" | "enclaves:write" | "tasks:read" | "tasks:write" | "logs:read")[];
185
+ }, {
186
+ walletAddress: string;
187
+ name: string;
188
+ permissions: ("enclaves:read" | "enclaves:write" | "tasks:read" | "tasks:write" | "logs:read")[];
189
+ }>;
190
+ export interface ToolDefinition {
191
+ name: string;
192
+ description: string;
193
+ schema: z.ZodObject<any>;
194
+ }
195
+ export declare const TOOL_DEFINITIONS: ToolDefinition[];
package/dist/tools.js ADDED
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TOOL_DEFINITIONS = exports.createApiKeySchema = exports.listApiKeysSchema = exports.createTaskSchema = exports.listTasksSchema = exports.getProviderSchema = exports.listProvidersSchema = exports.getVerificationStatusSchema = exports.verifyAttestationSchema = exports.getAttestationSchema = exports.getEnclaveLogsSchema = exports.enclaveActionSchema = exports.deleteEnclaveSchema = exports.updateEnclaveSchema = exports.createEnclaveSchema = exports.getEnclaveSchema = exports.listEnclavesSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Zod schemas and metadata for all MCP tools exposed by the Treza server.
7
+ * Each tool maps to a TrezaClient SDK method.
8
+ */
9
+ // ─── Enclave Management ─────────────────────────────────────────────────────
10
+ exports.listEnclavesSchema = zod_1.z.object({
11
+ walletAddress: zod_1.z.string().describe('Ethereum wallet address that owns the enclaves'),
12
+ });
13
+ exports.getEnclaveSchema = zod_1.z.object({
14
+ enclaveId: zod_1.z.string().describe('Unique enclave identifier (e.g. "enc_abc123")'),
15
+ });
16
+ exports.createEnclaveSchema = zod_1.z.object({
17
+ name: zod_1.z.string().describe('Human-readable name for the enclave'),
18
+ description: zod_1.z.string().describe('Description of the enclave purpose'),
19
+ region: zod_1.z.string().describe('AWS region to deploy in (e.g. "us-east-1", "eu-west-1")'),
20
+ walletAddress: zod_1.z.string().describe('Ethereum wallet address of the owner'),
21
+ providerId: zod_1.z.string().default('aws-nitro-enclave').describe('Provider ID (default: "aws-nitro-enclave")'),
22
+ dockerImage: zod_1.z.string().optional().describe('Docker image to run inside the enclave'),
23
+ cpuCount: zod_1.z.enum(['2', '4', '8', '16']).optional().describe('Number of vCPUs'),
24
+ memoryMiB: zod_1.z.enum(['1024', '2048', '4096', '8192', '16384']).optional().describe('Memory in MiB'),
25
+ workloadType: zod_1.z.enum(['batch', 'service', 'daemon']).optional().describe('Workload type'),
26
+ exposePorts: zod_1.z.string().optional().describe('Comma-separated ports to expose'),
27
+ enableDebug: zod_1.z.boolean().optional().describe('Enable debug mode'),
28
+ });
29
+ exports.updateEnclaveSchema = zod_1.z.object({
30
+ id: zod_1.z.string().describe('Enclave ID to update'),
31
+ walletAddress: zod_1.z.string().describe('Wallet address for authorization'),
32
+ name: zod_1.z.string().optional().describe('New name'),
33
+ description: zod_1.z.string().optional().describe('New description'),
34
+ });
35
+ exports.deleteEnclaveSchema = zod_1.z.object({
36
+ enclaveId: zod_1.z.string().describe('Enclave ID to delete'),
37
+ walletAddress: zod_1.z.string().describe('Wallet address for authorization'),
38
+ });
39
+ exports.enclaveActionSchema = zod_1.z.object({
40
+ enclaveId: zod_1.z.string().describe('Enclave ID to act on'),
41
+ action: zod_1.z.enum(['pause', 'resume', 'terminate']).describe('Lifecycle action'),
42
+ walletAddress: zod_1.z.string().describe('Wallet address for authorization'),
43
+ });
44
+ exports.getEnclaveLogsSchema = zod_1.z.object({
45
+ enclaveId: zod_1.z.string().describe('Enclave ID'),
46
+ logType: zod_1.z.enum(['all', 'ecs', 'stepfunctions', 'lambda', 'application', 'errors']).default('all').describe('Type of logs'),
47
+ limit: zod_1.z.number().default(50).describe('Max log entries to return'),
48
+ });
49
+ // ─── Attestation & Verification ─────────────────────────────────────────────
50
+ exports.getAttestationSchema = zod_1.z.object({
51
+ enclaveId: zod_1.z.string().describe('Enclave ID to get attestation for'),
52
+ });
53
+ exports.verifyAttestationSchema = zod_1.z.object({
54
+ enclaveId: zod_1.z.string().describe('Enclave ID to verify'),
55
+ nonce: zod_1.z.string().optional().describe('Nonce for replay protection'),
56
+ challenge: zod_1.z.string().optional().describe('Challenge string for additional verification'),
57
+ });
58
+ exports.getVerificationStatusSchema = zod_1.z.object({
59
+ enclaveId: zod_1.z.string().describe('Enclave ID to check'),
60
+ });
61
+ // ─── Providers ──────────────────────────────────────────────────────────────
62
+ exports.listProvidersSchema = zod_1.z.object({});
63
+ exports.getProviderSchema = zod_1.z.object({
64
+ providerId: zod_1.z.string().describe('Provider ID (e.g. "aws-nitro-enclave")'),
65
+ });
66
+ // ─── Tasks ──────────────────────────────────────────────────────────────────
67
+ exports.listTasksSchema = zod_1.z.object({
68
+ walletAddress: zod_1.z.string().describe('Wallet address that owns the tasks'),
69
+ });
70
+ exports.createTaskSchema = zod_1.z.object({
71
+ name: zod_1.z.string().describe('Task name'),
72
+ description: zod_1.z.string().describe('Task description'),
73
+ enclaveId: zod_1.z.string().describe('Enclave to run the task on'),
74
+ schedule: zod_1.z.string().describe('Cron expression (e.g. "0 */6 * * *")'),
75
+ walletAddress: zod_1.z.string().describe('Wallet address for authorization'),
76
+ });
77
+ // ─── API Keys ───────────────────────────────────────────────────────────────
78
+ exports.listApiKeysSchema = zod_1.z.object({
79
+ walletAddress: zod_1.z.string().describe('Wallet address that owns the API keys'),
80
+ });
81
+ exports.createApiKeySchema = zod_1.z.object({
82
+ name: zod_1.z.string().describe('Human-readable key name'),
83
+ permissions: zod_1.z.array(zod_1.z.enum(['enclaves:read', 'enclaves:write', 'tasks:read', 'tasks:write', 'logs:read'])).describe('Array of permission scopes'),
84
+ walletAddress: zod_1.z.string().describe('Wallet address for authorization'),
85
+ });
86
+ exports.TOOL_DEFINITIONS = [
87
+ {
88
+ name: 'treza_list_enclaves',
89
+ description: 'List all Treza Nitro Enclaves owned by a wallet address. Returns enclave IDs, names, statuses, regions, and configuration.',
90
+ schema: exports.listEnclavesSchema,
91
+ },
92
+ {
93
+ name: 'treza_get_enclave',
94
+ description: 'Get detailed information about a specific Treza enclave including its status, configuration, provider settings, and GitHub connection.',
95
+ schema: exports.getEnclaveSchema,
96
+ },
97
+ {
98
+ name: 'treza_create_enclave',
99
+ description: 'Create a new AWS Nitro Enclave with hardware-isolated TEE. The enclave will generate and manage private keys internally — keys never leave the enclave boundary. Deployment takes 2-5 minutes via Step Functions.',
100
+ schema: exports.createEnclaveSchema,
101
+ },
102
+ {
103
+ name: 'treza_update_enclave',
104
+ description: 'Update an existing enclave\'s name, description, or configuration.',
105
+ schema: exports.updateEnclaveSchema,
106
+ },
107
+ {
108
+ name: 'treza_delete_enclave',
109
+ description: 'Permanently delete a terminated enclave. The enclave must be in DESTROYED status before deletion.',
110
+ schema: exports.deleteEnclaveSchema,
111
+ },
112
+ {
113
+ name: 'treza_enclave_action',
114
+ description: 'Perform a lifecycle action on an enclave: pause (stop billing), resume (restart), or terminate (destroy infrastructure). Terminate is irreversible.',
115
+ schema: exports.enclaveActionSchema,
116
+ },
117
+ {
118
+ name: 'treza_get_enclave_logs',
119
+ description: 'Retrieve logs from an enclave. Supports filtering by source: ECS deployment, Step Functions workflow, Lambda triggers, application stdout/stderr, or errors only.',
120
+ schema: exports.getEnclaveLogsSchema,
121
+ },
122
+ {
123
+ name: 'treza_get_attestation',
124
+ description: 'Get the attestation document for a deployed enclave. Returns PCR measurements (enclave image hash, kernel hash, application hash, signing cert), certificate chain, and verification endpoints. Use this to cryptographically verify an enclave is running the expected code.',
125
+ schema: exports.getAttestationSchema,
126
+ },
127
+ {
128
+ name: 'treza_verify_attestation',
129
+ description: 'Perform comprehensive cryptographic verification of an enclave\'s attestation. Checks PCR measurements, certificate chain, timestamp validity, nonce matching, and signature. Returns trust level (HIGH/MEDIUM/LOW), compliance status (SOC2, HIPAA, FIPS), and risk score.',
130
+ schema: exports.verifyAttestationSchema,
131
+ },
132
+ {
133
+ name: 'treza_get_verification_status',
134
+ description: 'Quick check of an enclave\'s verification status and trust level without performing full verification.',
135
+ schema: exports.getVerificationStatusSchema,
136
+ },
137
+ {
138
+ name: 'treza_list_providers',
139
+ description: 'List all available enclave providers (e.g., AWS Nitro Enclave) with their supported regions and configuration schemas.',
140
+ schema: exports.listProvidersSchema,
141
+ },
142
+ {
143
+ name: 'treza_get_provider',
144
+ description: 'Get detailed information about a specific enclave provider including supported regions and configuration options.',
145
+ schema: exports.getProviderSchema,
146
+ },
147
+ {
148
+ name: 'treza_list_tasks',
149
+ description: 'List all scheduled tasks for a wallet. Tasks are cron-scheduled operations that run inside enclaves.',
150
+ schema: exports.listTasksSchema,
151
+ },
152
+ {
153
+ name: 'treza_create_task',
154
+ description: 'Create a new scheduled task to run inside an enclave on a cron schedule.',
155
+ schema: exports.createTaskSchema,
156
+ },
157
+ {
158
+ name: 'treza_list_api_keys',
159
+ description: 'List all API keys for a wallet address. Keys have scoped permissions (enclaves:read, enclaves:write, tasks:read, tasks:write, logs:read).',
160
+ schema: exports.listApiKeysSchema,
161
+ },
162
+ {
163
+ name: 'treza_create_api_key',
164
+ description: 'Create a new scoped API key for programmatic access to the Treza platform. Returns the key only once — store it securely.',
165
+ schema: exports.createApiKeySchema,
166
+ },
167
+ ];
@@ -0,0 +1,37 @@
1
+ export interface TrezaConfig {
2
+ baseUrl?: string;
3
+ timeout?: number;
4
+ }
5
+ export declare class TrezaSdkError extends Error {
6
+ readonly code?: string;
7
+ readonly statusCode?: number;
8
+ constructor(message: string, code?: string, statusCode?: number);
9
+ }
10
+ /**
11
+ * Lightweight Treza API client for the MCP server.
12
+ * Mirrors the full SDK's TrezaClient but with no extra dependencies.
13
+ */
14
+ export declare class TrezaClient {
15
+ private client;
16
+ constructor(config?: TrezaConfig);
17
+ getEnclaves(walletAddress: string): Promise<any>;
18
+ getEnclave(enclaveId: string): Promise<any>;
19
+ createEnclave(request: Record<string, unknown>): Promise<any>;
20
+ updateEnclave(request: Record<string, unknown>): Promise<any>;
21
+ deleteEnclave(enclaveId: string, walletAddress: string): Promise<any>;
22
+ performEnclaveAction(request: {
23
+ id: string;
24
+ action: string;
25
+ walletAddress: string;
26
+ }): Promise<any>;
27
+ getEnclaveLogs(enclaveId: string, logType?: string, limit?: number): Promise<any>;
28
+ getAttestation(enclaveId: string): Promise<any>;
29
+ getVerificationStatus(enclaveId: string): Promise<any>;
30
+ verifyAttestation(enclaveId: string, request?: Record<string, unknown>): Promise<any>;
31
+ getProviders(): Promise<any>;
32
+ getProvider(providerId: string): Promise<any>;
33
+ getTasks(walletAddress: string): Promise<any>;
34
+ createTask(request: Record<string, unknown>): Promise<any>;
35
+ getApiKeys(walletAddress: string): Promise<any>;
36
+ createApiKey(request: Record<string, unknown>): Promise<any>;
37
+ }
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TrezaClient = exports.TrezaSdkError = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ class TrezaSdkError extends Error {
9
+ constructor(message, code, statusCode) {
10
+ super(message);
11
+ this.name = 'TrezaSdkError';
12
+ this.code = code;
13
+ this.statusCode = statusCode;
14
+ }
15
+ }
16
+ exports.TrezaSdkError = TrezaSdkError;
17
+ /**
18
+ * Lightweight Treza API client for the MCP server.
19
+ * Mirrors the full SDK's TrezaClient but with no extra dependencies.
20
+ */
21
+ class TrezaClient {
22
+ constructor(config = {}) {
23
+ this.client = axios_1.default.create({
24
+ baseURL: config.baseUrl || 'https://app.trezalabs.com',
25
+ timeout: config.timeout || 30000,
26
+ headers: { 'Content-Type': 'application/json' },
27
+ });
28
+ this.client.interceptors.response.use((r) => r, (error) => {
29
+ if (error.response) {
30
+ const data = error.response.data;
31
+ throw new TrezaSdkError(data?.error || error.message, `HTTP_${error.response.status}`, error.response.status);
32
+ }
33
+ throw new TrezaSdkError(error.message, 'NETWORK_ERROR');
34
+ });
35
+ }
36
+ // ── Enclaves ────────────────────────────────────────────────────────────
37
+ async getEnclaves(walletAddress) {
38
+ const r = await this.client.get('/api/enclaves', { params: { wallet: walletAddress } });
39
+ return r.data.enclaves;
40
+ }
41
+ async getEnclave(enclaveId) {
42
+ const r = await this.client.get(`/api/enclaves/${enclaveId}`);
43
+ return r.data.enclave;
44
+ }
45
+ async createEnclave(request) {
46
+ const r = await this.client.post('/api/enclaves', request);
47
+ return r.data.enclave;
48
+ }
49
+ async updateEnclave(request) {
50
+ const r = await this.client.put('/api/enclaves', request);
51
+ return r.data.enclave;
52
+ }
53
+ async deleteEnclave(enclaveId, walletAddress) {
54
+ const r = await this.client.delete(`/api/enclaves/${enclaveId}`, {
55
+ params: { wallet: walletAddress },
56
+ });
57
+ return r.data.message;
58
+ }
59
+ async performEnclaveAction(request) {
60
+ const r = await this.client.patch(`/api/enclaves/${request.id}`, {
61
+ action: request.action,
62
+ walletAddress: request.walletAddress,
63
+ });
64
+ return r.data;
65
+ }
66
+ async getEnclaveLogs(enclaveId, logType = 'all', limit = 100) {
67
+ const r = await this.client.get(`/api/enclaves/${enclaveId}/logs`, {
68
+ params: { type: logType, limit },
69
+ });
70
+ return r.data;
71
+ }
72
+ // ── Attestation ─────────────────────────────────────────────────────────
73
+ async getAttestation(enclaveId) {
74
+ const r = await this.client.get(`/api/enclaves/${enclaveId}/attestation`);
75
+ return r.data;
76
+ }
77
+ async getVerificationStatus(enclaveId) {
78
+ const r = await this.client.get(`/api/enclaves/${enclaveId}/attestation/verify`);
79
+ return r.data;
80
+ }
81
+ async verifyAttestation(enclaveId, request) {
82
+ const r = await this.client.post(`/api/enclaves/${enclaveId}/attestation/verify`, request || {});
83
+ return r.data;
84
+ }
85
+ // ── Providers ───────────────────────────────────────────────────────────
86
+ async getProviders() {
87
+ const r = await this.client.get('/api/providers');
88
+ return r.data.providers;
89
+ }
90
+ async getProvider(providerId) {
91
+ const r = await this.client.get('/api/providers', { params: { id: providerId } });
92
+ return r.data.provider;
93
+ }
94
+ // ── Tasks ───────────────────────────────────────────────────────────────
95
+ async getTasks(walletAddress) {
96
+ const r = await this.client.get('/api/tasks', { params: { wallet: walletAddress } });
97
+ return r.data.tasks;
98
+ }
99
+ async createTask(request) {
100
+ const r = await this.client.post('/api/tasks', request);
101
+ return r.data.task;
102
+ }
103
+ // ── API Keys ────────────────────────────────────────────────────────────
104
+ async getApiKeys(walletAddress) {
105
+ const r = await this.client.get('/api/api-keys', { params: { wallet: walletAddress } });
106
+ return r.data.apiKeys;
107
+ }
108
+ async createApiKey(request) {
109
+ const r = await this.client.post('/api/api-keys', request);
110
+ return r.data.apiKey;
111
+ }
112
+ }
113
+ exports.TrezaClient = TrezaClient;
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@treza/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Model Context Protocol server for Treza Enclaves — lets AI agents manage TEEs, verify attestations, and sign transactions",
5
+ "keywords": [
6
+ "treza",
7
+ "mcp",
8
+ "model-context-protocol",
9
+ "ai-agents",
10
+ "enclaves",
11
+ "tee",
12
+ "attestation",
13
+ "nitro-enclaves"
14
+ ],
15
+ "homepage": "https://trezalabs.com",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/treza-labs/treza-sdk.git",
19
+ "directory": "packages/mcp"
20
+ },
21
+ "license": "MIT",
22
+ "author": "TREZA Labs <hello@trezalabs.com>",
23
+ "main": "dist/index.js",
24
+ "types": "dist/index.d.ts",
25
+ "bin": {
26
+ "treza-mcp": "./dist/index.js"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc",
34
+ "build:watch": "tsc -w",
35
+ "clean": "rm -rf dist",
36
+ "dev": "tsc -w",
37
+ "start": "node dist/index.js",
38
+ "lint": "eslint src/**/*.ts --fix",
39
+ "lint:check": "eslint src/**/*.ts",
40
+ "typecheck": "tsc --noEmit"
41
+ },
42
+ "dependencies": {
43
+ "@modelcontextprotocol/sdk": "^1.12.1",
44
+ "axios": "^1.7.0",
45
+ "zod": "^3.24.2"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^20.10.0",
49
+ "typescript": "^5.3.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }