EduChain MCP Server

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.

Category
访问服务器

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

  1. 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
  2. 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
  3. generate_flashcards: Generate flashcards for study purposes

    • Parameters: topic, num_cards (default: 10)
    • Returns: JSON formatted flashcards with questions and answers

Resources Implemented

  1. educhain://status: Server status information
  2. 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

  1. Install Dependencies:

    pip install -r requirements.txt
    
  2. 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.

  3. Test the Server:

    python3.11 test_mcp_server.py
    
  4. Configure Claude Desktop: Copy the claude_desktop_config.json to your Claude Desktop configuration directory.

Usage Examples

Starting the Server

python3.11 mcp_educhain_server.py

Sample Commands for Claude Desktop

  1. Generate MCQs: "Generate 5 multiple-choice questions on Python loops."

  2. Create Lesson Plan: "Provide a lesson plan for teaching algebra."

  3. 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

  1. Third Tool: Added flashcards generator as requested in bonus points
  2. Comprehensive Documentation: Detailed README and code comments
  3. Sample Responses: Documented test commands and their outputs
  4. 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:

  1. Additional Question Types: Support for True/False and Fill-in-the-Blank questions
  2. Content Persistence: Save generated content to files or databases
  3. User Preferences: Customizable default settings for question generation
  4. Batch Processing: Generate multiple content types in a single request
  5. Content Validation: Quality checks for generated educational content

Troubleshooting

Common Issues

  1. API Key Errors: Ensure the OpenRouter API key is valid and has sufficient credits
  2. Import Errors: Verify all dependencies are installed correctly
  3. Connection Issues: Check network connectivity for API requests
  4. 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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选