Open eClass集成
STDIOAI代理与eClass平台交互的MCP服务器
AI代理与eClass平台交互的MCP服务器
An MCP server for interacting with Open eClass platform instances, with specific support for UoA's SSO authentication system.
This server enables AI agents to authenticate with eClass, retrieve course information, and perform basic operations on the platform.
This project follows a modular architecture for better maintainability:
eclass-mcp-server/
├── run_server.py # Entry point script for running the server
├── eclass_client.py # Standalone client for eClass (non-MCP)
├── pyproject.toml # Project configuration and dependencies
├── .env # Environment variables (create from example.env)
├── docs/ # Documentation
│ ├── README.md # Documentation overview
│ ├── how-it-works.md # Core implementation explanation
│ ├── mcp-sdk-integration.md # Details on MCP SDK usage
│ └── tools-reference.md # Reference for available tools
├── src/
└── eclass_mcp_server/ # Main package
├── __init__.py # Package initialization
├── server.py # Core server implementation and tool handlers
├── authentication.py # Authentication functionality
├── course_management.py # Course-related functionality
├── html_parsing.py # HTML parsing utilities
└── test/ # Test scripts for functionality verification
├── __init__.py
├── test_login.py
├── test_courses.py
└── run_all_tests.py
Install the server using UV (recommended):
# Clone the repository git clone https://github.com/yourusername/eClass-MCP-server.git cd eClass-MCP-server # Install dependencies uv sync --dev --all-extras
Alternatively, install with pip:
pip install -e .
Create a .env
file in the root directory with the following configuration (or copy and rename the provided example.env
file):
ECLASS_URL=https://eclass.uoa.gr
ECLASS_USERNAME=your_username
ECLASS_PASSWORD=your_password
All credentials must be provided in the .env file. The server does not accept credentials as parameters.
Run the server using the entry point script:
python run_server.py
Or as a module:
python -m src.eclass_mcp_server.server
( as of version 0.48 )
Go to Settings -> MCP. Click on Add new global MCP server
:
This will open the global mcp.json
file:
{
"mcpServers": {
"server-name": {
"command": "python",
"args": ["absolute\\path\\to\\eclass-mcp-server\\run_server.py"]
}
}
}
Or try this path format on the args
field:
absolute/path/to/eclass-mcp-server/run_server.py
This command runs the run_server.py
script that connects the MCP Client with the main server entry point in server.py
.
To use with Claude Desktop:
The server provides the following tools for use with MCP clients:
Log in to eClass using SSO authentication.
{ "random_string": "any_value" }
Retrieve a list of enrolled courses (requires login first).
{ "random_string": "any_value" }
Log out from eClass.
{ "random_string": "any_value" }
Check the current authentication status.
{ "random_string": "any_value" }
The repository includes eclass_client.py
, a standalone client for interacting with the eClass platform. This was the initial implementation that inspired the creation of the MCP server.
This client serves as both:
You can run the client directly:
python eclass_client.py
The project includes test scripts to verify functionality:
# Run all tests python -m src.eclass_mcp_server.test.run_all_tests # Run specific tests python -m src.eclass_mcp_server.test.test_login python -m src.eclass_mcp_server.test.test_courses
Comprehensive documentation is available in the docs/
directory:
from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client import asyncio async def run_agent(): server_params = StdioServerParameters( command="python /path/to/eclass-mcp-server/run_server.py", ) async with stdio_client(server_params) as (read, write): async with ClientSession(read, write) as session: # Initialize the session await session.initialize() # Login to eClass login_result = await session.call_tool("login", { "random_string": "dummy" }) print(login_result) # Get courses courses_result = await session.call_tool("get_courses", { "random_string": "dummy" }) print(courses_result) # Logout logout_result = await session.call_tool("logout", { "random_string": "dummy" }) print(logout_result) if __name__ == "__main__": asyncio.run(run_agent())
This MCP server is designed to be used with AI agents that support the Model Context Protocol. This enables AI systems to interact with eClass directly, allowing for capabilities like:
The eClass MCP Server is designed with security as a top priority, particularly regarding credential handling:
.env
filerandom_string
).env
file securely and never commit it to version controlThis project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
The GPL-3.0 license is a strong copyleft license that requires anyone who distributes this code or derivative works to make the source code available under the same terms. Key points:
We chose the GPL-3.0 license to:
This license is particularly important for this software since it handles authentication and sensitive credentials. The GPL-3.0 ensures that any modifications to this code remain transparent, allowing users to verify how their credentials are being handled.
Contributions are welcome! Please feel free to submit a Pull Request.