Skip to main content
Glama

get_account_info_by_private_key

Retrieve Sui blockchain account details by inputting a private key, enabling users to access essential information for wallet management and transactions.

Instructions

Get account info by private key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
privateKeyYes

Implementation Reference

  • The handler function 'cb' that processes the private key input to derive and return account information including public key, private key, and Sui address.
    async cb(args: GetInfoByPrivateKeyParams) {
      if (!args.privateKey) {
        throw new Error('Private key is required');
      }
    
      const keypair = getKeypairFromPrivateKey(args.privateKey) as Ed25519Keypair;
      const publicKey = keypair.getPublicKey().toSuiPublicKey();
      const privateKey = keypair.getSecretKey();
      const address = keypair.toSuiAddress();
    
      const accountInfo = {
        publicKey,
        privateKey,
        address,
      };
    
      return this.createTextResponse(JSON.stringify(accountInfo));
    }
  • Zod input schema defining the required 'privateKey' parameter as a string, along with the corresponding TypeScript type.
    const getInfoByPrivateKeyParamsSchema = z.object({
      privateKey: z.string(),
    });
    
    type GetInfoByPrivateKeyParams = z.output<typeof getInfoByPrivateKeyParamsSchema>;
  • The tool is imported and added to the array of all tools exported from src/tools/index.ts, which is then used by the MCP server for registration.
    import getAccountInfoByPriKeyTool from './account/get-info-by-pri-key.js';
    
    export default [
      faucetTool,
      suiBalanceTool,
      suiTransferTool,
      randomSuiAccountTool,
      genMnemonicTool,
      genSuiAccountsByMnemonicTool,
      getAccountInfoByPriKeyTool,
    ];
  • src/index.ts:6-18 (registration)
    The tools array is imported and each tool is registered to the MCP server using server.tool() in a loop, providing name, description, schema, and callback.
    import tools from './tools/index.js';
    
    // Create an MCP server
    const server = new McpServer({
      name: 'Sui-mcp',
      version: '1.0.0',
    });
    
    for (const tool of tools) {
      const schema = tool.paramsSchema as z.ZodObject<any>;
      const cb = ((args: any) => tool.cb(args)) as any;
      server.tool(tool.name, tool.description, schema.shape, cb);
    }
Install Server

Other Tools

Related Tools

Latest Blog Posts

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/deanpluse/sui-mcp'

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