mcp-server
The Sample MCP Server is a development tool that provides seamless access to product and user data from the DummyJSON API. It features integration with VS Code for streamlined data management and development capabilities.
Sample MCP Server
This is a Model Context Protocol (MCP) server that provides access to product and user data from DummyJSON API. The server is integrated with VS Code to provide easy access to product and user information directly within your development environment.
Features
Products
- Get a list of products with pagination support
- Get detailed information about a specific product by ID
- Search products by keyword
- Browse products by category
- Get a list of all available product categories
Users
- Get a list of users with pagination support
- Get detailed information about a specific user by ID
- Search users by keyword
General
- Integration with VS Code as an extension
Tools Provided
This MCP server provides the following tools:
Product Tools
get-products
- Get a list of products with optional paginationget-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
User Tools
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 keywordget-categories
- Get a list of all product categories
SQL Database Integration
This MCP server now includes SQL Server integration for storing and retrieving product and user data directly from a SQL database.
Database Setup
-
Make sure you have SQL Server installed and running
-
Configure your database connection in the
.env
file:MSSQL_CONNECTION_STRING=Server=yourserver;Database=yourdatabase;User Id=username;Password=password;Encrypt=false;TrustServerCertificate=true;
Alternatively, you can set individual connection parameters:
MSSQL_USER=username MSSQL_PASSWORD=password MSSQL_HOST=yourserver MSSQL_DATABASE=yourdatabase
-
Create the necessary database tables and insert sample data using the SQL script:
# Using SQL Server Management Studio or sqlcmd # Execute the script at src/db/setup-database.sql
SQL Tools Provided
Product Tools
sql-get-all-products
- Get all products from the SQL databasesql-get-product-by-id
- Get a specific product by IDsql-search-products
- Search for products by name or descriptionsql-get-products-below-price
- Get products below a specified pricesql-get-low-inventory-products
- Get products with inventory below a thresholdsql-get-paginated-products
- Get paginated products with specified page and sizesql-add-product
- Add a new product to the databasesql-update-product
- Update an existing productsql-delete-product
- Delete a product from the database
User Tools
sql-get-all-users
- Get all users from the SQL databasesql-get-user-by-id
- Get a specific user by IDsql-search-users
- Search for users by username or emailsql-get-user-by-email
- Get a specific user by email addresssql-get-paginated-users
- Get paginated users with specified page and sizesql-add-user
- Add a new user to the databasesql-update-user
- Update an existing usersql-delete-user
- Delete a user from the database
Database Tools
sql-check-database-health
- Check the health of the SQL database connection
Testing the Database Connection
You can test your database connection by running:
npm run build
node dist/tools/testConnection.js
VS Code Integration
Running the Server
You can run the MCP server using the VS Code Tasks provided:
- Press
Ctrl+Shift+P
and select "Tasks: Run Task" - Choose one of the following tasks:
- Build MCP Server: Compiles the TypeScript code
- Start MCP Server: Builds and starts the server
- Dev MCP Server (Watch Mode): Runs the server in development mode with auto-recompilation on changes
- Serve MCP Server: Runs the server using the dedicated server script with improved console output
Using with MCP-enabled AI assistants
- Start the MCP server using the tasks above
- Connect your AI assistant (like GitHub Copilot) to the server
- Use natural language to request product information
Installation
To install the dependencies, run:
npm install
Development
- Clone the repository
- Install dependencies with
npm install
- Build the project with
npm run build
- Start the server with
npm run start
For development with auto-recompilation:
npm run dev
Project Structure
src/index.ts
- Main entry point for the MCP serversrc/extension.ts
- VS Code extension entry pointsrc/controllers/
- MCP tools implementationsrc/services/
- Business logic and API interactionssrc/models/
- TypeScript interfaces and data models
Debugging
You can debug the MCP server using the "Launch MCP Server" configuration in VS Code:
- Press
F5
or select "Run > Start Debugging" - Choose the "Launch MCP Server" configuration
- View debug output in the Debug Console
API Reference
This MCP server uses the DummyJSON API (https://dummyjson.com/products) to fetch product data. For more information about available endpoints, visit the DummyJSON documentation.
Data Sources
This server uses the following DummyJSON API endpoints as its data sources:
- Products: DummyJSON Products API
- Users: DummyJSON Users API
Output Directory
The compiled output is in the dist
directory as specified by the TypeScript configuration.