Skip to main content
Glama
getAddress.ts1.45 kB
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import type { Wallet } from "./wallet"; /** * Register the tool to get the wallet address * @param server The MCP server instance * @param wallet The initialized custom Wallet instance */ export function registerGetAddressTool( server: McpServer, wallet: Wallet, ): void { server.tool( "wallet_getAddress", "Retrieves the current wallet's Bitcoin SV address. This address can be used to receive BSV, ordinals, or tokens, and is derived from the wallet's private key.", { args: z .object({}) .optional() .describe( "No parameters required - simply returns the current wallet address", ), }, async () => { try { const address = wallet.getAddress(); if (!address) { throw new Error( "Could not retrieve address from wallet instance. Key might be missing or getAddress method failed.", ); } return { content: [ { type: "text", text: JSON.stringify({ address, status: "ok" }), }, ], }; } catch (err: unknown) { const msg = err instanceof Error ? err.message : String(err); return { content: [ { type: "text", text: JSON.stringify({ error: "Failed to get wallet address", message: msg, status: "error", }), }, ], isError: true, }; } }, ); }

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/b-open-io/bsv-mcp'

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