A TypeScript project demonstrating how to build an interactive educational analytics assistant using OpenAI tool calling and the Model Context Protocol (MCP).
- Clone the repository and navigate into its directory:
git clone <repo-url> cd openai-tools-and-mcp-examples
- Install dependencies:
npm install
- Create a
.envfile in the project root and set your OpenAI API key:OPENAI_API_KEY=your_api_key_here
This will automatically start the MCP server and launch an interactive prompt:
npm run clientAsk questions about student and school performance (type quit to exit).
Run a series of predefined analytics queries:
npm run client-demo- Run built client/server:
npm run server # Build and run MCP server npm run client # Build and run interactive client
To automatically generate and evaluate prompt responses for each MCP tool:
# In one terminal, start the MCP server:
npm run server
# In another terminal, run the evaluation script:
npm run evaluate
# To force regeneration of prompts and conversations:
npm run evaluate:overwrite
# To regenerate only prompts:
npm run evaluate:overwrite-prompts
# To regenerate only conversations:
npm run evaluate:overwrite-conversations# Run dialog-based context evaluation (25 multi-turn conversations):
npm run evaluate:dialog
# To regenerate only dialog conversations:
npm run evaluate:dialog -- --overwriteThis will:
- Generate 50 diverse prompts per registered tool (valid, invalid, and incomplete questions).
- Send each prompt to the MCP server via the client and record user–assistant conversations.
- Use the Python
LLM_as_judge.pyscript to assess responses with the LLM and save results toevaluation/evaluations.json.
- Sets up the MCP server and registers analysis tools defined in
src/tools/:analyze-student-performancecompare-domain-performanceidentify-struggling-studentsget-school-overviewget-exam-percentilepredict-next-exam-scores
- Discovers tools from the MCP server and converts them to OpenAI function definitions.
- Sends user queries to OpenAI, automatically executes any tool calls, and returns the final analysis.
The example conversation script provides both an interactive REPL and a predefined examples mode.