perform_login
Automate login to localhost web applications using predefined credentials via the Playwright MCP server, enabling secure and efficient browser automation.
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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | The URL to navigate to for login (defaults to http://localhost) |
Implementation Reference
- src/tools.ts:27-84 (handler)The core handler function for the 'perform_login' tool. It generates login steps using predefined credentials, formats a detailed response message, and returns it as structured content. Includes error handling with McpError.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:24-26 (schema)Zod input schema for 'perform_login' tool defining an optional 'url' parameter validated as a string URL.{ url: z.string().url().optional().describe("The URL to navigate to for login (defaults to http://localhost)") },
- src/tools.ts:21-86 (registration)The server.tool call within registerPerformLoginTool that registers the 'perform_login' tool, specifying name, description, schema, and handler.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)}` ); } } ); }
- src/tools.ts:8-12 (helper)Helper constant providing hardcoded login credentials (username, password, targetUrl) used by the perform_login handler.export const LOGIN_CREDENTIALS = { username: "admin", password: "AIWorkshopJuly!25", targetUrl: "http://localhost" };
- src/tools.ts:242-242 (registration)Call to registerPerformLoginTool inside registerAllTools function, which is invoked during server setup.registerPerformLoginTool(server);