Skip to main content
Glama

MCP Login Server

by nieperdragon
  • Apple
  • Linux
REFACTORING_SUMMARY.md2.25 kB
# Refactoring Summary ## Changes Made ### 1. Created `src/tools.ts` - **Purpose**: Centralized tool definitions and registration - **Benefits**: - Separates tool logic from server setup - Makes adding new tools easier - Improves code organization and maintainability ### 2. Refactored `src/index.ts` - **Before**: 220 lines with server setup + all tool definitions - **After**: 51 lines focused only on server setup and startup - **Changes**: - Removed all tool definitions - Added import for tool registration functions - Simplified main function - Used `getAvailableTools()` for logging ### 3. New Architecture #### `src/tools.ts` exports: - `LOGIN_CREDENTIALS`: Configuration constants - `registerPerformLoginTool()`: Individual tool registration - `registerGetLoginCredentialsTool()`: Individual tool registration - `registerTestConnectionTool()`: Individual tool registration - `registerAllTools()`: Registers all tools at once - `getAvailableTools()`: Returns array of tool names #### `src/index.ts` responsibilities: - Server configuration and instantiation - Tool registration (via `registerAllTools()`) - Transport setup and connection - Process management and graceful shutdown - Startup logging ## Benefits 1. **Modularity**: Tools are self-contained and can be developed independently 2. **Extensibility**: Adding new tools requires minimal changes to existing code 3. **Maintainability**: Clear separation of concerns makes code easier to understand 4. **Testing**: Individual tools can be tested in isolation 5. **Reusability**: Tool definitions can be easily shared between projects ## Adding New Tools To add a new tool, developers only need to: 1. Create a new `registerYourTool()` function in `tools.ts` 2. Add it to the `registerAllTools()` function 3. Add the tool name to `getAvailableTools()` See `ADDING_TOOLS.md` for detailed instructions. ## Verification - ✅ Server starts successfully - ✅ All three tools are registered correctly - ✅ MCP protocol communication works - ✅ No TypeScript compilation errors - ✅ Tools can be listed via MCP protocol The refactoring is complete and the server maintains full compatibility with the original implementation while being much more extensible.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nieperdragon/custom_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server