EduChain MCP Server
Enables AI-powered generation of educational content including multiple-choice questions, lesson plans, and flashcards on any topic through integration with the EduChain library and DeepSeek model via OpenRouter.
README
EduChain MCP Server - AI Intern Assignment
Overview
This project implements a Model Context Protocol (MCP) server that integrates with the EduChain library to provide educational content generation capabilities. The server exposes EduChain's functionality through standardized MCP tools and resources, allowing Claude Desktop and other MCP-compatible clients to generate multiple-choice questions, lesson plans, and flashcards.
Project Structure
educhain-mcp-assignment/
├── README.md # This documentation file
├── requirements.txt # Python dependencies
├── mcp_educhain_server.py # Main MCP server implementation
├── test_mcp_server.py # Test script for server functionality
├── educhain_setup.py # EduChain environment setup script
├── claude_desktop_config.json # Claude Desktop configuration
├── sample_responses.txt # Sample commands and responses
├── python_mcqs.json # Generated MCQ samples
└── python_lesson_plan.json # Generated lesson plan sample
Features
Tools Implemented
-
generate_mcqs: Generate multiple-choice questions on any topic
- Parameters: topic, num_questions (default: 5), difficulty_level (default: "Medium")
- Returns: JSON formatted MCQs with questions, options, answers, and explanations
-
generate_lesson_plan: Create comprehensive lesson plans
- Parameters: topic, duration (default: "60 minutes"), grade_level (default: "Intermediate")
- Returns: JSON formatted lesson plan with objectives, structure, and materials
-
generate_flashcards: Generate flashcards for study purposes
- Parameters: topic, num_cards (default: 10)
- Returns: JSON formatted flashcards with questions and answers
Resources Implemented
- educhain://status: Server status information
- educhain://capabilities: Available tools and supported features
Technical Implementation
Architecture
The MCP server is built using the FastMCP framework from the official MCP Python SDK. It integrates with EduChain using a custom LLM configuration that routes requests through OpenRouter to the DeepSeek model for cost-effective AI generation.
Key Components
- MCP Server: FastMCP-based server handling protocol communication
- EduChain Integration: Custom configuration using OpenRouter and DeepSeek
- Tool Handlers: Individual functions for each educational content type
- Resource Providers: Static and dynamic resource endpoints
- Error Handling: Comprehensive error management for API failures
Installation and Setup
Prerequisites
- Python 3.11 or higher
- OpenRouter API key (for DeepSeek model access)
- Claude Desktop (for testing MCP integration)
Installation Steps
-
Install Dependencies:
pip install -r requirements.txt -
Configure API Key: The server is pre-configured to use OpenRouter with the DeepSeek model. The API key is embedded in the server code for demonstration purposes.
-
Test the Server:
python3.11 test_mcp_server.py -
Configure Claude Desktop: Copy the
claude_desktop_config.jsonto your Claude Desktop configuration directory.
Usage Examples
Starting the Server
python3.11 mcp_educhain_server.py
Sample Commands for Claude Desktop
-
Generate MCQs: "Generate 5 multiple-choice questions on Python loops."
-
Create Lesson Plan: "Provide a lesson plan for teaching algebra."
-
Generate Flashcards: "Create flashcards for Python data types."
Testing Results
The MCP server has been thoroughly tested and demonstrates:
- ✅ Successful MCP protocol compliance
- ✅ Proper tool registration and execution
- ✅ Resource availability and access
- ✅ EduChain integration functionality
- ✅ Error handling and recovery
- ✅ JSON response formatting
Configuration Files
Claude Desktop Configuration
The claude_desktop_config.json file configures Claude Desktop to connect to the EduChain MCP server:
{
"mcpServers": {
"educhain": {
"command": "python3.11",
"args": ["/home/ubuntu/mcp_educhain_server.py"],
"env": {
"OPENAI_API_KEY": "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"
}
}
}
}
Dependencies
- mcp: Model Context Protocol Python SDK
- educhain: Educational content generation library
- langchain-openai: OpenAI integration for LangChain
- python-dotenv: Environment variable management
Bonus Features Implemented
- Third Tool: Added flashcards generator as requested in bonus points
- Comprehensive Documentation: Detailed README and code comments
- Sample Responses: Documented test commands and their outputs
- Error Handling: Robust error management throughout the codebase
Development Notes
API Integration
The server uses OpenRouter as a proxy to access the DeepSeek model, providing cost-effective AI generation while maintaining compatibility with the OpenAI API format used by EduChain.
MCP Compliance
The implementation follows MCP specification standards:
- Proper tool and resource registration
- Standardized request/response formats
- Error handling and status reporting
- Protocol version compatibility
Code Quality
- Comprehensive docstrings for all functions
- Type hints for better code maintainability
- Modular design for easy extension
- Proper error handling and logging
Future Enhancements
Potential improvements for the MCP server:
- Additional Question Types: Support for True/False and Fill-in-the-Blank questions
- Content Persistence: Save generated content to files or databases
- User Preferences: Customizable default settings for question generation
- Batch Processing: Generate multiple content types in a single request
- Content Validation: Quality checks for generated educational content
Troubleshooting
Common Issues
- API Key Errors: Ensure the OpenRouter API key is valid and has sufficient credits
- Import Errors: Verify all dependencies are installed correctly
- Connection Issues: Check network connectivity for API requests
- Claude Desktop Integration: Ensure the configuration file path is correct
Debug Mode
To enable debug logging, modify the server startup to include verbose logging:
import logging
logging.basicConfig(level=logging.DEBUG)
Conclusion
This MCP server successfully demonstrates the integration of EduChain with the Model Context Protocol, providing a standardized interface for educational content generation. The implementation meets all assignment requirements and includes bonus features, comprehensive documentation, and thorough testing.
The server is ready for production use and can be easily extended with additional educational content generation capabilities as needed.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.