MCP 教室
Aula平台的模型上下文协议(MCP)实现,提供对来自Aula的学校时间表、消息和其他信息的程序化访问。
特性
- 认证:使用UniLogin凭据安全登录到Aula
- 日历:检索和解析日历/学校日程事件
- 消息:检查未读邮件
- 存在数据:获取儿童在场信息
- MCP服务器:FastMCP服务器实现,易于集成
- Pydantic模型:对所有数据结构进行强大的键入和验证
安装
# Clone the repository
git clone https://github.com/yourusername/aula-mcp.git
cd aula-mcp
# Install dependencies
pip install -r requirements.txt配置
使用您的Aula凭据创建配置文件:
{
"username": "your_unilogin_username",
"password": "your_unilogin_password",
"schoolschedule": true,
"ugeplan": true,
"mu_opgaver": true
}用法
运行MCP服务器
python -m aula_mcp.scripts.run_server --config /path/to/config.json可选参数:
--host/-H:要监听的主机(默认值:0.0.0.0)--port/-p:要侦听的端口(默认值:8000)--debug/-d:启用调试日志记录
使用MCP客户端
import asyncio
from fastmcp import Client
async def main():
# Connect to the MCP server
client = Client("http://localhost:8000/sse")
async with client:
# Login
await client.call_tool("login")
# Get children
children = await client.call_tool("get_children")
# Get calendar events for the first child
child_id = children[0]["id"]
events = await client.call_tool("get_calendar_events", {
"child_id": child_id,
"days": 7
})
# Display events
for event in events:
print(f"{event['start']}: {event['summary']}")
if __name__ == "__main__":
asyncio.run(main())请参阅 examples 目录以获取更详细的示例。
可用工具
MCP服务器提供以下工具:
| 工具名称 | 描述 | 参数 |
|---|---|---|
login | 登录到Aula | 无 |
get_children | 获取儿童列表 | 无 |
get_child_by_id | 按ID获取子数据 | child_id |
get_calendar_events | 获取日历事件 | child_id, days (可选) |
get_events_for_date_range | 获取日期范围内的事件 | child_id, start_date, end_date, days (可选) |
get_unread_messages | 获取未读邮件 | 无 |
get_presence_data | 获取状态数据 | child_id |
refresh_data | 刷新所有数据 | 无 |
图书馆使用情况
您也可以在没有MCP服务器的情况下直接使用该库:
from aula_mcp import AulaClient, AulaCalendar, AulaConfig
# Create config
config = AulaConfig(
username="your_username",
password="your_password",
schoolschedule=True
)
# Initialize client
client = AulaClient(config)
client.login()
# Use calendar functionality
calendar = AulaCalendar(client)
events = calendar.get_calendar_events("child_id")
# Format events
formatted_events = calendar.format_calendar_events(events)依赖项
fastmcp:用于MCP服务器实施pydantic:用于数据验证requests:用于HTTP通信beautifulsoup4:用于HTML解析pytz:用于时区处理
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
致谢
基于Aula Home Assistant集成(https://github.com/scaarup/aula).
