Skip to main content
Glama
README.md
# google-classroom-mcp

An MCP server that gives an AI assistant a **student's** view of Google Classroom: classes, the stream, classwork, your to-do list, due dates, attachments (download and read), comments, and your own submissions. It can also act for you: comment, attach work, turn in, unsubmit, answer questions, join and leave classes.

It needs no OAuth app and no admin consent. It signs in with **your own Google browser session cookies** and calls the same internal endpoints the Classroom web app uses.

> ⚠️ This uses undocumented internal Google endpoints. They can change without notice, and using them may go against Google's terms. Your session cookies give **full access to your Google account**: keep them private, and don't commit them (`cookies.txt` and `cookies.json` are git-ignored).

## Install

```bash
git clone <this repo> && cd google-classroom-mcp
npm install
npm run build
```

## Give it your session

Choose **one** of these:

| Variable | What to put in it |
|---|---|
| `GCLASSROOM_BROWSER` | `chrome`, `brave`, `edge`, `arc`, `chromium` or `vivaldi`. The server reads and decrypts the cookies straight from that browser's profile (macOS and Linux; on macOS it asks for Keychain access once). Choose another profile with `GCLASSROOM_BROWSER_PROFILE` (for example `Profile 1`). |
| `GCLASSROOM_COOKIES_FILE` | Path to a cookies export: Netscape `cookies.txt`, a JSON array from a cookie-export extension, or a plain `Cookie:` header. |
| `GCLASSROOM_COOKIES` | A raw `Cookie` header value copied from DevTools (Network tab → any `classroom.google.com` request → Request Headers → `cookie`). |

Optional settings:

- `GCLASSROOM_AUTHUSER`: the account index if you're signed in to several Google accounts (the `N` in `/u/N/`). Default `0`.
- `GCLASSROOM_DOWNLOAD_DIR`: where `download_file` saves files. Default `~/Downloads/classroom-mcp`.
- `GCLASSROOM_USER_ID`: override your Classroom user id. It's normally detected from the page.

The cookies must include `SID`, `HSID`, `SSID`, `APISID`, `SAPISID` and the `__Secure-*` cookies for `.google.com`. Exporting every cookie for `google.com` covers them.

## Use it with Claude

Claude Code:

```bash
claude mcp add google-classroom -e GCLASSROOM_BROWSER=chrome -- node /absolute/path/to/google-classroom-mcp/dist/index.js
```

Claude Desktop (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "google-classroom": {
      "command": "node",
      "args": ["/absolute/path/to/google-classroom-mcp/dist/index.js"],
      "env": { "GCLASSROOM_COOKIES_FILE": "/absolute/path/to/cookies.txt" }
    }
  }
}
```

Course arguments accept a numeric id, a `classroom.google.com/c/...` link, or part of the class name. Item arguments accept an id or a link to the post; a full link also supplies the course.

## Tools

### Reading (verified against a live student account)

| Tool | What it does |
|---|---|
| `whoami` | Shows your Classroom user id, name and email |
| `list_courses` | Lists your classes (archived ones are optional) |
| `get_course` | Shows class details, teachers, your role and your class Drive folder |
| `list_course_people` | Lists teachers and classmates |
| `list_topics` | Lists classwork topics |
| `get_stream` | Shows stream posts and announcements with full text (paged) |
| `list_classwork` | Shows the Classwork page grouped by topic, with optional topic and kind filters (paged) |
| `list_todo` | Shows assigned, missing or done work across classes |
| `list_due_work` | Lists work due between two dates (calendar view) |
| `search_classwork` | Searches post titles and text across classes |
| `get_item` | Shows everything about one post: text, due date, points, attachments, your submission, class comments and private comments |
| `get_my_submission` | Shows your submission state, status, attachments and answer |
| `get_my_work_in_course` | Lists your assigned work in a class with the status of each |
| `list_class_comments` / `list_private_comments` | Read comment threads |
| `get_file_info` | Shows Drive metadata for an attachment |
| `download_file` | Saves an attachment to disk; Docs, Sheets and Slides are exported to PDF, DOCX, CSV and other formats |
| `read_file_content` | Returns an attachment's content: Docs and Slides as text, Sheets as CSV, `.docx`/`.pptx`/`.xlsx` as extracted text, images inline, PDFs embedded |
| `list_class_drive_folder` | Lists your Drive folder for a class |

### Writing (acts on your real account)

| Tool | What it does |
|---|---|
| `post_class_comment` | Posts a public class comment |
| `post_private_comment` | Sends a private comment to your teacher |
| `edit_comment` / `delete_comment` | Edits or deletes one of your comments |
| `turn_in` | Turns in an assignment or marks it as done |
| `unsubmit` | Takes back work you turned in |
| `answer_question` | Answers a short-answer or multiple-choice question (this also turns it in) |
| `add_link_attachment` | Attaches a URL to your work |
| `add_drive_file_attachment` | Attaches an existing Drive file to your work |
| `upload_to_drive` | Uploads a local file to Drive (optionally into your class folder) |
| `upload_and_attach_file` | Uploads a local file and attaches it to your work |
| `remove_attachment` | Removes one of your attachments |
| `join_class` | Joins a class with a class code |
| `accept_invitation` | Accepts a class invitation |
| `leave_class` | Unenrolls you from a class |
| `raw_rpc` | Escape hatch: calls any Classroom RPC by id |

**Verification status of the write tools:** their request formats were taken from the Classroom web client's JavaScript and checked offline, but **none has been run against a live account yet**. Each tool's description says so. Try them on something low-stakes first, and check the result with `get_item` / `get_my_submission`. Known gaps:

- **Grades** aren't decoded yet. Use `raw: true` on `get_item` / `get_my_submission` to see the raw submission.
- **Multiple-choice options** may not appear in `get_item`. The `answer_question` answer format is a best guess.
- The `delete_comment` request shape is inferred.
- `upload_to_drive` uses Drive's multipart upload through `clients6.google.com`. Reading through that host is verified; uploading isn't.

## How it works

- **Classroom data:** `POST https://classroom.google.com/u/N/_/ClassroomUi/data/batchexecute`. These are Google's internal "batchexecute" RPCs with array-encoded protobuf payloads and field masks captured from the web client (`src/masks.ts`). The XSRF token (`SNlM0e`), session id (`FdrFJe`), build label (`cfb2h`) and your user id are read from the `/u/N/h` page.
- **Drive files:** `https://clients6.google.com/drive/v3/...`, authenticated with `SAPISIDHASH` and cookies (the same way the web app does it). `www.googleapis.com` rejects cookie auth from another origin.
- Cookies that Google rotates through `Set-Cookie` are updated in memory, so a long-running server keeps working until your session ends. When that happens, export fresh cookies.

## Development

```bash
npm run dev        # tsc --watch
npm run typecheck
```

Source layout: `cookies.ts` (cookie sources and Chromium decryption), `http.ts` (transport and SAPISIDHASH), `client.ts` (session and batchexecute), `classroom.ts` (Classroom operations), `parse.ts` (JSPB → JSON), `drive.ts`, `office.ts` (docx/pptx/xlsx text), `tools.ts` (MCP tools), `index.ts` (stdio entry point).

TDQS

A3.7/5.0

Scored across 35 tools

Disambiguation4/5

Most tools carve out distinct resource+action pairs (course, stream, classwork, comments, submissions, attachments, Drive). A few pairs blur: get_item vs get_my_submission (item details already include your submission), and upload_to_drive vs upload_and_attach_file, which differ only by whether an attachment is added. These overlaps are resolvable from descriptions but could cause occasional misselection.

Naming Consistency4/5

Overwhelmingly consistent snake_case verb_noun (list_courses, get_course, turn_in, add_link_attachment, post_private_comment). Minor deviations are the standalone commands whoami and raw_rpc, plus upload_and_attach_file using 'and' for a compound action. The pattern remains highly predictable overall.

Tool Count4/5

35 tools is heavy, but the surface genuinely spans courses, people, stream, topics, classwork, comments, submissions, attachments, and Drive, so most tools earn their place. A few could be consolidated (e.g. upload_to_drive plus upload_and_attach_file, get_my_submission folded into get_item).

Completeness5/5

Excellent student-lifecycle coverage: discover/join/leave classes, browse stream and classwork, attach and upload work, answer questions, turn in/unsubmit, and manage comments. Drive read/download/upload and a raw_rpc escape hatch close remaining gaps; no obvious dead ends for a student-facing client.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues