Google Classroom MCP服务器

一个通过MCP协议提供Google Classroom数据访问的服务器,支持Claude等AI助手。

  • by faizan45640
  • JavaScript
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 faizan45640/google-classroom-mcp-server

使用说明

谷歌课堂MCP服务器

一个MCP(模型上下文协议)服务器,通过克劳德和其他支持MCP协议的人工智能助手提供对谷歌课堂数据的访问。

设置

先决条件

  • Node.js(v16或更高版本)
  • 启用了Google Classroom API的Google云平台项目
  • 用于Google Classroom API的OAuth 2.0客户端凭据

安装

通过Smithery安装

通过以下方式自动安装适用于Claude Desktop的Google课堂MCP服务器 史密瑟里:

npx -y @smithery/cli install @faizan45640/google-classroom-mcp-server --client claude

手动安装

  1. 克隆此存储库
  2. 安装依赖项:
npm install
  1. 将您的Google OAuth客户端凭据放入名为的文件中 credentials.json 在项目根目录中:
{
  "web": {
    "client_id": "YOUR_CLIENT_ID",
    "project_id": "YOUR_PROJECT_ID",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "YOUR_CLIENT_SECRET",
    "redirect_uris": ["http://localhost:3000/auth/google/callback"]
  }
}
  1. 使用Google进行身份验证:
node index.js auth

这将启动一个浏览器窗口以完成OAuth流程,并将您的凭据保存到 tokens.json.

  1. 通过更新配置Claude以使用此服务器 claude_desktop_config.json (通常在 %APPDATA%\Claude\):
{
  "mcpServers": {
    "class": {
      "command": "node",
      "args": [
        "PATH_TO_YOUR_DIRECTORY\\index.js"
      ]
    }
  }
}

用法

可用工具

服务器提供了几个与Google Classroom交互的工具:

1. courses -列出您的所有Google课堂课程

Use the 'courses' tool to get a list of all your Google Classroom courses

2. course-details -获取特定课程的详细信息

Use the 'course-details' tool with the courseId parameter to get details and announcements for a specific course

参数:

  • courseId:课程ID(可从 courses 工具)

3. assignments -获取特定课程的作业

Use the 'assignments' tool with the courseId parameter to get assignments and your submissions for a specific course

参数:

  • courseId:课程ID(可从 courses 工具)

克劳德提示示例

  1. 显示我的所有Google课堂课程
  2. 获取ID为123456789的数学课程的详细信息
  3. 显示ID为987654321的历史课程的所有作业

权限

服务器请求以下Google Classroom API权限:

  • classroom.courses.readonly -访问课程信息
  • classroom.announcements.readonly -访问课程公告
  • classroom.coursework.me.readonly -访问您的课程作业和作业
  • classroom.rosters.readonly -访问班级名册

故障排除

如果遇到权限错误,请尝试:

  1. 再次运行auth命令以刷新权限:

    node index.js auth
    
  2. 如果您的应用程序处于测试模式,请确保您的Google帐户在Google Cloud Console中添加为测试用户

  3. 检查OAuth作用域 authenticateAndSaveCredentials 确保它们符合您的需求

备注

  • 此服务器旨在与Claude AI或其他MCP兼容助手一起使用
  • 所有API请求都是使用您经过身份验证的Google帐户进行的
  • 令牌刷新由服务器自动处理
  • 敏感凭据存储在本地 tokens.json 文件