Skip to main content
Glama

MSSQL MCP Server

by Nirmal123K
PROJECT_STRUCTURE.md•7.21 kB
# Project Structure This document outlines the organization and structure of the MSSQL MCP Server project. ## šŸ“ Repository Layout ``` mssql-mcp-server/ ā”œā”€ā”€ šŸ“„ README.md # Main project documentation ā”œā”€ā”€ šŸ“„ LICENSE # MIT License with proper attribution ā”œā”€ā”€ šŸ“„ CONTRIBUTING.md # Contribution guidelines ā”œā”€ā”€ šŸ“„ CHANGELOG.md # Version history and release notes ā”œā”€ā”€ šŸ“„ package.json # Node.js package configuration ā”œā”€ā”€ šŸ“„ package-lock.json # Dependency lock file ā”œā”€ā”€ šŸ“„ tsconfig.json # TypeScript configuration ā”œā”€ā”€ šŸ“„ .gitignore # Git ignore patterns ā”œā”€ā”€ šŸ“„ .env.example # Environment configuration template ā”œā”€ā”€ šŸ“ src/ # Source code │ ā”œā”€ā”€ šŸ“„ index.ts # Main MCP server implementation │ └── šŸ“ tools/ # Database operation tools │ ā”œā”€ā”€ šŸ“„ ReadDataTool.ts # SELECT queries with security validation │ ā”œā”€ā”€ šŸ“„ InsertDataTool.ts # INSERT operations │ ā”œā”€ā”€ šŸ“„ UpdateDataTool.ts # UPDATE operations with WHERE validation │ ā”œā”€ā”€ šŸ“„ CreateTableTool.ts # Table creation │ ā”œā”€ā”€ šŸ“„ CreateIndexTool.ts # Index management │ ā”œā”€ā”€ šŸ“„ DropTableTool.ts # Table deletion │ ā”œā”€ā”€ šŸ“„ ListTableTool.ts # Schema discovery │ └── šŸ“„ DescribeTableTool.ts # Table structure inspection ā”œā”€ā”€ šŸ“ dist/ # Compiled JavaScript output (generated) ā”œā”€ā”€ šŸ“ docs/ # Additional documentation │ └── šŸ“„ PROJECT_STRUCTURE.md # This file └── šŸ“ node_modules/ # Dependencies (generated) ``` ## šŸ—ļø Architecture Overview ### Core Components #### `src/index.ts` - **Main MCP Server**: Entry point and server implementation - **Dual Authentication**: Logic for SQL Server vs Azure AD authentication - **Connection Management**: Database connection pooling and token handling - **Tool Registration**: Registration of all 8 database operation tools - **Error Handling**: Centralized error management and logging #### `src/tools/` Database operation tools implementing the MCP Tool interface: | Tool | Purpose | Security Level | Operations | |------|---------|----------------|------------| | **ReadDataTool** | Execute SELECT queries | šŸ”’šŸ”’šŸ”’ High | Read data with injection prevention | | **InsertDataTool** | Add new records | šŸ”’šŸ”’ Medium | Single/bulk inserts with validation | | **UpdateDataTool** | Modify existing data | šŸ”’šŸ”’šŸ”’ High | Updates with mandatory WHERE clauses | | **CreateTableTool** | Create new tables | šŸ”’šŸ”’ Medium | Table creation with column definitions | | **CreateIndexTool** | Optimize performance | šŸ”’šŸ”’ Medium | Index creation and management | | **DropTableTool** | Remove tables | šŸ”’šŸ”’šŸ”’ High | Safe table deletion with validation | | **ListTableTool** | Browse schema | šŸ”’ Low | List tables and metadata | | **DescribeTableTool** | Inspect structure | šŸ”’ Low | Table schema and column details | ## šŸ”§ Configuration Files ### `package.json` - **Metadata**: Project name, description, keywords for npm - **Scripts**: Build, development, and utility commands - **Dependencies**: Runtime and development dependencies - **Publishing**: Configuration for npm distribution ### `tsconfig.json` - **Target**: ES2020 for modern JavaScript features - **Module**: ES2020 modules for compatibility - **Strict Mode**: Enabled for type safety - **Output**: Compiled to `dist/` directory with source maps ### `.env.example` - **Template**: Example environment configuration - **Documentation**: Inline comments explaining each variable - **Examples**: Multiple configuration scenarios - **Security**: Guidelines for credential management ## šŸ“š Documentation Structure ### Primary Documentation - **README.md**: Complete user guide and reference - **CONTRIBUTING.md**: Developer contribution guidelines - **LICENSE**: MIT License with proper attribution - **CHANGELOG.md**: Version history and release notes ### Additional Documentation - **docs/PROJECT_STRUCTURE.md**: This architectural overview - **Inline Comments**: Comprehensive code documentation - **JSDoc**: TypeScript documentation for APIs ## šŸ”„ Build Process ### Development Workflow ```bash npm install # Install dependencies npm run build # Compile TypeScript to JavaScript npm run watch # Watch mode for development npm run dev # Build and start server npm run clean # Clean build artifacts ``` ### Output Structure ``` dist/ ā”œā”€ā”€ index.js # Compiled main server ā”œā”€ā”€ index.d.ts # TypeScript declarations ā”œā”€ā”€ index.js.map # Source map for debugging └── tools/ # Compiled tool implementations ā”œā”€ā”€ ReadDataTool.js ā”œā”€ā”€ InsertDataTool.js └── ... (other tools) ``` ## šŸ›”ļø Security Architecture ### Input Validation - **SQL Injection Prevention**: Multi-layer protection in ReadDataTool - **Query Validation**: Syntax and semantic analysis - **Parameter Binding**: Automatic parameterization for all queries - **Keyword Filtering**: Dangerous SQL keyword detection ### Authentication Flow ``` Environment Check ā”œā”€ā”€ SQL_USER + SQL_PASSWORD present? │ ā”œā”€ā”€ Yes → SQL Server Authentication │ └── No → Azure AD Authentication └── Connection established with appropriate method ``` ### Access Control - **Read-Only Mode**: Environment variable to restrict operations - **Tool-Level Security**: Each tool implements appropriate validation - **Connection Pooling**: Secure token management and expiration ## šŸ¤ Contribution Guidelines ### Code Organization - **Single Responsibility**: Each tool has one clear purpose - **Consistent Patterns**: All tools follow the same interface - **Error Handling**: Comprehensive error management - **Type Safety**: Full TypeScript coverage ### File Naming Conventions - **PascalCase**: Class files (e.g., `ReadDataTool.ts`) - **camelCase**: Function and variable names - **UPPER_CASE**: Constants and environment variables - **kebab-case**: Configuration files (e.g., `package.json`) ### Development Standards - **TypeScript**: Strict mode with comprehensive types - **ES2020**: Modern JavaScript features - **Modular Design**: Clear separation of concerns - **Documentation**: Inline comments and JSDoc ## šŸš€ Deployment Considerations ### Package Distribution - **npm Registry**: Configured for npm publication - **Binary**: Executable via `mssql-mcp-server` command - **Files**: Only essential files included in package - **Dependencies**: Minimal runtime dependencies ### Environment Support - **Node.js**: 16+ compatibility - **Platforms**: Windows, macOS, Linux - **Databases**: SQL Server 2016+, Azure SQL Database - **AI Assistants**: Claude Desktop, VS Code Agent, MCP-compatible clients This structure ensures maintainability, security, and ease of contribution while providing a professional foundation for the open-source project.

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/Nirmal123K/mssql-mcp'

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