#!/usr/bin/env node
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { registerAllTools, getAvailableTools, LOGIN_CREDENTIALS } from "./tools.js";
/**
* MCP Server for Login Operations
*
* This server provides tools for automated login functionality that can interact
* with the Playwright MCP server for browser automation.
*/
// Server configuration
const SERVER_NAME = "login-server";
const SERVER_VERSION = "1.0.0";
// Create the MCP server instance
const server = new McpServer({
name: SERVER_NAME,
version: SERVER_VERSION,
capabilities: {
tools: {}
}
});
// Register all tools with the server
registerAllTools(server);
/**
* Main server function
*/
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
// Log server startup (to stderr so it doesn't interfere with MCP protocol)
console.error(`🚀 MCP Login Server v${SERVER_VERSION} started`);
console.error(`📋 Available tools: ${getAvailableTools().join(', ')}`);
console.error(`🎯 Target URL: ${LOGIN_CREDENTIALS.targetUrl}`);
console.error(`👤 Username: ${LOGIN_CREDENTIALS.username}`);
}
// Handle graceful shutdown
process.on('SIGINT', async () => {
console.error('\n🛑 Shutting down MCP Login Server...');
process.exit(0);
});
process.on('SIGTERM', async () => {
console.error('\n🛑 Shutting down MCP Login Server...');
process.exit(0);
});
// Start the server
if (require.main === module) {
main().catch((error) => {
console.error('💥 Fatal error in MCP Login Server:', error);
process.exit(1);
});
}