@dritan/mcp 0.7.0 → 0.8.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 +2 -2
- package/dist/index.js +26 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,13 +79,13 @@ npm run build && npm start
|
|
|
79
79
|
|
|
80
80
|
## Notes
|
|
81
81
|
|
|
82
|
-
- Wallets default to
|
|
82
|
+
- Wallets default to the current working directory (`process.cwd()`).
|
|
83
83
|
- Private keys never leave local files; only public address/signature are returned.
|
|
84
84
|
- `swap_sign_and_broadcast` signs locally, then broadcasts via Dritan.
|
|
85
85
|
- `auth_set_api_key` activates a key for the running MCP process without restart.
|
|
86
86
|
- `auth_set_api_key` and successful `x402_create_api_key` responses include a capability summary so agents can immediately guide users to next actions.
|
|
87
87
|
- Agent onboarding without `DRITAN_API_KEY` should present two options:
|
|
88
|
-
- Option 1: paid x402 flow (`
|
|
88
|
+
- Option 1: paid x402 flow (`wallet_create_local` in current directory -> share wallet + backup file path -> user chooses SOL amount and funds agent wallet -> if no key exists use `x402_create_api_key_quote` -> `wallet_transfer_sol` -> `x402_create_api_key`).
|
|
89
89
|
- Option 2: user gets a free key at `https://dritan.dev`.
|
|
90
90
|
- `x402_create_api_key` auto-activates returned keys for the current MCP session.
|
|
91
91
|
- `token_get_ohlcv_chart` returns a shareable chart URL plus a ready-to-send markdown image snippet.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { mkdirSync, readFileSync, existsSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
3
|
import { dirname, join, resolve } from "node:path";
|
|
5
4
|
import { spawnSync } from "node:child_process";
|
|
6
5
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -9,7 +8,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextpro
|
|
|
9
8
|
import { DritanClient, MeteoraThsClient, } from "dritan-sdk";
|
|
10
9
|
import { Connection, Keypair, PublicKey, SystemProgram, Transaction, VersionedTransaction, clusterApiUrl, } from "@solana/web3.js";
|
|
11
10
|
import { z } from "zod";
|
|
12
|
-
const DEFAULT_WALLET_DIR =
|
|
11
|
+
const DEFAULT_WALLET_DIR = process.cwd();
|
|
13
12
|
const LAMPORTS_PER_SOL = 1_000_000_000;
|
|
14
13
|
function normalizeApiKey(value) {
|
|
15
14
|
const trimmed = value?.trim();
|
|
@@ -68,7 +67,10 @@ const server = new Server({
|
|
|
68
67
|
},
|
|
69
68
|
instructions: [
|
|
70
69
|
"This server supports two API-key onboarding options when DRITAN_API_KEY is missing:",
|
|
71
|
-
"1) x402 pay-per-use key flow:
|
|
70
|
+
"1) x402 pay-per-use key flow:",
|
|
71
|
+
" a) Create a local agent wallet with wallet_create_local (saved in current working directory by default).",
|
|
72
|
+
" b) Ask user how much SOL they want to allocate and provide both wallet address and backup file path.",
|
|
73
|
+
" c) If no active key exists, create quote -> pay from agent wallet -> claim key.",
|
|
72
74
|
"2) Free key flow: user creates a free API key at https://dritan.dev.",
|
|
73
75
|
"After key is obtained, set it with auth_set_api_key (no restart needed), or restart with DRITAN_API_KEY configured.",
|
|
74
76
|
"Suggested setup command:",
|
|
@@ -82,6 +84,7 @@ function missingApiKeyError() {
|
|
|
82
84
|
return new Error([
|
|
83
85
|
"Missing DRITAN_API_KEY in environment.",
|
|
84
86
|
"Option 1 (paid): use x402 tools (x402_get_pricing, x402_create_api_key_quote, x402_create_api_key) and wallet tools.",
|
|
87
|
+
"Paid flow order: create wallet in current directory -> tell user funding amount + backup file path -> if no key exists then create/claim x402 key.",
|
|
85
88
|
"Option 2 (free): create a free key at https://dritan.dev and set DRITAN_API_KEY.",
|
|
86
89
|
"You can activate a key immediately with auth_set_api_key without restarting MCP.",
|
|
87
90
|
].join(" "));
|
|
@@ -471,7 +474,12 @@ function createLocalWalletFile(walletPath) {
|
|
|
471
474
|
throw new Error(`solana-keygen failed (${cmd.status}): ${cmd.stderr || cmd.stdout}`);
|
|
472
475
|
}
|
|
473
476
|
const keypair = loadKeypairFromPath(walletPath);
|
|
474
|
-
return {
|
|
477
|
+
return {
|
|
478
|
+
walletPath,
|
|
479
|
+
backupFilePath: walletPath,
|
|
480
|
+
walletDir: dir,
|
|
481
|
+
address: keypair.publicKey.toBase58(),
|
|
482
|
+
};
|
|
475
483
|
}
|
|
476
484
|
function loadKeypairFromPath(walletPath) {
|
|
477
485
|
const bytes = JSON.parse(readFileSync(walletPath, "utf8"));
|
|
@@ -1107,11 +1115,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1107
1115
|
preview: apiKeyPreview(activeApiKey),
|
|
1108
1116
|
hint: apiKeySet
|
|
1109
1117
|
? "API key is configured."
|
|
1110
|
-
: "Missing DRITAN_API_KEY.
|
|
1118
|
+
: "Missing DRITAN_API_KEY. Use x402 flow (wallet in current directory, user funds it, then claim key) or get a free key at https://dritan.dev.",
|
|
1111
1119
|
},
|
|
1112
1120
|
],
|
|
1113
1121
|
nextAction: !apiKeySet
|
|
1114
|
-
? "Choose one: (1) x402 paid onboarding flow
|
|
1122
|
+
? "Choose one: (1) x402 paid onboarding flow: wallet_create_local -> share wallet + backup file path -> user funds -> x402 quote/claim, or (2) get a free key at https://dritan.dev and set DRITAN_API_KEY."
|
|
1115
1123
|
: !solanaCli.ok
|
|
1116
1124
|
? "Install Solana CLI using installHint, then retry wallet_create_local."
|
|
1117
1125
|
: "Environment ready.",
|
|
@@ -1125,7 +1133,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1125
1133
|
preview: apiKeyPreview(activeApiKey),
|
|
1126
1134
|
controlBaseUrl: getControlBaseUrl(),
|
|
1127
1135
|
onboardingOptions: [
|
|
1128
|
-
"Option 1 (paid x402): create wallet ->
|
|
1136
|
+
"Option 1 (paid x402): create wallet in current directory -> share wallet address and backup file path -> user funds wallet -> if no key exists, quote/transfer/claim key.",
|
|
1129
1137
|
"Option 2 (free): create key at https://dritan.dev and set it with auth_set_api_key.",
|
|
1130
1138
|
],
|
|
1131
1139
|
...(activeApiKey ? buildPostAuthGuidance() : {}),
|
|
@@ -1149,7 +1157,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1149
1157
|
const input = walletCreateSchema.parse(args);
|
|
1150
1158
|
const walletPath = toWalletPath(input.name, input.walletDir);
|
|
1151
1159
|
const created = createLocalWalletFile(walletPath);
|
|
1152
|
-
return ok(
|
|
1160
|
+
return ok({
|
|
1161
|
+
...created,
|
|
1162
|
+
fundingInstruction: "Ask the user how much SOL they want to allocate to this wallet, and tell them this backup file path.",
|
|
1163
|
+
});
|
|
1153
1164
|
}
|
|
1154
1165
|
case "wallet_get_address": {
|
|
1155
1166
|
const input = walletPathSchema.parse(args);
|
|
@@ -1220,7 +1231,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1220
1231
|
return ok({
|
|
1221
1232
|
...(pricing ?? {}),
|
|
1222
1233
|
onboardingOptions: [
|
|
1223
|
-
"Option 1 (paid x402): create wallet ->
|
|
1234
|
+
"Option 1 (paid x402): create wallet in current directory -> share wallet + backup path -> user funds wallet -> if no key exists, quote/payment/claim.",
|
|
1224
1235
|
"Option 2 (free): user gets API key at https://dritan.dev and provides it as DRITAN_API_KEY.",
|
|
1225
1236
|
],
|
|
1226
1237
|
});
|
|
@@ -1228,12 +1239,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1228
1239
|
case "x402_create_api_key_quote": {
|
|
1229
1240
|
const input = x402QuoteSchema.parse(args);
|
|
1230
1241
|
const client = getX402Client();
|
|
1242
|
+
const activeApiKey = getActiveApiKey();
|
|
1231
1243
|
const quote = await x402CreateQuote(client, input);
|
|
1232
1244
|
return ok({
|
|
1233
1245
|
...(quote ?? {}),
|
|
1246
|
+
apiKeyAlreadyConfigured: !!activeApiKey,
|
|
1247
|
+
keyPreview: apiKeyPreview(activeApiKey),
|
|
1234
1248
|
nextSteps: [
|
|
1235
|
-
"
|
|
1236
|
-
"
|
|
1249
|
+
"Ensure agent has a local wallet in current directory (wallet_create_local + wallet_get_address) and tell user the backup file path.",
|
|
1250
|
+
"Ask user how much SOL they want to allocate; user funds the agent wallet.",
|
|
1251
|
+
"Only proceed if no API key is active; otherwise skip paid key creation.",
|
|
1237
1252
|
"Transfer quoted SOL amount to receiver wallet using wallet_transfer_sol.",
|
|
1238
1253
|
"Claim key with x402_create_api_key using returned tx signature (MCP auto-activates returned apiKey).",
|
|
1239
1254
|
],
|