get_current_web_app_url
Retrieve the connection URL and QR code for the AFK Mode web app to access remote task monitoring and decision prompts from mobile devices.
Instructions
Returns the connection URL and QR code for the AFK Mode web app. Call this when the user asks for the AFK app link or QR code.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server/mcp-tools.ts:20-41 (handler)The handler function for 'get_current_web_app_url' tool. It retrieves the current session, gets the web app URL via the getWebAppUrl callback, generates a QR code markdown, and returns a JSON response containing the URL, QR code markdown, and session ID.
async () => { const session = getSession(); const url = getWebAppUrl(); const qrCodeMarkdown = await generateQrMarkdown(url); return { content: [ { type: "text" as const, text: JSON.stringify( { url, qrCodeMarkdown, sessionId: session.sessionId, }, null, 2, ), }, ], }; }, - src/server/mcp-tools.ts:16-42 (registration)Registration of the 'get_current_web_app_url' tool using server.tool(). Defines the tool name, description, empty input schema ({}), and the async handler function.
server.tool( "get_current_web_app_url", "Returns the connection URL and QR code for the AFK Mode web app. Call this when the user asks for the AFK app link or QR code.", {}, async () => { const session = getSession(); const url = getWebAppUrl(); const qrCodeMarkdown = await generateQrMarkdown(url); return { content: [ { type: "text" as const, text: JSON.stringify( { url, qrCodeMarkdown, sessionId: session.sessionId, }, null, 2, ), }, ], }; }, ); - src/server/mcp-tools.ts:19-19 (schema)Input schema for the tool - an empty object {} indicating no input parameters are required.
{}, - src/server/qr.ts:3-10 (helper)Helper function generateQrMarkdown that creates a QR code data URI from a URL and returns it as markdown image syntax. Used by the get_current_web_app_url handler.
export async function generateQrMarkdown(url: string): Promise<string> { const dataUri = await QRCode.toDataURL(url, { width: 256, margin: 2, errorCorrectionLevel: "M", }); return ``; } - src/server/index.ts:65-74 (helper)Definition of the getWebAppUrl callback function that constructs the web app URL using local IP, port, and session token. Passed to registerTools and used by the tool handler.
const localIp = getLocalIp(); const getWebAppUrl = () => `http://${localIp}:${port}/?token=${session.sessionToken}`; // ── MCP Server (stdio) ── const mcpServer = new McpServer({ name: "afk-mode-mcp", version: "1.0.0", }); registerTools(mcpServer, getWebAppUrl);