Back to MCP directory
publicPublicdnsLocal runtime

mcp-canvas-lms

一个基于Node.js的Canvas API交互服务器,提供课程、作业、成绩等管理功能,支持与Claude桌面端集成。

article

README

🚀 Canvas MCP 服务器

Canvas MCP 服务器是一个用于与 Canvas API 交互的模型上下文协议 (MCP) 服务器。借助该服务器,您能够轻松管理课程、作业、选课和成绩等操作。

🚀 快速开始

先决条件

  • Node.js:版本 18 或更高
  • Canvas API 令牌:需从您的 Canvas 账户获取
  • Canvas 域名:通常为 canvas.instructure.com

设置

  1. 克隆仓库
git clone https://github.com/yourusername/canvas-mcp-server.git
cd canvas-mcp-server
  1. 安装依赖项
npm install
  1. 配置环境变量 复制示例环境文件:
cp .env.example .env

编辑 .env 文件,并用您的实际 Canvas API 令牌和域名替换占位符。 构建项目:

npm run build
  1. 运行服务器
npm start

服务器将启动并通过标准输入输出监听 MCP 请求。

连接到 Claude Desktop

  1. 更新 Claude 配置 在您的 claude_desktop_config.json 中添加 MCP 服务器配置:
  "canvas-mcp-server": {
      "command": "npx",
      "args": ["-y", "canvas-mcp-server"]
    },
  1. 重启 Claude Desktop
    • 完全退出 Claude Desktop。
    • 再次启动 Claude Desktop。
    • 在 🔌 菜单中找到并连接您的 Canvas MCP 服务器。

✨ 主要特性

可用工具(更多针对学生的功能即将推出)

  • canvas_create_course:创建 Canvas 中的新课程。
  • canvas_update_course:更新现有课程。
  • canvas_create_assignment:在 Canvas 课程中创建新作业。
  • canvas_update_assignment:更新现有作业。
  • canvas_submit_grade:提交学生作业的成绩。
  • canvas_enroll_user:将用户加入课程。

错误处理

工具通过返回包含 isError: true 的错误消息来指示问题。请确保所有必需的环境变量都已设置,以避免运行时错误。

故障排除

  • 构建错误
    • 检查 TypeScript 版本:npx tsc --version
    • 清理并重新构建:rm -rf build/ && npm run build
  • 运行时错误
    • 检查日志以获取详细错误消息。
    • 确保环境变量正确设置。
  • 类型错误
    • 使用 TypeScript 的类型检查验证类型:npx tsc --noEmit

🔧 技术细节

  • 类型安全types.ts 文件确保 Canvas API 的所有交互都是类型安全的,从而减少运行时错误并提高代码维护性。
  • 错误处理:服务器通过返回有意义的消息并设置 isError 标志来优雅地处理错误,允许客户端(例如 Claude Desktop)理解和响应。
  • 环境变量:使用环境变量管理敏感信息(如 API 令牌),以增强安全性和不同环境之间的灵活性。
  • 模块化:将关注点分开到不同的文件(如 types.tsclient.tsindex.ts)使代码库更易于导航和维护。

🤝 贡献

欢迎贡献!请打开问题或提交拉取请求以报告任何改进或错误修复。

📄 许可证

本项目根据 MIT 许可证发布。

额外说明

根据项目的具体需求,您可以随意调整文件路径和配置。如果您有任何其他问题,请随时告知!

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client