gabrielgst56/mcp-server-sample
If you are the rightful owner of mcp-server-sample and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This MCP server provides comprehensive CRUD operations for Work Orders with database integration using Entity Framework Core and SQL Server.
Work Order MCP Server
This MCP server provides comprehensive CRUD operations for Work Orders with database integration using Entity Framework Core and SQL Server.
Features
- Create Work Orders: Add new work orders with title, description, status, assignment, and more
- Read Work Orders: Retrieve work orders by ID or with filtering options
- Update Work Orders: Modify existing work orders with new information
- Delete Work Orders: Remove work orders from the system
- Search Work Orders: Find work orders by title or description
- Work Order Statistics: Get counts and statistics about work orders
Database Setup
The server uses SQL Server LocalDB by default. To set up the database:
- Ensure SQL Server LocalDB is installed
- Run the following commands to create and update the database:
dotnet ef database update
Configuration
Connection String
You can configure the database connection string in several ways:
- Environment Variable: Set
ConnectionStrings__DefaultConnection - appsettings.json: Add your connection string to the configuration file
- Default: Uses LocalDB if no connection string is provided
Example connection string:
Server=(localdb)\mssqllocaldb;Database=WorkOrderDb;Trusted_Connection=true;MultipleActiveResultSets=true
Available Tools
Create Work Order
- Tool:
create_work_order - Description: Creates a new work order with specified details
- Parameters: title, description, status, assignedTo, createdBy, dueDate, priority, category
Get Work Order
- Tool:
get_work_order - Description: Retrieves a work order by its ID
- Parameters: id
Get Work Orders
- Tool:
get_work_orders - Description: Retrieves work orders with optional filtering
- Parameters: status, assignedTo, priority, category, limit
Update Work Order
- Tool:
update_work_order - Description: Updates an existing work order
- Parameters: id, title, description, status, assignedTo, dueDate, priority, category
Delete Work Order
- Tool:
delete_work_order - Description: Deletes a work order by its ID
- Parameters: id
Search Work Orders
- Tool:
search_work_orders - Description: Searches work orders by title or description
- Parameters: searchTerm, limit
Get Work Order Statistics
- Tool:
get_work_order_stats - Description: Gets work order statistics and counts
- Parameters: None
Developing locally
To test this MCP server from source code (locally) without using a built MCP server package, you can configure your IDE to run the project directly using dotnet run.
{
"servers": {
"SampleMcpServer": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"<PATH TO PROJECT DIRECTORY>"
]
}
}
}
Connecting MCP Server to Copilot in VS Code
To connect this MCP server to GitHub Copilot in VS Code and test it interactively:
- Configure the MCP server
- Create a
.vscode/mcp.jsonfile in your project directory with the following content:
- Create a
{
"servers": {
"WorkOrderServer": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"<PATH TO PROJECT DIRECTORY>"
],
"env": {
"ConnectionStrings__DefaultConnection": "Server=localhost;Database=WorkOrderDb;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=true;Encrypt=false"
}
}
}
}
Replace <PATH TO PROJECT DIRECTORY> with the absolute path to your MCP server project.
-
Start the MCP server
- Open a terminal in VS Code and run:
dotnet run --project <PATH TO PROJECT DIRECTORY> - Or let Copilot Chat start the server automatically when you interact with it.
- Open a terminal in VS Code and run:
-
Test with Copilot Chat
- Open Copilot Chat in VS Code.
- Use natural language prompts to interact with your MCP server, for example:
- "Create a new work order for my internet issue, assigned to Gabriel Silva."
- "Show all open work orders."
- "Update work order #7 to completed."
- "Get work order statistics."
Copilot will use the MCP protocol to communicate with your server and perform the requested operations. You can view results and debug directly in VS Code.
For more details, see Use MCP servers in VS Code (Preview).
Testing the MCP Server
Once configured, you can ask Copilot Chat to perform work order operations, for example:
- "Create a new work order for fixing the printer"
- "Show me all open work orders"
- "Update work order #5 to completed status"
- "Search for work orders containing 'server'"
- "Get work order statistics"
Publishing to NuGet.org
- Run
dotnet pack -c Releaseto create the NuGet package - Publish to NuGet.org with
dotnet nuget push bin/Release/*.nupkg --api-key <your-api-key> --source https://api.nuget.org/v3/index.json
Using the MCP Server from NuGet.org
Once the MCP server package is published to NuGet.org, you can configure it in your preferred IDE. Both VS Code and Visual Studio use the dnx command to download and install the MCP server package from NuGet.org.
- VS Code: Create a
<WORKSPACE DIRECTORY>/.vscode/mcp.jsonfile - Visual Studio: Create a
<SOLUTION DIRECTORY>\.mcp.jsonfile
For both VS Code and Visual Studio, the configuration file uses the following server definition:
{
"servers": {
"SampleMcpServer": {
"type": "stdio",
"command": "dnx",
"args": [
"SampleMcpServer",
"--version",
"0.1.0-beta",
"--yes"
]
}
}
}
More information
.NET MCP servers use the ModelContextProtocol C# SDK. For more information about MCP:
Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers: