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.

feat(mcp): let the wallet mint path broadcast a split create-then-register

nirholas129a528e4c2c
diff --git a/packages/metaplex-agent-mcp/README.md b/packages/metaplex-agent-mcp/README.md
index 217d11cb2..5e51f6be7 100644
--- a/packages/metaplex-agent-mcp/README.md
+++ b/packages/metaplex-agent-mcp/README.md
@@ -2,7 +2,7 @@
Deploy AI agents on-chain into the **[Metaplex Agent Registry](https://www.metaplex.com/agents)** on Solana, from any MCP client.
-One atomic transaction mints a **Metaplex Core asset** and registers its **EIP-8004 agent identity**, so the agent shows up on metaplex.com/agents with its own built-in wallet, reputation surface, and explorer pages. The default output reproduces the exact shape of the [three.ws](https://three.ws) Genesis 333 mints, verified byte-for-byte against the live assets:
+One flow mints a **Metaplex Core asset** and registers its **EIP-8004 agent identity** (a single atomic transaction when it fits Solana's 1232-byte limit, create + register in sequence otherwise, exactly how the Genesis 333 landed), so the agent shows up on metaplex.com/agents with its own built-in wallet, reputation surface, and explorer pages. The default output reproduces the exact shape of the [three.ws](https://three.ws) Genesis 333 mints, verified byte-for-byte against the live assets:
- asset metadata as a self-contained `data:application/json;base64` URI (`name`, `image`, `animation_url` GLB)
- Royalties plugin (5% to the owner), VerifiedCreators (the signing wallet), ImmutableMetadata
@@ -66,9 +66,9 @@ The mint costs ~0.007 SOL on mainnet (Core rent + identity PDA rent + fees).
| Tool | What it does |
|---|---|
-| `mint_onchain_agent` | Atomic mint + register, signed by your key. `confirm:true` gates the spend; anything else returns a full preview. |
-| `prepare_agent_mint` | The same transaction, built for an external wallet (`wallet` param) to sign. Returns base64, already co-signed by the new asset keypair. |
-| `send_signed_transaction` | Broadcast a wallet-signed transaction and poll to confirmation. |
+| `mint_onchain_agent` | Mint + register, signed by your key (atomic when it fits, auto-split otherwise). `confirm:true` gates the spend; anything else returns a full preview. |
+| `prepare_agent_mint` | The same mint, built for an external wallet (`wallet` param) to sign. Returns `txs_base64`, already co-signed by the new asset keypair; sign with `signTransaction` / `signAllTransactions`. |
+| `send_signed_transaction` | Broadcast wallet-signed transactions in order, polling each to confirmation and absorbing the create/register propagation race. |
| `register_agent_identity` | Enrol an already-minted Core asset in the Agent Registry (idempotent; the signer must be the asset authority). |
| `get_onchain_agent` | Read any registered agent: asset, plugins, decoded metadata + registration documents, identity PDA, built-in wallet + balance. |
| `agent_wallet` | An asset's built-in wallet (mpl-core Asset Signer PDA), any address, or the configured signer, with live SOL balance. |
diff --git a/packages/metaplex-agent-mcp/src/lib/index.js b/packages/metaplex-agent-mcp/src/lib/index.js
index a286d4712..d7f61e776 100644
--- a/packages/metaplex-agent-mcp/src/lib/index.js
+++ b/packages/metaplex-agent-mcp/src/lib/index.js
@@ -11,7 +11,13 @@ export {
decodeJsonUri,
} from './registration.js';
-export { buildPlugins, buildAgentMint } from './mint.js';
+export {
+ buildPlugins,
+ buildAgentMint,
+ sendAgentMint,
+ waitForAsset,
+ isAssetPropagationError,
+} from './mint.js';
export {
LAMPORTS_PER_SOL,
diff --git a/packages/metaplex-agent-mcp/src/tools/send-signed-transaction.js b/packages/metaplex-agent-mcp/src/tools/send-signed-transaction.js
index e32a55293..40a33abbd 100644
--- a/packages/metaplex-agent-mcp/src/tools/send-signed-transaction.js
+++ b/packages/metaplex-agent-mcp/src/tools/send-signed-transaction.js
@@ -1,67 +1,90 @@
-// `send_signed_transaction`: broadcast a fully signed transaction (usually
-// the output of prepare_agent_mint after the owner's wallet signed it) and
-// wait for confirmation.
+// `send_signed_transaction`: broadcast one or more fully signed transactions
+// (usually the output of prepare_agent_mint after the owner's wallet signed)
+// IN ORDER, waiting for confirmation between them. The order matters for the
+// split mint: register only succeeds once create has landed, and the bounded
+// retry below absorbs the RPC propagation race in between.
import { z } from 'zod';
import { NETWORK } from '../config.js';
+import { isAssetPropagationError } from '../lib/mint.js';
import { buildUmi, toBase58Signature, txLink } from '../lib/solana.js';
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+async function broadcastOne(umi, txBase64, network) {
+ let tx;
+ try {
+ tx = umi.transactions.deserialize(new Uint8Array(Buffer.from(txBase64, 'base64')));
+ } catch {
+ throw Object.assign(new Error('a transaction does not deserialize from base64'), { code: 'bad_transaction' });
+ }
+
+ let rawSignature;
+ for (let attempt = 0; ; attempt++) {
+ try {
+ rawSignature = await umi.rpc.sendTransaction(tx, { commitment: 'confirmed' });
+ break;
+ } catch (err) {
+ if (!isAssetPropagationError(err) || attempt >= 4) throw err;
+ await sleep(2000);
+ }
+ }
+ const signature = toBase58Signature(rawSignature);
+
+ // Bounded confirmation poll: ~60s at 2s intervals.
+ let status = null;
+ for (let i = 0; i < 30; i++) {
+ const [s] = await umi.rpc.getSignatureStatuses([rawSignature]);
+ if (s?.error) {
+ throw Object.assign(new Error(`transaction ${signature} failed on-chain: ${JSON.stringify(s.error)}`), {
+ code: 'tx_failed',
+ });
+ }
+ if (s && (s.commitment === 'confirmed' || s.commitment === 'finalized')) {
+ status = s.commitment;
+ break;
+ }
+ await sleep(2000);
+ }
+ return { signature, commitment: status, tx: txLink(signature, network) };
+}
+
export const def = {
name: 'send_signed_transaction',
- title: 'Broadcast a signed Solana transaction and confirm it',
+ title: 'Broadcast signed Solana transactions in order and confirm them',
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
description:
- 'Broadcast a fully signed Solana transaction (base64) and poll until it confirms. Use it to complete the ' +
- 'prepare_agent_mint flow when the signing wallet does not broadcast on its own. Whatever the transaction ' +
- 'does on-chain happens for real, so only send bytes you built and inspected.',
+ 'Broadcast one or more fully signed Solana transactions (base64) IN ORDER, polling each to confirmation ' +
+ 'before the next. Use it to complete the prepare_agent_mint flow: pass the wallet-signed txs_base64 array ' +
+ 'and the create/register sequencing (including the propagation race) is handled. Whatever the transactions ' +
+ 'do on-chain happens for real, so only send bytes you built and inspected.',
inputSchema: {
- tx_base64: z.string().min(64).describe('The fully signed transaction, base64 encoded.'),
+ tx_base64: z.string().min(64).optional().describe('A single fully signed transaction, base64 encoded.'),
+ txs_base64: z.array(z.string().min(64)).min(1).max(4).optional().describe('Fully signed transactions to broadcast in order (e.g. create then register).'),
network: z.enum(['mainnet', 'devnet']).optional().describe('Cluster to broadcast on. Defaults to the configured network.'),
},
async handler(args) {
const network = args.network || NETWORK;
- const umi = buildUmi({ network });
-
- let tx;
- try {
- tx = umi.transactions.deserialize(new Uint8Array(Buffer.from(args.tx_base64, 'base64')));
- } catch {
- throw Object.assign(new Error('tx_base64 does not deserialize as a Solana transaction'), {
- code: 'bad_transaction',
- });
+ const txs = args.txs_base64?.length ? args.txs_base64 : args.tx_base64 ? [args.tx_base64] : null;
+ if (!txs) {
+ throw Object.assign(new Error('pass tx_base64 or txs_base64'), { code: 'validation_error' });
}
+ const umi = buildUmi({ network });
- const rawSignature = await umi.rpc.sendTransaction(tx, { commitment: 'confirmed' });
- const signature = toBase58Signature(rawSignature);
-
- // Bounded confirmation poll: ~60s at 2s intervals.
- let status = null;
- for (let i = 0; i < 30; i++) {
- const [s] = await umi.rpc.getSignatureStatuses([rawSignature]);
- if (s?.error) {
- throw Object.assign(new Error(`transaction ${signature} failed on-chain: ${JSON.stringify(s.error)}`), {
- code: 'tx_failed',
- });
- }
- if (s && (s.commitment === 'confirmed' || s.commitment === 'finalized')) {
- status = s.commitment;
- break;
- }
- await sleep(2000);
+ const results = [];
+ for (const txBase64 of txs) {
+ results.push(await broadcastOne(umi, txBase64, network));
}
+ const unconfirmed = results.filter((r) => r.commitment === null);
return {
ok: true,
network,
- signature,
- confirmed: status !== null,
- commitment: status,
- tx: txLink(signature, network),
- ...(status === null
- ? { note: 'Broadcast succeeded but confirmation was not observed within 60s. Check the tx link before retrying; re-sending a landed transaction is harmless (same signature).' }
+ confirmed: unconfirmed.length === 0,
+ transactions: results,
+ ...(unconfirmed.length
+ ? { note: 'Broadcast succeeded but at least one confirmation was not observed within 60s. Check the tx links before retrying; re-sending a landed transaction is harmless (same signature).' }
: {}),
};
},