Skip to main content
Glama

sign-message

Sign messages using MetaMask wallet for blockchain interactions without exposing private keys. This tool enables secure message signing within AI-powered applications.

Instructions

Sign messages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes

Implementation Reference

  • The execute handler for the 'sign-message' tool. It extracts the message from args, calls wagmi's signMessage with the configured wagmiConfig, returns the signature hash as a JSON string in MCP content format, logs and rethrows errors.
    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(),
    }),
  • The registerSignMessageTools function that defines and registers the 'sign-message' tool on the FastMCP server, including name, description, schema, and handler.
    export function registerSignMessageTools(server: FastMCP): void {
      server.addTool({
        name: "sign-message",
        description: "Sign messages",
        parameters: z.object({
          message: z.string(),
        }),
        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;
          }
        },
      });
    };
  • The call to registerSignMessageTools during server initialization in the main entry point.
    registerSignMessageTools(server);

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/mcpilot'

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