Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ folders; in `design/`, `src/…` and `scripts/…` mean the player's unless a fi
| `packages/normalize/` | rewrites a package so it streams | [normalize](design/normalize.md) |
| `packages/verify/` | plays a package headless and reports | [verify](design/verify.md) |
| `packages/author/`, `skills/h5p-author/` | a playable package of any content type from a short source, and a package back to one | [author](design/author.md) |
| `packages/mcp/` | the local MCP server: builds, reads, checks and previews in an app with no shell | [mcp](design/mcp.md) |
| `packages/mcp/` | the local MCP server: builds, reads, checks and previews in an app with no shell; and the app server, which plays an activity in a chat app's reply | [mcp](design/mcp.md) |
| `packages/cmi5/` | the element as a cmi5 assignable unit | [cmi5](design/cmi5.md) |
| `packages/embed/`, `skills/h5p-to-scorm/` | the embed site for a player domain, and a package as a SCORM zip | [embed](design/embed.md), [scorm](design/scorm.md) |
| `packages/vscode/` | H5P Preview, the VS Code extension | [vscode](design/vscode.md) |
Expand Down
6 changes: 6 additions & 0 deletions design/author.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ text to the content check's rules, and `apps/skills` plays every example untrust
- `check` (`build --check`) runs a build's checks, `checkContent` being `composePackage`'s, and
writes no package; a media file named by web address is still downloaded, to a temporary
folder removed after, and a video on the four hosts stays an address.
- `unread`, with `check`, checks a source whose files are elsewhere (#270): the app server's
`h5p_play` gets a source and never the file a person attached in the chat, which only their
browser reads. No file is looked for, none downloaded and no site asked; a file named by a
path is judged by its name, which must be of a type its field takes, and listed in the
result's `unread`; one named by a web address is left as written. A picture then has no size
and a video no length, so what a build says of those is not said.
- `publicFetch`, passed as `fetch`, refuses every network that is not the public internet on
every hop, through `net.BlockList`, which matches an IPv4 address however IPv6 writes it
(`[::ffff:7f00:1]` is loopback). The local IPv4 ranges are refused behind NAT64 and 6to4 too,
Expand Down
68 changes: 65 additions & 3 deletions design/mcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
`packages/mcp` is `@missing-elements/h5p-mcp`, shown as **H5P Author MCP by Missing Elements**: a
local MCP server over standard input and output that builds a package onto the person's disk,
checks it, and opens it in their browser, or reads one back to change it. It is for apps with no
shell, Claude Desktop first; in an app with a shell, the skill and `npx` build already. A remote
server, for ChatGPT or Claude on the web, is #210 and not this.
shell, Claude Desktop first; in an app with a shell, the skill and `npx` build already. The
package's second command, `h5p-mcp-app`, is the server for a chat app on the web: *The app server*,
below.

- **It holds no rules of its own.** The build, the read, their checks, the outline and the
- **It holds no rules of its own.** What both servers say alike, the content types, a source's
fields, a build's notes and outline, is `lib/answers.mjs`. The build, the read, their checks, the outline and the
confinement to folders (`buildPackage`, `readPackage`, `within`, `publicFetch`, `inside`) are
h5p-author's; the check, the preview and opening the browser (`verifyPackage`, `summarize`,
`previewPackage`, `openBrowser`) are h5p-verify's. A rule a tool needs goes into those packages
Expand Down Expand Up @@ -75,3 +77,63 @@ server, for ChatGPT or Claude on the web, is #210 and not this.
the skill's type files into the author package, as the author's `prepack` does.

Not built yet: the MCP registry's `server.json` and Claude Desktop's one-click bundle.

## The app server

`h5p-mcp-app` (`lib/app.mjs`, #210, #270) is an MCP server over HTTP for a chat app that shows a
card in its reply, ChatGPT first: the person asks for an activity, the reply plays it, and its
`.h5p` is saved from there. `createApp()` is a web-standard handler, `fetch(request)`, so a host
that runs Node, or one that takes such a handler, serves it; the command is that handler on a
port. Its endpoint is `/mcp`.

- **No server of ours processes a person's file** (the owner's rule, 2026-11-24, and a goal of the
whole toolkit). The chat sends the tool a reference to an attached file, an address and an id,
never its bytes. The server never asks that address and never passes it on: it hands the id to
the card, which asks the chat for the file's address (`getFileDownloadUrl`), and only the
person's browser fetches from it. So an address that came in a call, which a model can be made
to write, is one nobody fetches: the card fetches what the chat itself gives for a file of the
person's. What
the server cannot avoid is receiving the call, with the activity's source in it; it checks the
source and keeps nothing. Each request gets a fresh server and no session; nothing of a request
is stored and nothing is logged, not its body, not its address, not how it was answered, and no
error of the protocol's, which may quote what was sent. `app.test.ts` holds it to this: a file
store that counts every connection gets none, an answer carries the address nowhere, and all
the command ever writes is where it listens.
- **Two tools, in the local server's words.** `h5p_types` answers from `answers.mjs` as the local
one does, without the lines on folders, which it has none of. `h5p_play` takes a source and
checks it with the author package's check that reads no file (`check` with `unread`), since a
source's files are in the chat's store: it answers with the problems by their paths, or with
the type, the files not checked, the notes and the outline, as `h5p_build` does, so a chat that
changed an activity reads back what it holds (#268). The instructions say to pass an attachment
as it is and not to open it: a reply that began with the chat's own analysis of the file drew
no card, twice, and without it the card came (ChatGPT, 2026-11-23 and 11-24; one cause is not
proven).
- **The file input is ChatGPT's, to the letter, and not held to.** `file` is named in
`openai/fileParams` and its schema is the reference's: `download_url` and `file_id` required,
`mime_type` and `file_name`, nothing else. It is shown and not enforced, as `source` is: a
model that writes the file's name there is answered that no attachment came, where a schema
would refuse the call unread. One file is taken: a source that names several gets the
attachment under its own name, and the page asks the person for the rest.
- **The card is the play page's way to the chat, and holds nothing of the activity.**
`lib/card.html` frames `/h5p/play/` of the org site with the source in its fragment; the page
builds and plays in the person's browser, and its rules are that site's. The card gives it
what only the chat has, by the page's messages: the attached file's address, asked of the chat
by the file's id, and what it weighs, its bytes where the page needs them or that they did not
come, the chat's theme, a save (`ui/download-file`), and an open tab for a link of the site's
and no other (`openExternal`). It sends nothing to the server it came from and calls no tool. Its policy
names the one site it frames and the chat's file store. A chat keeps a card by its address, so
the address carries the card's hash.
- **What ChatGPT's frame was found to do is written in the card, with its date.** A card's frame
saves no file and opens no tab on a press; the chat saves a file handed to it of 8 MB and
refuses one of 16 MB, downloads from no address, and takes no package into its own files; its
file store answers any site (all 2026-11-24). So the card says it saves up to 8 MB, and a
bigger package is saved by a tab of the play page, which the page asks the card to open. The
card's script is one function: a chat puts names of its own on the card's window.
- **Tested as a host runs it.** `tests/app.test.ts` starts the command on a free port and asks it
over HTTP with the SDK's own client: the two tools and their words, the file input's schema,
the card and its policy, a source checked, one refused, an attachment handed to the card alone,
a call whose file is no reference, a body over 1 MB, and that nothing was written. The card is
checked by hand in a page that stands in for a chat, its frame sandboxed as ChatGPT's was found
to be; in ChatGPT itself ran the probe's card, which this one is without its test parts.

Not built yet: where the server is hosted, the app's privacy policy and its listing (#210).
9 changes: 6 additions & 3 deletions packages/author/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,19 @@ Set's 2.6 MB, a container's up to 8.4 MB. `--all <folder>` writes one per conten
```js
import { buildPackage, schemaOf, SourceError } from '@missing-elements/h5p-author'

const { output, source: built, builtWith, manifest, content, libraries, install, coreApi, translations, notes, media, outline } =
const { output, source: built, builtWith, manifest, content, libraries, install, coreApi, translations, notes, media, unread, outline } =
await buildPackage(source, 'rivers.h5p', { base: process.cwd() })
```

`buildPackage(source, output, { libraries, base, fetch, within, check })` refuses an existing output,
`buildPackage(source, output, { libraries, base, fetch, within, check, unread })` refuses an existing output,
and throws a `SourceError` whose `problems` are `{ path, message }`; with `check` it builds and
writes no package and takes no output (`buildPackage(source, undefined, { check: true })`), though a
media file named by web address is still downloaded, to a temporary folder removed after; a video on
YouTube, Vimeo, Panopto or Echo360 stays an address, as in a build, a YouTube or Vimeo one asked
of the site with the same `fetch`. For a build run
of the site with the same `fetch`. With `unread` beside `check`, for a source whose files are
elsewhere, as an attachment in a chat is, no file is looked for, none downloaded and no site asked:
a file named by a path is judged by its name alone, and the result's `unread` lists those names.
For a build run
on what a model wrote: `within` is a list of the folders the output and every local file the source
names must be inside, on their real paths, and its problems then name no path but the one the
source wrote. It does not cover a file named by web address, which is downloaded with the `fetch`
Expand Down
38 changes: 35 additions & 3 deletions packages/author/lib/media.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,17 @@ const IDLE_MS = 60_000
* local(source: string): Promise<{ file: F } | { missing: string }>,
* keep(body: ReadableStream<Uint8Array>, extension: string): Promise<F>,
* open(file: F): Promise<{ size: number, read(offset: number, length: number): Promise<Uint8Array>, close(): Promise<void> }>,
* linked?(source: string): string | undefined
* linked?(source: string): string | undefined,
* unread?: boolean
* }} MediaAccess
* `what`, what a source's path names, for problems; `name`, the file's own name it names;
* `local`, that file, or why there is none; `keep`, a download's bytes kept; `open`, a kept
* file's length, and its bytes read from an offset, fewer at its end; `linked`, the web address
* a file the source names stays at and is played from, where it has one (#263)
* a file the source names stays at and is played from, where it has one (#263); `unread`, for
* a check of a source whose files are elsewhere (#270): none is looked for, none downloaded and
* no host asked; one named by a path is judged by its name alone, a problem where its field
* takes no such type and listed where it does, and one named by a web address is left as
* written
*/

/**
Expand Down Expand Up @@ -319,6 +324,8 @@ export class MediaStore {
this.unanswered = new Set()
/** @type {string[]} the files left at an address and played from there, as the source names them (#263) */
this.linked = []
/** @type {string[]} the files not looked at, as the source names them, where none is read (#270) */
this.unread = []
}

/**
Expand Down Expand Up @@ -350,7 +357,7 @@ export class MediaStore {
const address = short ? `https://www.youtube.com/watch?v=${short[1]}` : source
const hosted = HOSTED.find(({ plays }) => plays.test(address))
if (hosted) {
await this.#there(hosted, address, source, `${at}.path`, report, note)
if (!this.access.unread) await this.#there(hosted, address, source, `${at}.path`, report, note)
return { path: address, mime: hosted.mime, copyright }
}
const url = URL.canParse(address) ? new URL(address) : null
Expand All @@ -365,6 +372,7 @@ export class MediaStore {
return { path: source, copyright }
}
const types = /** @type {Record<string, string>} */ (TYPES[kind])
if (this.access.unread) return { ...this.#unread(source, web, types, at, report), copyright }
const address = web ? undefined : this.access.linked?.(source)
if (address !== undefined) return { ...this.#linked(kind, source, address, types, at, report), copyright }
const key = `${kind} ${source}`
Expand Down Expand Up @@ -493,6 +501,30 @@ export class MediaStore {
return { from: found.file, extension, stem: name.slice(0, name.length - extension.length - 1) }
}

/**
* A file that is not looked at (#270): a check of a source whose files are elsewhere, as an
* attachment in a chat is, which only the person's browser reads. One named by a path is judged
* by its name, which must be of a type the field takes, and listed in `unread`; one named by a
* web address is left as written, since its type is what its host says it is. Nothing of
* either is read, so a picture has no size and a video no length.
* @param {string} source
* @param {boolean} web
* @param {Record<string, string>} types
* @param {string} at
* @param {(path: string, message: string) => void} report
* @returns {{ path: string, mime?: string }}
*/
#unread(source, web, types, at, report) {
if (web) return { path: source }
const extension = extensionOf(this.access.name(source))
if (!Object.hasOwn(types, extension)) {
report(`${at}.path`, `${source}: this field takes ${Object.keys(types).map((each) => `.${each}`).join(', ')}`)
return { path: source }
}
if (!this.unread.includes(source)) this.unread.push(source)
return { path: source, mime: types[extension] }
}

/**
* A file left at a web address of its own and played from there (#263), as a video on YouTube
* is: a video or a recording only, since a picture's size is read from its bytes, its type taken
Expand Down
20 changes: 14 additions & 6 deletions packages/author/lib/node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@ import { SourceError } from './source-error.mjs'
* @typedef {import('./translate.mjs').TranslationReport} TranslationReport
* @typedef {{
* output: string, source: import('./build.mjs').Source, builtWith: string, manifest: Record<string, unknown>, content: Record<string, unknown>,
* libraries: string[], install: string[], coreApi: import('./install.mjs').CoreApi, translations: TranslationReport[], notes: Problem[], media: string[], outline: string
* libraries: string[], install: string[], coreApi: import('./install.mjs').CoreApi, translations: TranslationReport[], notes: Problem[], media: string[], unread: string[], outline: string
* }} BuildResult what was written, and what is worth telling about it: `libraries`, the folders the
* package plays with; `install`, those carried for an H5P site's upload check; `coreApi`, the
* newest H5P core they ask for, which a site needs to take the package (`coreApiLine` says it);
* `outline`, the content as text for a review (`outlineOf`); `builtWith`, the content type and
* the pack's version of it, "H5P.Blanks 1.14", and `source`, the source as built, naming it: what
* to keep with the package, so that a build with a later pack can say the type has moved
* @typedef {{ libraries?: string, base?: string, fetch?: typeof fetch, within?: string[], check?: boolean }} BuildOptions
* to keep with the package, so that a build with a later pack can say the type has moved;
* `unread`, the files a check with `unread` did not look at, as the source names them
* @typedef {{ libraries?: string, base?: string, fetch?: typeof fetch, within?: string[], check?: boolean, unread?: boolean }} BuildOptions
* `libraries`, a library pack's parts folder in place of the pinned pack; `base`, the folder a
* source's file paths are read from; `fetch`, for media named by web address; `within`, the
* folders the output and every local file a source names must be inside, on their real paths, a
* list even of one; `check`, to build and write no package: no output is needed or looked at, and
* the result's `output` is empty, but a media file named by web address is still downloaded, to a
* temporary folder removed after, as the build checks it; a video on YouTube, Vimeo, Panopto or
* Echo360 stays an address, as in a build, a YouTube or Vimeo one asked of the site's oEmbed with
* `fetch` as a build asks it
* `fetch` as a build asks it; `unread`, with `check`, for a source whose files are elsewhere, as
* an attachment in a chat is (#270): no file is looked for, none downloaded and no site asked,
* one named by a path is judged by its name alone and listed in the result's `unread`, and
* `base`, `within` and `fetch` are not used
* @typedef {{ output: string, source: import('./build.mjs').Source, files: string[], notes: Problem[] }} ReadResult
* `output`, the source's path; `files`, the media written beside it, by the paths the source
* names them by, from its folder; `notes`, what was left out or could not be read back as it is
Expand Down Expand Up @@ -369,8 +373,9 @@ function foldersOf(within) {
* @returns {Promise<BuildResult>}
*/
export async function buildPackage(input, output, options = {}) {
const { check = false } = options
const { check = false, unread = false } = options
const within = foldersOf(options.within)
if (unread && !check) throw new TypeError('unread goes with a check (check: true): a package needs its files')
if (!check && (typeof output !== 'string' || !output.trim())) throw new TypeError('a build takes the path to write its package to, and a check (check: true) none')
// A check writes nothing, so where a package would go is not looked at.
const target = check ? '' : resolve(/** @type {string} */ (output))
Expand All @@ -388,7 +393,8 @@ export async function buildPackage(input, output, options = {}) {
const read = sourceOf(input, typeNames(pack))
if (!read.typed) throw new SourceError(read.problems)
temporary = await mkdtemp(join(check ? tmpdir() : dirname(target), '.h5p-author-'))
const media = new MediaStore(nodeMedia({ base: options.base ?? process.cwd(), temporary, within }), { fetch: options.fetch })
const access = nodeMedia({ base: options.base ?? process.cwd(), temporary, within })
const media = new MediaStore(unread ? { ...access, unread } : access, { fetch: options.fetch })
const built = await composePackage(read.source, pack, media, read.problems)
if (check) {
return {
Expand All @@ -403,6 +409,7 @@ export async function buildPackage(input, output, options = {}) {
translations: built.translations,
notes: built.notes,
media: media.files.map((item) => item.name),
unread: [...media.unread],
get outline() { return built.outline }
}
}
Expand Down Expand Up @@ -443,6 +450,7 @@ export async function buildPackage(input, output, options = {}) {
translations: built.translations,
notes: built.notes,
media: media.files.map((item) => item.name),
unread: [],
get outline() { return built.outline }
}
} finally {
Expand Down
Loading