test_connection
Verify connectivity to the MCP Login Server's target URL to ensure the server is accessible before attempting automated login procedures for localhost applications.
Instructions
Tests if the target URL (http://localhost) is accessible
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:129-170 (handler)The inline asynchronous handler function that implements the core logic of the 'test_connection' tool. It attempts a HEAD fetch to the target URL with a 5-second timeout and returns a structured response indicating accessibility.async () => { try { // Basic connectivity test const response = await fetch(LOGIN_CREDENTIALS.targetUrl, { method: 'HEAD', signal: AbortSignal.timeout(5000) }); return { content: [ { type: "text", text: `Connection Test Results: šÆ Target URL: ${LOGIN_CREDENTIALS.targetUrl} ā Status: ${response.status} ${response.statusText} š Accessible: Yes ā±ļø Response Time: Available š” The target URL is accessible and ready for login operations.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Connection Test Results: šÆ Target URL: ${LOGIN_CREDENTIALS.targetUrl} ā Status: Connection Failed š Accessible: No ā ļø Error: ${error instanceof Error ? error.message : String(error)} š” Please ensure the target server is running on localhost.` } ] }; } } );
- src/tools.ts:125-171 (registration)Direct registration of the 'test_connection' tool via server.tool() call within registerTestConnectionTool function, specifying name, description, input schema (empty), and handler.server.tool( "test_connection", "Tests if the target URL (http://localhost) is accessible", {}, async () => { try { // Basic connectivity test const response = await fetch(LOGIN_CREDENTIALS.targetUrl, { method: 'HEAD', signal: AbortSignal.timeout(5000) }); return { content: [ { type: "text", text: `Connection Test Results: šÆ Target URL: ${LOGIN_CREDENTIALS.targetUrl} ā Status: ${response.status} ${response.statusText} š Accessible: Yes ā±ļø Response Time: Available š” The target URL is accessible and ready for login operations.` } ] }; } catch (error) { return { content: [ { type: "text", text: `Connection Test Results: šÆ Target URL: ${LOGIN_CREDENTIALS.targetUrl} ā Status: Connection Failed š Accessible: No ā ļø Error: ${error instanceof Error ? error.message : String(error)} š” Please ensure the target server is running on localhost.` } ] }; } } ); }
- src/tools.ts:241-246 (registration)The registerAllTools function that includes the call to registerTestConnectionTool(server), thereby registering the test_connection tool as part of all tools.export function registerAllTools(server: McpServer): void { registerPerformLoginTool(server); registerGetLoginCredentialsTool(server); registerTestConnectionTool(server); registerNavigateToPimTool(server); }
- src/index.ts:28-28 (registration)Top-level call to registerAllTools(server) in the main MCP server initialization, which triggers registration of test_connection.registerAllTools(server);
- src/tools.ts:8-12 (helper)Configuration object providing the targetUrl used by the test_connection handler for the fetch request.export const LOGIN_CREDENTIALS = { username: "admin", password: "AIWorkshopJuly!25", targetUrl: "http://localhost" };