@xache/mcp-server 0.3.3 → 0.4.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/dist/index.js +58 -0
- package/package.json +3 -3
- package/src/index.ts +63 -0
package/dist/index.js
CHANGED
|
@@ -74,14 +74,72 @@ function getDID() {
|
|
|
74
74
|
return `did:agent:${chainPrefix}:${config.walletAddress.toLowerCase()}`;
|
|
75
75
|
}
|
|
76
76
|
function validateConfig() {
|
|
77
|
+
// Required: wallet address
|
|
77
78
|
if (!config.walletAddress) {
|
|
78
79
|
console.error('Error: XACHE_WALLET_ADDRESS environment variable is required');
|
|
79
80
|
process.exit(1);
|
|
80
81
|
}
|
|
82
|
+
// Required: private key
|
|
81
83
|
if (!config.privateKey) {
|
|
82
84
|
console.error('Error: XACHE_PRIVATE_KEY environment variable is required');
|
|
83
85
|
process.exit(1);
|
|
84
86
|
}
|
|
87
|
+
// Validate chain
|
|
88
|
+
if (!['base', 'solana'].includes(config.chain)) {
|
|
89
|
+
console.error('Error: XACHE_CHAIN must be "base" or "solana"');
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
// Validate wallet address format based on chain
|
|
93
|
+
if (config.chain === 'solana') {
|
|
94
|
+
// Solana: base58 (32-44 chars)
|
|
95
|
+
if (!/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(config.walletAddress)) {
|
|
96
|
+
console.error('Error: Invalid Solana wallet address format');
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// EVM: 0x + 40 hex chars
|
|
102
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(config.walletAddress)) {
|
|
103
|
+
console.error('Error: Invalid EVM wallet address format (expected 0x + 40 hex chars)');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Validate private key format (hex string)
|
|
108
|
+
const cleanKey = config.privateKey.startsWith('0x')
|
|
109
|
+
? config.privateKey.slice(2)
|
|
110
|
+
: config.privateKey;
|
|
111
|
+
if (!/^[a-fA-F0-9]{64}$/.test(cleanKey) && !/^[a-fA-F0-9]{128}$/.test(cleanKey)) {
|
|
112
|
+
console.error('Error: XACHE_PRIVATE_KEY must be a 64 or 128 character hex string');
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
// Validate API URL format
|
|
116
|
+
try {
|
|
117
|
+
new URL(config.apiUrl);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
console.error('Error: XACHE_API_URL is not a valid URL');
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
// Validate LLM provider if specified
|
|
124
|
+
if (config.llmProvider && !SUPPORTED_PROVIDERS.includes(config.llmProvider)) {
|
|
125
|
+
console.error(`Error: XACHE_LLM_PROVIDER must be one of: ${SUPPORTED_PROVIDERS.join(', ')}`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
// Validate LLM endpoint URL if specified
|
|
129
|
+
if (config.llmEndpoint) {
|
|
130
|
+
try {
|
|
131
|
+
new URL(config.llmEndpoint);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
console.error('Error: XACHE_LLM_ENDPOINT is not a valid URL');
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Validate LLM format
|
|
139
|
+
if (!['openai', 'anthropic', 'cohere'].includes(config.llmFormat)) {
|
|
140
|
+
console.error('Error: XACHE_LLM_FORMAT must be "openai", "anthropic", or "cohere"');
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
85
143
|
}
|
|
86
144
|
// =============================================================================
|
|
87
145
|
// Helpers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xache/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "MCP server for Xache Protocol - collective intelligence, verifiable memory, extraction, and reputation for AI agents",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://xache.xyz",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
36
|
-
"@xache/sdk": "^5.
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
36
|
+
"@xache/sdk": "^5.4.0",
|
|
37
37
|
"zod": "^3.22.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -84,14 +84,77 @@ function getDID(): DID {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
function validateConfig(): void {
|
|
87
|
+
// Required: wallet address
|
|
87
88
|
if (!config.walletAddress) {
|
|
88
89
|
console.error('Error: XACHE_WALLET_ADDRESS environment variable is required');
|
|
89
90
|
process.exit(1);
|
|
90
91
|
}
|
|
92
|
+
|
|
93
|
+
// Required: private key
|
|
91
94
|
if (!config.privateKey) {
|
|
92
95
|
console.error('Error: XACHE_PRIVATE_KEY environment variable is required');
|
|
93
96
|
process.exit(1);
|
|
94
97
|
}
|
|
98
|
+
|
|
99
|
+
// Validate chain
|
|
100
|
+
if (!['base', 'solana'].includes(config.chain)) {
|
|
101
|
+
console.error('Error: XACHE_CHAIN must be "base" or "solana"');
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Validate wallet address format based on chain
|
|
106
|
+
if (config.chain === 'solana') {
|
|
107
|
+
// Solana: base58 (32-44 chars)
|
|
108
|
+
if (!/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(config.walletAddress)) {
|
|
109
|
+
console.error('Error: Invalid Solana wallet address format');
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
// EVM: 0x + 40 hex chars
|
|
114
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(config.walletAddress)) {
|
|
115
|
+
console.error('Error: Invalid EVM wallet address format (expected 0x + 40 hex chars)');
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Validate private key format (hex string)
|
|
121
|
+
const cleanKey = config.privateKey.startsWith('0x')
|
|
122
|
+
? config.privateKey.slice(2)
|
|
123
|
+
: config.privateKey;
|
|
124
|
+
if (!/^[a-fA-F0-9]{64}$/.test(cleanKey) && !/^[a-fA-F0-9]{128}$/.test(cleanKey)) {
|
|
125
|
+
console.error('Error: XACHE_PRIVATE_KEY must be a 64 or 128 character hex string');
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Validate API URL format
|
|
130
|
+
try {
|
|
131
|
+
new URL(config.apiUrl);
|
|
132
|
+
} catch {
|
|
133
|
+
console.error('Error: XACHE_API_URL is not a valid URL');
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Validate LLM provider if specified
|
|
138
|
+
if (config.llmProvider && !SUPPORTED_PROVIDERS.includes(config.llmProvider)) {
|
|
139
|
+
console.error(`Error: XACHE_LLM_PROVIDER must be one of: ${SUPPORTED_PROVIDERS.join(', ')}`);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Validate LLM endpoint URL if specified
|
|
144
|
+
if (config.llmEndpoint) {
|
|
145
|
+
try {
|
|
146
|
+
new URL(config.llmEndpoint);
|
|
147
|
+
} catch {
|
|
148
|
+
console.error('Error: XACHE_LLM_ENDPOINT is not a valid URL');
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Validate LLM format
|
|
154
|
+
if (!['openai', 'anthropic', 'cohere'].includes(config.llmFormat)) {
|
|
155
|
+
console.error('Error: XACHE_LLM_FORMAT must be "openai", "anthropic", or "cohere"');
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
95
158
|
}
|
|
96
159
|
|
|
97
160
|
// =============================================================================
|