Control Escolar — Spring AI + MCP

A school management web app (students, teachers, subjects, classrooms, schedules, grades, reports, users and roles) with an AI assistant built on the Spring AI ChatClient and an MCP server that exposes school data to any MCP client.

Stack

What's inside

MCP server

16 tools, 5 resources, 1 resource template, 3 prompts and 3 completions at /mcp.

Chat memory

MessageChatMemoryAdvisor with a JDBC repository, one conversation per user.

RAG

QuestionAnswerAdvisor over the school rules and calendar in a SimpleVectorStore.

Safeguards

SafeGuardAdvisor blocks sensitive words before they reach memory.

Streaming & structured output

SSE token streaming and .entity(AnalisisAlumno.class) for student analysis.

Secure tool calling

registrarCalificacion reads the user's role from ToolContext, which the model cannot alter.

MCP tools

Endpoints

PathDescription
/mcpMCP server (Streamable HTTP, SYNC), no login
/asistente, /asistente/streamAI assistant page and SSE stream
POST /api/ia/preguntarAsk the assistant (JSON)
GET /api/ia/analisis-alumno/{matricula}Structured student analysis
GET /api/alumnos[/…]Students (by id, ID number, group)
GET /api/calificaciones[/…]Grades and averages
/reportes/exportar-csvCSV report export
/actuator/prometheusMetrics, including gen_ai_client_*

Run it

export OPENAI_API_KEY=<your key>   # optional
mvn spring-boot:run
# open http://localhost:8080  (demo user: admin / admin123)
npx @modelcontextprotocol/inspector   # connect to http://localhost:8080/mcp