Skip to main content
Glama

sign-message

Sign messages securely using MetaMask to verify identity and authenticate blockchain transactions without exposing private keys.

Instructions

Sign a message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesMessage to sign.

Implementation Reference

  • The execute function implements the core logic of the 'sign-message' tool: extracts the message from args, calls wagmi's signMessage, returns the hash in a structured content response, with error handling.
    execute: async (args, { log }) => {
      try {
        const message = args.message;
        const result = await signMessage(wagmiConfig, {
          message,
        });
        return {
          content: [
            {
              type: "text",
              text: JSONStringify({
                hash: result,
              }),
            },
          ],
        };
      }
      catch (error) {
        log.debug((error as Error).message);
        throw error;
      }
    },
  • Zod schema defining the input parameters for the tool: a single 'message' string.
    parameters: z.object({
      message: z.string().describe("Message to sign."),
    }),
  • The registration function that adds the 'sign-message' tool to the FastMCP server using server.addTool, including name, description, schema, and handler.
    export function registerSignMessageTools(server: FastMCP, wagmiConfig: Config): void {
      server.addTool({
        name: "sign-message",
        description: "Sign a message.",
        parameters: z.object({
          message: z.string().describe("Message to sign."),
        }),
        execute: async (args, { log }) => {
          try {
            const message = args.message;
            const result = await signMessage(wagmiConfig, {
              message,
            });
            return {
              content: [
                {
                  type: "text",
                  text: JSONStringify({
                    hash: result,
                  }),
                },
              ],
            };
          }
          catch (error) {
            log.debug((error as Error).message);
            throw error;
          }
        },
      });
    };
  • Top-level call to registerSignMessageTools within the central registerTools function, invoked as part of initializing all tools.
    registerSignMessageTools(server, wagmiConfig);

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/Xiawpohr/metamask-mcp'

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