Skolemelding MCP
<div align="center">
<img src="docs/assets/logo.png" alt="Skolemelding MCP logo: a clay envelope sealed with a school backpack" width="160" height="160">
<h1>Skolemelding MCP</h1>
<p>
<strong>Read-only access to Oslo's Skolemelding parent app from your own AI assistant.</strong>
<br />
Ask "what did the school send this week for Ola?" instead of scrolling through the app.
<br />
<br />
<a href="#-getting-started">Getting started</a>
·
<a href="#-privacy-and-security">Privacy and security</a>
·
<a href="#-usage">Usage</a>
·
<a href="#-troubleshooting">Troubleshooting</a>
</p>
<sub>Unofficial; not affiliated with Oslo kommune, Utdanningsetaten or CGI; may break at any time; you are responsible for your own account.</sub>
</div>
## 👋 About the project
I'm a parent in Oslo, and most of what the school tells us arrives through Skolemelding. That's a lot of messages to keep up with, and the app is built for reading them one by one. I wanted to ask "is there anything I need to answer this week?" and get an answer.
Skolemelding MCP is an [MCP](https://modelcontextprotocol.io) server and CLI that gives an MCP client (Claude Desktop, Claude Code and others) read access to **Skolemelding foresatte**, the parent app, using your own ID-porten sign-in. It runs on your machine, under your account, with nothing in between.
What it does:
- Reads messages, threads and attachments for each of your children, including text from PDFs.
- Lists the children and teachers linked to your account.
- Keeps children apart. With several children you pick one, and results are never mixed.
- Signs in the normal way: BankID or MinID in your usual browser, no tokens to copy into config files.
It doesn't send anything: no replies, absence reports, confirmations or settings changes. It's read-only on purpose, and I intend to keep it that way.
The privacy parts I cared about most:
- Recipient lists don't name other families. A message to the whole class shows your child's family and counts the rest ("+ 16 other families"), so browsing your inbox doesn't send the class list to your AI provider. Names inside message text and attachments still go through, see [Where your data goes](#where-your-data-goes).
- Your national identity number stays in the credential store and goes only to the portal, when the session is refreshed. It's not shown, logged or passed to the model.
- No server of mine, no telemetry. It talks to the Skolemelding portal, ID-porten and the app's Google Play page, nothing else.
- Credentials live in your OS keychain, and the session token is only ever sent to the portal.
More in [Privacy and security](#-privacy-and-security).
### Built with
- [Python 3.14](https://www.python.org/) and [uv](https://docs.astral.sh/uv/)
- [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
- [httpx](https://www.python-httpx.org/), [pydantic](https://docs.pydantic.dev/), [keyring](https://github.com/jaraco/keyring), [filelock](https://github.com/tox-dev/filelock), [pypdf](https://github.com/py-pdf/pypdf)
## 🔒 Privacy and security
These messages are about our kids: absence, other families. Below is where the data goes and what can go wrong.
### Where your data goes
```mermaid
flowchart LR
A[Skolemelding portal] --> B[Skolemelding MCP on your machine]
C[ID-porten sign-in] --> B
D[Google Play, app version only] -.-> B
B --> E[Your MCP client]
E --> F[Your LLM provider]
```
- **There's no server of mine in between, and no telemetry or analytics.** The program talks to three places only:
1. the Skolemelding portal
2. ID-porten, to sign you in
3. the public Google Play page of the app, only to look up the current app version (see [App version](#app-version)).
- Other families' names are left out of recipient lists, with limits. The portal lists every participant of a message, so a class-wide message carries each child in the class with their guardians. In the sender, `From:` line and reply headings, Skolemelding MCP:
- names your own family: you and all your children, matched by full name as whole words
- names class groups, like a whole class's guardians
- names one other family when it's the only one, since that's a conversation, not a mailing list
- names up to three people listed without a family (usually staff), so a list of pupils alone can still show three names
- replaces the rest with a count ("+ 16 other families")
- hides the whole list if it's malformed and can't be split safely.
"Confirmed by" names only your own family and counts everyone else ("2 others").
- Message text and attachments are passed on as they are, since that's what you asked to read. If a teacher writes names in a message or attaches a schedule for the whole class, those names reach your LLM provider when you open it.
- Your LLM provider sees what you open. A message you ask about is sent to the model your MCP client uses, under that provider's terms, so pick your client and provider with that in mind.
- The portal uses your national identity number (fødselsnummer) as your user name. Skolemelding MCP keeps it in the credential store, because refreshing the session needs it, and never displays it, logs it or returns it to the model.
- Very little is kept, and only on your machine. The access token lives in memory only, results are cached in memory for 60 seconds, and nothing from your messages is written to disk unless you ask for an attachment too large to return inline.
- Logs go to stderr and never contain tokens, codes or message bodies.
### Security model
- **Read-only by construction.**
- Every request goes through one allowlist of permitted endpoints, checked on the requested path and again on the final URL.
- Write endpoints aren't on the list and can't be called. That covers replies, absence reports, marking as read and the internet controls for children.
- The session token is only ever sent to the Skolemelding portal origin.
- **One side effect.** Opening a message (`get_message` or `get_attachment`) marks it as read in the Skolemelding app, the same as opening it in the app.
- **Credentials stay in your OS keychain.**
- That's the macOS Keychain, Windows Credential Manager, or Secret Service on Linux.
- The optional file store (`credentials.json`) is only read if it's a 0600 regular file owned by you, in a directory only you can write to.
- Signing out in one process (`skolemelding-mcp logout`, for example) signs out every other running process on its next data call.
- **Sign-in uses PKCE.**
- If you finish a sign-in by hand, the `com.cgi.oslomelding.foresatte://oauth?code=...` link can pass through the link handler's command line, or through your MCP client's transcript.
- I think that's acceptable. The code is single-use, expires within minutes and is useless without the PKCE verifier, which never leaves the waiting Skolemelding MCP process.
- A forged link from a web page is ignored, because its `state` won't match.
- **Treat messages as untrusted.**
- Message bodies, subjects, attachments and PDF text come from teachers and other guardians.
- Skolemelding MCP tells the model to treat them as data and renders them inert: no Markdown images, no raw HTML, links only as plain text, and only PNG, JPEG, GIF and WebP shown as images.
- It can't fully prevent prompt injection. If your MCP client also has tools that send, post or change things (email, chat, files), keep it asking for your confirmation before it uses them, especially right after it has read school messages.
- **Proxies.** The standard `HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY` and `SSL_CERT_FILE` variables are honoured. A proxy you configure can see your traffic, tokens included.
### Files written to disk
| What | Where |
| --- | --- |
| Credentials | OS keychain, or `credentials.json` (0600) in the config directory if you opt in |
| Coordination files | `auth.lock`, `relay.json`, `relay.json.lock` in the config directory |
| App version state | `app_version.json` in the config directory (the last version the portal accepted) |
| Large attachments | `~/Downloads/skolemelding/<child>/`, only when you ask for one (directories 0700, files 0600, symlinked directories refused, existing files never overwritten) |
| Sign-in link handler | Linux: `~/.local/share/applications/skolemelding-mcp-handler.desktop` (set with `xdg-mime`) and the launcher it runs, `~/.local/share/skolemelding-mcp/login-handler` (under `$XDG_DATA_HOME` instead of `~/.local/share` when that's set) · macOS: `~/Library/Application Support/skolemelding-mcp/SkolemeldingLogin.app` · Windows: `HKCU\Software\Classes\com.cgi.oslomelding.foresatte` |
The config directory is `~/.config/skolemelding-mcp` on macOS and Linux, and `%APPDATA%\skolemelding-mcp` on Windows.
## 🚀 Getting started
### Prerequisites
- A parent account in Skolemelding (Oslo), with BankID or MinID.
- [uv](https://docs.astral.sh/uv/getting-started/installation/). It installs Python 3.14 for you if needed.
- An MCP client, for example [Claude Code](https://docs.claude.com/en/docs/claude-code/overview) or Claude Desktop.
### Installation
It's not on PyPI yet, so the commands below install the `v1.0.2` release straight from GitHub.
1. Sign in once from a terminal:
```sh
uvx --from git+https://github.com/thedotedge/skolemelding-mcp@v1.0.2 skolemelding-mcp login
```
Your browser opens ID-porten. After BankID or MinID, let the browser open "Skolemelding MCP login" and the terminal confirms you're signed in.
2. Add the server to your MCP client.
**Claude Code:**
```sh
claude mcp add skolemelding -- uvx --from git+https://github.com/thedotedge/skolemelding-mcp@v1.0.2 skolemelding-mcp
```
**Claude Desktop** (`claude_desktop_config.json`):
```json
{
"mcpServers": {
"skolemelding": {
"command": "uvx",
"args": ["--from", "git+https://github.com/thedotedge/skolemelding-mcp@v1.0.2", "skolemelding-mcp"]
}
}
}
```
3. Check that it works:
```sh
uvx --from git+https://github.com/thedotedge/skolemelding-mcp@v1.0.2 skolemelding-mcp doctor
```
## 💬 Usage
The things I actually ask:
- "What did the school send this week for Ola?"
- "Is there anything I need to answer?"
- "Summarise the PDF the teacher sent about the trip."
- "Who are Kari's teachers?"
### Tools
All tools are read-only.
| Tool | What it does |
| --- | --- |
| `login` | Starts signing in (opens the browser). Optionally finishes with a pasted redirect URL. |
| `auth_status` | Reports whether you're signed in and what to do next. |
| `list_children` | Lists the linked children with their ids. |
| `list_messages` | Lists one child's messages, newest first (`since`, `query`, `unread_only`, `limit`, paging `cursor`). |
| `get_message` | Reads one message thread in full. **Marks it as read in the app.** |
| `get_attachment` | Fetches one attachment: an image, a PDF with extracted text, or a saved file path when it's large. **Marks the message as read.** |
| `list_teachers` | Lists the teachers and contacts for one child. |
With more than one child linked, the `child` argument (first name or id) is required on the child-scoped tools.
### CLI
| Command | What it does |
| --- | --- |
| *(none)* | Serves MCP over stdio. This is what your MCP client runs. |
| `login` | Signs in with ID-porten in your browser. |
| `logout` | Signs out and removes the stored credentials. |
| `status` | Shows whether you're signed in, your children and the app version in use. |
| `doctor` | Checks token refresh, reading data and the app version against the live portal. |
### How sign-in works
1. `login` opens ID-porten in your default browser, and you sign in with BankID or MinID.
2. ID-porten redirects to the app's address (`com.cgi.oslomelding.foresatte://oauth?...`). Skolemelding MCP registers itself as the handler for that address, so the browser hands the result straight back.
3. The tool exchanges it for a Skolemelding session and keeps the refresh token in your keychain.
If the handoff doesn't happen (the browser doesn't offer to open the link, or the official app grabs it), paste the link instead:
1. Open the browser's developer tools before signing in (Network tab, and in Chrome tick "Preserve log").
2. Sign in.
3. Find the failed request or blocked navigation to `com.cgi.oslomelding.foresatte://oauth?code=...` and copy its full URL.
4. Paste it when the terminal asks (the input is hidden).
The `login` tool's `redirect_url` argument works the same way. Only a URL that starts with exactly `com.cgi.oslomelding.foresatte://oauth?` and carries one `state` and one `code` (or `error`) is accepted.
Your assistant can also start a sign-in itself with the `login` tool and follow it with `auth_status`.
## 🔧 Configuration
| Variable | Required | Meaning |
| --- | --- | --- |
| `SKOLEMELDING_APP_VERSION` | Optional | App version to present to the portal, e.g. `6.0.7`. Overrides the default and any discovered version, and turns discovery off. |
| `SKOLEMELDING_AUTO_VERSION` | Optional | Set to `0` to turn off app-version discovery and ignore a previously discovered version. |
| `SKOLEMELDING_BASE_URL` | Optional | Portal origin (default `https://portal.skoleplattform.no`). Only `https://portal.skoleplattform.no`, `https://skoleplattform2025.no` or an `https://….skoleplattform2025.no` origin is accepted, with no path, port or query. |
| `SKOLEMELDING_TOKEN_STORE` | Optional | Set to `file` to keep credentials in `credentials.json` (0600) in the config directory instead of the OS keychain. Useful on headless Linux. |
| `SKOLEMELDING_LOG_LEVEL` | Optional | Log level on stderr (default `WARNING`). |
### App version
The portal checks which version of the Skolemelding app you're on. Skolemelding MCP presents itself as `6.0.7` by default, and `status` and `doctor` show the version in use and where it came from (`env`, `discovered` or `default`).
When the portal says a newer app exists, Skolemelding MCP looks up the current version on the app's public Google Play page. It's a plain page view with no token, cookie or personal data. It runs:
1. at most once a day, or an hour after a failed lookup
2. in the background when the server starts, after `login`, and in `doctor`
3. right away (at most once an hour) if the portal refuses the version at sign-in or refresh, and then the step is retried.
A newer version, at most one major version up, is tried at once. It's saved to `app_version.json` only after the portal accepts it, and if the portal rejects it Skolemelding MCP goes back to the last version that worked. It never moves to an older version on its own.
Precedence: `SKOLEMELDING_APP_VERSION`, then the discovered version, then the built-in default.
## 🩺 Troubleshooting
- **Something's off:** run `skolemelding-mcp doctor` (the command from step 3 of Installation). If the portal says a newer app exists, you get a ⚠ warning rather than a failure, and it tries discovery and checks again.
- **App version rejected:** let discovery update it, or set `SKOLEMELDING_APP_VERSION` to the version shown on Google Play and restart.
- **Session expired:** run the `login` command from Installation again.
- **macOS, the browser doesn't hand the sign-in back:** the official Skolemelding app may have claimed the link. Use the paste fallback from [How sign-in works](#how-sign-in-works).
- **Linux without a keychain** (headless, WSL, containers): set `SKOLEMELDING_TOKEN_STORE=file`.
## 📍 Roadmap
- [x] Read-only messages, threads, attachments, children and teachers
- [x] Browser sign-in with link handler and paste fallback (macOS, Linux, Windows)
- [x] Automatic app-version discovery
- [ ] Publish to PyPI
- [ ] Show inline images posted in messages
Writing to Skolemelding (replies, absence reports, confirmations) isn't on the roadmap. This stays read-only.
## 🤝 Contributing
Contributions are welcome, especially fixes for when the portal changes under us.
1. Fork the repo and create a branch (`git checkout -b fix/something`).
2. Set up and run all checks (lint, strict type check, tests, the same as CI):
```sh
make install
make check
```
`make help` lists the other targets (`test`, `typecheck`, `lint`, `format`).
3. Commit with a [Conventional Commits](https://www.conventionalcommits.org/) subject, e.g. `fix: handle missing thread id`.
4. Open a pull request.
Three rules I'd ask you to keep:
1. No write endpoints in the allowlist.
2. No real responses in fixtures. Sanitise names, ids and message text.
3. Never print the portal user name (it's a national identity number).
## 📄 License
MIT. See [`LICENSE`](LICENSE).
TDQS
Scored across 7 tools
Each tool has a distinct target: signing in (login/auth_status), enumerating children, listing teachers, listing messages, reading a thread, and downloading an attachment. The login/auth_status split is clearly delineated by the descriptions (start flow vs. report state), and get_message vs. get_attachment cannot be confused. No two tools plausibly compete for the same call.
Five tools follow a clean verb_noun pattern (list_children, list_messages, get_message, get_attachment, list_teachers) and are consistently snake_case. The auth pair (login, auth_status) deviates from the verb_noun convention, though it is idiomatic and readable.
Seven tools is well-scoped for a read-oriented school messaging client: auth (2), navigation (2 list tools), and content retrieval (2). Nothing feels padded or missing at the structural level.
Coverage of the read path is solid and the workflow is connected (list_children -> list_messages -> get_message/get_attachment), but the surface is read-only: there is no send/reply to a message, no marking read/unread, and no search or filtering by teacher/class beyond the per-child listing.