This is a Model Context Protocol (MCP) server built with TypeScript and Express.js that provides comprehensive integration with SQL databases, Jira API, and intelligent AI-powered tools for data processing and analysis. The server uses Server-Sent Events (SSE) for real-time communication and features persistent storage for enhanced user experience.
- Complete CRUD operations for Users, Vendors, Commodities, Currencies, and Roles
- Advanced search and pagination capabilities
- Robust connection management with SQL Server
- Database health monitoring and connection testing
- Comprehensive Jira API integration with JQL (Jira Query Language) support
- Intelligent JQL query generation using AI
- Persistent JQL example storage with similarity-based deduplication
- Issue creation, searching, and management
- Sprint and project analytics
- OpenAI integration for intelligent tool routing and data processing
- Real-time streaming responses for better user experience
- Smart JQL query generation with learning capabilities
- Contextual data analysis and markdown formatting
- Products from DummyJSON API integration
- Users from DummyJSON API integration
- Real-time application status monitoring
- Persistent storage with automatic file synchronization
- Server-Sent Events (SSE) for streaming responses
- Multiple concurrent session management
- Graceful error handling and connection management
get-users
- Get a list of users with optional paginationget-user-by-id
- Get detailed information about a specific user by IDsearch-users
- Search for users by keyword
get-vendors
- Get a list of vendors with optional paginationget-vendor-by-id
- Get detailed information about a specific vendor by IDsearch-vendors
- Search for vendors by keyword
get-commodities
- Get a list of commodities with optional paginationget-commodity-by-id
- Get detailed information about a specific commodity by IDsearch-commodities
- Search for commodities by keyword
get-currencies
- Get a list of currencies with optional paginationget-currency-by-id
- Get detailed information about a specific currency by IDsearch-currencies
- Search for currencies by keyword
get-roles
- Get a list of roles with optional paginationget-role-by-id
- Get detailed information about a specific role by IDsearch-roles
- Search for roles by keyword
get-jira-issue-by-id
- Get detailed information about a specific Jira issuesearch-jira-issues
- Search for Jira issues using intelligent JQL generationcreate-jira-issue
- Create new Jira issues with specified project, summary, and issue typecreate-jira-subtask
- Create subtasks under existing Jira issues
get-products
- Get a list of products with optional pagination from DummyJSON APIget-product-by-id
- Get detailed information about a specific product by IDsearch-products
- Search for products by keywordget-products-by-category
- Get all products in a specific categoryget-categories
- Get a list of all product categories
get-application-status
- Get real-time status information for specific applications in different environments
This MCP server includes comprehensive SQL Server integration for enterprise-grade data management.
-
Install and Configure SQL Server
- Ensure SQL Server is installed and running
- Create your target database
-
Configure Database Connection
Create a
.env
file in the project root with your database credentials:# SQL Server Configuration MSSQL_USER=your_username MSSQL_PASSWORD=your_password MSSQL_HOST=your_server_host MSSQL_DATABASE=your_database_name # Alternative: Connection String MSSQL_CONNECTION_STRING=Server=yourserver;Database=yourdatabase;User Id=username;Password=password;Encrypt=false;TrustServerCertificate=true; # OpenAI Configuration (Required for AI features) OPENAI_API_KEY=your_openai_api_key LLM_MODEL=gpt-4 # Jira Configuration (Optional) JIRA_URL=https://your-domain.atlassian.net JIRA_USERNAME=your_email@example.com JIRA_API_TOKEN=your_jira_api_token
-
Database Schema
The server expects the following tables in your SQL database:
Users
- User management with roles and authentication detailsVendors
- Vendor/supplier informationCommodities
- Product commodities dataCurrencies
- Currency informationRoles
- User role definitions
Verify your database setup:
npm run build
npm run test-connection
-
Create Jira API Token
- Go to https://id.atlassian.com/manage-profile/security/api-tokens
- Create a new API token
- Add it to your
.env
file
-
Configure Jira Settings
JIRA_URL=https://your-domain.atlassian.net JIRA_USERNAME=your_email@example.com JIRA_API_TOKEN=your_jira_api_token
The server includes advanced JQL (Jira Query Language) capabilities:
- AI-Powered JQL Generation: Converts natural language queries to JQL
- Persistent Learning: Stores successful JQL examples for improved future queries
- Smart Deduplication: Prevents duplicate JQL examples using similarity detection
- Real-time Synchronization: JQL examples are immediately saved to
data/jql-examples.json
The system learns from usage and can generate JQL for queries like:
- "Show me open bugs in the current sprint"
- "Get all tasks assigned to John Doe"
- "Find issues created this week with high priority"
- "Display all closed sprints for velocity analysis"
The server uses OpenAI for intelligent data processing and query generation:
-
Get OpenAI API Key
- Visit https://platform.openai.com/api-keys
- Create a new secret key
- Add it to your
.env
file
-
Supported Models
- GPT-4 (recommended)
- GPT-3.5-turbo
- Any OpenAI-compatible model
- Intelligent Tool Routing: Automatically determines which tool to use based on user queries
- Real-time Streaming: Responses stream in real-time for better user experience
- Context-Aware Processing: Maintains context across multiple interactions
- Data Formatting: Automatically formats responses as markdown tables, charts, or text
- Node.js (v16 or higher)
- npm or yarn
- SQL Server (for database features)
- OpenAI API key (for AI features)
- Jira account (optional, for Jira integration)
-
Clone the Repository
git clone <repository-url> cd MCP-SERVER
-
Install Dependencies
npm install
-
Environment Configuration
Copy the example environment file and configure your settings:
copy .env.example .env
Edit
.env
with your specific configuration (see setup sections above). -
Build the Project
npm run build
-
Start the Server
npm run start
For development with auto-recompilation and hot-reload:
npm run dev
The project includes VS Code tasks for easy development:
- Press
Ctrl+Shift+P
and select "Tasks: Run Task" - Choose from available tasks:
- Build MCP Server: Compiles TypeScript code
- Start MCP Server: Builds and starts the server
- Dev MCP Server (Watch Mode): Development mode with auto-reload
Debug the MCP server in VS Code:
- Press
F5
or select "Run > Start Debugging" - Choose the "Launch MCP Server" configuration
- View debug output in the Debug Console
- Start the MCP server using the tasks above
- Connect your AI assistant (like GitHub Copilot) to the server
- Use natural language to request data and perform operations
graph TD
A[๐ฏ MCP Server] --> B[๐ฎ Controllers Layer]
A --> C[๐ข Services Layer]
A --> D[๐ Models Layer]
A --> E[โ๏ธ Configuration Layer]
B --> B1[๐ฅ User Controller]
B --> B2[๐ซ Jira Controller]
B --> B3[๐ฆ Product Controller]
B --> B4[๐ช Vendor Controller]
B --> B5[๐ Commodity Controller]
B --> B6[๐ฐ Currency Controller]
B --> B7[๐ Role Controller]
C --> C1[๐๏ธ SQL Services]
C --> C2[๐ซ Jira Service]
C --> C3[๐ฆ Product Service]
C --> C4[๐ฅ User Service]
C1 --> C1A[SQL User Service]
C1 --> C1B[SQL Vendor Service]
C1 --> C1C[SQL Commodity Service]
C1 --> C1D[SQL Currency Service]
C1 --> C1E[SQL Role Service]
D --> D1[๐๏ธ Database Models]
D --> D2[๐ API Models]
D --> D3[๐ Type Definitions]
E --> E1[๐พ Database Config]
E --> E2[๐ API Config]
E --> E3[๐๏ธ MSSQL Config]
F[๐ External Systems] --> F1[๐๏ธ SQL Server Database]
F --> F2[๐ซ Jira API]
F --> F3[๐ฆ DummyJSON API]
F --> F4[๐ค OpenAI API]
G[๐พ Data Storage] --> G1[๐ JQL Examples JSON]
G --> G2[๐ Application Data]
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
style D fill:#fff3e0
style E fill:#fce4ec
style F fill:#e0f2f1
style G fill:#f1f8e9
sequenceDiagram
participant ๐ค Client
participant ๐ SSE Transport
participant ๐ค AI Router
participant ๐ฎ Controller
participant ๐ข Service
participant ๐๏ธ Database
participant ๐ง OpenAI
๐ค->>๐: ๐ Natural Language Request
๐->>๐ค: ๐ Route Message
๐ค->>๐ง : ๐ Analyze Intent
๐ง -->>๐ค: ๐ฏ Tool Selection
๐ค->>๐ฎ: โก Execute Tool
๐ฎ->>๐ข: ๐ ๏ธ Business Logic
๐ข->>๐๏ธ: ๐ Data Query
๐๏ธ-->>๐ข: ๐ Raw Data
๐ข-->>๐ฎ: ๐ง Processed Data
๐ฎ->>๐ง : ๐ Format Request
๐ง -->>๐ฎ: ๐ Formatted Response
๐ฎ-->>๐: ๐ Stream Response
๐-->>๐ค: โก Real-time Output
MCP-SERVER/
โโโ ๐ data/ # ๐พ Persistent Data Storage
โ โโโ ๐ ... # ๐ Configuration files
โ
โโโ ๐ src/ # ๐ป Source Code
โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ app-data/ # ๐ Application Data
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ config/ # โ๏ธ Configuration Files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ controllers/ # ๐ฎ MCP Tool Controllers
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ db-models/ # ๐๏ธ Database Models
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ llm-api/ # ๐ค AI Integration
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ models/ # ๐ Data Models
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ modules/ # ๐ง Core Server Modules
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ services/ # ๐ข Business Logic Services
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ types/ # ๐ TypeScript Definitions
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ โโโ ๐ ... # ๐ TypeScript files
โ โ
โ โโโ ๐ utils/ # ๐ ๏ธ Utility Functions
โ โโโ ๐ ... # ๐ TypeScript files
โ
โโโ ๐ scripts/ # ๐จ Build & Deployment
โ โโโ ๐ ... # ๐ JavaScript files
โ
โโโ ๐ ... # ๐ HTML files
โโโ ๐ ... # ๐ Configuration files
โโโ ๐ ... # ๐ Configuration files
โโโ ๐ ... # ๐ Configuration files
โโโ ๐ ... # ๐ Documentation files
graph LR
subgraph "๐ External APIs"
EXT1[๐๏ธ SQL Server]
EXT2[๐ซ Jira API]
EXT3[๐ฆ DummyJSON]
EXT4[๐ค OpenAI]
end
subgraph "๐ฏ MCP Server Core"
SSE[๐ SSE Transport]
ROUTE[๐ค AI Router]
CTRL[๐ฎ Controllers]
SVC[๐ข Services]
end
subgraph "๐พ Data Layer"
DB[(๐๏ธ Database)]
FILES[๐ JSON Files]
end
CLIENT[๐ค Client] --> SSE
SSE --> ROUTE
ROUTE --> CTRL
CTRL --> SVC
SVC --> EXT1
SVC --> EXT2
SVC --> EXT3
SVC --> EXT4
SVC --> DB
SVC --> FILES
style CLIENT fill:#e3f2fd
style SSE fill:#f1f8e9
style ROUTE fill:#fff3e0
style CTRL fill:#fce4ec
style SVC fill:#e8f5e8
style DB fill:#e0f2f1
style FILES fill:#f3e5f5
- DummyJSON Products: https://dummyjson.com/products
- DummyJSON Users: https://dummyjson.com/users
- Jira REST API: Atlassian Cloud/Server REST API v2/v3
- OpenAI API: GPT models for intelligent processing
The server supports multiple response formats:
- Markdown Tables: Structured data in table format
- Markdown Text: Formatted text with analysis
- Charts: Data visualization using chart libraries
- JSON: Raw structured data
The server uses SSE for real-time communication:
- Endpoint:
/sse/stream
- Message Endpoint:
/messages
- Session Management: Automatic session handling with IDs
- Streaming Responses: Real-time data streaming for better UX
The server is configured to handle cross-origin requests with appropriate CORS headers.
# Get all users with pagination
curl "http://localhost:3000/messages" -X POST \
-H "Content-Type: application/json" \
-d '{"message": "show me all users"}'
# Search for specific vendor
curl "http://localhost:3000/messages" -X POST \
-H "Content-Type: application/json" \
-d '{"message": "find vendor with name containing Microsoft"}'
# Get Jira issues
curl "http://localhost:3000/messages" -X POST \
-H "Content-Type: application/json" \
-d '{"message": "show me open bugs in current sprint"}'
The AI-powered server understands natural language:
- "Show me all high-priority bugs assigned to John"
- "Get the last 10 vendors created this month"
- "Find all USD currency transactions"
- "Display sprint velocity chart for closed sprints"
- "List all users with admin role"
The server learns from JQL usage:
User Query: "show me open bugs"
Generated JQL: project = SCRUM AND issuetype = Bug AND status != "Done" ORDER BY priority DESC
Saved: โ
(New example learned)
User Query: "get open bugs"
Generated JQL: project = SCRUM AND issuetype = Bug AND status != "Done" ORDER BY priority DESC
Saved: โ (Duplicate detected - 85% similarity)
-
Create Controller
// src/controllers/myController.ts export function registerMyTools(server: McpServer) { server.tool('my-tool', 'Description', schema, handler); }
-
Register in Main
// src/index.ts import { registerMyTools } from './controllers/myController.js'; registerMyTools(server);
-
Add Interface
// src/db-models/myModel.ts export interface MyModel { Id: number; Name: string; // ... other fields }
-
Create Service
// src/services/myService.ts export class MyService { async getAll(): Promise<MyModel[]> { // Implementation } }
Edit prompts in src/llm-api/prompts.ts
:
export const MyCustomPrompt = `
Your custom system prompt here...
Format responses as markdown tables.
`;
-
Database Connection Failed
- Verify SQL Server is running
- Check credentials in
.env
file - Test with
npm run test-connection
-
OpenAI API Errors
- Verify API key is valid
- Check model availability
- Monitor API usage limits
-
Jira Authentication Failed
- Ensure API token is correct
- Verify Jira URL format
- Check user permissions
-
Port Already in Use
- Change port in configuration
- Kill existing processes:
npx kill-port 3000
Enable detailed logging:
DEBUG=mcp:* npm run start
Check logs in:
- Console output for real-time logs
data/jql-examples.json
for JQL learning progress- SQL Server logs for database issues
- Database connection health
- API response times
- JQL query success rates
- Memory usage patterns
- Active session counts
# Database health
curl "http://localhost:3000/messages" -X POST \
-H "Content-Type: application/json" \
-d '{"message": "check database health"}'
# Application status
curl "http://localhost:3000/messages" -X POST \
-H "Content-Type: application/json" \
-d '{"message": "get application status for MyApp in production"}'
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow TypeScript best practices
- Add proper error handling
- Include JSDoc comments
- Test database operations
- Validate all inputs with Zod schemas
This project is licensed under the ISC License - see the package.json file for details.
For support and questions:
- Check the troubleshooting section above
- Review the project issues on GitHub
- Consult the MCP Protocol documentation
- Check OpenAI API documentation for AI-related issues
Built with โค๏ธ using the Model Context Protocol (MCP)