Skip to main content
Glama

get-connect-uri

Generate a connection URI to integrate MetaMask wallet with applications, enabling secure blockchain interactions without exposing private keys through MCPilot.

Instructions

Get the connect URI to connect to a MetaMask wallet

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The execute handler for the 'get-connect-uri' tool. It calls the helper function getMetaMaskConnectURI and returns the URI as structured text content.
    execute: async (_, { log }) => { const uri = await getMetaMaskConnectURI(log); return { content: [ { type: "text", text: JSONStringify({ uri, }), }, ], } },
  • Input schema for the 'get-connect-uri' tool, which takes no parameters.
    parameters: z.object({}),
  • Registration of the 'get-connect-uri' tool using FastMCP's addTool method.
    server.addTool({ name: "get-connect-uri", description: "Get the connect URI to connect to a MetaMask wallet", parameters: z.object({}), execute: async (_, { log }) => { const uri = await getMetaMaskConnectURI(log); return { content: [ { type: "text", text: JSONStringify({ uri, }), }, ], } }, });
  • Helper function that generates the MetaMask connect URI by setting up a headless metaMask connector with wagmi, listening for the display_uri message event, and resolving the promise with the URI.
    async function getMetaMaskConnectURI(log: any) { return new Promise((resolve, reject) => { const connectorFn = metaMask({ headless: true, }); const connector = wagmiConfig._internal.connectors.setup(connectorFn) connector.emitter.on("message", (payload) => { if (payload.type === "display_uri") { const uri = payload.data resolve(uri) } }); connector.emitter.on("connect", (payload) => { log.debug("connect success!", payload.accounts) }) connector.emitter.on("error", (payload) => { log.error(payload.error) }) connect(wagmiConfig, { connector }) .catch((error) => { log.error("connect error: ", error) reject(error) }) }) }

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