perform_login
Automates login to localhost applications using predefined credentials. Requires Playwright MCP server for browser automation to handle authentication processes.
Instructions
Performs automated login to http://localhost using predefined credentials (admin/AIWorkshopJuly!25). This tool requires a Playwright MCP server to be running for browser automation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | The URL to navigate to for login (defaults to http://localhost) |
Implementation Reference
- src/tools.ts:8-12 (helper)Constant object defining the predefined login credentials (username, password, target URL) used by the perform_login tool handler.
export const LOGIN_CREDENTIALS = { username: "admin", password: "AIWorkshopJuly!25", targetUrl: "http://localhost" }; - src/tools.ts:24-26 (schema)Zod input schema for the perform_login tool, defining an optional 'url' parameter.
{ url: z.string().url().optional().describe("The URL to navigate to for login (defaults to http://localhost)") }, - src/tools.ts:27-84 (handler)The core handler function for 'perform_login' tool. Generates step-by-step login instructions using predefined credentials and returns a formatted response. Designed to integrate with Playwright for actual automation (demo version provides instructions).
async ({ url = LOGIN_CREDENTIALS.targetUrl }) => { try { // Note: This is a demonstration tool that provides login instructions // In a real implementation, this would interface with the Playwright MCP server // to perform actual browser automation const loginSteps = [ `Navigate to ${url}`, `Fill username field with: ${LOGIN_CREDENTIALS.username}`, `Fill password field with: ${LOGIN_CREDENTIALS.password}`, `Click the login button`, `Wait for successful login confirmation` ]; const response = { success: true, message: "Login tool executed successfully", steps: loginSteps, credentials: { username: LOGIN_CREDENTIALS.username, target_url: url }, note: "This tool provides login instructions. To perform actual browser automation, integrate with a running Playwright MCP server." }; return { content: [ { type: "text", text: `Login Tool Response: ✅ Tool: perform_login 🎯 Target URL: ${url} 👤 Username: ${LOGIN_CREDENTIALS.username} 🔑 Password: [Protected] 📋 Login Steps: ${loginSteps.map((step, index) => `${index + 1}. ${step}`).join('\n')} 💡 Note: This tool is designed to work with the Playwright MCP server for actual browser automation. To perform real login automation, ensure the Playwright MCP server is running and accessible. 🔧 For browser automation integration, this tool can be extended to: - Connect to the Playwright MCP server - Execute browser commands through MCP protocol - Handle login success/failure scenarios - Provide detailed feedback on login process` } ] }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Login tool failed: ${error instanceof Error ? error.message : String(error)}` ); } } - src/tools.ts:20-86 (registration)Function that registers the 'perform_login' tool with the MCP server, specifying name, description, input schema, and handler implementation.
export function registerPerformLoginTool(server: McpServer): void { server.tool( "perform_login", "Performs automated login to http://localhost using predefined credentials (admin/AIWorkshopJuly!25). This tool requires a Playwright MCP server to be running for browser automation.", { url: z.string().url().optional().describe("The URL to navigate to for login (defaults to http://localhost)") }, async ({ url = LOGIN_CREDENTIALS.targetUrl }) => { try { // Note: This is a demonstration tool that provides login instructions // In a real implementation, this would interface with the Playwright MCP server // to perform actual browser automation const loginSteps = [ `Navigate to ${url}`, `Fill username field with: ${LOGIN_CREDENTIALS.username}`, `Fill password field with: ${LOGIN_CREDENTIALS.password}`, `Click the login button`, `Wait for successful login confirmation` ]; const response = { success: true, message: "Login tool executed successfully", steps: loginSteps, credentials: { username: LOGIN_CREDENTIALS.username, target_url: url }, note: "This tool provides login instructions. To perform actual browser automation, integrate with a running Playwright MCP server." }; return { content: [ { type: "text", text: `Login Tool Response: ✅ Tool: perform_login 🎯 Target URL: ${url} 👤 Username: ${LOGIN_CREDENTIALS.username} 🔑 Password: [Protected] 📋 Login Steps: ${loginSteps.map((step, index) => `${index + 1}. ${step}`).join('\n')} 💡 Note: This tool is designed to work with the Playwright MCP server for actual browser automation. To perform real login automation, ensure the Playwright MCP server is running and accessible. 🔧 For browser automation integration, this tool can be extended to: - Connect to the Playwright MCP server - Execute browser commands through MCP protocol - Handle login success/failure scenarios - Provide detailed feedback on login process` } ] }; } catch (error) { throw new McpError( ErrorCode.InternalError, `Login tool failed: ${error instanceof Error ? error.message : String(error)}` ); } } ); }