AS
ALOC Stationdeveloper docs
DOCS/DEVELOPER PORTAL
v1.0.0
folio 4.2 — cookbook

Build an AI Socratic Exam Tutor with LangChain & MCP

Learn how to connect ALOC's curriculum data and step-by-step reasoning directly to LLM agents (Claude / GPT-4) to deliver pedagogical Socratic tutoring without spoiling answers.

View Tutor Agent Repo12 min implementation

4.2.0The Socratic Tutoring Pattern

Standard LLM question-answering immediately reveals the correct option and solution. Socratic tutoring inverts this behavior by providing progressive scaffolding:

Tier 1: Guiding Question

Prompts the student to recall the underlying law or formula (e.g. Newton's 2nd Law).

Tier 2: Misconception Hint

Diagnoses why a specific distractor was chosen (e.g. forgot to square the radius).

Tier 3: Worked Derivation

Reveals the full step-by-step solution only after repeated attempts.

4.2.1Step 1: Connect ALOC MCP Server

Our official package @massteck/aloc-mcp-server provides tools like aloc_search_questions and aloc_get_question_explanation:

// mcp-config.json
{
  "mcpServers": {
    "aloc": {
      "command": "npx",
      "args": ["-y", "@massteck/aloc-mcp-server"],
      "env": {
        "ALOC_API_KEY": "alc_live_your_key_here",
        "ALOC_BASE_URL": "https://dev.aloc.com.ng/api/v1"
      }
    }
  }
}

4.2.2Step 2: Implement Socratic Tutor Agent Loop

Using TypeScript and LLM system prompts, enforce progressive scaffolding:

import { QuestionsApi, ExplanationsApi, Configuration } from "@massteck/aloc-sdk";

const aloc = new QuestionsApi(new Configuration({ apiKey: process.env.ALOC_API_KEY }));
const explainer = new ExplanationsApi(new Configuration({ apiKey: process.env.ALOC_API_KEY }));

export async function handleStudentAttempt(questionId: string, selectedOption: string) {
  // 1. Fetch explanation & misconception models
  const explanation = await explainer.explainQuestion({
    id: questionId,
    explainQuestionRequest: { depth: "step_by_step" },
  });

  const isCorrect = selectedOption.toLowerCase() === explanation.data.correctAnswer?.toLowerCase();

  if (isCorrect) {
    return {
      status: "correct",
      feedback: "Excellent! You applied the principle correctly.",
    };
  }

  // 2. Return remedial hint without giving away the answer
  return {
    status: "incorrect",
    hint: explanation.data.simplifiedExplanation,
    misconceptions: explanation.data.commonMistakes,
  };
}
Looking for backend exam automation?

Learn how to generate and export complete exam papers in Python.

Next Guide: Python Exam Generator