"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LOGIN_CREDENTIALS = void 0;
exports.registerPerformLoginTool = registerPerformLoginTool;
exports.registerGetLoginCredentialsTool = registerGetLoginCredentialsTool;
exports.registerTestConnectionTool = registerTestConnectionTool;
exports.registerNavigateToPimTool = registerNavigateToPimTool;
exports.registerAllTools = registerAllTools;
exports.getAvailableTools = getAvailableTools;
var types_js_1 = require("@modelcontextprotocol/sdk/types.js");
var zod_1 = require("zod");
/**
* Login credentials configuration
*/
exports.LOGIN_CREDENTIALS = {
username: "admin",
password: "AIWorkshopJuly!25",
targetUrl: "http://localhost"
};
/**
* Tool: perform_login
*
* Performs automated login to the specified URL using predefined credentials.
* This tool is designed to work with the Playwright MCP server for browser automation.
*/
function registerPerformLoginTool(server) {
var _this = this;
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: zod_1.z.string().url().optional().describe("The URL to navigate to for login (defaults to http://localhost)")
}, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
var loginSteps, response;
var _c = _b.url, url = _c === void 0 ? exports.LOGIN_CREDENTIALS.targetUrl : _c;
return __generator(this, function (_d) {
try {
loginSteps = [
"Navigate to ".concat(url),
"Fill username field with: ".concat(exports.LOGIN_CREDENTIALS.username),
"Fill password field with: ".concat(exports.LOGIN_CREDENTIALS.password),
"Click the login button",
"Wait for successful login confirmation"
];
response = {
success: true,
message: "Login tool executed successfully",
steps: loginSteps,
credentials: {
username: exports.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 [2 /*return*/, {
content: [
{
type: "text",
text: "Login Tool Response:\n \n\u2705 Tool: perform_login\n\uD83C\uDFAF Target URL: ".concat(url, "\n\uD83D\uDC64 Username: ").concat(exports.LOGIN_CREDENTIALS.username, "\n\uD83D\uDD11 Password: [Protected]\n\n\uD83D\uDCCB Login Steps:\n").concat(loginSteps.map(function (step, index) { return "".concat(index + 1, ". ").concat(step); }).join('\n'), "\n\n\uD83D\uDCA1 Note: This tool is designed to work with the Playwright MCP server for actual browser automation.\nTo perform real login automation, ensure the Playwright MCP server is running and accessible.\n\n\uD83D\uDD27 For browser automation integration, this tool can be extended to:\n- Connect to the Playwright MCP server\n- Execute browser commands through MCP protocol\n- Handle login success/failure scenarios\n- Provide detailed feedback on login process")
}
]
}];
}
catch (error) {
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, "Login tool failed: ".concat(error instanceof Error ? error.message : String(error)));
}
return [2 /*return*/];
});
}); });
}
/**
* Tool: get_login_credentials
*
* Returns the login credentials that will be used for authentication.
* This is useful for verification and debugging purposes.
*/
function registerGetLoginCredentialsTool(server) {
var _this = this;
server.tool("get_login_credentials", "Returns the login credentials that will be used for authentication to http://localhost", {}, function () { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, {
content: [
{
type: "text",
text: "Login Credentials:\n \n\uD83C\uDFAF Target URL: ".concat(exports.LOGIN_CREDENTIALS.targetUrl, "\n\uD83D\uDC64 Username: ").concat(exports.LOGIN_CREDENTIALS.username, "\n\uD83D\uDD11 Password: AIWorkshopJuly!25\n\n\u2139\uFE0F These credentials are configured for the OrangeHRM system running on localhost.")
}
]
}];
});
}); });
}
/**
* Tool: test_connection
*
* Tests if the target URL is accessible.
* This is useful for debugging connection issues.
*/
function registerTestConnectionTool(server) {
var _this = this;
server.tool("test_connection", "Tests if the target URL (http://localhost) is accessible", {}, function () { return __awaiter(_this, void 0, void 0, function () {
var response, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, fetch(exports.LOGIN_CREDENTIALS.targetUrl, {
method: 'HEAD',
signal: AbortSignal.timeout(5000)
})];
case 1:
response = _a.sent();
return [2 /*return*/, {
content: [
{
type: "text",
text: "Connection Test Results:\n \n\uD83C\uDFAF Target URL: ".concat(exports.LOGIN_CREDENTIALS.targetUrl, "\n\u2705 Status: ").concat(response.status, " ").concat(response.statusText, "\n\uD83D\uDD17 Accessible: Yes\n\u23F1\uFE0F Response Time: Available\n\n\uD83D\uDCA1 The target URL is accessible and ready for login operations.")
}
]
}];
case 2:
error_1 = _a.sent();
return [2 /*return*/, {
content: [
{
type: "text",
text: "Connection Test Results:\n \n\uD83C\uDFAF Target URL: ".concat(exports.LOGIN_CREDENTIALS.targetUrl, "\n\u274C Status: Connection Failed\n\uD83D\uDD17 Accessible: No\n\u26A0\uFE0F Error: ").concat(error_1 instanceof Error ? error_1.message : String(error_1), "\n\n\uD83D\uDCA1 Please ensure the target server is running on localhost.")
}
]
}];
case 3: return [2 /*return*/];
}
});
}); });
}
/**
* Tool: navigate_to_pim
*
* Navigates to the PIM (Personal Information Management) page using the left-hand navigation menu.
* This tool assumes the user is already logged in and has access to the navigation menu.
*/
function registerNavigateToPimTool(server) {
var _this = this;
server.tool("navigate_to_pim", "Navigates to the PIM (Personal Information Management) page using the left-hand navigation menu. Assumes user is already logged in.", {}, function () { return __awaiter(_this, void 0, void 0, function () {
var navigationSteps, response;
return __generator(this, function (_a) {
try {
navigationSteps = [
"Locate the left-hand navigation menu",
"Find the 'PIM' menu item in the navigation list",
"Click on the 'PIM' link to navigate to the PIM module",
"Wait for the PIM page to load"
];
response = {
success: true,
message: "PIM navigation tool executed successfully",
steps: navigationSteps,
target_module: "PIM",
expected_url: "/web/index.php/pim/viewPimModule",
note: "This tool provides navigation instructions for the PIM module. Requires user to be logged in first."
};
return [2 /*return*/, {
content: [
{
type: "text",
text: "PIM Navigation Tool Response:\n \n\u2705 Tool: navigate_to_pim\n\uD83C\uDFAF Target Module: PIM (Personal Information Management)\n\uD83D\uDD17 Expected URL: ".concat(exports.LOGIN_CREDENTIALS.targetUrl, "/web/index.php/pim/viewPimModule\n\n\uD83D\uDCCB Navigation Steps:\n").concat(navigationSteps.map(function (step, index) { return "".concat(index + 1, ". ").concat(step); }).join('\n'), "\n\n\uD83D\uDCA1 Note: This tool assumes the user is already logged in and has access to the navigation menu.\nThe PIM module provides functionality for managing employee personal information, employment details, and related HR data.\n\n\uD83D\uDD27 For browser automation integration, this tool can be extended to:\n- Verify user is logged in before navigation\n- Click the PIM menu item using Playwright\n- Wait for page load confirmation\n- Handle navigation errors or timeouts\n- Provide feedback on successful navigation")
}
]
}];
}
catch (error) {
throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, "PIM navigation tool failed: ".concat(error instanceof Error ? error.message : String(error)));
}
return [2 /*return*/];
});
}); });
}
/**
* Registers all tools with the MCP server
*/
function registerAllTools(server) {
registerPerformLoginTool(server);
registerGetLoginCredentialsTool(server);
registerTestConnectionTool(server);
registerNavigateToPimTool(server);
}
/**
* Returns an array of all available tool names
*/
function getAvailableTools() {
return [
"perform_login",
"get_login_credentials",
"test_connection",
"navigate_to_pim"
];
}