Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

Wire pumpfun_upload_metadata MCP tool; fix settle-fee charge mint; vercel routes

nirholasa0634fbc9682
diff --git a/api/copy/settle-fee.js b/api/copy/settle-fee.js
index cf0412c69..291784ca8 100644
--- a/api/copy/settle-fee.js
+++ b/api/copy/settle-fee.js
@@ -121,6 +121,7 @@ export default wrap(async (req, res) => {
fee_usd: Number(usd.toFixed(4)),
quote: quote.token,
memo: quote.quote.nonce,
+ mint: quote.quote.mint,
legs: quote.quote.legs,
expires_at: quote.expiresAt,
});
diff --git a/api/pump-fun-mcp.js b/api/pump-fun-mcp.js
index 744420e5d..36d6daabe 100644
--- a/api/pump-fun-mcp.js
+++ b/api/pump-fun-mcp.js
@@ -978,6 +978,103 @@ async function handleGetCoinIntel({ mint, network = 'mainnet' } = {}) {
}
}
+// ── pumpfun_upload_metadata ────────────────────────────────────────────────
+//
+// Build + pin a pump.fun-ready metadata JSON to IPFS. Returns an ipfs:// URI
+// the caller passes to /api/pump/launch-agent as the `uri` field to launch
+// their coin. Requires bearer auth (API key) so Pinata credits aren't open.
+//
+// Two-step: (1) pin the image, (2) build the metadata JSON with the image CID
+// and pin that too. Both steps use the same Pinata/Web3.Storage credentials
+// already wired for the pinning API — no new env vars needed.
+
+const PINATA_PIN_API = 'https://api.pinata.cloud/pinning/pinFileToIPFS';
+const W3S_PIN_API = 'https://api.web3.storage/upload';
+const IMG_MAX_BYTES = 5 * 1024 * 1024; // 5 MB
+const META_IMG_TIMEOUT_MS = 8_000;
+
+async function _pinBuffer(buf, filename) {
+ const pinataJwt = process.env.PINATA_JWT;
+ if (pinataJwt) {
+ const form = new FormData();
+ form.append('file', new Blob([buf]), filename);
+ const r = await fetch(PINATA_PIN_API, {
+ method: 'POST',
+ headers: { Authorization: `Bearer ${pinataJwt}` },
+ body: form,
+ });
+ if (!r.ok) throw Object.assign(new Error(`Pinata ${r.status}`), { rpcCode: -32004 });
+ return { cid: (await r.json()).IpfsHash, provider: 'pinata' };
+ }
+ const w3sToken = process.env.WEB3_STORAGE_TOKEN;
+ if (w3sToken) {
+ const r = await fetch(W3S_PIN_API, {
+ method: 'POST',
+ headers: { Authorization: `Bearer ${w3sToken}`, 'X-NAME': filename },
+ body: buf,
+ });
+ if (!r.ok) throw Object.assign(new Error(`Web3.Storage ${r.status}`), { rpcCode: -32004 });
+ return { cid: (await r.json()).cid, provider: 'web3.storage' };
+ }
+ throw rpcError(-32004, 'no IPFS pinning provider configured (PINATA_JWT or WEB3_STORAGE_TOKEN)');
+}
+
+async function _fetchImgBuf(imageUrl) {
+ if (imageUrl.startsWith('data:')) {
+ const comma = imageUrl.indexOf(',');
+ if (comma === -1) throw rpcError(-32602, 'invalid data: URI');
+ const meta = imageUrl.slice(0, comma);
+ const payload = imageUrl.slice(comma + 1);
+ const buf = meta.includes('base64')
+ ? Buffer.from(payload, 'base64')
+ : Buffer.from(decodeURIComponent(payload));
+ if (buf.byteLength > IMG_MAX_BYTES) throw rpcError(-32602, 'image exceeds 5 MB');
+ const mime = meta.split(':')[1]?.split(';')[0] || 'image/png';
+ return { buf, filename: `image.${mime.split('/')[1] || 'png'}` };
+ }
+ const ctrl = new AbortController();
+ const tid = setTimeout(() => ctrl.abort(), META_IMG_TIMEOUT_MS);
+ try {
+ const r = await fetch(imageUrl, { signal: ctrl.signal });
+ if (!r.ok) throw rpcError(-32004, `image fetch failed: HTTP ${r.status}`);
+ const buf = Buffer.from(await r.arrayBuffer());
+ if (buf.byteLength > IMG_MAX_BYTES) throw rpcError(-32602, 'image exceeds 5 MB');
+ const ct = r.headers.get('content-type') || 'image/png';
+ const ext = ct.split('/')[1]?.split(';')[0] || 'png';
+ const fname = new URL(imageUrl, 'https://x').pathname.split('/').pop() || `image.${ext}`;
+ return { buf, filename: fname };
+ } finally { clearTimeout(tid); }
+}
+
+async function handleUploadMetadata({ name, symbol, description, image_url, twitter, telegram, website } = {}) {
+ if (!name || !symbol || !description || !image_url)
+ throw rpcError(-32602, 'name, symbol, description, and image_url are required');
+ if (String(name).length > 32) throw rpcError(-32602, 'name exceeds 32 chars');
+ if (String(symbol).length > 10) throw rpcError(-32602, 'symbol exceeds 10 chars');
+ if (String(description).length > 500) throw rpcError(-32602, 'description exceeds 500 chars');
+
+ const { buf: imgBuf, filename: imgFilename } = await _fetchImgBuf(image_url);
+ const { cid: imageCid, provider } = await _pinBuffer(imgBuf, imgFilename);
+ const imageUri = `https://ipfs.io/ipfs/${imageCid}`;
+
+ const meta = {
+ name: String(name).slice(0, 32),
+ symbol: String(symbol).replace(/^\$/, '').slice(0, 10),
+ description: String(description).slice(0, 500),
+ image: imageUri,
+ showName: true,
+ createdOn: 'https://three.ws',
+ };
+ if (twitter) meta.twitter = String(twitter);
+ if (telegram) meta.telegram = String(telegram);
+ if (website) meta.website = String(website);
+
+ const metaBuf = Buffer.from(JSON.stringify(meta), 'utf8');
+ const { cid } = await _pinBuffer(metaBuf, 'metadata.json');
+ const uri = `https://ipfs.io/ipfs/${cid}`;
+ return { uri, cid, image_cid: imageCid, provider };
+}
+
// ── pumpfun_bot_status (metadata, always available) ────────────────────────
// Reports whether the indexer is configured and, when it is, whether it's
@@ -1222,6 +1319,7 @@ const HANDLERS = {
pumpfun_quote_swap: handleQuoteSwap,
sns_resolve: handleSnsResolve,
sns_reverseLookup: handleSnsReverseLookup,
+ pumpfun_upload_metadata: handleUploadMetadata,
pumpfun_bot_status: handlePumpfunBotStatus,
};
@@ -1253,7 +1351,11 @@ const INSTRUCTIONS =
'market signals (kol_radar, kol_leaderboard, pumpfun_quote_swap, ' +
'pumpfun_watch_whales), and social sentiment (social_cashtag_sentiment, ' +
'social_x_post_impact). Discovery tools require the indexer backend — call ' +
- 'pumpfun_bot_status (always available) to check. All data is live; no API key required.';
+ 'pumpfun_bot_status (always available) to check. ' +
+ 'LAUNCH A COIN: to deploy a new pump.fun coin as an agent, call pumpfun_upload_metadata ' +
+ '(bearer required) to pin name/symbol/description/image to IPFS and get a uri, then POST ' +
+ 'to /api/pump/launch-agent with agent_id + uri to build, sign, and submit the launch ' +
+ 'transaction using the agent\'s custodial wallet. All data is live; most tools need no key.';
const MAX_BATCH = 16;
// Tools that are expensive (CPU grind or long-lived RPC subscriptions) or that
@@ -1264,6 +1366,7 @@ const AUTH_REQUIRED_TOOLS = new Set([
'pumpfun_vanity_mint',
'pumpfun_watch_whales',
'pumpfun_watch_claims',
+ 'pumpfun_upload_metadata',
]);
// Resolve the caller's credentials for a gated tool, once per request. Returns
diff --git a/src/dashboard-next/pages/copy.js b/src/dashboard-next/pages/copy.js
index ed637cdc3..928167ecc 100644
--- a/src/dashboard-next/pages/copy.js
+++ b/src/dashboard-next/pages/copy.js
@@ -268,7 +268,7 @@ async function payWithCopyFee(subscriptionId, onStatus = () => {}) {
const connection = new Connection(rpc, 'confirmed');
// 3. Build the $THREE SPL transfer + memo transaction
- const mint = new PublicKey(charge.legs[0]?.mint || 'FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump');
+ const mint = new PublicKey(charge.mint);
const fromAta = getAssociatedTokenAddressSync(mint, payer);
const tx = new Transaction();
for (const leg of charge.legs) {
diff --git a/vercel.json b/vercel.json
index 1c5f3924f..0f9930324 100644
--- a/vercel.json
+++ b/vercel.json
@@ -178,6 +178,14 @@
"api/copy/subscriptions.js": {
"includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}",
"maxDuration": 30
+ },
+ "api/copy/earnings.js": {
+ "includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}",
+ "maxDuration": 30
+ },
+ "api/copy/settle-fee.js": {
+ "includeFiles": "{examples/skills/**,data/pages.json,data/archives/**,data/rss/**,data/_generated/**,sdk/src/sas-config.json}",
+ "maxDuration": 60
}
},
"routes": [
@@ -1801,6 +1809,14 @@
"src": "/api/copy/subscriptions",
"dest": "/api/copy/subscriptions.js"
},
+ {
+ "src": "/api/copy/earnings",
+ "dest": "/api/copy/earnings.js"
+ },
+ {
+ "src": "/api/copy/settle-fee",
+ "dest": "/api/copy/settle-fee.js"
+ },
{
"src": "/api/pump/build-metadata",
"dest": "/api/pump/[action]?action=build-metadata"