Skip to main content
Glama
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.

Latest Blog Posts

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