@ecadlabs/tezosx-mcp 1.0.0 → 1.0.2
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 +87 -66
- package/dist/api.d.ts +3 -0
- package/dist/api.js +155 -0
- package/dist/config-store.d.ts +15 -0
- package/dist/config-store.js +38 -0
- package/dist/index.d.ts +0 -6
- package/dist/index.js +43 -44
- package/dist/live-config.d.ts +32 -0
- package/dist/live-config.js +55 -0
- package/dist/tools/create_x402_payment.d.ts +2 -2
- package/dist/tools/create_x402_payment.js +2 -1
- package/dist/tools/fetch_with_x402.d.ts +3 -3
- package/dist/tools/fetch_with_x402.js +7 -6
- package/dist/tools/get_addresses.d.ts +2 -2
- package/dist/tools/get_addresses.js +2 -1
- package/dist/tools/get_balance.d.ts +2 -2
- package/dist/tools/get_balance.js +2 -1
- package/dist/tools/get_dashboard.d.ts +2 -1
- package/dist/tools/get_dashboard.js +2 -2
- package/dist/tools/get_limits.d.ts +2 -2
- package/dist/tools/get_limits.js +2 -1
- package/dist/tools/get_operation_history.d.ts +2 -1
- package/dist/tools/get_operation_history.js +2 -1
- package/dist/tools/index.d.ts +3 -3
- package/dist/tools/index.js +15 -24
- package/dist/tools/reveal_account.d.ts +2 -1
- package/dist/tools/reveal_account.js +2 -1
- package/dist/tools/send_xtz.d.ts +2 -9
- package/dist/tools/send_xtz.js +33 -15
- package/dist/webserver.d.ts +2 -1
- package/dist/webserver.js +11 -4
- package/frontend/dist/assets/index-CTdz8_ps.css +1 -0
- package/frontend/dist/assets/index-Do1wIlnj.js +278 -0
- package/frontend/dist/index.html +2 -2
- package/package.json +5 -3
- package/dist/adapters/index.d.ts +0 -37
- package/dist/adapters/index.js +0 -57
- package/dist/adapters/node.d.ts +0 -18
- package/dist/adapters/node.js +0 -35
- package/dist/adapters/types.d.ts +0 -52
- package/dist/adapters/types.js +0 -25
- package/dist/adapters/worker.d.ts +0 -35
- package/dist/adapters/worker.js +0 -50
- package/dist/server.d.ts +0 -36
- package/dist/server.js +0 -80
- package/dist/tools/get_address.d.ts +0 -20
- package/dist/tools/get_address.js +0 -24
- package/dist/worker.bundle.js +0 -134265
- package/dist/worker.d.ts +0 -13
- package/dist/worker.js +0 -132
- package/frontend/dist/assets/index-RtTL1nIl.js +0 -257
- package/frontend/dist/assets/index-mSsI3AqQ.css +0 -1
package/frontend/dist/index.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-Do1wIlnj.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CTdz8_ps.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecadlabs/tezosx-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "MCP server for Tezos wallet operations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,10 +53,12 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
56
|
-
"@taquito/signer": "^
|
|
57
|
-
"@taquito/taquito": "^
|
|
56
|
+
"@taquito/signer": "^24.0.2",
|
|
57
|
+
"@taquito/taquito": "^24.0.2",
|
|
58
|
+
"@taquito/utils": "^24.0.2",
|
|
58
59
|
"axios": "^1.13.2",
|
|
59
60
|
"bn.js": "^5.2.2",
|
|
61
|
+
"conf": "^15.1.0",
|
|
60
62
|
"dotenv": "^17.2.3",
|
|
61
63
|
"express": "^5.2.1",
|
|
62
64
|
"node-fetch": "^3.3.2",
|
package/dist/adapters/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment adapter factory and exports
|
|
3
|
-
* Automatically detects the runtime environment and creates the appropriate adapter
|
|
4
|
-
*/
|
|
5
|
-
export type { EnvironmentAdapter, EnvConfig, StaticFileConfig, RuntimeEnvironment } from './types.js';
|
|
6
|
-
export { detectEnvironment } from './types.js';
|
|
7
|
-
export { NodeAdapter, createNodeAdapter } from './node.js';
|
|
8
|
-
export { WorkerAdapter, createWorkerAdapter } from './worker.js';
|
|
9
|
-
export type { WorkerEnv } from './worker.js';
|
|
10
|
-
import { type EnvironmentAdapter } from './types.js';
|
|
11
|
-
import { type WorkerEnv } from './worker.js';
|
|
12
|
-
/**
|
|
13
|
-
* Create an environment adapter based on the detected runtime
|
|
14
|
-
* For Workers, pass the env bindings from the fetch handler
|
|
15
|
-
*/
|
|
16
|
-
export declare function createAdapter(workerEnv?: WorkerEnv): EnvironmentAdapter;
|
|
17
|
-
/**
|
|
18
|
-
* Get or create the singleton adapter instance
|
|
19
|
-
* Use this for convenience in modules that don't have access to the env bindings
|
|
20
|
-
*/
|
|
21
|
-
export declare function getAdapter(): EnvironmentAdapter;
|
|
22
|
-
/**
|
|
23
|
-
* Set the adapter instance (useful for Workers where env is per-request)
|
|
24
|
-
*/
|
|
25
|
-
export declare function setAdapter(adapter: EnvironmentAdapter): void;
|
|
26
|
-
/**
|
|
27
|
-
* Cross-platform base64 encode helper
|
|
28
|
-
*/
|
|
29
|
-
export declare function base64Encode(data: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Cross-platform base64 decode helper
|
|
32
|
-
*/
|
|
33
|
-
export declare function base64Decode(data: string): string;
|
|
34
|
-
/**
|
|
35
|
-
* Cross-platform logging helper
|
|
36
|
-
*/
|
|
37
|
-
export declare function log(message: string): void;
|
package/dist/adapters/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment adapter factory and exports
|
|
3
|
-
* Automatically detects the runtime environment and creates the appropriate adapter
|
|
4
|
-
*/
|
|
5
|
-
export { detectEnvironment } from './types.js';
|
|
6
|
-
export { NodeAdapter, createNodeAdapter } from './node.js';
|
|
7
|
-
export { WorkerAdapter, createWorkerAdapter } from './worker.js';
|
|
8
|
-
import { detectEnvironment } from './types.js';
|
|
9
|
-
import { createNodeAdapter } from './node.js';
|
|
10
|
-
import { createWorkerAdapter } from './worker.js';
|
|
11
|
-
// Singleton adapter instance for convenience
|
|
12
|
-
let _adapter = null;
|
|
13
|
-
/**
|
|
14
|
-
* Create an environment adapter based on the detected runtime
|
|
15
|
-
* For Workers, pass the env bindings from the fetch handler
|
|
16
|
-
*/
|
|
17
|
-
export function createAdapter(workerEnv) {
|
|
18
|
-
const env = detectEnvironment();
|
|
19
|
-
if (env === 'worker') {
|
|
20
|
-
return createWorkerAdapter(workerEnv);
|
|
21
|
-
}
|
|
22
|
-
return createNodeAdapter();
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get or create the singleton adapter instance
|
|
26
|
-
* Use this for convenience in modules that don't have access to the env bindings
|
|
27
|
-
*/
|
|
28
|
-
export function getAdapter() {
|
|
29
|
-
if (!_adapter) {
|
|
30
|
-
_adapter = createAdapter();
|
|
31
|
-
}
|
|
32
|
-
return _adapter;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Set the adapter instance (useful for Workers where env is per-request)
|
|
36
|
-
*/
|
|
37
|
-
export function setAdapter(adapter) {
|
|
38
|
-
_adapter = adapter;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Cross-platform base64 encode helper
|
|
42
|
-
*/
|
|
43
|
-
export function base64Encode(data) {
|
|
44
|
-
return getAdapter().base64Encode(data);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Cross-platform base64 decode helper
|
|
48
|
-
*/
|
|
49
|
-
export function base64Decode(data) {
|
|
50
|
-
return getAdapter().base64Decode(data);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Cross-platform logging helper
|
|
54
|
-
*/
|
|
55
|
-
export function log(message) {
|
|
56
|
-
getAdapter().log(message);
|
|
57
|
-
}
|
package/dist/adapters/node.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js environment adapter
|
|
3
|
-
* Uses filesystem operations and process.env for local development
|
|
4
|
-
*/
|
|
5
|
-
import type { EnvironmentAdapter, EnvConfig } from './types.js';
|
|
6
|
-
export declare class NodeAdapter implements EnvironmentAdapter {
|
|
7
|
-
private envOverrides;
|
|
8
|
-
constructor(envOverrides?: Partial<EnvConfig>);
|
|
9
|
-
getEnv(key: keyof EnvConfig): string | undefined;
|
|
10
|
-
isWorker(): boolean;
|
|
11
|
-
base64Encode(data: string): string;
|
|
12
|
-
base64Decode(data: string): string;
|
|
13
|
-
log(message: string): void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Create a Node.js adapter instance
|
|
17
|
-
*/
|
|
18
|
-
export declare function createNodeAdapter(envOverrides?: Partial<EnvConfig>): EnvironmentAdapter;
|
package/dist/adapters/node.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js environment adapter
|
|
3
|
-
* Uses filesystem operations and process.env for local development
|
|
4
|
-
*/
|
|
5
|
-
export class NodeAdapter {
|
|
6
|
-
envOverrides;
|
|
7
|
-
constructor(envOverrides = {}) {
|
|
8
|
-
this.envOverrides = envOverrides;
|
|
9
|
-
}
|
|
10
|
-
getEnv(key) {
|
|
11
|
-
// Check overrides first, then process.env
|
|
12
|
-
if (key in this.envOverrides) {
|
|
13
|
-
return this.envOverrides[key];
|
|
14
|
-
}
|
|
15
|
-
return process.env[key];
|
|
16
|
-
}
|
|
17
|
-
isWorker() {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
base64Encode(data) {
|
|
21
|
-
return Buffer.from(data).toString('base64');
|
|
22
|
-
}
|
|
23
|
-
base64Decode(data) {
|
|
24
|
-
return Buffer.from(data, 'base64').toString('utf-8');
|
|
25
|
-
}
|
|
26
|
-
log(message) {
|
|
27
|
-
console.error(`[tezosx-mcp] ${message}`);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create a Node.js adapter instance
|
|
32
|
-
*/
|
|
33
|
-
export function createNodeAdapter(envOverrides) {
|
|
34
|
-
return new NodeAdapter(envOverrides);
|
|
35
|
-
}
|
package/dist/adapters/types.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment adapter interface for abstracting platform-specific operations.
|
|
3
|
-
* This allows the MCP server to run in both Node.js and Cloudflare Workers environments.
|
|
4
|
-
*/
|
|
5
|
-
export interface EnvConfig {
|
|
6
|
-
MCP_TRANSPORT?: string;
|
|
7
|
-
SKIP_FRONTEND?: string;
|
|
8
|
-
WEB_PORT?: string;
|
|
9
|
-
PORT?: string;
|
|
10
|
-
TEZOS_NETWORK?: string;
|
|
11
|
-
SPENDING_PRIVATE_KEY?: string;
|
|
12
|
-
SPENDING_CONTRACT?: string;
|
|
13
|
-
}
|
|
14
|
-
export interface EnvironmentAdapter {
|
|
15
|
-
/**
|
|
16
|
-
* Get environment variable value
|
|
17
|
-
*/
|
|
18
|
-
getEnv(key: keyof EnvConfig): string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Check if we're running in a Workers environment
|
|
21
|
-
*/
|
|
22
|
-
isWorker(): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Base64 encode a string (Buffer.from in Node, btoa in Workers)
|
|
25
|
-
*/
|
|
26
|
-
base64Encode(data: string): string;
|
|
27
|
-
/**
|
|
28
|
-
* Base64 decode a string
|
|
29
|
-
*/
|
|
30
|
-
base64Decode(data: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Log a message (stderr in Node, console.log in Workers)
|
|
33
|
-
*/
|
|
34
|
-
log(message: string): void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Static file serving configuration for HTTP mode
|
|
38
|
-
*/
|
|
39
|
-
export interface StaticFileConfig {
|
|
40
|
-
/** Path to serve static files from (Node.js only) */
|
|
41
|
-
staticPath?: string;
|
|
42
|
-
/** Whether to use SPA fallback (serve index.html for unknown routes) */
|
|
43
|
-
spaFallback?: boolean;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Runtime environment type
|
|
47
|
-
*/
|
|
48
|
-
export type RuntimeEnvironment = 'node' | 'worker';
|
|
49
|
-
/**
|
|
50
|
-
* Detect the current runtime environment
|
|
51
|
-
*/
|
|
52
|
-
export declare function detectEnvironment(): RuntimeEnvironment;
|
package/dist/adapters/types.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environment adapter interface for abstracting platform-specific operations.
|
|
3
|
-
* This allows the MCP server to run in both Node.js and Cloudflare Workers environments.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Detect the current runtime environment
|
|
7
|
-
*/
|
|
8
|
-
export function detectEnvironment() {
|
|
9
|
-
// Check for Cloudflare Workers-specific globals
|
|
10
|
-
// @ts-ignore - caches is a Workers global
|
|
11
|
-
if (typeof globalThis.caches !== 'undefined' && typeof globalThis.caches.default !== 'undefined') {
|
|
12
|
-
return 'worker';
|
|
13
|
-
}
|
|
14
|
-
// Check for other Workers indicators
|
|
15
|
-
// @ts-ignore - WorkerGlobalScope is a Workers type
|
|
16
|
-
if (typeof WorkerGlobalScope !== 'undefined') {
|
|
17
|
-
return 'worker';
|
|
18
|
-
}
|
|
19
|
-
// Check for Node.js process
|
|
20
|
-
if (typeof process !== 'undefined' && process.versions?.node) {
|
|
21
|
-
return 'node';
|
|
22
|
-
}
|
|
23
|
-
// Default to worker if we can't determine (safer for bundled code)
|
|
24
|
-
return 'worker';
|
|
25
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cloudflare Workers environment adapter
|
|
3
|
-
* Uses Web APIs and Worker bindings instead of Node.js filesystem/process
|
|
4
|
-
*/
|
|
5
|
-
import type { EnvironmentAdapter, EnvConfig } from './types.js';
|
|
6
|
-
/**
|
|
7
|
-
* Cloudflare Worker environment bindings type
|
|
8
|
-
* These are passed to the fetch handler by Cloudflare
|
|
9
|
-
*/
|
|
10
|
-
export interface WorkerEnv {
|
|
11
|
-
MCP_TRANSPORT?: string;
|
|
12
|
-
SKIP_FRONTEND?: string;
|
|
13
|
-
WEB_PORT?: string;
|
|
14
|
-
PORT?: string;
|
|
15
|
-
TEZOS_NETWORK?: string;
|
|
16
|
-
SPENDING_PRIVATE_KEY?: string;
|
|
17
|
-
SPENDING_CONTRACT?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare class WorkerAdapter implements EnvironmentAdapter {
|
|
20
|
-
private env;
|
|
21
|
-
constructor(env?: WorkerEnv);
|
|
22
|
-
/**
|
|
23
|
-
* Update the environment bindings (called per-request with the env from fetch handler)
|
|
24
|
-
*/
|
|
25
|
-
setEnv(env: WorkerEnv): void;
|
|
26
|
-
getEnv(key: keyof EnvConfig): string | undefined;
|
|
27
|
-
isWorker(): boolean;
|
|
28
|
-
base64Encode(data: string): string;
|
|
29
|
-
base64Decode(data: string): string;
|
|
30
|
-
log(message: string): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create a Worker adapter instance
|
|
34
|
-
*/
|
|
35
|
-
export declare function createWorkerAdapter(env?: WorkerEnv): WorkerAdapter;
|
package/dist/adapters/worker.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cloudflare Workers environment adapter
|
|
3
|
-
* Uses Web APIs and Worker bindings instead of Node.js filesystem/process
|
|
4
|
-
*/
|
|
5
|
-
export class WorkerAdapter {
|
|
6
|
-
env;
|
|
7
|
-
constructor(env = {}) {
|
|
8
|
-
this.env = env;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Update the environment bindings (called per-request with the env from fetch handler)
|
|
12
|
-
*/
|
|
13
|
-
setEnv(env) {
|
|
14
|
-
this.env = env;
|
|
15
|
-
}
|
|
16
|
-
getEnv(key) {
|
|
17
|
-
return this.env[key];
|
|
18
|
-
}
|
|
19
|
-
isWorker() {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
base64Encode(data) {
|
|
23
|
-
// Use TextEncoder for proper UTF-8 handling
|
|
24
|
-
const encoder = new TextEncoder();
|
|
25
|
-
const bytes = encoder.encode(data);
|
|
26
|
-
let binary = '';
|
|
27
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
28
|
-
binary += String.fromCharCode(bytes[i]);
|
|
29
|
-
}
|
|
30
|
-
return btoa(binary);
|
|
31
|
-
}
|
|
32
|
-
base64Decode(data) {
|
|
33
|
-
const binary = atob(data);
|
|
34
|
-
const bytes = new Uint8Array(binary.length);
|
|
35
|
-
for (let i = 0; i < binary.length; i++) {
|
|
36
|
-
bytes[i] = binary.charCodeAt(i);
|
|
37
|
-
}
|
|
38
|
-
const decoder = new TextDecoder();
|
|
39
|
-
return decoder.decode(bytes);
|
|
40
|
-
}
|
|
41
|
-
log(message) {
|
|
42
|
-
console.log(`[tezosx-mcp] ${message}`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Create a Worker adapter instance
|
|
47
|
-
*/
|
|
48
|
-
export function createWorkerAdapter(env) {
|
|
49
|
-
return new WorkerAdapter(env);
|
|
50
|
-
}
|
package/dist/server.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core MCP server setup - shared between Node.js and Workers environments
|
|
3
|
-
*/
|
|
4
|
-
import { TezosToolkit } from "@taquito/taquito";
|
|
5
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
-
import type { EnvironmentAdapter } from "./adapters/index.js";
|
|
7
|
-
export type WalletConfig = {
|
|
8
|
-
Tezos: TezosToolkit;
|
|
9
|
-
spendingContract: string;
|
|
10
|
-
spendingAddress: string;
|
|
11
|
-
} | null;
|
|
12
|
-
declare const NETWORKS: {
|
|
13
|
-
readonly mainnet: {
|
|
14
|
-
readonly rpcUrl: "https://mainnet.tezos.ecadinfra.com";
|
|
15
|
-
readonly tzktApi: "https://api.tzkt.io";
|
|
16
|
-
};
|
|
17
|
-
readonly shadownet: {
|
|
18
|
-
readonly rpcUrl: "https://shadownet.tezos.ecadinfra.com";
|
|
19
|
-
readonly tzktApi: "https://api.shadownet.tzkt.io";
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
export type NetworkName = keyof typeof NETWORKS;
|
|
23
|
-
export type NetworkConfig = typeof NETWORKS[NetworkName];
|
|
24
|
-
export interface ServerConfig {
|
|
25
|
-
server: McpServer;
|
|
26
|
-
walletConfig: WalletConfig;
|
|
27
|
-
network: NetworkConfig;
|
|
28
|
-
networkName: NetworkName;
|
|
29
|
-
isHttp: boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Initialize the MCP server with tools and wallet configuration
|
|
33
|
-
* This is the shared core that works in both Node.js and Workers
|
|
34
|
-
*/
|
|
35
|
-
export declare function createMcpServer(adapter: EnvironmentAdapter): Promise<ServerConfig>;
|
|
36
|
-
export {};
|
package/dist/server.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core MCP server setup - shared between Node.js and Workers environments
|
|
3
|
-
*/
|
|
4
|
-
import { InMemorySigner } from "@taquito/signer";
|
|
5
|
-
import { TezosToolkit } from "@taquito/taquito";
|
|
6
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
-
import { createTools } from "./tools/index.js";
|
|
8
|
-
// Network configurations
|
|
9
|
-
const NETWORKS = {
|
|
10
|
-
mainnet: {
|
|
11
|
-
rpcUrl: 'https://mainnet.tezos.ecadinfra.com',
|
|
12
|
-
tzktApi: 'https://api.tzkt.io',
|
|
13
|
-
},
|
|
14
|
-
shadownet: {
|
|
15
|
-
rpcUrl: 'https://shadownet.tezos.ecadinfra.com',
|
|
16
|
-
tzktApi: 'https://api.shadownet.tzkt.io',
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Initialize the MCP server with tools and wallet configuration
|
|
21
|
-
* This is the shared core that works in both Node.js and Workers
|
|
22
|
-
*/
|
|
23
|
-
export async function createMcpServer(adapter) {
|
|
24
|
-
const log = (msg) => adapter.log(msg);
|
|
25
|
-
log('Initializing MCP server...');
|
|
26
|
-
const server = new McpServer({
|
|
27
|
-
name: "tezosx-mcp",
|
|
28
|
-
version: "1.0.0"
|
|
29
|
-
});
|
|
30
|
-
// Network configuration
|
|
31
|
-
const networkName = (adapter.getEnv('TEZOS_NETWORK') || 'mainnet');
|
|
32
|
-
const network = NETWORKS[networkName];
|
|
33
|
-
if (!network) {
|
|
34
|
-
throw new ReferenceError(`Invalid network: ${networkName}. Valid options: ${Object.keys(NETWORKS).join(', ')}`);
|
|
35
|
-
}
|
|
36
|
-
log(`Network: ${networkName}`);
|
|
37
|
-
// Taquito setup
|
|
38
|
-
const Tezos = new TezosToolkit(network.rpcUrl);
|
|
39
|
-
// Wallet configuration (optional - tools will guide user to configure if not set)
|
|
40
|
-
let walletConfig = null;
|
|
41
|
-
const privateKey = adapter.getEnv('SPENDING_PRIVATE_KEY')?.trim();
|
|
42
|
-
const spendingContract = adapter.getEnv('SPENDING_CONTRACT')?.trim();
|
|
43
|
-
if (privateKey && spendingContract) {
|
|
44
|
-
log('Configuring wallet...');
|
|
45
|
-
// Validate private key format
|
|
46
|
-
if (!privateKey.startsWith('edsk') && !privateKey.startsWith('spsk') && !privateKey.startsWith('p2sk')) {
|
|
47
|
-
log(`Warning: Invalid SPENDING_PRIVATE_KEY format. Must start with edsk, spsk, or p2sk. Wallet not configured.`);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
try {
|
|
51
|
-
const signer = await InMemorySigner.fromSecretKey(privateKey);
|
|
52
|
-
Tezos.setSignerProvider(signer);
|
|
53
|
-
const spendingAddress = await Tezos.signer.publicKeyHash();
|
|
54
|
-
walletConfig = { Tezos, spendingContract, spendingAddress };
|
|
55
|
-
log(`Wallet configured: ${spendingAddress}`);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
log(`Warning: Failed to initialize signer: ${error instanceof Error ? error.message : 'Unknown error'}. Wallet not configured.`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
log('Wallet not configured (missing SPENDING_PRIVATE_KEY or SPENDING_CONTRACT)');
|
|
64
|
-
}
|
|
65
|
-
// Tools
|
|
66
|
-
log('Registering tools...');
|
|
67
|
-
const isHttp = adapter.getEnv('MCP_TRANSPORT') === 'http';
|
|
68
|
-
const tools = createTools(walletConfig, network.tzktApi, isHttp);
|
|
69
|
-
tools.forEach(tool => {
|
|
70
|
-
server.registerTool(tool.name, tool.config, tool.handler);
|
|
71
|
-
});
|
|
72
|
-
log(`Registered ${tools.length} tools`);
|
|
73
|
-
return {
|
|
74
|
-
server,
|
|
75
|
-
walletConfig,
|
|
76
|
-
network,
|
|
77
|
-
networkName,
|
|
78
|
-
isHttp
|
|
79
|
-
};
|
|
80
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TezosToolkit } from "@taquito/taquito";
|
|
2
|
-
import z from "zod";
|
|
3
|
-
export declare const createGetAddressTool: (Tezos: TezosToolkit) => {
|
|
4
|
-
name: string;
|
|
5
|
-
config: {
|
|
6
|
-
title: string;
|
|
7
|
-
description: string;
|
|
8
|
-
inputSchema: z.ZodObject<{}, z.z.core.$strip>;
|
|
9
|
-
annotations: {
|
|
10
|
-
readOnlyHint: boolean;
|
|
11
|
-
destructiveHint: boolean;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
handler: () => Promise<{
|
|
15
|
-
content: {
|
|
16
|
-
type: "text";
|
|
17
|
-
text: string;
|
|
18
|
-
}[];
|
|
19
|
-
}>;
|
|
20
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import z from "zod";
|
|
2
|
-
export const createGetAddressTool = (Tezos) => ({
|
|
3
|
-
name: "tezos_get_address",
|
|
4
|
-
config: {
|
|
5
|
-
title: "Get Tezos Address",
|
|
6
|
-
description: "Returns the currently configured Tezos address",
|
|
7
|
-
inputSchema: z.object({}),
|
|
8
|
-
annotations: {
|
|
9
|
-
readOnlyHint: true,
|
|
10
|
-
destructiveHint: false
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
handler: async () => {
|
|
14
|
-
try {
|
|
15
|
-
const address = await Tezos.signer.publicKeyHash();
|
|
16
|
-
return {
|
|
17
|
-
content: [{ type: "text", text: address }]
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
throw new ReferenceError("Failed to get public key from signer.");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|