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
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | Message to sign. |
Implementation Reference
- src/tools/sign-message.ts:14-35 (handler)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; } },
- src/tools/sign-message.ts:11-13 (schema)Zod schema defining the input parameters for the tool: a single 'message' string.parameters: z.object({ message: z.string().describe("Message to sign."), }),
- src/tools/sign-message.ts:7-37 (registration)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; } }, }); };
- src/tools/register-tools.ts:53-53 (registration)Top-level call to registerSignMessageTools within the central registerTools function, invoked as part of initializing all tools.registerSignMessageTools(server, wagmiConfig);