dot-net-sse-mcp-server

srijonchakraborty/dot-net-sse-mcp-server

3.2

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.

Tools
7
Resources
0
Prompts
0

.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

šŸ› ļø Installation & Setup

  1. Clone the repository

    git clone https://github.com/yourusername/dot-net-sse-mcp-server.git
    cd dot-net-sse-mcp-server
    
  2. Navigate to the project directory

    cd StudentWebAPIWithMCPServer
    
  3. Restore dependencies

    dotnet restore
    
  4. 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

ToolDescriptionParameters
GetAllStudentsRetrieves all studentsNone
GetStudentByIdGets a specific student by IDid (int)
GetStudentsByMajorFilters students by majormajor (string)
GetStudentsWithGpaAboveGets students with GPA above thresholdminGpa (double)
AddStudentAdds a new studentid, firstName, lastName, dateOfBirth, email, gpa, major
GetStudentStatisticsReturns comprehensive statisticsNone
GetStudentsWithFieldsReturns students with specified fields onlyfieldsToInclude (List)

🌐 REST API Endpoints

Student Endpoints

MethodEndpointDescription
POST/Student/GetAllStudentsGet all students
POST/Student/GetStudentByIdGet student by ID
POST/Student/GetStudentsByMajorFilter by major
POST/Student/GetStudentsWithGpaAboveFilter by minimum GPA
POST/Student/AddStudentAdd new student
POST/Student/GetStudentStatisticsGet statistics
POST/Student/GetStudentsWithFieldsGet 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

image

Run in local server from project

image

VS Code Detected the Tools

image image

Use MCP Server in .NET Client Application

https://github.com/srijonchakraborty/mcp-client-sse

šŸ¤ Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

šŸ“ License

This project is licensed under the MIT License - see the file for details.

šŸ™ Acknowledgments

šŸ“ž 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.