srijonchakraborty/dot-net-sse-mcp-server
If you are the rightful owner of dot-net-sse-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A modern .NET 9.0 web API implementing the Model Context Protocol (MCP) server with Server-Sent Events (SSE) transport for student management.
.NET SSE MCP Server - Student Information
A modern .NET 9.0 web API that implements the Model Context Protocol (MCP) server with Server-Sent Events (SSE) transport, providing a comprehensive student management system with both REST API endpoints and MCP tools.
š Features
- Model Context Protocol (MCP) Server: Implements MCP specification for AI model integration
- Server-Sent Events (SSE) Transport: Real-time communication capabilities
- REST API Endpoints: Traditional HTTP endpoints for student management
- Swagger/OpenAPI Documentation: Interactive API documentation
- Student Management: Complete CRUD operations for student data
- Advanced Queries: Filter students by major, GPA, and custom fields
- Statistics: Generate comprehensive student statistics
- Modern .NET 9.0: Built with the latest .NET framework
š Prerequisites
- .NET 9.0 SDK
- Visual Studio 2022 or VS Code
- Git
š ļø Installation & Setup
-
Clone the repository
git clone https://github.com/yourusername/dot-net-sse-mcp-server.git cd dot-net-sse-mcp-server
-
Navigate to the project directory
cd StudentWebAPIWithMCPServer
-
Restore dependencies
dotnet restore
-
Run the application
dotnet run
The application will start on https://localhost:7000
(or the configured port in launchSettings.json
).
š API Documentation
Once the application is running, you can access:
- Swagger UI:
https://localhost:7000/swagger
- OpenAPI JSON:
https://localhost:7000/openapi.json
š§ MCP Tools
The server exposes the following MCP tools:
Student Management Tools
Tool | Description | Parameters |
---|---|---|
GetAllStudents | Retrieves all students | None |
GetStudentById | Gets a specific student by ID | id (int) |
GetStudentsByMajor | Filters students by major | major (string) |
GetStudentsWithGpaAbove | Gets students with GPA above threshold | minGpa (double) |
AddStudent | Adds a new student | id , firstName , lastName , dateOfBirth , email , gpa , major |
GetStudentStatistics | Returns comprehensive statistics | None |
GetStudentsWithFields | Returns students with specified fields only | fieldsToInclude (List |
š REST API Endpoints
Student Endpoints
Method | Endpoint | Description |
---|---|---|
POST | /Student/GetAllStudents | Get all students |
POST | /Student/GetStudentById | Get student by ID |
POST | /Student/GetStudentsByMajor | Filter by major |
POST | /Student/GetStudentsWithGpaAbove | Filter by minimum GPA |
POST | /Student/AddStudent | Add new student |
POST | /Student/GetStudentStatistics | Get statistics |
POST | /Student/GetStudentsWithFields | Get students with specific fields |
Example API Calls
Get All Students
curl -X POST "https://localhost:7000/Student/GetAllStudents" \
-H "Content-Type: application/json"
Add New Student
curl -X POST "https://localhost:7000/Student/AddStudent" \
-H "Content-Type: application/json" \
-d '{
"id": 7,
"firstName": "Alice",
"lastName": "Johnson",
"dateOfBirth": "2002-04-15",
"email": "alice.j@university.edu",
"gpa": 3.85,
"major": "Computer Science"
}'
Get Students by Major
curl -X POST "https://localhost:7000/Student/GetStudentsByMajor" \
-H "Content-Type: application/json" \
-d '"Computer Science"'
š Student Model
public class Student
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
public string Email { get; set; }
public double GPA { get; set; }
public string Major { get; set; }
}
š Sample Data
The application comes with pre-loaded sample student data:
- John Doe (Computer Science, GPA: 3.75)
- Jane Smith (Mathematics, GPA: 3.92)
- Michael Johnson (Physics, GPA: 3.45)
- Emily Williams (Biology, GPA: 3.88)
- David Brown (Chemistry, GPA: 3.21)
- Srijon Chakraborty (Computer Science and Engineering, GPA: 3.21)
šļø Project Structure
StudentWebAPIWithMCPServer/
āāā Controllers/
ā āāā StudentController.cs # REST API endpoints
āāā Model/
ā āāā Student.cs # Student entity and sample data
āāā Dto/
ā āāā StudentDto.cs # Data transfer objects
āāā Tools/
ā āāā StudentTool.cs # MCP tools implementation
āāā Program.cs # Application entry point
āāā StudentWebAPIWithMCPServer.csproj # Project configuration
š ļø Dependencies
- .NET 9.0: Latest .NET framework
- ModelContextProtocol.AspNetCore: MCP server implementation
- Swashbuckle.AspNetCore: Swagger/OpenAPI documentation
- Microsoft.AspNetCore.OpenApi: OpenAPI support
š Development
Running in Development Mode
dotnet run --environment Development
Building for Production
dotnet build --configuration Release
dotnet publish --configuration Release
Use MCP Server in VS Code Github Copilot
Add this config to settings of VS code
"mcp": {
"inputs": [],
"servers": {
"Srijon_Student_MCP": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"E:\\Personal Project\\mcptry\\MyFirstMCP\\MyFirstMCP.csproj"
]
},
"Student_MCP_Remote": {
"type": "sse",
"url":"http://mcpserversijon.runasp.net/sse",
}
}
}
Run in remote server
Run in local server from project
VS Code Detected the Tools
Use MCP Server in .NET Client Application
https://github.com/srijonchakraborty/mcp-client-sse
š¤ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
š License
This project is licensed under the MIT License - see the file for details.
š Acknowledgments
- Model Context Protocol for the MCP specification
- ASP.NET Core for the web framework
- Swagger for API documentation
š Support
If you have any questions or need support, please open an issue on GitHub or contact the maintainers.
Note: This is a demonstration project showcasing the integration of MCP servers with .NET web APIs. The student data is in-memory and will reset when the application restarts.