Skip to main content
Glama

Aptos Blockchain MCP

config.ts•2 kB
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk"; // Environment variables for Aptos MCP export const APTOS_MCP_PRIVATE_KEY = process.env.APTOS_MCP_PRIVATE_KEY; export const APTOS_MCP_NETWORK = (process.env.APTOS_MCP_NETWORK as Network) || Network.TESTNET; export const APTOS_MCP_NODE_URL = process.env.APTOS_MCP_NODE_URL; export const APTOS_MCP_FAUCET_URL = process.env.APTOS_MCP_FAUCET_URL; // Global Aptos client instance let aptosClient: Aptos | null = null; /** * Get or create the Aptos client instance * @returns Aptos client configured for the specified network */ export function getAptosClient(): Aptos { if (!aptosClient) { // Ensure we have a valid network configuration const network = APTOS_MCP_NETWORK || Network.TESTNET; const config = new AptosConfig({ network, ...(APTOS_MCP_NODE_URL && { fullnode: APTOS_MCP_NODE_URL }), ...(APTOS_MCP_FAUCET_URL && { faucet: APTOS_MCP_FAUCET_URL }) }); aptosClient = new Aptos(config); } return aptosClient; } /** * Reset the Aptos client (useful for testing or changing networks) */ export function resetAptosClient(): void { aptosClient = null; } /** * Get the current network configuration */ export function getCurrentNetwork(): Network { return APTOS_MCP_NETWORK; } /** * Check if we're on testnet */ export function isTestnet(): boolean { return APTOS_MCP_NETWORK === Network.TESTNET; } /** * Check if we're on mainnet */ export function isMainnet(): boolean { return APTOS_MCP_NETWORK === Network.MAINNET; } /** * Validate that required environment variables are set */ export function validateEnvironment(): void { if (!APTOS_MCP_PRIVATE_KEY) { throw new Error("APTOS_MCP_PRIVATE_KEY environment variable is required. Please configure the server with your Aptos private key."); } } /** * Check if environment is configured (non-throwing version) */ export function isEnvironmentConfigured(): boolean { return !!APTOS_MCP_PRIVATE_KEY; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/punkpeye/aptos-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server