diff --git a/.claude/skills/local-dev/SKILL.md b/.claude/skills/local-dev/SKILL.md index 9935de473c..3872ca1446 100644 --- a/.claude/skills/local-dev/SKILL.md +++ b/.claude/skills/local-dev/SKILL.md @@ -79,6 +79,19 @@ streams: HTTP+SSE writes everything to stderr, while Streamable HTTP writes its request and session messages to stdout and its listening line (which names the bound `host:port`) and errors to stderr. +The other six servers serve Streamable HTTP too (#576), selected with a flag +rather than an argument, on the same `PORT`, `HOST` and `/mcp` path: + +```sh +node src/memory/dist/index.js --transport streamable-http +node src/filesystem/dist/index.js --transport streamable-http /tmp/scratch # directories required over HTTP +(cd src/time && uv run mcp-server-time --transport streamable-http) +``` + +Each one's endpoint is stateless for 2025-era clients (a fresh server per +request; GET and DELETE answer 405), so nothing the server asks of the client +mid-session (filesystem's Roots) reaches it over HTTP. + ## Run the local package the way a user would A user starts these servers with `npx` or `uvx`. Both accept a path in place of diff --git a/.claude/skills/project-structure/SKILL.md b/.claude/skills/project-structure/SKILL.md index c67e4e127f..78e9bf9a3a 100644 --- a/.claude/skills/project-structure/SKILL.md +++ b/.claude/skills/project-structure/SKILL.md @@ -29,9 +29,9 @@ includes the tests) and `vitest.config.ts`. | Server | Layout | Where its features are registered | | --- | --- | --- | | `everything` | `index.ts` picks a transport from `argv`; `server/` holds the factory; `tools/`, `resources/`, `prompts/` hold one file per feature plus an `index.ts`; `transports/` holds one file per transport; `version.ts` reads the package version; `docs/` is shipped | Each feature file exports a `register…` function, wired into its area's `index.ts` (`registerTools`, `registerResources`, `registerPrompts`), which `server/index.ts` calls from `createServer()` | -| `filesystem` | `index.ts` is the stdio entry point (argv → allowed directories, `main()`); `server.ts` exports `createServer(allowedDirectories)`; `lib.ts` holds the file operations and path validation, with the allow-list passed in rather than held globally; `path-utils.ts`, `path-validation.ts` and `roots-utils.ts` are focused helpers, and `pinned-directory.ts` runs the write operations inside their verified directory; `version.ts` reads the package version | Inline in `createServer()` in `server.ts`, with `server.registerTool(...)` | -| `memory` | `index.ts` holds the `KnowledgeGraphManager`, `createServer(memoryFilePath)` and the stdio `main()`; `version.ts` reads the package version | Inline in `createServer()`; the resource and its subscription handlers are exported `register…` functions in the same file | -| `sequentialthinking` | `index.ts` holds `createServer()` and the stdio `main()`; `lib.ts` holds `SequentialThinkingServer`, the logic; `version.ts` reads the package version | Inline in `createServer()` | +| `filesystem` | `index.ts` is the entry point (argv → transport and allowed directories, `main()`); `http.ts` serves the factory over Streamable HTTP; `server.ts` exports `createServer(allowedDirectories)`; `lib.ts` holds the file operations and path validation, with the allow-list passed in rather than held globally; `path-utils.ts`, `path-validation.ts` and `roots-utils.ts` are focused helpers, and `pinned-directory.ts` runs the write operations inside their verified directory; `version.ts` reads the package version | Inline in `createServer()` in `server.ts`, with `server.registerTool(...)` | +| `memory` | `index.ts` holds the `KnowledgeGraphManager`, `createServer(memoryFilePath)`, the stdio `main()` and `run()`, which picks the transport; `http.ts` serves the factory over Streamable HTTP; `version.ts` reads the package version | Inline in `createServer()`; the resource and its subscription handlers are exported `register…` functions in the same file | +| `sequentialthinking` | `index.ts` holds `createServer()`, the stdio `main()` and `run()`, which picks the transport; `http.ts` serves the factory over Streamable HTTP; `lib.ts` holds `SequentialThinkingServer`, the logic; `version.ts` reads the package version | Inline in `createServer()` | Three things about `everything` that the table cannot hold: @@ -69,6 +69,7 @@ src// ├── src/mcp_server_/ │ ├── __init__.py main(): the command-line flags, then asyncio.run(serve(...)) │ ├── __main__.py python -m mcp_server_ +│ ├── transport.py --transport: stdio, or Streamable HTTP on $HOST:$PORT │ └── server.py everything else └── tests/ pytest suite, driving serve() in-process ``` diff --git a/.claude/skills/testing/SKILL.md b/.claude/skills/testing/SKILL.md index 1527dbce82..0cf090d7fe 100644 --- a/.claude/skills/testing/SKILL.md +++ b/.claude/skills/testing/SKILL.md @@ -40,7 +40,7 @@ connection harness does (`__tests__/harness.ts` in `everything`, | Server | How its tests reach the code | | --- | --- | -| `everything`, `filesystem`, `memory`, `sequentialthinking` | An SDK `Client` connected to the server's `createServer()` over `InMemoryTransport`, in the vitest process, through the server's own harness, plus unit tests of helper modules such as `lib.ts`. `everything` drives its stdio, SSE and Streamable HTTP transports in-process too; the other three have one thin spawn smoke of the built `dist/index.js` | +| `everything`, `filesystem`, `memory`, `sequentialthinking` | An SDK `Client` connected to the server's `createServer()` over `InMemoryTransport`, in the vitest process, through the server's own harness, plus unit tests of helper modules such as `lib.ts`. `everything` drives its stdio, SSE and Streamable HTTP transports in-process too; the other three drive their `http.ts` in-process over a free loopback port, and have one thin spawn smoke of the built `dist/index.js` | | `fetch`, `git`, `time` | A `ClientSession` linked in-process to the real `serve()` over in-memory streams (below), plus direct calls on the pure functions in `server.py` | No TypeScript test uses an in-memory transport yet. diff --git a/.github/workflows/everything-mcp-diff.yml b/.github/workflows/everything-mcp-diff.yml index ca94985acc..3de61944a4 100644 --- a/.github/workflows/everything-mcp-diff.yml +++ b/.github/workflows/everything-mcp-diff.yml @@ -52,6 +52,9 @@ # dispatches only a workflow whose file exists on the default branch (`main`), # and both version workflows dispatch this one by file name from `v2/main`, so # renaming it here would break their dispatch until the next milestone merge. +# The rename is staged instead: `mcp-interface-diff.yml` lands on `main` first +# as a dispatch-only placeholder (#5463), then #5527 moves this file's contents +# there, switches the callers and deletes this file. # # See: https://github.com/modelcontextprotocol/inspector/issues/1034 name: MCP Interface Diff diff --git a/.github/workflows/mcp-interface-diff.yml b/.github/workflows/mcp-interface-diff.yml new file mode 100644 index 0000000000..4bda642ed5 --- /dev/null +++ b/.github/workflows/mcp-interface-diff.yml @@ -0,0 +1,42 @@ +# Placeholder for the MCP interface diff's future file name (#5463, Step 1 of +# a rename staged across a milestone merge). +# +# The interface diff lives in `everything-mcp-diff.yml`, a name left over from +# when it diffed only the Everything server. GitHub dispatches a workflow only +# when its file exists on the default branch (`main`), and both version +# workflows (`version-packages.yml`, `prepare-python-release.yml`) dispatch +# the diff by file name from `v2/main`. Renaming it in one step on `v2/main` +# would break their dispatch until the next milestone merge. So the rename is +# staged: +# +# 1. This file ships to `main` in a milestone merge. It is a placeholder, not +# a copy of the diff: a dispatch resolves the file name on `main` but runs +# the file as it is on the dispatched ref, so a placeholder makes the name +# dispatchable as well as a copy would, without a second copy to keep in +# step meanwhile. It has only a `workflow_dispatch` trigger, so it never +# runs beside the real diff on a push or a pull request. +# 2. After that merge, #5527 (Step 2) moves `everything-mcp-diff.yml`'s +# contents here, switches the callers to this name, and deletes the old +# file. +# +# Until then, nothing dispatches this file, and a manual dispatch only says +# where the diff is. +name: MCP Interface Diff (rename placeholder) + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + placeholder: + name: Point to the interface diff + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - name: Say where the interface diff runs + run: | + echo "This file is a placeholder for a staged rename (#5463, #5527)." + echo "The MCP interface diff runs from .github/workflows/everything-mcp-diff.yml:" + echo " gh workflow run everything-mcp-diff.yml --ref " diff --git a/AGENTS.md b/AGENTS.md index bad74767a6..c090e1a5d0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -64,6 +64,7 @@ servers/ ├── .github/workflows/ typescript.yml, python.yml (per-package CI), release.yml (publishes on a GitHub Release), │ version-packages.yml (the changesets PR), prepare-python-release.yml (the CalVer PR), │ everything-mcp-diff.yml (each changed server's interface diff on PRs), +│ mcp-interface-diff.yml (a dispatch-only placeholder for that file's new name, #5463), │ main-source.yml (a PR into main must bring nothing that is not on v2/main), │ and the scheduled sweeps that file issues: dependency-refresh.yml, dependabot-alerts.yml, sdk-watch.yml ├── .github/ISSUE_TEMPLATE/ Bug and feature issue forms; config.yml routes security and new servers away @@ -100,7 +101,11 @@ opening paragraph instead, as this one does. A format with no comment syntax Node **24** for the TypeScript servers: the development version and the oldest supported (`engines` is `>=24`), and CI validates each TypeScript server on 24 -and 26 in parallel legs. Python **>= 3.10** for the Python servers, at the version each server's `.python-version` pins. Python +and 26 in parallel legs. Python **>= 3.10** for the Python servers, at the version each server's `.python-version` pins, +except `fetch`, whose floor is **>= 3.11.5**: no `soupsieve` release patched +against its open advisories supports an older Python (#5546). A server's +floor is the `requires-python` in its `pyproject.toml`; raise one only when a +dependency forces it, and record the exception here. Python dependencies are managed with **`uv`, never `pip`**. ```sh @@ -688,8 +693,11 @@ look before retrying. 2026-07-28 request lives under a handle the server mints. Ask a client for input (elicitation, sampling, roots) by returning `inputRequired(...)`, which the SDK's legacy shim also serves to 2025-era clients. -- **Transports**: stdio is the default and every server supports it. - `everything` also serves Streamable HTTP and HTTP+SSE. **HTTP+SSE is +- **Transports**: stdio is the default and every server supports it. Every + server also serves Streamable HTTP on `/mcp` at `HOST`:`PORT` + (loopback:3001 by default), which `everything` selects with its + `streamableHttp` argument and the others with `--transport + streamable-http`; `everything` alone also serves HTTP+SSE. **HTTP+SSE is deprecated**: keep what exists working, and never make it the default or the recommended option in new code or docs. - **Tool annotations**: every tool you add or change sets `readOnlyHint`, diff --git a/README.md b/README.md index 9e612a110b..93219eea1b 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ An MCP server talks to its client over a **transport**. The protocol defines two | **stdio** | The client launches the server as a subprocess and talks to it over the process's stdin and stdout. The server opens no port. | A `command` and `args` in the client's configuration, as in the examples above | | **Streamable HTTP** | The server runs on its own as an HTTP service, and can serve many clients | A URL, such as `http://localhost:3001/mcp` | -**Every server in this repository serves stdio, and only [Everything](src/everything) also serves Streamable HTTP** (its README shows how to start it that way, and covers its deprecated HTTP+SSE transport too). So when you run `uvx mcp-server-git` or `npx -y @modelcontextprotocol/server-memory` in a terminal, it opens no port, prints at most a one-line startup notice, and then appears to hang. That is expected: it is waiting for a client to send it messages on stdin. You do not normally start a stdio server yourself; your MCP client starts it from its configuration and stops it when it is done. +**Every server in this repository serves stdio by default, and every one can also serve Streamable HTTP** on `http://127.0.0.1:3001/mcp` (set `PORT` and `HOST` to move it): [Everything](src/everything) with its `streamableHttp` argument (its README also covers its deprecated HTTP+SSE transport), and the others with `--transport streamable-http`, as each server's README shows. Started without one, a server uses stdio, so when you run `uvx mcp-server-git` or `npx -y @modelcontextprotocol/server-memory` in a terminal, it opens no port, prints at most a one-line startup notice, and then appears to hang. That is expected: it is waiting for a client to send it messages on stdin. You do not normally start a stdio server yourself; your MCP client starts it from its configuration and stops it when it is done. To try a server without setting up a client, use the [MCP Inspector](https://github.com/modelcontextprotocol/inspector). Given a stdio server's command, it launches the server for you and lets you browse and call its tools; given a URL, it connects to a running Streamable HTTP server: @@ -144,7 +144,7 @@ To try a server without setting up a client, use the [MCP Inspector](https://git npx @modelcontextprotocol/inspector uvx mcp-server-git # A Streamable HTTP server: start it first, then connect to its URL -npx @modelcontextprotocol/server-everything streamableHttp +npx @modelcontextprotocol/server-everything streamableHttp # or: uvx mcp-server-time --transport streamable-http npx @modelcontextprotocol/inspector --transport http --server-url http://localhost:3001/mcp ``` diff --git a/docs/quality-gate.md b/docs/quality-gate.md index eaa51a1ff9..9dcee6551c 100644 --- a/docs/quality-gate.md +++ b/docs/quality-gate.md @@ -105,7 +105,7 @@ Notes on the stages: offline. - **`smoke` launches what a user launches**: the built `dist/index.js` for a TypeScript server, the console script through `uv run --no-sync` for a Python - one. stdio for all seven; HTTP+SSE and Streamable HTTP as well for + one. stdio and Streamable HTTP for all seven; HTTP+SSE as well for `everything`. The servers are given nothing outside the machine to talk to and none of your files: `fetch` is pointed at a page the smoke serves on the loopback interface, and the HTTP transports listen on a free port rather diff --git a/package-lock.json b/package-lock.json index 9d5a1db14b..01186d0bdf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -590,9 +590,9 @@ } }, "node_modules/@hono/node-server": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.4.tgz", - "integrity": "sha512-2g1qeHl4BduwDn6L8nkAvDrPUWPMlkQ//a5NhP/zIyaXKMjZNRV+cG9Csu+BiJFf6+68pqzjf4Hi5sJGKHuS1g==", + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.9.tgz", + "integrity": "sha512-Sk4NQd3GFY0WZWCzndwFMPwJhtD0y9qjsQ+pjID0/03nK9pxyBCUoUHCho8QYBLBVhi0ssL8UkNPHqbgSOFPIQ==", "license": "MIT", "engines": { "node": ">=20" @@ -3060,9 +3060,9 @@ } }, "node_modules/hono": { - "version": "4.13.13", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.13.tgz", - "integrity": "sha512-CQ46U0ZkAGmbT/4UxdzzGJpacP2IeKgY4a5/tOI9AABbpOMfK739wfDXmv1usCk+3RkKj1hQy4/fjhiwa2xlrA==", + "version": "4.13.19", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.19.tgz", + "integrity": "sha512-KmXvQAXwcAHV+muzbIwoJ23niEB5nMoDVr9WcRkU8mvjUECm/1+7v4Jgp7P7a+H6MLFrh+vXrGonGrGS+RQfkA==", "license": "MIT", "engines": { "node": ">=16.9.0" @@ -5253,7 +5253,7 @@ }, "src/everything": { "name": "@modelcontextprotocol/server-everything", - "version": "2.3.0", + "version": "2.3.1", "license": "SEE LICENSE IN LICENSE", "dependencies": { "@modelcontextprotocol/node": "^2.1.1", @@ -5282,9 +5282,10 @@ }, "src/filesystem": { "name": "@modelcontextprotocol/server-filesystem", - "version": "2.3.0", + "version": "2.4.0", "license": "SEE LICENSE IN LICENSE", "dependencies": { + "@modelcontextprotocol/node": "^2.1.1", "@modelcontextprotocol/server": "^2.3.1", "diff": "^8.0.3", "minimatch": "^11.0.4", @@ -5309,9 +5310,10 @@ }, "src/memory": { "name": "@modelcontextprotocol/server-memory", - "version": "2.1.1", + "version": "2.2.1", "license": "SEE LICENSE IN LICENSE", "dependencies": { + "@modelcontextprotocol/node": "^2.1.1", "@modelcontextprotocol/server": "^2.3.1", "zod": "^4.2.0" }, @@ -5332,9 +5334,10 @@ }, "src/sequentialthinking": { "name": "@modelcontextprotocol/server-sequential-thinking", - "version": "2.1.1", + "version": "2.2.0", "license": "SEE LICENSE IN LICENSE", "dependencies": { + "@modelcontextprotocol/node": "^2.1.1", "@modelcontextprotocol/server": "^2.3.1", "chalk": "^5.3.0", "zod": "^4.2.0" diff --git a/package.json b/package.json index b155e84110..979811b59b 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,8 @@ }, "overrides": { "qs": ">=6.16.1", - "hono": ">=4.13.7", + "hono": ">=4.13.16", + "@hono/node-server": ">=2.1.6", "proxy-addr": "^2.0.8", "ip-address": "^10.7.4", "brace-expansion": "^5.0.12", diff --git a/scripts/dependabot-alerts.mjs b/scripts/dependabot-alerts.mjs index ce19de92b0..b8f0f1b682 100644 --- a/scripts/dependabot-alerts.mjs +++ b/scripts/dependabot-alerts.mjs @@ -271,11 +271,12 @@ export function npmLockEntries(lock, pkg) { /** * The manifests that declare `pkg` (any dependency section): the root, and - * each workspace, as the lockfile records them. + * each workspace, as the lockfile records them, with the range each declares. * * @param {object} lock parsed `package-lock.json` * @param {string} pkg - * @returns {string[]} manifest paths, e.g. `package.json`, `src/everything/package.json` + * @returns {Array<{manifest: string, range: string}>} sorted by manifest path, + * e.g. `package.json`, `src/everything/package.json` */ export function npmDeclarers(lock, pkg) { const declarers = []; @@ -287,12 +288,13 @@ export function npmDeclarers(lock, pkg) { entry?.optionalDependencies?.[pkg] ?? entry?.peerDependencies?.[pkg]; if (declared) { - declarers.push( - lockPath === "" ? "package.json" : `${lockPath}/package.json`, - ); + declarers.push({ + manifest: lockPath === "" ? "package.json" : `${lockPath}/package.json`, + range: declared, + }); } } - return declarers.sort(); + return declarers.sort((a, b) => a.manifest.localeCompare(b.manifest)); } /** @@ -310,8 +312,9 @@ export function overrideAncestors(lockPath) { /** * A parent-scoped `overrides` block for the nested vulnerable copies. npm - * rejects a package-wide override that contradicts a direct dependency of the - * same name (`EOVERRIDE`), so when a manifest declares the package the nested + * rejects a package-wide override that contradicts the ROOT package's own + * direct dependency of the same name (`EOVERRIDE`; a workspace's declaration + * does not trigger it), so when the root declares the package the nested * copies have to be reached through their parents. * * @param {Array<{path: string}>} affected @@ -651,7 +654,7 @@ export function buildIssueTitle(group) { * the root declares, or one no manifest declares, names no server. * * @param {{manifestPath: string, ecosystem?: string}} group - * @param {{affected?: Array<{path: string, topLevel: boolean}>, declarers?: string[]}} [probe] + * @param {{affected?: Array<{path: string, version?: string, topLevel: boolean}>, declarers?: Array<{manifest: string, range: string}>}} [probe] * @returns {string[]} */ export function issueLabels(group, { affected = [], declarers = [] } = {}) { @@ -670,41 +673,56 @@ export function issueLabels(group, { affected = [], declarers = [] } = {}) { return [...SWEEP_LABELS, ...labels]; } -/** - * What an npm fix edits, from WHICH copies are vulnerable: the declared copy - * needs its range raised, a nested or undeclared copy needs an `overrides` - * pin, and both at once need both. - */ /** * The manifests whose declared range resolves to this copy. A copy under * another package's `node_modules` is nobody's declaration. A copy at the top * of a workspace's own `node_modules` is that workspace's, and only if that * workspace declares the package: the root declaring it says nothing about a - * copy the workspace could not share. The hoisted root copy serves every - * manifest that declares the package. + * copy the workspace could not share. The hoisted root copy serves each + * manifest whose declared range its version satisfies; a manifest it does not + * satisfy gets a nested copy of its own, so for that manifest the root copy is + * only something other packages pulled in (#5506). A range semver cannot read + * (an alias, a URL) is assumed to resolve to the root copy, as before. * - * @param {{path: string, topLevel: boolean}} entry - * @param {string[]} declarers every manifest that declares the package - * @returns {string[]} + * @param {{path: string, version?: string, topLevel: boolean}} entry + * @param {Array<{manifest: string, range: string}>} declarers every manifest + * that declares the package, with its declared range + * @returns {string[]} manifest paths */ export function npmCopyDeclarers(entry, declarers) { if (!entry.topLevel) return []; const { owner } = splitOwner(entry.path); - return owner === "" - ? declarers - : declarers.filter((m) => m === `${owner}/package.json`); + if (owner !== "") { + return declarers + .filter((d) => d.manifest === `${owner}/package.json`) + .map((d) => d.manifest); + } + return declarers + .filter( + (d) => + semver.validRange(d.range) === null || + semver.valid(entry.version ?? "") === null || + semver.satisfies(entry.version, d.range), + ) + .map((d) => d.manifest); } +/** + * What an npm fix edits, from WHICH copies are vulnerable: the declared copy + * needs its range raised, a nested or undeclared copy needs an `overrides` + * pin, and both at once need both. + */ function npmFix(group, { affected, declarers }) { const copyDeclarers = (entry) => npmCopyDeclarers(entry, declarers); const raise = [...new Set(affected.flatMap(copyDeclarers))].sort(); const direct = raise.length > 0; const nested = affected.filter((entry) => copyDeclarers(entry).length === 0); const transitive = nested.length > 0; - // A package-wide override contradicting ANY declaration of the package is - // refused (`EOVERRIDE`), so the scoped form is needed whenever one exists, - // not only when the declared copy is itself vulnerable. - const scoped = declarers.length > 0; + // A package-wide override contradicting the ROOT package's own declaration + // is refused (`EOVERRIDE`), so the scoped form is needed whenever the root + // declares the package, not only when the root's copy is itself vulnerable. + // A workspace's declaration does not trigger it (verified against npm 11). + const scoped = declarers.some((d) => d.manifest === "package.json"); const unscopable = nested.some((e) => overrideAncestors(e.path).length === 0); const steps = []; if (direct) { @@ -715,7 +733,7 @@ function npmFix(group, { affected, declarers }) { if (transitive) { steps.push( scoped - ? `**Add a parent-scoped [\`overrides\`](${DEPENDENCIES_DOC}) entry** in the root \`package.json\` for the nested copies below:\n\n\`\`\`json\n${scopedOverrideExample(nested, group)}\n\`\`\`\n\n${unscopable ? ` A copy at the top of a workspace's own \`node_modules\` names no parent in its path; \`npm explain ${group.package}\` shows which dependency pulls it in, to scope the entry under.\n\n` : ""} A package-wide \`"${group.package}": "${group.fixedIn}"\` would fail with \`EOVERRIDE\`, because a manifest also declares \`${group.package}\` directly. **Not** \`npm audit fix\`, which can resolve an advisory by silently downgrading.` + ? `**Add a parent-scoped [\`overrides\`](${DEPENDENCIES_DOC}) entry** in the root \`package.json\` for the nested copies below:\n\n\`\`\`json\n${scopedOverrideExample(nested, group)}\n\`\`\`\n\n${unscopable ? ` A copy at the top of a workspace's own \`node_modules\` names no parent in its path; \`npm explain ${group.package}\` shows which dependency pulls it in, to scope the entry under.\n\n` : ""} A package-wide \`"${group.package}": "${group.fixedIn}"\` would fail with \`EOVERRIDE\`, because the root \`package.json\` also declares \`${group.package}\` directly. **Not** \`npm audit fix\`, which can resolve an advisory by silently downgrading.` : `**Add an [\`overrides\`](${DEPENDENCIES_DOC}) entry** in the root \`package.json\` pinning \`${group.package}\` to \`>=${group.fixedIn}\`, for the copies below, which no declared range reaches. **Not** \`npm audit fix\`, which can resolve an advisory by silently downgrading.`, ); } @@ -737,7 +755,7 @@ function pipFix(group, { declaredSpec }) { /** * @param {ReturnType[number]} group narrowed to what applies - * @param {{affected: Array<{path: string, version: string, topLevel: boolean}>, declarers?: string[], declaredSpec?: string, ghsas?: string[], securityPrsOff?: boolean}} probe + * @param {{affected: Array<{path: string, version: string, topLevel: boolean}>, declarers?: Array<{manifest: string, range: string}>, declaredSpec?: string, ghsas?: string[], securityPrsOff?: boolean}} probe * @returns {string} */ export function buildIssueBody( diff --git a/scripts/dependabot-alerts.test.mjs b/scripts/dependabot-alerts.test.mjs index b77e0ba9f1..e48cf457ee 100644 --- a/scripts/dependabot-alerts.test.mjs +++ b/scripts/dependabot-alerts.test.mjs @@ -282,9 +282,11 @@ test("npm lockfile reading is workspace-aware", () => { [], ); assert.deepEqual(npmDeclarers(NPM_LOCK, "hono"), [ - "src/everything/package.json", + { manifest: "src/everything/package.json", range: "^4.12.0" }, + ]); + assert.deepEqual(npmDeclarers(NPM_LOCK, "semver"), [ + { manifest: "package.json", range: "^7" }, ]); - assert.deepEqual(npmDeclarers(NPM_LOCK, "semver"), ["package.json"]); assert.deepEqual(npmDeclarers(NPM_LOCK, "fast-uri"), []); assert.deepEqual( overrideAncestors("node_modules/@scope/a/node_modules/b/node_modules/c"), @@ -480,7 +482,7 @@ test("a vulnerable interval above the target is called out, and every fix is ver affected: [ { path: "node_modules/hono", version: "4.12.0", topLevel: true }, ], - declarers: ["package.json"], + declarers: [decl("package.json")], }); assert.match(body, /\*\*Then verify\*\*/); }); @@ -575,7 +577,7 @@ test("npm labels come from the vulnerable copies, not the root lockfile", () => assert.deepEqual( issueLabels(npm, { affected: [{ path: "node_modules/hono", topLevel: true }], - declarers: ["src/everything/package.json"], + declarers: [decl("src/everything/package.json")], }), [...base, "server-everything"], ); @@ -583,7 +585,7 @@ test("npm labels come from the vulnerable copies, not the root lockfile", () => assert.deepEqual( issueLabels(npm, { affected: [{ path: "src/filesystem/node_modules/diff", topLevel: true }], - declarers: ["package.json"], + declarers: [decl("package.json")], }), [...base, "server-filesystem"], ); @@ -591,7 +593,7 @@ test("npm labels come from the vulnerable copies, not the root lockfile", () => assert.deepEqual( issueLabels(npm, { affected: [{ path: "node_modules/semver", topLevel: true }], - declarers: ["package.json"], + declarers: [decl("package.json")], }), base, ); @@ -604,6 +606,11 @@ test("npm labels come from the vulnerable copies, not the root lockfile", () => ); }); +/** A manifest declaring the package; `*` lets any copy satisfy it. */ +function decl(manifest, range = "*") { + return { manifest, range }; +} + function npmGroup(pkg, fixedIn, range = "< 99") { const [group] = groupAlerts([ alert({ name: pkg, range, fixed: fixedIn, ghsa: "GHSA-x" }), @@ -630,7 +637,7 @@ test("an npm body says which edit clears which copy", () => { affected: [ { path: "node_modules/hono", version: "4.12.0", topLevel: true }, ], - declarers: ["src/everything/package.json"], + declarers: [decl("src/everything/package.json")], securityPrsOff: true, }); assert.match( @@ -648,7 +655,7 @@ test("an npm body says which edit clears which copy", () => { topLevel: false, }, ], - declarers: ["package.json"], + declarers: [decl("package.json")], }); assert.match(both, /Both edits are needed/); assert.match(both, /1\. \*\*Raise/); @@ -662,21 +669,24 @@ test("a workspace's own copy is direct only if that workspace declares it", () = const ws = { path: "src/filesystem/node_modules/diff", topLevel: true }; const hoisted = { path: "node_modules/diff", topLevel: true }; const nested = { path: "node_modules/a/node_modules/diff", topLevel: false }; - assert.deepEqual(npmCopyDeclarers(ws, ["package.json"]), []); + assert.deepEqual(npmCopyDeclarers(ws, [decl("package.json")]), []); assert.deepEqual( - npmCopyDeclarers(ws, ["package.json", "src/filesystem/package.json"]), + npmCopyDeclarers(ws, [ + decl("package.json"), + decl("src/filesystem/package.json"), + ]), ["src/filesystem/package.json"], ); - assert.deepEqual(npmCopyDeclarers(hoisted, ["package.json"]), [ + assert.deepEqual(npmCopyDeclarers(hoisted, [decl("package.json")]), [ "package.json", ]); - assert.deepEqual(npmCopyDeclarers(nested, ["package.json"]), []); + assert.deepEqual(npmCopyDeclarers(nested, [decl("package.json")]), []); // The root declares `diff`; only the workspace's undeclared copy is // vulnerable. The fix is the override, scoped, not the root's range. const body = buildIssueBody(npmGroup("diff", "5.2.2"), { affected: [{ ...ws, version: "5.0.0" }], - declarers: ["package.json"], + declarers: [decl("package.json")], }); assert.ok(!body.includes("Raise the declared range")); assert.match(body, /\*\*Add a parent-scoped/); @@ -684,6 +694,55 @@ test("a workspace's own copy is direct only if that workspace declares it", () = assert.match(body, /EOVERRIDE/); }); +test("a hoisted copy no declared range resolves to is transitive (#5506)", () => { + // The #5481 shape: src/filesystem declares minimatch ^11.0.4 and has its + // own fixed nested copy; the hoisted root copy is 10.2.5, pulled in only by + // dev tooling. The root copy is not filesystem's, so the fix is a + // package-wide override and no server is in scope. + const lock = { + packages: { + "": { name: "@modelcontextprotocol/servers", devDependencies: {} }, + "src/filesystem": { + name: "@modelcontextprotocol/server-filesystem", + dependencies: { minimatch: "^11.0.4" }, + }, + "src/filesystem/node_modules/minimatch": { version: "11.0.4" }, + "node_modules/minimatch": { version: "10.2.5", dev: true }, + }, + }; + const declarers = npmDeclarers(lock, "minimatch"); + assert.deepEqual(declarers, [ + { manifest: "src/filesystem/package.json", range: "^11.0.4" }, + ]); + const hoisted = npmLockEntries(lock, "minimatch").find( + (e) => e.path === "node_modules/minimatch", + ); + assert.ok(hoisted); + assert.deepEqual(npmCopyDeclarers(hoisted, declarers), []); + // The same copy is a declarer's when its range does admit it. + assert.deepEqual( + npmCopyDeclarers(hoisted, [decl("src/filesystem/package.json", "^10.0.0")]), + ["src/filesystem/package.json"], + ); + + const affected = [hoisted]; + assert.deepEqual( + issueLabels( + { manifestPath: "package-lock.json", ecosystem: "npm" }, + { affected, declarers }, + ), + ["v2", "chore", "dependencies"], + ); + const body = buildIssueBody(npmGroup("minimatch", "10.2.6"), { + affected, + declarers, + }); + assert.ok(!body.includes("Raise the declared range")); + assert.match(body, /\*\*Add an \[`overrides`\]/); + // Only the root's own declaration makes a package-wide override fail. + assert.ok(!body.includes("EOVERRIDE")); +}); + test("a pip body says whether to raise the bound or refresh the lock", () => { const [group] = groupAlerts([ alert({ diff --git a/scripts/smoke-servers.mjs b/scripts/smoke-servers.mjs index 94cbe47ba2..8212f9ee7c 100755 --- a/scripts/smoke-servers.mjs +++ b/scripts/smoke-servers.mjs @@ -8,8 +8,8 @@ * npm run smoke # the root entry point (all) * * For each server and transport it connects an MCP client, lists the tools, - * and calls one of them: stdio for all seven servers, plus HTTP+SSE and - * Streamable HTTP for `everything`, the only server that serves them. + * and calls one of them: stdio and Streamable HTTP for all seven servers + * (#576), plus HTTP+SSE for `everything`, the only server that serves it. * * Why it exists when every server has a test suite: the suites import the * source. Nothing in them runs the artifact a user actually launches, which is @@ -40,8 +40,9 @@ * 3001, so the smoke does not collide with a server the developer has running. * That port is not reserved between the probe and the server's own `listen`, * so a launch whose server reports the port taken is relaunched on a fresh - * one. Both HTTP transports report it (`listenOrExit` in `everything`'s - * `transports/listen.ts`). + * one. Every HTTP launch reports it: `listenOrExit` in `everything`'s + * `transports/listen.ts`, the other TypeScript servers' `http.ts` (through + * their fatal-error line), and uvicorn under the Python servers. * * One server failing does not stop the rest: the run reports every target's * verdict and exits non-zero if any failed, so one run shows the whole picture. @@ -122,7 +123,7 @@ export const SERVERS = [ { name: "filesystem", language: "ts", - transports: ["stdio"], + transports: ["stdio", "streamableHttp"], args: (ctx) => [ctx.dir], call: () => ({ name: "list_allowed_directories", arguments: {} }), expect: (ctx) => path.basename(ctx.dir), @@ -130,14 +131,14 @@ export const SERVERS = [ { name: "memory", language: "ts", - transports: ["stdio"], + transports: ["stdio", "streamableHttp"], env: (ctx) => ({ MEMORY_FILE_PATH: path.join(ctx.dir, "memory.jsonl") }), call: () => ({ name: "read_graph", arguments: {} }), }, { name: "sequentialthinking", language: "ts", - transports: ["stdio"], + transports: ["stdio", "streamableHttp"], call: () => ({ name: "sequentialthinking", arguments: { @@ -151,7 +152,7 @@ export const SERVERS = [ { name: "fetch", language: "py", - transports: ["stdio"], + transports: ["stdio", "streamableHttp"], // fetch refuses loopback addresses by default (#4838); the smoke page is // on loopback, so the guard is turned off for it. args: () => ["--allow-private-ips"], @@ -167,7 +168,7 @@ export const SERVERS = [ { name: "git", language: "py", - transports: ["stdio"], + transports: ["stdio", "streamableHttp"], args: (ctx) => ["--repository", ctx.dir], prepare: (ctx) => run("git", ["init", "--quiet", ctx.dir]), call: (ctx) => ({ name: "git_status", arguments: { repo_path: ctx.dir } }), @@ -175,14 +176,14 @@ export const SERVERS = [ { name: "time", language: "py", - transports: ["stdio"], + transports: ["stdio", "streamableHttp"], args: () => ["--local-timezone", "UTC"], call: () => ({ name: "get_current_time", arguments: { timezone: "UTC" } }), expect: "UTC", }, ]; -/** The argument that selects a transport; only `everything` takes one. */ +/** The path each HTTP transport is served on. */ const TRANSPORT_ENDPOINT = { sse: "/sse", streamableHttp: "/mcp" }; /** Run a setup command to completion; throw with its output if it fails. */ @@ -289,9 +290,14 @@ export function launchSpec( * @returns {string[]} */ export function serverArguments(server, transport, ctx) { - // `everything` picks its transport from its first argument; the others are - // stdio-only and take none. - const transportArg = server.transports.length > 1 ? [transport] : []; + // `everything` picks its transport from its first argument; the others + // default to stdio and take `--transport streamable-http` for HTTP (#576). + const transportArg = + server.name === "everything" + ? [transport] + : transport === "streamableHttp" + ? ["--transport", "streamable-http"] + : []; return [...transportArg, ...(server.args?.(ctx) ?? [])]; } diff --git a/scripts/smoke-servers.test.mjs b/scripts/smoke-servers.test.mjs index 22f002f4b5..f346b33109 100644 --- a/scripts/smoke-servers.test.mjs +++ b/scripts/smoke-servers.test.mjs @@ -45,12 +45,15 @@ test("findUnlistedServers names a server the table lacks, either language", (t) assert.deepEqual(findUnlistedServers(src), ["newpy", "newts"]); }); -test("stdio for all seven; SSE and Streamable HTTP for everything only", () => { +test("stdio and Streamable HTTP for all seven; SSE for everything only", () => { assert.equal(SERVERS.length, 7); for (const server of SERVERS) { - assert.ok(server.transports.includes("stdio"), server.name); if (server.name !== "everything") - assert.deepEqual(server.transports, ["stdio"], server.name); + assert.deepEqual( + server.transports, + ["stdio", "streamableHttp"], + server.name, + ); } assert.deepEqual(byName("everything").transports, [ "stdio", @@ -60,7 +63,7 @@ test("stdio for all seven; SSE and Streamable HTTP for everything only", () => { }); test("selectTargets: no names means every server and transport", () => { - assert.equal(selectTargets([]).length, 9); + assert.equal(selectTargets([]).length, 15); }); test("selectTargets: named servers only, in the table's order", () => { @@ -73,6 +76,7 @@ test("selectTargets: named servers only, in the table's order", () => { "everything/sse", "everything/streamableHttp", "time/stdio", + "time/streamableHttp", ], ); }); @@ -102,6 +106,12 @@ test("launchSpec: a TypeScript server runs its built bin, with the transport whe ); assert.equal(filesystem.command, bin("filesystem")); assert.deepEqual(filesystem.args, ["/tmp/x"]); + // The other servers take the HTTP transport as a flag (#576). + assert.deepEqual( + launchSpec(byName("filesystem"), "streamableHttp", ctx, "/repo", "linux") + .args, + ["--transport", "streamable-http", "/tmp/x"], + ); // Windows has no shebang: the file is handed to node. const win = launchSpec(byName("everything"), "sse", ctx, "/repo", "win32"); assert.equal(win.command, process.execPath); diff --git a/scripts/version-pr-ci.test.mjs b/scripts/version-pr-ci.test.mjs index 4166bed272..31bd4ed19c 100644 --- a/scripts/version-pr-ci.test.mjs +++ b/scripts/version-pr-ci.test.mjs @@ -257,3 +257,18 @@ test("RELEASING.md names the statuses a version PR is merged on", () => { assert.ok(releasing.includes(`\`${context}\``), context); assert.doesNotMatch(releasing, /Close and reopen the PR to run CI/); }); + +// #5463 (Step 1 of a staged rename): `mcp-interface-diff.yml` exists so the +// name is on `main` before #5527 (Step 2) points the version workflows at it. +// Until then it must not run beside the real diff on a push or a pull +// request, and nothing may dispatch it yet: the version workflows keep +// dispatching `everything-mcp-diff.yml` (pinned in VERSION_WORKFLOWS above). +test("mcp-interface-diff.yml is a dispatch-only placeholder until Step 2", () => { + const wf = workflow("mcp-interface-diff.yml"); + assert.deepEqual(Object.keys(wf.on), ["workflow_dispatch"]); + for (const { file } of VERSION_WORKFLOWS) + assert.ok( + !read(`.github/workflows/${file}`).includes("mcp-interface-diff.yml"), + `${file} does not dispatch the placeholder yet`, + ); +}); diff --git a/src/everything/CHANGELOG.md b/src/everything/CHANGELOG.md index c2c9b47988..1ce679f52a 100644 --- a/src/everything/CHANGELOG.md +++ b/src/everything/CHANGELOG.md @@ -1,5 +1,11 @@ # @modelcontextprotocol/server-everything +## 2.3.1 + +### Patch Changes + +- [#5583](https://github.com/modelcontextprotocol/servers/pull/5583) [`66f641e`](https://github.com/modelcontextprotocol/servers/commit/66f641e9ae2fc7726a9420b15fbf68e0613a254b) [@cliffhall](https://github.com/cliffhall) - Fix GHSA-38j4-j742-j7r3. + ## 2.3.0 ### Minor Changes diff --git a/src/everything/README.md b/src/everything/README.md index c924689468..0d597af143 100644 --- a/src/everything/README.md +++ b/src/everything/README.md @@ -17,7 +17,7 @@ The resource collections (`demo://resource/collection/summer-specials`, and the The server info and every tool, prompt, resource and resource template carry a pair of [icons](docs/features.md#icons), one for a light theme and one for a dark theme, so a client can show the variant that suits its own background. -The `get-env` tool returns the server's environment variables, but masks the value of any credential-like name (a `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `CREDENTIAL`, `AUTH` or `COOKIE` segment, such as `OPENAI_API_KEY`) as `""`. To see every value unmasked while debugging, start the server with `GET_ENV_INCLUDE_SECRETS=1` (or `true`). Leave it unset otherwise: with it set, every credential in the server's environment reaches the model's context. +The `get-env` tool returns the server's environment variables, but masks the value of any credential-like name (one with a `KEY`, `TOKEN`, `SECRET`, `PASSWORD`, `PASSWD`, `CREDENTIAL`, `AUTH` or `COOKIE` segment between underscores, in any case: whole segments, not substrings, so `OPENAI_API_KEY` is masked and `APIKEY` is not) as `""`. To see every value unmasked while debugging, start the server with `GET_ENV_INCLUDE_SECRETS=1` (or `true`). Leave it unset otherwise: with it set, every credential in the server's environment reaches the model's context. ## Protocol versions @@ -39,7 +39,7 @@ The `gzip-file-as-resource` tool fetches the URL it is given, so these environme | `GZIP_ALLOWED_DOMAINS` | empty (any name) | Comma-separated host names; a host must be one of them or a subdomain of one. Checked on the caller's URL and on every redirect hop | | `GZIP_ALLOW_PRIVATE_IPS` | off | Set to `1` or `true` to allow loopback, private (RFC 1918), CGNAT, link-local (cloud metadata) and other non-public addresses | -By default the tool refuses a URL whose host resolves to a non-public address, and follows at most five redirects, checking each hop the same way. `GZIP_ALLOWED_DOMAINS` filters names, not addresses: a listed name that resolves to a private address is still refused unless `GZIP_ALLOW_PRIVATE_IPS` is set. The address is checked before the request and resolved again when it is made, so a DNS answer that changes in between (DNS rebinding) is not caught. `data:` URLs are not fetched, so neither check applies to them. +By default the tool refuses a URL whose host resolves to a non-public address, and follows at most five redirects, checking each hop the same way. An IPv6 address that wraps an IPv4 one (IPv4-mapped, IPv4-translated, or in the NAT64 prefix `64:ff9b::/96`) is judged by that IPv4, and any other IPv6 address outside global unicast (`2000::/3`) is refused. `GZIP_ALLOWED_DOMAINS` filters names, not addresses: a listed name that resolves to a private address is still refused unless `GZIP_ALLOW_PRIVATE_IPS` is set. The address is checked before the request and resolved again when it is made, so a DNS answer that changes in between (DNS rebinding) is not caught. `data:` URLs are not fetched, so neither check applies to them. ## Requirements diff --git a/src/everything/__tests__/gzip-address-classification.test.ts b/src/everything/__tests__/gzip-address-classification.test.ts new file mode 100644 index 0000000000..ed6e06da76 --- /dev/null +++ b/src/everything/__tests__/gzip-address-classification.test.ts @@ -0,0 +1,68 @@ +/** + * Pins how the `gzip-file-as-resource` guard classifies a resolved address, + * one address at a time, so that every range is covered without a resolver or + * a request. An IPv6 address that carries an IPv4 destination (IPv4-mapped, + * IPv4-translated, or the well-known NAT64 prefix 64:ff9b::/96) is judged by + * the IPv4 it wraps; deprecated IPv4-compatible (::/96) and site-local + * (fec0::/10) addresses are refused, and so is any IPv6 address outside + * global unicast (2000::/3). This mirrors the fetch server's + * `_is_public_address`. The suite in gzip-private-addresses.test.ts drives the + * same cases through the tool. + */ +import { describe, expect, it } from "vitest"; +import { isNonPublic } from "../tools/gzip-file-as-resource.js"; + +describe("gzip-file-as-resource address classification", () => { + it.each([ + // The well-known NAT64 prefix, judged by the IPv4 it wraps + ["64:ff9b::a9fe:a9fe", "NAT64 of 169.254.169.254 (cloud metadata)"], + ["64:ff9b::7f00:1", "NAT64 of 127.0.0.1"], + ["64:ff9b::a00:1", "NAT64 of 10.0.0.1"], + ["64:ff9b::169.254.169.254", "NAT64 of the metadata address, dotted"], + ["64:ff9b:0:0:0:0:c0a8:1", "NAT64 of 192.168.0.1, uncompressed"], + ["64:ff9b::", "NAT64 of 0.0.0.0"], + ["64:ff9b:1::1", "local-use NAT64"], + // IPv4-mapped and IPv4-translated, judged by the IPv4 they wrap + ["::ffff:127.0.0.1", "IPv4-mapped loopback, dotted"], + ["::ffff:a9fe:a9fe", "IPv4-mapped metadata address"], + ["::ffff:0:7f00:1", "IPv4-translated loopback"], + // Deprecated IPv4-compatible, refused whatever it holds + ["::7f00:1", "IPv4-compatible loopback"], + ["::5db8:d70e", "IPv4-compatible public address"], + ["::", "unspecified"], + ["::1", "loopback"], + // Deprecated site-local + ["fec0::1", "site-local"], + ["feff::1", "site-local, top of the range"], + // Outside 2000::/3, though in no listed range + ["4000::1", "reserved by the IETF"], + ["1::1", "reserved by the IETF, low"], + ["3fff::1", "documentation (RFC 9637)"], + ["fd00:ec2::254", "unique local"], + ["fe80::1", "link-local"], + ["ff02::1", "multicast"], + ])("refuses %s (%s)", (address) => { + expect(isNonPublic(address, 6)).toBe(true); + }); + + it.each([ + ["64:ff9b::5db8:d70e", "NAT64 of the public 93.184.215.14"], + ["64:ff9b::93.184.215.14", "the same, dotted"], + ["64:ff9b::c000:9", "NAT64 of the 192.0.0.9 exception"], + ["::ffff:93.184.215.14", "IPv4-mapped public address"], + ["::ffff:0:5db8:d70e", "IPv4-translated public address"], + ["2606:4700::1", "global unicast"], + ["2001:3::1", "the 2001:3::/32 exception"], + ])("allows %s (%s)", (address) => { + expect(isNonPublic(address, 6)).toBe(false); + }); + + it.each([ + ["169.254.169.254", true], + ["10.0.0.1", true], + ["192.0.0.9", false], + ["93.184.215.14", false], + ])("judges the IPv4 address %s as non-public: %s", (address, refused) => { + expect(isNonPublic(address, 4)).toBe(refused); + }); +}); diff --git a/src/everything/__tests__/gzip-private-addresses.test.ts b/src/everything/__tests__/gzip-private-addresses.test.ts index 44608d5454..80ded98720 100644 --- a/src/everything/__tests__/gzip-private-addresses.test.ts +++ b/src/everything/__tests__/gzip-private-addresses.test.ts @@ -33,6 +33,9 @@ vi.mock("node:dns/promises", async (importOriginal) => { "public.example": { address: "93.184.215.14", family: 4 }, "anycast.example": { address: "192.0.0.9", family: 4 }, // inside 192.0.0.0/24 "anycast6.example": { address: "2001:3::1", family: 6 }, // inside 2001::/23 + // DNS64 synthesizes these: NAT64 of 169.254.169.254, and of 93.184.215.14 + "nat64-metadata.example": { address: "64:ff9b::a9fe:a9fe", family: 6 }, + "nat64-public.example": { address: "64:ff9b::5db8:d70e", family: 6 }, }; return { ...actual, @@ -150,6 +153,31 @@ describe("gzip-file-as-resource private addresses (#5130)", () => { expect(textOf(await gzip(url))).toBe(refusal(url, address, address)); }); + it.each([ + ["NAT64 of a link-local IPv4", "64:ff9b::a9fe:a9fe"], + ["NAT64 of a loopback IPv4", "64:ff9b::7f00:1"], + ["NAT64 of an RFC 1918 IPv4", "64:ff9b::a00:1"], + ["IPv4-compatible loopback", "::7f00:1"], + ["site-local", "fec0::1"], + ["reserved (outside 2000::/3)", "4000::1"], + ])("refuses an IPv6 %s address", async (_kind, address) => { + const url = `http://[${address}]/latest/meta-data/`; + expect(textOf(await gzip(url))).toBe(refusal(url, address, address)); + }); + + it("refuses a name whose DNS64 answer wraps a link-local IPv4", async () => { + const url = "http://nat64-metadata.example/latest/meta-data/"; + expect(textOf(await gzip(url))).toBe( + refusal(url, "nat64-metadata.example", "64:ff9b::a9fe:a9fe"), + ); + }); + + it("fetches from a NAT64 address that wraps a public IPv4", async () => { + expect(await gzip("http://nat64-public.example/file")).toMatchObject({ + type: "resource_link", + }); + }); + it("fetches from a public address", async () => { expect(await gzip("http://public.example/file")).toMatchObject({ type: "resource_link", diff --git a/src/everything/package.json b/src/everything/package.json index 2beb5f5648..9d2155fc3f 100644 --- a/src/everything/package.json +++ b/src/everything/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/server-everything", - "version": "2.3.0", + "version": "2.3.1", "description": "MCP server that exercises all the features of the MCP protocol", "license": "SEE LICENSE IN LICENSE", "mcpName": "io.github.modelcontextprotocol/server-everything", diff --git a/src/everything/tools/gzip-file-as-resource.ts b/src/everything/tools/gzip-file-as-resource.ts index 2ad289f34c..3d646f6b8f 100644 --- a/src/everything/tools/gzip-file-as-resource.ts +++ b/src/everything/tools/gzip-file-as-resource.ts @@ -67,9 +67,9 @@ const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]); // Addresses that are not public destinations: the IANA special-purpose ranges // the fetch server refuses (src/fetch's _NON_PUBLIC_NETWORKS), plus -// multicast. BlockList judges an IPv4-mapped IPv6 address (::ffff:a.b.c.d) by -// the IPv4 rules, so those need no ranges of their own. The well-known NAT64 -// prefix (64:ff9b::/96) is not unwrapped and so passes as public. +// multicast. An IPv6 address that carries an IPv4 destination is unwrapped +// and judged by that IPv4 first (see IPV4_CARRIERS), so these ranges need no +// IPv6 copies of the IPv4 ones. const NON_PUBLIC_ADDRESSES = new BlockList(); for (const [network, prefix] of [ ["0.0.0.0", 8], // "this network", including the unspecified address @@ -91,15 +91,20 @@ for (const [network, prefix] of [ NON_PUBLIC_ADDRESSES.addSubnet(network, prefix, "ipv4"); } for (const [network, prefix] of [ - ["::", 128], // unspecified - ["::1", 128], // loopback + // IPv4-compatible IPv6 (RFC 4291 2.5.5.1), deprecated and never routed; + // it also holds the unspecified (::) and loopback (::1) addresses. + ["::", 96], ["64:ff9b:1::", 48], // local-use NAT64 ["100::", 64], // discard-only ["2001::", 23], // IETF protocol assignments (Teredo among them) ["2001:db8::", 32], // documentation ["2002::", 16], // 6to4 + ["3fff::", 20], // documentation (RFC 9637) ["fc00::", 7], // unique local (AWS's fd00:ec2::254) ["fe80::", 10], // link-local + // Deprecated site-local (RFC 3879). Outside 2000::/3 as well, but listed so + // it is refused by name. + ["fec0::", 10], ["ff00::", 8], // multicast ] as const) { NON_PUBLIC_ADDRESSES.addSubnet(network, prefix, "ipv6"); @@ -121,12 +126,61 @@ for (const [network, prefix] of [ PUBLIC_EXCEPTIONS.addSubnet(network, prefix, "ipv6"); } +// IPv6 ranges whose low 32 bits are the IPv4 destination: IPv4-mapped +// (::ffff:0:0/96), IPv4-translated (RFC 6145, ::ffff:0:0:0/96), which a +// stateless translator forwards to that IPv4, and the well-known NAT64 prefix +// (RFC 6052, 64:ff9b::/96), which a NAT64 gateway forwards to it. An address +// in one is judged by the IPv4 it wraps, as the fetch server judges it, so a +// public IPv4 stays reachable through NAT64 and a private one is refused. +const IPV4_CARRIERS = new BlockList(); +for (const network of ["::ffff:0:0", "::ffff:0:0:0", "64:ff9b::"]) { + IPV4_CARRIERS.addSubnet(network, 96, "ipv6"); +} + +// IPv6 global unicast (RFC 4291 2.4). The rest of the IPv6 space is reserved, +// unique or site-local, link-local or multicast, none of it a public +// destination, so an IPv6 address outside it is refused: a range missing from +// NON_PUBLIC_ADDRESSES cannot pass as public. +const IPV6_GLOBAL_UNICAST = new BlockList(); +IPV6_GLOBAL_UNICAST.addSubnet("2000::", 3, "ipv6"); + +/** + * The IPv4 address held in the low 32 bits of a valid IPv6 address, as + * dotted quad. + */ +function lowIPv4(address: string): string { + // A resolver may spell those bits as a trailing dotted quad (::ffff:1.2.3.4) + const tail = address.slice(address.lastIndexOf(":") + 1); + if (tail.includes(".")) return tail; + const [head, rest] = address.split("::"); + const groups = + rest === undefined + ? head.split(":") + : [ + ...(head ? head.split(":") : []), + ...Array(8).fill("0"), + ...(rest ? rest.split(":") : []), + ].slice(-8); + const high = parseInt(groups[6], 16); + const low = parseInt(groups[7], 16); + return [high >> 8, high & 255, low >> 8, low & 255].join("."); +} + /** True when `address` is not a public destination. */ -function isNonPublic(address: string, family: number): boolean { - const type = family === 6 ? "ipv6" : "ipv4"; +export function isNonPublic(address: string, family: number): boolean { + if (family !== 6) { + return ( + !PUBLIC_EXCEPTIONS.check(address, "ipv4") && + NON_PUBLIC_ADDRESSES.check(address, "ipv4") + ); + } + if (IPV4_CARRIERS.check(address, "ipv6")) { + return isNonPublic(lowIPv4(address), 4); + } + if (PUBLIC_EXCEPTIONS.check(address, "ipv6")) return false; return ( - !PUBLIC_EXCEPTIONS.check(address, type) && - NON_PUBLIC_ADDRESSES.check(address, type) + NON_PUBLIC_ADDRESSES.check(address, "ipv6") || + !IPV6_GLOBAL_UNICAST.check(address, "ipv6") ); } diff --git a/src/fetch/Dockerfile b/src/fetch/Dockerfile index d491ccc4f3..133b60dacf 100644 --- a/src/fetch/Dockerfile +++ b/src/fetch/Dockerfile @@ -46,5 +46,4 @@ USER 999:999 # Place executables in the environment at the front of the path ENV PATH="/app/.venv/bin:$PATH" -# when running the container, add --db-path and a bind mount to the host's db file ENTRYPOINT ["mcp-server-fetch"] diff --git a/src/fetch/README.md b/src/fetch/README.md index 8bd0f48942..c051833aec 100644 --- a/src/fetch/README.md +++ b/src/fetch/README.md @@ -11,7 +11,7 @@ Requires MCP Python SDK 2.x (`mcp>=2.3,<3`). > [!CAUTION] > This server can access local/internal IP addresses and may represent a security risk. Exercise caution when using this MCP server to ensure this does not expose any sensitive data. > -> By default the server refuses to fetch private, loopback, link-local and other non-public addresses, including cloud metadata endpoints such as `169.254.169.254`, and checks every redirect hop the same way. The `--allow-private-ips` argument turns this guard off; see [Customization - Private addresses](#customization---private-addresses). The guard checks the addresses a hostname resolves to before each request, so it does not protect against DNS rebinding between that check and the connection, and a hostname the server cannot resolve itself (one only a proxy can resolve) is not checked. +> By default the server refuses to fetch private, loopback, link-local and other non-public addresses, including cloud metadata endpoints such as `169.254.169.254`, and checks every redirect hop the same way. The `--allow-private-ips` argument turns this guard off; see [Customization - Private addresses](#customization---private-addresses). The server connects only to an address the guard checked, so a hostname cannot pass the check with one address and be fetched from another (DNS rebinding). A request sent through a proxy is the exception: the proxy resolves the hostname and makes the connection, so the address it reaches is not the server's to check, and a hostname the server cannot resolve itself (one only a proxy can resolve) is not checked at all. The fetch tool will truncate the response, but by using the `start_index` argument, you can specify where to start the content extraction. This lets models read a webpage in chunks, until they find the information they need. @@ -56,6 +56,9 @@ The server speaks both eras of the Model Context Protocol over stdio, with nothi ## Installation +Requires **Python 3.11.5 or newer**. `uvx` fetches a suitable interpreter on its own; with pip, install into an +environment on 3.11.5 or later. + Optionally: Install node.js, this will cause the fetch server to use a different HTML simplifier that is more robust. Its JavaScript dependencies are then installed with npm on first use, which contacts the npm registry. To keep the server from ever starting Node.js, see [Customization - HTML extraction](#customization---html-extraction). @@ -202,6 +205,18 @@ judged by the IPv4 address it carries; a deprecated IPv4-compatible address (`:: refused whatever IPv4 it carries. A hostname is refused if any one of its addresses is in those ranges. The client receives an error naming the refused address. +The address that is checked is the address the server connects to. When it opens a connection the server resolves the +hostname itself, checks every address in that answer, and connects to one of those addresses directly, so the name is +not looked up again in between: a hostname whose DNS answer changes from a public address to a private one between the +check and the connection (DNS rebinding) is refused. This holds for every connection the server opens, redirect hops +and robots.txt fetches included. The request still carries the hostname in its `Host` header, and an HTTPS connection +still sends it as the TLS server name and verifies the certificate against it, not against the address. + +A request that goes through a proxy (`--proxy-url`, or the proxy environment variables) is different, because the +server connects to the proxy and the proxy resolves the hostname and connects to it. The hostname is still checked +against what it resolves to for the server, but the proxy's own lookup is not pinned to that answer, and a hostname +only the proxy can resolve is not checked. + To fetch from local or internal hosts (a development server, an intranet page), add the argument `--allow-private-ips` to the `args` list in the configuration. @@ -216,6 +231,10 @@ repeated). Each entry is one of: (`api.github.com`, `a.b.github.com`) but not `github.com` itself: list both to allow both; - an IP address, such as `203.0.113.7` or `2001:db8::7`, which matches a URL that uses that address literally. +A wildcard applies to domain names only. An entry that puts `*.` in front of an IP address or of a numeric suffix of +one, such as `*.10.0.0.1` or `*.0.0.1`, is refused at startup, and a URL that uses an IP address is only ever matched +by an entry naming that exact address. + Matching ignores case and a trailing dot, and an internationalized name may be given in either its Unicode or its `xn--` form. An entry names a host only, so it carries no scheme, port or path. The list is checked before every request the server sends, by the host name in the URL rather than by the addresses it resolves to: the requested page, its @@ -320,6 +339,31 @@ To always use the pure-Python extractor, add the argument `--no-readability-js` configuration. The server then never starts Node.js (or npm), whether or not it is installed, and never contacts the npm registry. +## Streamable HTTP + +The server talks over stdio by default. With `--transport streamable-http` it +runs on its own as an HTTP service instead, serving one MCP endpoint, `/mcp`, +to any number of clients of either protocol era: + +```sh +uvx mcp-server-fetch --transport streamable-http +``` + +It listens on `127.0.0.1:3001` unless `HOST` and `PORT` say otherwise (for +example `PORT=8080`); `HOST=0.0.0.0` exposes it to every machine that can reach +this one, so set it deliberately. Point a client at the URL, such as +`http://127.0.0.1:3001/mcp`, instead of giving it a command: + +```json +{ + "mcpServers": { + "fetch": { "type": "http", "url": "http://127.0.0.1:3001/mcp" } + } +} +``` + +Every other option works as it does over stdio. A browser page from any origin but localhost is refused with `403`, whatever `HOST` is, to guard against DNS rebinding; on loopback the SDK also checks each request's `Host` header. + ## Windows Configuration If you're experiencing timeout issues on Windows, you may need to set the `PYTHONIOENCODING` environment variable to ensure proper character encoding: diff --git a/src/fetch/pyproject.toml b/src/fetch/pyproject.toml index 866236181f..95a6ec077b 100644 --- a/src/fetch/pyproject.toml +++ b/src/fetch/pyproject.toml @@ -1,9 +1,9 @@ [project] name = "mcp-server-fetch" -version = "2026.11.11" +version = "2026.11.18" description = "A Model Context Protocol server providing tools to fetch and convert web content for usage by LLMs" readme = "README.md" -requires-python = ">=3.10" +requires-python = ">=3.11.5" authors = [{ name = "Anthropic, PBC." }] maintainers = [{ name = "Jack Adamson", email = "jadamson@anthropic.com" }] keywords = ["http", "mcp", "llm", "automation"] @@ -13,7 +13,7 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] dependencies = [ "beautifulsoup4>=4.7.1", diff --git a/src/fetch/src/mcp_server_fetch/__init__.py b/src/fetch/src/mcp_server_fetch/__init__.py index fa3a6eba88..02a41ddf3e 100644 --- a/src/fetch/src/mcp_server_fetch/__init__.py +++ b/src/fetch/src/mcp_server_fetch/__init__.py @@ -8,6 +8,7 @@ parse_timeout_ms, timeout_ms_from_env, ) +from .transport import TRANSPORTS, http_endpoint def main(): @@ -53,6 +54,13 @@ def main(): help="Extract HTML with the pure-Python extractor only, never starting Node.js " "or npm (by default Readability.js is used when Node.js is on PATH)", ) + parser.add_argument( + "--transport", + choices=TRANSPORTS, + default="stdio", + help="How clients reach the server (default: stdio). streamable-http " + "listens on $HOST:$PORT, 127.0.0.1:3001 by default", + ) args = parser.parse_args() # The server reads its timeout from the environment (see timeout.py), and @@ -63,6 +71,12 @@ def main(): timeout_ms_from_env() except ValueError as e: parser.error(str(e)) + if args.transport == "streamable-http": + # A bad HOST or PORT stops the server here, as a usage error. + try: + http_endpoint() + except ValueError as e: + parser.error(str(e)) asyncio.run( serve( args.user_agent, @@ -71,6 +85,7 @@ def main(): args.allow_private_ips, args.allowed_hosts, not args.no_readability_js, + args.transport, ) ) diff --git a/src/fetch/src/mcp_server_fetch/allowlist.py b/src/fetch/src/mcp_server_fetch/allowlist.py index 102a87fba5..5a4bb7aa52 100644 --- a/src/fetch/src/mcp_server_fetch/allowlist.py +++ b/src/fetch/src/mcp_server_fetch/allowlist.py @@ -13,6 +13,12 @@ # keep the semantics obvious: an exact host (a name or an IP literal), and # `*.example.com`, which matches any subdomain at any depth of example.com but # not example.com itself. Ports and schemes are not part of an entry. +# +# A wildcard is for domain names only (#5521). `*.` in front of an address, or +# of anything whose last label is a number, is refused when the list is read: +# `*.0.0.1` is not a domain, and matched as a suffix it would cover 10.0.0.1 +# and 127.0.0.1 alike. Matching holds the same line from the other side: an +# IP-literal host is only ever compared with exact entries. import argparse import ipaddress @@ -29,7 +35,7 @@ def normalize_allowed_host(entry: str) -> str: ASCII form requests are checked in (``bücher.example`` becomes ``xn--bcher-kva.example``). An IP literal is written in its compressed form, an IPv6 one with or without brackets. A wildcard is ``*.`` followed - by a name. + by a domain name, never by an address or a numeric suffix of one. """ value = entry.strip().rstrip(".").lower() wildcard = value.startswith("*.") @@ -48,9 +54,27 @@ def normalize_allowed_host(entry: str) -> str: ascii_name = httpx.URL(f"http://{name}/").raw_host.decode("ascii") except httpx.InvalidURL as e: raise ValueError(f"{entry!r} is not a valid host name: {e}") from None + if wildcard and _ends_in_a_number(ascii_name): + raise ValueError( + f"{entry!r} puts a wildcard on an IP address: *. takes a " + "domain name, and an address is listed exactly" + ) return f"*.{ascii_name}" if wildcard else ascii_name +def _ends_in_a_number(name: str) -> bool: + """Whether a host's last label is a number, so it reads as an IPv4 address. + + The test URL parsers apply: a host whose last label is decimal digits or + ``0x`` hex is an address (``10.0.0.1``, ``0.0.1``, ``1``, ``0x7f.1``), + never a domain, since no top-level domain is numeric. + """ + last = name.rsplit(".", 1)[-1] + if last.isascii() and last.isdigit(): + return True + return last.startswith("0x") and all(c in "0123456789abcdef" for c in last[2:]) + + def parse_allowed_host(entry: str) -> str: """``normalize_allowed_host`` as an argparse ``type``, with its message.""" try: @@ -67,13 +91,15 @@ def normalize_allowed_hosts(entries: Iterable[str] | None) -> tuple[str, ...]: def host_is_allowed(host: str, allowed_hosts: tuple[str, ...]) -> bool: """Whether ``host`` (a request's ``raw_host``) matches a normalized entry.""" host = host.rstrip(".").lower() + is_address = _ends_in_a_number(host) try: host = ipaddress.ip_address(host).compressed + is_address = True except ValueError: pass for entry in allowed_hosts: if entry.startswith("*."): - if host.endswith(entry[1:]): + if not is_address and host.endswith(entry[1:]): return True elif host == entry: return True diff --git a/src/fetch/src/mcp_server_fetch/pinning.py b/src/fetch/src/mcp_server_fetch/pinning.py new file mode 100644 index 0000000000..23b043e183 --- /dev/null +++ b/src/fetch/src/mcp_server_fetch/pinning.py @@ -0,0 +1,235 @@ +# Pins the fetch server's direct connections to addresses the private-address +# guard approved (#5557). The guard in server.py is a request hook: it resolves +# the URL's host and refuses a non-public address. httpx then opened the +# connection by resolving the same name a second time, so a name whose DNS +# answer changed between the two lookups (DNS rebinding) passed the check with +# a public address and connected to a private one. +# +# The fix is to make the lookup that picks the address the one that is +# checked. httpcore opens every TCP connection through a network backend's +# `connect_tcp(host, port)`. `PinnedBackend` stands in front of the real +# backend there: it resolves the host itself, hands every address to the +# guard, and then connects to those addresses by IP literal, so nothing below +# it resolves a name again. Nothing above it changes: httpcore still derives +# the `Host` header, the TLS SNI name and the certificate's expected name from +# the URL's host, not from what `connect_tcp` was given. +# +# Only the client's direct transport is pinned. A request that goes through a +# proxy connects to the proxy, which may well be on loopback and which resolves +# the destination on its side, so the proxy transports are left as httpx built +# them and the request hook stays the (best-effort) check for that case. +# +# httpx has no public way to give its default transport a network backend +# while it still reads the proxy environment variables (passing `transport=` +# turns those off), so `pin_direct_connections` replaces the client's default +# transport after construction, and fails loudly if httpx's internals are not +# the shape it expects, rather than leave connections unpinned. + +import asyncio +import socket +from collections.abc import Awaitable, Callable, Iterable, Sequence +from typing import Any, cast + +import anyio +import httpcore +import httpx + +# How long a connection attempt gets before the next address is tried +# alongside it (RFC 8305's "Connection Attempt Delay"), so one unresponsive +# address does not hold up a host that has a working one. The name-based +# connect this replaces raced a host's addresses the same way. +CONNECTION_ATTEMPT_DELAY = 0.25 + +# httpx's own defaults for its connection pool (`httpx.Limits()`), which the +# pinned transport keeps. +_MAX_CONNECTIONS = 100 +_MAX_KEEPALIVE_CONNECTIONS = 20 +_KEEPALIVE_EXPIRY = 5.0 + +Resolver = Callable[[str], Awaitable[Sequence[str]]] +# Raises to refuse a host given every address it resolved to. +Vetter = Callable[[str, Sequence[str]], None] + + +async def _close(streams: list[httpcore.AsyncNetworkStream]) -> None: + """Close and forget every stream in ``streams``, even while cancelled.""" + with anyio.CancelScope(shield=True): + while streams: + await streams.pop().aclose() + + +class PinnedBackend(httpcore.AsyncNetworkBackend): + """A network backend that connects only to addresses it resolved and vetted. + + ``resolve`` turns a host into its addresses and ``vet`` raises when any of + them is refused; ``inner`` (the anyio backend by default) then opens the + socket to an address, never to the name. + """ + + def __init__( + self, + resolve: Resolver, + vet: Vetter, + inner: httpcore.AsyncNetworkBackend | None = None, + ) -> None: + self._resolve = resolve + self._vet = vet + # The cast: httpcore also declares a placeholder `AnyIOBackend` for an + # install without anyio, which is the declaration a type checker sees. + # httpx requires anyio, so the real backend is what this builds. + self._inner = ( + cast(httpcore.AsyncNetworkBackend, httpcore.AnyIOBackend()) + if inner is None + else inner + ) + + async def connect_tcp( + self, + host: str, + port: int, + timeout: float | None = None, + local_address: str | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + # The connect timeout covers the lookup too, as it does for a + # name-based connect: the attempts below get what the lookup left. + loop = asyncio.get_running_loop() + started = loop.time() + try: + resolved = await asyncio.wait_for(self._resolve(host), timeout) + except socket.gaierror as e: + # What the inner backend reports for a name it cannot resolve. + raise httpcore.ConnectError(str(e)) from e + except TimeoutError as e: + raise httpcore.ConnectTimeout(f"Timed out resolving {host}") from e + # getaddrinfo lists an address once per socket type. + addresses = list(dict.fromkeys(resolved)) + self._vet(host, addresses) + + waiting = list(addresses) + attempts: set[asyncio.Task[httpcore.AsyncNetworkStream]] = set() + failures: list[Exception] = [] + # Every stream an attempt produced is owned here until one is + # returned: `winner` is the one to hand over, `spare` the rest. + winner: httpcore.AsyncNetworkStream | None = None + spare: list[httpcore.AsyncNetworkStream] = [] + try: + try: + while winner is None and (waiting or attempts): + if waiting: + # Each attempt gets what is left of the one connect + # timeout, so trying several addresses does not + # extend it. + left = ( + None + if timeout is None + else timeout - (loop.time() - started) + ) + attempts.add( + loop.create_task( + self._inner.connect_tcp( + waiting.pop(0), + port, + timeout=left, + local_address=local_address, + socket_options=socket_options, + ) + ) + ) + # Wake on the first attempt to finish, or to start the + # next address once this one has had its head start. + done, attempts = await asyncio.wait( + attempts, + timeout=CONNECTION_ATTEMPT_DELAY if waiting else None, + return_when=asyncio.FIRST_COMPLETED, + ) + for attempt in done: + error = attempt.exception() + if isinstance(error, Exception): + failures.append(error) + elif winner is None: + winner = attempt.result() + else: + spare.append(attempt.result()) + finally: + # Attempts still running lost the race, or the caller gave + # up. Shielded, so a caller's timeout (an anyio cancel scope, + # which cancels every await inside it) cannot cut the + # teardown short. + with anyio.CancelScope(shield=True): + for attempt in attempts: + attempt.cancel() + for outcome in await asyncio.gather( + *attempts, return_exceptions=True + ): + if isinstance(outcome, httpcore.AsyncNetworkStream): + spare.append(outcome) + await _close(spare) + except BaseException: + # The winner was never handed over (the caller was cancelled + # during the teardown, say), so it is closed here with the rest. + if winner is not None: + spare.append(winner) + await _close(spare) + raise + if winner is not None: + return winner + # Every address failed: report the first, as a single connect would. + if failures: + raise failures[0] + raise httpcore.ConnectError(f"{host} has no addresses") + + async def connect_unix_socket( + self, + path: str, + timeout: float | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + # A Unix socket has no name to resolve. The server never asks for one. + return await self._inner.connect_unix_socket( + path, timeout=timeout, socket_options=socket_options + ) + + async def sleep(self, seconds: float) -> None: + await self._inner.sleep(seconds) + + +class PinnedTransport(httpx.AsyncHTTPTransport): + """httpx's HTTP transport with its connections opened by ``backend``. + + Everything else is httpx's default transport: certificate verification + against the URL's host with the default trust store (``SSL_CERT_FILE`` and + ``SSL_CERT_DIR`` honored), HTTP/1.1, and the default pool limits. + """ + + def __init__(self, backend: httpcore.AsyncNetworkBackend) -> None: + ssl_context = httpx.create_ssl_context() + super().__init__(verify=ssl_context) + # `AsyncHTTPTransport` takes no network backend, so its pool is + # rebuilt with one; httpcore's pool takes it as a public argument. + self._pool = httpcore.AsyncConnectionPool( + ssl_context=ssl_context, + max_connections=_MAX_CONNECTIONS, + max_keepalive_connections=_MAX_KEEPALIVE_CONNECTIONS, + keepalive_expiry=_KEEPALIVE_EXPIRY, + network_backend=backend, + ) + + +def pin_direct_connections( + client: httpx.AsyncClient, resolve: Resolver, vet: Vetter +) -> None: + """Make ``client``'s direct connections go only to vetted addresses. + + Replaces the client's default transport, the one used for every request + no proxy applies to, with a `PinnedTransport`. Proxy transports are left + alone (see the top of this file). Raises ``TypeError`` when the client + is not built the way this relies on, so a future httpx cannot silently + drop the pinning. + """ + if not isinstance(getattr(client, "_transport", None), httpx.AsyncHTTPTransport): + raise TypeError( + "Cannot pin connections to the checked addresses: this version of " + "httpx does not expose its default transport as expected" + ) + client._transport = PinnedTransport(PinnedBackend(resolve, vet)) diff --git a/src/fetch/src/mcp_server_fetch/server.py b/src/fetch/src/mcp_server_fetch/server.py index c1bbbd3f91..696459e620 100644 --- a/src/fetch/src/mcp_server_fetch/server.py +++ b/src/fetch/src/mcp_server_fetch/server.py @@ -3,7 +3,9 @@ # beside the handlers because every request path (tool, prompt and robots.txt # check) must go through it: the private-address guard on each request and # redirect hop, robots.txt for autonomous fetches, the cap on how much of a -# response body is read (#5370), and proxy normalization. +# response body is read (#5370), and proxy normalization. The guard's check at +# connect time, which closes the gap between checking a name and connecting to +# it, is in `pinning.py` (#5557). # # Built on the MCP Python SDK's high-level `MCPServer` (#5174), as the example # to follow: the tool and the prompt are plain decorated functions, whose type @@ -47,6 +49,7 @@ from pydantic import AnyUrl, Field, TypeAdapter, ValidationError from .allowlist import normalize_allowed_hosts, refuse_unlisted_destination +from .pinning import pin_direct_connections from .readability_js import extract_article from .timeout import ( DEFAULT_TIMEOUT_MS, @@ -55,6 +58,7 @@ timeout_ms_from_env, ) from .title import with_page_title +from .transport import run # The version this server reports in serverInfo, read from the installed # distribution's metadata (pyproject.toml) so it cannot drift from the @@ -206,6 +210,24 @@ async def _refuse_private_destination(request: httpx.Request) -> None: ) +def _refuse_private_addresses(host: str, addresses: Sequence[str]) -> None: + """The same refusal at connect time, for the addresses about to be used. + + `pin_direct_connections` calls this with what ``host`` resolved to when + the connection is opened, and connects only to those addresses, so the + address that was checked is the address that is reached (#5557). The hook + above still runs first: it names the URL, and it is the only check a + proxied request gets. + """ + for address in addresses: + if not _is_public_address(address): + raise ToolError( + f"Refused to connect to {host}: it resolves to {address}, " + "which is not a public address. Start the server with " + "--allow-private-ips to allow private, loopback and link-local addresses." + ) + + def _readability_content(html: str) -> str: """readabilipy's pure-Python simplified HTML for ``html``, or "" when it has none. @@ -405,21 +427,32 @@ def normalize_proxy_env() -> None: os.environ[name] = normalize_proxy_url(value) -def make_client(proxy_url: str | None) -> httpx.AsyncClient: +def make_client( + proxy_url: str | None, allow_private_ips: bool = False +) -> httpx.AsyncClient: """Build the httpx client, turning a bad proxy setting into a ``ToolError``. httpx validates the proxy (``--proxy-url`` or the proxy environment variables) when the client is constructed, before any request, so this failure is not an ``HTTPError``. + + Unless ``allow_private_ips``, the client's direct connections are pinned + to addresses the private-address guard checked (see `pinning.py`). """ try: - return httpx.AsyncClient(proxy=proxy_url) + client = httpx.AsyncClient(proxy=proxy_url) except (ValueError, ImportError) as e: raise ToolError( f"Failed to set up the HTTP client, check the proxy " f"configuration (--proxy-url or the HTTP_PROXY, HTTPS_PROXY and " f"ALL_PROXY environment variables): {e}" ) + if not allow_private_ips: + # The lambda looks `_resolve_host` up on each call, as the hook does. + pin_direct_connections( + client, lambda host: _resolve_host(host), _refuse_private_addresses + ) + return client # The most body bytes the server reads from one response (#5370). A body is @@ -740,7 +773,7 @@ async def check_may_autonomously_fetch_url( robot_txt_url = get_robots_txt_url(url) - async with make_client(proxy_url) as client: + async with make_client(proxy_url, allow_private_ips) as client: hooks: list[Callable[[httpx.Request], Awaitable[None]]] = [] if allowed_hosts: hooks.append(refuse_unlisted_destination(allowed_hosts)) @@ -842,7 +875,7 @@ async def _check_redirect_robots_txt(request: httpx.Request) -> None: str(request.url), user_agent, proxy_url, allow_private_ips, allowed_hosts ) - async with make_client(proxy_url) as client: + async with make_client(proxy_url, allow_private_ips) as client: hooks: list[Callable[[httpx.Request], Awaitable[None]]] = [] if allowed_hosts: hooks.append(refuse_unlisted_destination(allowed_hosts)) @@ -1115,8 +1148,9 @@ async def serve( allow_private_ips: bool = False, allowed_hosts: Sequence[str] | None = None, use_readability_js: bool = True, + transport: str = "stdio", ) -> None: - """Run the fetch MCP server over stdio. + """Run the fetch MCP server over stdio, or over Streamable HTTP. Args: custom_user_agent: Optional custom User-Agent string to use for requests @@ -1131,6 +1165,7 @@ async def serve( use_readability_js: Extract HTML with Readability.js under Node.js when Node.js is on PATH (falling back to the pure-Python extractor when it cannot run); False always uses the pure-Python extractor + transport: ``stdio``, or ``streamable-http`` to listen on $HOST:$PORT """ server = create_server( custom_user_agent, @@ -1140,9 +1175,4 @@ async def serve( allowed_hosts, use_readability_js, ) - # Both eras (#4853): the SDK's dual-era loop lets the client's first - # request decide. `initialize` gets the 2025-11-25 handshake; - # `server/discover` or a request carrying a 2026-07-28 envelope gets the - # modern, sessionless era, with its required result fields (resultType, - # ttlMs, cacheScope) filled in by the SDK. - await server.run_stdio_async() + await run(server, transport) diff --git a/src/fetch/src/mcp_server_fetch/transport.py b/src/fetch/src/mcp_server_fetch/transport.py new file mode 100644 index 0000000000..42de67ec48 --- /dev/null +++ b/src/fetch/src/mcp_server_fetch/transport.py @@ -0,0 +1,89 @@ +"""How the fetch server is reached: stdio (the default) or Streamable HTTP (#576). + +`--transport streamable-http` serves the same server on one `/mcp` endpoint +through the SDK's Streamable HTTP app, which answers 2026-07-28 and 2025-era +clients alike. It listens on `HOST`:`PORT` from the environment, loopback:3001 +by default: the same variables, defaults and loopback-first posture as the +TypeScript servers. + +A browser page may reach it only from a localhost Origin, whatever `HOST` is, +as with the TypeScript servers' `localhostOriginValidation`. The SDK's own +DNS-rebinding protection checks Origin only when it binds loopback, and its +Host check cannot name the addresses of an interface `HOST` widens to, so the +Origin check is this module's middleware; on loopback the SDK's Host and +Origin checks still run behind it. +""" + +import os +from collections.abc import Mapping +from urllib.parse import urlsplit + +import uvicorn +from mcp.server.mcpserver import MCPServer +from starlette.datastructures import Headers +from starlette.responses import PlainTextResponse +from starlette.types import ASGIApp, Receive, Scope, Send + +TRANSPORTS = ("stdio", "streamable-http") +DEFAULT_HOST = "127.0.0.1" +DEFAULT_PORT = 3001 + + +def http_endpoint(env: Mapping[str, str] = os.environ) -> tuple[str, int]: + """The host and port to listen on: `HOST` and `PORT`, else the defaults.""" + host = env.get("HOST") or DEFAULT_HOST + raw = env.get("PORT") + if not raw: + return host, DEFAULT_PORT + if not raw.isascii() or not raw.isdigit() or int(raw) > 65535: + raise ValueError( + f"Invalid PORT {raw!r}: expected a whole number from 0 to 65535" + ) + return host, int(raw) + + +LOCALHOST_NAMES = ("localhost", "127.0.0.1", "::1") + + +def origin_allowed(origin: str | None) -> bool: + """Whether a request with this Origin may proceed: none (a non-browser + client), or one whose host is localhost, 127.0.0.1 or [::1].""" + if origin is None: + return True + try: + hostname = urlsplit(origin).hostname + except ValueError: + return False + return hostname in LOCALHOST_NAMES + + +class LocalhostOriginMiddleware: + """Answer an HTTP request from any other Origin with 403 before `app` sees it.""" + + def __init__(self, app: ASGIApp) -> None: + self.app = app + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + if scope["type"] == "http" and not origin_allowed( + Headers(scope=scope).get("origin") + ): + response = PlainTextResponse("Invalid Origin header", status_code=403) + await response(scope, receive, send) + return + await self.app(scope, receive, send) + + +async def run(server: MCPServer, transport: str) -> None: + """Serve `server` on `transport` until it is stopped.""" + if transport == "streamable-http": + host, port = http_endpoint() + app = LocalhostOriginMiddleware(server.streamable_http_app(host=host)) + config = uvicorn.Config(app, host=host, port=port) + await uvicorn.Server(config).serve() + else: + # Both eras (#4853): the SDK's dual-era loop lets the client's first + # request decide. `initialize` gets the 2025-11-25 handshake; + # `server/discover` or a request carrying a 2026-07-28 envelope gets + # the modern, sessionless era, with its required result fields + # (resultType, ttlMs, cacheScope) filled in by the SDK. + await server.run_stdio_async() diff --git a/src/fetch/tests/harness.py b/src/fetch/tests/harness.py index d85e3c3c40..c9e2749dcb 100644 --- a/src/fetch/tests/harness.py +++ b/src/fetch/tests/harness.py @@ -115,6 +115,9 @@ def factory(**kwargs: Any) -> httpx.AsyncClient: # patching the attribute on the httpx module is what it picks up. monkeypatch.setattr(httpx, "AsyncClient", factory) monkeypatch.setattr(server_module, "_resolve_host", fake.resolve) + # The mock transport opens no connection, so there is nothing to pin, and + # pinning would replace it with a real transport (test_pinning.py covers it). + monkeypatch.setattr(server_module, "pin_direct_connections", lambda *_: None) return fake diff --git a/src/fetch/tests/test_allowed_hosts.py b/src/fetch/tests/test_allowed_hosts.py index 3d27fbe97e..220ae13174 100644 --- a/src/fetch/tests/test_allowed_hosts.py +++ b/src/fetch/tests/test_allowed_hosts.py @@ -174,6 +174,7 @@ def test_flag_is_normalized_and_passed_to_serve( False, ["example.com", "*.docs.example.org", "10.0.0.1"], True, + "stdio", ) diff --git a/src/fetch/tests/test_allowed_hosts_wildcard_ip.py b/src/fetch/tests/test_allowed_hosts_wildcard_ip.py new file mode 100644 index 0000000000..6a841cf90d --- /dev/null +++ b/src/fetch/tests/test_allowed_hosts_wildcard_ip.py @@ -0,0 +1,92 @@ +"""``--allowed-hosts`` wildcards are for domain names, never addresses (#5521). + +``*.0.0.1`` used to be accepted and then matched, as a suffix, every IPv4 +literal ending ``.0.0.1``: 10.0.0.1 and 127.0.0.1 alike. These tests pin both +halves of the fix: such an entry is refused when the list is read, and an +IP-literal host is never matched by a wildcard entry, even one that reached +``host_is_allowed`` without going through ``normalize_allowed_host``. The +last test builds the real server, which refuses to start on such a list. +""" + +from __future__ import annotations + +import argparse + +import pytest + +from mcp_server_fetch.allowlist import ( + host_is_allowed, + normalize_allowed_host, + normalize_allowed_hosts, + parse_allowed_host, +) + + +@pytest.mark.parametrize( + "entry", + [ + "*.10.0.0.1", + "*.0.0.1", + "*.1", + "*.0.0.1.", + "*.[::1]", + "*.::1", + "*.0x7f.1", + "*.0x", + "*.example.123", + " *.0.0.1 ", + ], +) +def test_wildcard_address_entries_are_rejected(entry: str) -> None: + with pytest.raises(ValueError): + normalize_allowed_host(entry) + + +def test_the_rejection_says_what_a_wildcard_takes() -> None: + with pytest.raises(argparse.ArgumentTypeError, match="wildcard on an IP address"): + parse_allowed_host("*.0.0.1") + + +@pytest.mark.parametrize( + ("entry", "normalized"), + [ + ("*.example.com", "*.example.com"), + ("*.1.example.com", "*.1.example.com"), + ("*.123abc", "*.123abc"), + ("*.0xyz", "*.0xyz"), + ("*.xn--p1ai", "*.xn--p1ai"), + ("10.0.0.1", "10.0.0.1"), + ("[::1]", "::1"), + ], +) +def test_domain_wildcards_and_exact_addresses_are_still_accepted( + entry: str, normalized: str +) -> None: + assert normalize_allowed_host(entry) == normalized + + +@pytest.mark.parametrize( + "host", ["127.0.0.1", "10.0.0.1", "10.0.0.1.", "0x7f.0.0.1", "8.0.0.1"] +) +def test_a_wildcard_entry_never_matches_an_address(host: str) -> None: + # Entries given already-normalized, as a caller bypassing the parser could. + assert host_is_allowed(host, ("*.0.0.1",)) is False + + +def test_a_wildcard_entry_never_matches_an_ipv6_address() -> None: + assert host_is_allowed("2001:db8::7", ("*.db8::7", "*.7")) is False + + +def test_an_address_still_matches_its_exact_entry() -> None: + entries = normalize_allowed_hosts(["*.example.com", "10.0.0.1", "[2001:db8::7]"]) + assert host_is_allowed("10.0.0.1", entries) is True + assert host_is_allowed("2001:DB8:0::7", entries) is True + assert host_is_allowed("127.0.0.1", entries) is False + assert host_is_allowed("a.example.com", entries) is True + + +def test_create_server_rejects_a_wildcard_address_entry() -> None: + from mcp_server_fetch.server import create_server + + with pytest.raises(ValueError, match="wildcard on an IP address"): + create_server(allowed_hosts=["*.0.0.1"]) diff --git a/src/fetch/tests/test_entrypoints.py b/src/fetch/tests/test_entrypoints.py index 6b4438b771..dac809a8ed 100644 --- a/src/fetch/tests/test_entrypoints.py +++ b/src/fetch/tests/test_entrypoints.py @@ -33,7 +33,7 @@ def run_main(monkeypatch: pytest.MonkeyPatch, *argv: str) -> AsyncMock: def test_main_defaults(monkeypatch: pytest.MonkeyPatch) -> None: serve = run_main(monkeypatch) - serve.assert_awaited_once_with(None, False, None, False, None, True) + serve.assert_awaited_once_with(None, False, None, False, None, True, "stdio") def test_main_passes_every_flag(monkeypatch: pytest.MonkeyPatch) -> None: @@ -47,7 +47,7 @@ def test_main_passes_every_flag(monkeypatch: pytest.MonkeyPatch) -> None: "--allow-private-ips", ) serve.assert_awaited_once_with( - "MyBot/1.0", True, "http://proxy.example.com:8080", True, None, True + "MyBot/1.0", True, "http://proxy.example.com:8080", True, None, True, "stdio" ) @@ -92,7 +92,7 @@ def test_package_init_run_as_main_calls_main(monkeypatch: pytest.MonkeyPatch) -> monkeypatch.setattr(mcp_server_fetch.server, "serve", serve) monkeypatch.setattr(sys, "argv", ["mcp-server-fetch"]) runpy.run_module("mcp_server_fetch.__init__", run_name="__main__") - serve.assert_awaited_once_with(None, False, None, False, None, True) + serve.assert_awaited_once_with(None, False, None, False, None, True, "stdio") def console_script() -> Path: diff --git a/src/fetch/tests/test_http.py b/src/fetch/tests/test_http.py new file mode 100644 index 0000000000..6992d59f07 --- /dev/null +++ b/src/fetch/tests/test_http.py @@ -0,0 +1,175 @@ +# The Streamable HTTP transport (#576): `serve(transport="streamable-http")` +# run in-process on a free loopback port and driven by the SDK `Client` over +# real HTTP in both protocol eras, plus `main()`'s `--transport` flag and +# `http_endpoint()`'s reading of HOST and PORT. + +import socket +import sys +from collections.abc import AsyncIterator +from contextlib import asynccontextmanager +from functools import partial +from typing import Any +from unittest.mock import AsyncMock, patch + +import anyio +import pytest +from mcp import Client + +import mcp_server_fetch +from mcp_server_fetch.server import serve +from mcp_server_fetch.transport import ( + DEFAULT_HOST, + DEFAULT_PORT, + LocalhostOriginMiddleware, + http_endpoint, + origin_allowed, +) + +ERAS = [ + pytest.param("2026-07-28", "2026-07-28", id="2026-07-28"), + pytest.param("legacy", "2025-11-25", id="2025-11-25"), +] + + +def free_port() -> int: + """A loopback port nothing is listening on right now.""" + with socket.socket() as sock: + sock.bind(("127.0.0.1", 0)) + return sock.getsockname()[1] + + +@asynccontextmanager +async def http_server(monkeypatch: pytest.MonkeyPatch) -> AsyncIterator[str]: + """Run `serve()` over Streamable HTTP and yield its URL once it answers.""" + port = free_port() + monkeypatch.setenv("HOST", "127.0.0.1") + monkeypatch.setenv("PORT", str(port)) + async with anyio.create_task_group() as tg: + tg.start_soon(partial(serve, transport="streamable-http")) + with anyio.fail_after(10): + while True: + try: + await (await anyio.connect_tcp("127.0.0.1", port)).aclose() + break + except OSError: + await anyio.sleep(0.05) + yield f"http://127.0.0.1:{port}/mcp" + tg.cancel_scope.cancel() + + +@pytest.mark.parametrize(("mode", "negotiated"), ERAS) +async def test_serves_each_era_over_streamable_http( + monkeypatch: pytest.MonkeyPatch, mode: str, negotiated: str +) -> None: + async with http_server(monkeypatch) as url, Client(url, mode=mode) as client: + assert client.session.protocol_version == negotiated + tools = await client.list_tools() + assert [tool.name for tool in tools.tools] == ["fetch"] + + +def test_http_endpoint_defaults_to_loopback() -> None: + assert http_endpoint({}) == (DEFAULT_HOST, DEFAULT_PORT) + + +def test_http_endpoint_reads_host_and_port() -> None: + assert http_endpoint({"HOST": "0.0.0.0", "PORT": "8080"}) == ("0.0.0.0", 8080) + + +@pytest.mark.parametrize("port", ["abc", "-1", "65536", "1.5", "٣"]) +def test_http_endpoint_refuses_a_bad_port(port: str) -> None: + with pytest.raises(ValueError, match="Invalid PORT"): + http_endpoint({"PORT": port}) + + +@pytest.mark.parametrize( + "argv,transport", + [ + ([], "stdio"), + (["--transport", "stdio"], "stdio"), + (["--transport", "streamable-http"], "streamable-http"), + ], +) +def test_main_passes_the_transport_to_serve( + monkeypatch: pytest.MonkeyPatch, argv: list[str], transport: str +) -> None: + monkeypatch.delenv("PORT", raising=False) + serve_mock = AsyncMock() + with ( + patch.object(mcp_server_fetch, "serve", serve_mock), + patch.object(sys, "argv", ["mcp-server-fetch", *argv]), + ): + mcp_server_fetch.main() + serve_mock.assert_awaited_once_with(None, False, None, False, None, True, transport) + + +@pytest.mark.parametrize( + "argv", [["--transport", "sse"], ["--transport", "streamable-http"]] +) +def test_main_refuses_an_unknown_transport_or_a_bad_port( + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture[str], + argv: list[str], +) -> None: + monkeypatch.setenv("PORT", "not-a-port") + serve_mock = AsyncMock() + with ( + patch.object(mcp_server_fetch, "serve", serve_mock), + patch.object(sys, "argv", ["mcp-server-fetch", *argv]), + pytest.raises(SystemExit) as exit_info, + ): + mcp_server_fetch.main() + assert exit_info.value.code == 2 + serve_mock.assert_not_awaited() + assert "error:" in capsys.readouterr().err + + +@pytest.mark.parametrize( + "origin,allowed", + [ + (None, True), + ("http://localhost:6274", True), + ("http://127.0.0.1", True), + ("http://[::1]:3000", True), + ("https://evil.example", False), + ("http://localhost.evil.example", False), + ("http://[::1", False), + ("null", False), + ], +) +def test_origin_allowed(origin: str | None, allowed: bool) -> None: + assert origin_allowed(origin) is allowed + + +async def test_middleware_refuses_a_foreign_origin_whatever_the_host() -> None: + """The check does not depend on the bind address, so it holds under HOST=0.0.0.0.""" + reached: list[str] = [] + + async def app(scope: Any, receive: Any, send: Any) -> None: + reached.append(scope["type"]) + + sent: list[Any] = [] + + async def send(message: Any) -> None: + sent.append(message) + + async def receive() -> Any: + return {"type": "http.request", "body": b"", "more_body": False} + + middleware = LocalhostOriginMiddleware(app) + foreign = { + "type": "http", + "method": "POST", + "path": "/mcp", + "headers": [ + (b"host", b"192.168.1.20:3001"), + (b"origin", b"https://evil.example"), + ], + } + await middleware(foreign, receive, send) + assert reached == [] + assert sent[0]["status"] == 403 + + local = {**foreign, "headers": [(b"origin", b"http://localhost:6274")]} + await middleware(local, receive, send) + await middleware({"type": "lifespan"}, receive, send) + assert reached == ["http", "lifespan"] diff --git a/src/fetch/tests/test_pinning.py b/src/fetch/tests/test_pinning.py new file mode 100644 index 0000000000..cafa11bcd8 --- /dev/null +++ b/src/fetch/tests/test_pinning.py @@ -0,0 +1,999 @@ +"""The connection goes to the address the private-address guard checked (#5557). + +The guard used to resolve a URL's host, check the addresses, and leave httpx +to resolve the name again when it connected, so a name that answered with a +public address first and a private one second (DNS rebinding) was fetched +from the private address. These tests pin the fix in ``pinning.py``. + +Unlike the rest of the suite they use the real ``httpx.AsyncClient``, because +the connection path is what is under test, with three stand-ins: + +- ``dns`` replaces the event loop's ``getaddrinfo``, the one lookup both the + guard and a name-based connect go through, with scripted answers per name + (an answer per lookup, the last one repeating). It is patched that low so a + second, unchecked resolution anywhere in the stack would get the "rebound" + answer and be caught here. +- ``Origin`` is a real HTTP (or HTTPS) server on loopback that records what it + was asked. +- ``Nat`` stands in for the route to a public address: a connection to + ``PUBLIC_IP`` lands on loopback, and every address a connection was opened + to is recorded. Without it a test could only ever prove a refusal. + +The HTTPS tests issue their own certificates with ``cryptography``, which the +MCP SDK already depends on; it is not a dependency of this server. +""" + +from __future__ import annotations + +import asyncio +import datetime +import ipaddress +import socket +import ssl +from collections.abc import AsyncIterator, Iterable, Sequence +from contextlib import asynccontextmanager +from dataclasses import dataclass, field +from pathlib import Path +from typing import Any, cast + +import httpcore +import httpx +import pytest +from cryptography import x509 +from cryptography.hazmat.primitives import hashes, serialization +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.x509.oid import ExtendedKeyUsageOID, NameOID +from mcp.types import CallToolResult + +import mcp_server_fetch.server as server_module +from mcp_server_fetch import pinning +from mcp_server_fetch.pinning import ( + PinnedBackend, + PinnedTransport, + pin_direct_connections, +) + +from .harness import PUBLIC_IP, connect + +TOOL_ERROR = "Error executing tool fetch: " +RAW_PREFIX = "Content type text/plain cannot be simplified to markdown" + + +def text_of(result: CallToolResult) -> str: + assert len(result.content) == 1 + block = result.content[0] + assert block.type == "text" + return block.text + + +# --- stand-ins --------------------------------------------------------------- + + +@dataclass +class FakeDns: + """Scripted ``getaddrinfo`` answers: one per lookup, the last repeating.""" + + answers: dict[str, list[list[str]]] = field(default_factory=dict) + lookups: list[str] = field(default_factory=list) + + def answer(self, host: str) -> list[str] | None: + script = self.answers.get(host) + if script is None: + return None + self.lookups.append(host) + return script.pop(0) if len(script) > 1 else script[0] + + +@pytest.fixture +def dns(monkeypatch: pytest.MonkeyPatch) -> FakeDns: + fake = FakeDns() + real = asyncio.BaseEventLoop.getaddrinfo + + async def getaddrinfo( + self: asyncio.BaseEventLoop, host: Any, port: Any, **kwargs: Any + ) -> Any: + # anyio hands a name over IDNA-encoded, as bytes. + name = host.decode("ascii") if isinstance(host, bytes) else host + addresses = fake.answer(name) if isinstance(name, str) else None + if addresses is None: + return await real(self, host, port, **kwargs) + if not addresses: + raise socket.gaierror(socket.EAI_NONAME, "Name or service not known") + return [ + ( + socket.AF_INET6 if ":" in address else socket.AF_INET, + socket.SOCK_STREAM, + socket.IPPROTO_TCP, + "", + (address, port or 0), + ) + for address in addresses + ] + + monkeypatch.setattr(asyncio.BaseEventLoop, "getaddrinfo", getaddrinfo) + return fake + + +@dataclass +class Origin: + """A loopback HTTP server: path -> (status, headers, body).""" + + routes: dict[str, tuple[int, dict[str, str], bytes]] = field(default_factory=dict) + # (request line, headers) of every request received. + requests: list[tuple[str, dict[str, str]]] = field(default_factory=list) + # The SNI name of every TLS handshake received. + sni: list[str | None] = field(default_factory=list) + port: int = 0 + + def lines(self) -> list[str]: + return [line for line, _ in self.requests] + + async def handle( + self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter + ) -> None: + try: + head = (await reader.readuntil(b"\r\n\r\n")).decode("latin-1") + request_line, *header_lines = head.strip().split("\r\n") + headers = { + name.strip().lower(): value.strip() + for name, _, value in (line.partition(":") for line in header_lines) + } + self.requests.append((request_line, headers)) + target = request_line.split(" ")[1] + status, extra, body = self.routes.get(target, (404, {}, b"not found")) + response_headers = { + "Content-Type": "text/plain", + "Content-Length": str(len(body)), + "Connection": "close", + **extra, + } + writer.write( + f"HTTP/1.1 {status} X\r\n".encode() + + "".join(f"{k}: {v}\r\n" for k, v in response_headers.items()).encode() + + b"\r\n" + + body + ) + await writer.drain() + except (asyncio.IncompleteReadError, ConnectionError): + # A client that gave up mid-handshake (a refused certificate). + pass + finally: + writer.close() + + +@asynccontextmanager +async def serving( + origin: Origin, tls: ssl.SSLContext | None = None +) -> AsyncIterator[Origin]: + if tls is not None: + tls.sni_callback = lambda _socket, name, _context: origin.sni.append(name) + server = await asyncio.start_server(origin.handle, "127.0.0.1", 0, ssl=tls) + origin.port = server.sockets[0].getsockname()[1] + try: + yield origin + finally: + server.close() + await server.wait_closed() + + +def real_backend() -> httpcore.AsyncNetworkBackend: + # The cast is the one in pinning.py: a type checker sees httpcore's + # placeholder declaration of AnyIOBackend. + return cast(httpcore.AsyncNetworkBackend, httpcore.AnyIOBackend()) + + +class Nat(httpcore.AsyncNetworkBackend): + """Opens real connections, landing ``PUBLIC_IP`` on loopback, and records them.""" + + def __init__(self) -> None: + self.real = real_backend() + self.connects: list[str] = [] + + async def connect_tcp( + self, + host: str, + port: int, + timeout: float | None = None, + local_address: str | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + self.connects.append(host) + return await self.real.connect_tcp( + "127.0.0.1" if host == PUBLIC_IP else host, + port, + timeout=timeout, + local_address=local_address, + socket_options=socket_options, + ) + + +@pytest.fixture +def nat(monkeypatch: pytest.MonkeyPatch) -> Nat: + """Put a `Nat` under every `PinnedBackend` the server builds.""" + backend = Nat() + monkeypatch.setattr(pinning.httpcore, "AnyIOBackend", lambda: backend) + return backend + + +@dataclass +class Certificates: + """A private CA and server contexts whose certificates it issued.""" + + directory: Path + key: ec.EllipticCurvePrivateKey = field( + default_factory=lambda: ec.generate_private_key(ec.SECP256R1()) + ) + + def __post_init__(self) -> None: + self.name = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "test CA")]) + self.certificate = self._issue( + self.name, self.key.public_key(), ca=True, names=[] + ) + self.ca_file = self.directory / "ca.pem" + self.ca_file.write_bytes( + self.certificate.public_bytes(serialization.Encoding.PEM) + ) + + def _issue( + self, + subject: x509.Name, + public_key: ec.EllipticCurvePublicKey, + ca: bool, + names: Sequence[x509.GeneralName], + ) -> x509.Certificate: + now = datetime.datetime.now(datetime.UTC) + builder = ( + x509.CertificateBuilder() + .subject_name(subject) + .issuer_name(self.name) + .public_key(public_key) + .serial_number(x509.random_serial_number()) + .not_valid_before(now - datetime.timedelta(days=1)) + .not_valid_after(now + datetime.timedelta(days=1)) + .add_extension(x509.BasicConstraints(ca=ca, path_length=None), True) + .add_extension( + x509.KeyUsage( + digital_signature=True, + key_cert_sign=ca, + crl_sign=ca, + content_commitment=False, + key_encipherment=False, + data_encipherment=False, + key_agreement=False, + encipher_only=False, + decipher_only=False, + ), + True, + ) + .add_extension(x509.SubjectKeyIdentifier.from_public_key(public_key), False) + .add_extension( + x509.AuthorityKeyIdentifier.from_issuer_public_key( + self.key.public_key() + ), + False, + ) + ) + if not ca: + builder = builder.add_extension( + x509.SubjectAlternativeName(names), False + ).add_extension( + x509.ExtendedKeyUsage([ExtendedKeyUsageOID.SERVER_AUTH]), False + ) + return builder.sign(self.key, hashes.SHA256()) + + def server_context(self, *names: x509.GeneralName) -> ssl.SSLContext: + """A server-side TLS context whose certificate is valid for ``names``.""" + key = ec.generate_private_key(ec.SECP256R1()) + certificate = self._issue( + x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "test server")]), + key.public_key(), + ca=False, + names=names, + ) + stem = f"server-{certificate.serial_number}" + cert_file = self.directory / f"{stem}.pem" + key_file = self.directory / f"{stem}.key" + cert_file.write_bytes(certificate.public_bytes(serialization.Encoding.PEM)) + key_file.write_bytes( + key.private_bytes( + serialization.Encoding.PEM, + serialization.PrivateFormat.PKCS8, + serialization.NoEncryption(), + ) + ) + context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + context.load_cert_chain(cert_file, key_file) + return context + + +@pytest.fixture +def certificates(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Certificates: + """A CA the server's HTTP client trusts (httpx reads ``SSL_CERT_FILE``).""" + issued = Certificates(tmp_path) + monkeypatch.setenv("SSL_CERT_FILE", str(issued.ca_file)) + return issued + + +@pytest.fixture(autouse=True) +def no_proxy_environment(monkeypatch: pytest.MonkeyPatch) -> None: + """Keep the machine's own proxy settings out of these real-client tests.""" + for name in (*server_module.PROXY_ENV_VARS, "NO_PROXY", "no_proxy"): + monkeypatch.delenv(name, raising=False) + + +# --- DNS rebinding, through the server --------------------------------------- + + +async def test_rebinding_on_the_requested_url_is_refused(dns: FakeDns) -> None: + """Public for the guard's lookup, loopback for the next one: never fetched.""" + async with serving(Origin({"/secret": (200, {}, b"internal secret")})) as origin: + dns.answers["rebind.test"] = [[PUBLIC_IP], ["127.0.0.1"]] + url = f"http://rebind.test:{origin.port}/secret" + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool("fetch", {"url": url}) + + assert result.is_error is True + assert text_of(result) == ( + f"{TOOL_ERROR}Refused to connect to rebind.test: it resolves to 127.0.0.1, " + "which is not a public address. Start the server with " + "--allow-private-ips to allow private, loopback and link-local addresses." + ) + assert origin.requests == [] + # The request hook's lookup, then the one made (and checked) to connect. + assert dns.lookups == ["rebind.test", "rebind.test"] + + +async def test_rebinding_on_a_redirect_hop_is_refused(dns: FakeDns, nat: Nat) -> None: + async with serving(Origin()) as origin: + rebound = f"http://rebind.test:{origin.port}/secret" + origin.routes["/start"] = (302, {"Location": rebound}, b"") + origin.routes["/secret"] = (200, {}, b"internal secret") + dns.answers["start.test"] = [[PUBLIC_IP]] + dns.answers["rebind.test"] = [[PUBLIC_IP], ["127.0.0.1"]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"http://start.test:{origin.port}/start"} + ) + + assert result.is_error is True + assert "Refused to connect to rebind.test: it resolves to 127.0.0.1" in text_of( + result + ) + assert origin.lines() == ["GET /start HTTP/1.1"] + # Only the first hop's checked address was ever connected to. + assert nat.connects == [PUBLIC_IP] + + +async def test_rebinding_during_the_robots_txt_check_is_refused(dns: FakeDns) -> None: + """The robots.txt request is pinned like the page's.""" + async with serving(Origin({"/robots.txt": (200, {}, b"")})) as origin: + dns.answers["rebind.test"] = [[PUBLIC_IP], ["127.0.0.1"]] + async with connect() as (session, _): + result = await session.call_tool( + "fetch", {"url": f"http://rebind.test:{origin.port}/secret"} + ) + + assert result.is_error is True + assert "Refused to connect to rebind.test: it resolves to 127.0.0.1" in text_of( + result + ) + assert origin.requests == [] + + +async def test_rebinding_is_refused_for_the_prompt_too(dns: FakeDns) -> None: + async with serving(Origin({"/secret": (200, {}, b"internal secret")})) as origin: + dns.answers["rebind.test"] = [[PUBLIC_IP], ["127.0.0.1"]] + async with connect() as (session, _): + result = await session.get_prompt( + "fetch", {"url": f"http://rebind.test:{origin.port}/secret"} + ) + + content = result.messages[0].content + assert content.type == "text" + assert content.text.startswith("Refused to connect to rebind.test") + assert origin.requests == [] + + +async def test_a_mixed_answer_at_connect_time_is_refused(dns: FakeDns) -> None: + """Every address of the connect-time answer is checked, not only the first.""" + async with serving(Origin({"/secret": (200, {}, b"internal secret")})) as origin: + dns.answers["rebind.test"] = [[PUBLIC_IP], [PUBLIC_IP, "10.0.0.5"]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"http://rebind.test:{origin.port}/secret"} + ) + + assert result.is_error is True + assert "it resolves to 10.0.0.5" in text_of(result) + assert origin.requests == [] + + +# --- the connection goes to the checked address, as the hostname -------------- + + +async def test_connects_to_the_checked_address_and_keeps_the_host_header( + dns: FakeDns, nat: Nat +) -> None: + async with serving( + Origin( + {"/robots.txt": (404, {}, b""), "/page": (200, {}, b"hello from origin")} + ) + ) as origin: + dns.answers["pinned.test"] = [[PUBLIC_IP]] + async with connect() as (session, _): + result = await session.call_tool( + "fetch", {"url": f"http://pinned.test:{origin.port}/page"} + ) + + assert result.is_error is False + assert text_of(result).startswith(RAW_PREFIX) + assert text_of(result).endswith("hello from origin") + # Two connections (robots.txt, then the page), each to the address that + # was checked, given as an IP literal: nothing below resolved the name. + assert nat.connects == [PUBLIC_IP, PUBLIC_IP] + assert origin.lines() == ["GET /robots.txt HTTP/1.1", "GET /page HTTP/1.1"] + assert [headers["host"] for _, headers in origin.requests] == [ + f"pinned.test:{origin.port}" + ] * 2 + + +async def test_a_redirect_hop_is_resolved_checked_and_pinned_on_its_own( + dns: FakeDns, nat: Nat +) -> None: + async with serving(Origin()) as origin: + origin.routes["/start"] = ( + 302, + {"Location": f"http://second.test:{origin.port}/page"}, + b"", + ) + origin.routes["/page"] = (200, {}, b"second hop") + dns.answers["first.test"] = [[PUBLIC_IP]] + dns.answers["second.test"] = [[PUBLIC_IP]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"http://first.test:{origin.port}/start"} + ) + + assert text_of(result).endswith("second hop") + assert nat.connects == [PUBLIC_IP, PUBLIC_IP] + assert [headers["host"] for _, headers in origin.requests] == [ + f"first.test:{origin.port}", + f"second.test:{origin.port}", + ] + # Each hop: the hook's lookup, then the checked lookup that connects. + assert dns.lookups == ["first.test"] * 2 + ["second.test"] * 2 + + +async def test_tls_sends_the_hostname_as_sni_and_verifies_the_certificate_for_it( + dns: FakeDns, nat: Nat, certificates: Certificates +) -> None: + """Connected by address, yet the handshake is for the name in the URL.""" + tls = certificates.server_context(x509.DNSName("pinned.test")) + async with serving(Origin({"/page": (200, {}, b"over tls")}), tls) as origin: + dns.answers["pinned.test"] = [[PUBLIC_IP]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"https://pinned.test:{origin.port}/page"} + ) + + assert result.is_error is False + assert text_of(result).endswith("over tls") + assert nat.connects == [PUBLIC_IP] + assert origin.sni == ["pinned.test"] + assert origin.requests[0][1]["host"] == f"pinned.test:{origin.port}" + + +async def test_tls_refuses_a_certificate_issued_for_another_name( + dns: FakeDns, nat: Nat, certificates: Certificates +) -> None: + tls = certificates.server_context(x509.DNSName("pinned.test")) + async with serving(Origin({"/page": (200, {}, b"over tls")}), tls) as origin: + dns.answers["other.test"] = [[PUBLIC_IP]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"https://other.test:{origin.port}/page"} + ) + + assert result.is_error is True + assert "CERTIFICATE_VERIFY_FAILED" in text_of(result) + assert origin.sni == ["other.test"] + assert origin.requests == [] + + +async def test_tls_refuses_a_certificate_issued_for_the_address_only( + dns: FakeDns, nat: Nat, certificates: Certificates +) -> None: + """The certificate is checked against the hostname, never the pinned address.""" + tls = certificates.server_context( + x509.IPAddress(ipaddress.ip_address(PUBLIC_IP)), + x509.IPAddress(ipaddress.ip_address("127.0.0.1")), + ) + async with serving(Origin({"/page": (200, {}, b"over tls")}), tls) as origin: + dns.answers["pinned.test"] = [[PUBLIC_IP]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"https://pinned.test:{origin.port}/page"} + ) + + assert result.is_error is True + assert "CERTIFICATE_VERIFY_FAILED" in text_of(result) + assert origin.requests == [] + + +# --- what stays as it was ---------------------------------------------------- + + +async def test_allow_private_ips_still_fetches_a_private_address(dns: FakeDns) -> None: + async with serving( + Origin({"/robots.txt": (404, {}, b""), "/page": (200, {}, b"local page")}) + ) as origin: + dns.answers["intranet.test"] = [["127.0.0.1"]] + async with connect(allow_private_ips=True) as (session, _): + by_name = await session.call_tool( + "fetch", {"url": f"http://intranet.test:{origin.port}/page"} + ) + by_address = await session.call_tool( + "fetch", {"url": f"http://127.0.0.1:{origin.port}/page"} + ) + + assert text_of(by_name).endswith("local page") + assert text_of(by_address).endswith("local page") + + +async def test_a_private_address_is_still_refused_before_connecting( + dns: FakeDns, nat: Nat +) -> None: + """The request hook's refusal, naming the URL, is unchanged.""" + dns.answers["intranet.test"] = [["10.0.0.5"]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool("fetch", {"url": "http://intranet.test/page"}) + + assert text_of(result).startswith( + f"{TOOL_ERROR}Refused to fetch http://intranet.test/page: " + "intranet.test resolves to 10.0.0.5" + ) + assert nat.connects == [] + + +async def test_an_unresolvable_host_is_a_connection_failure(dns: FakeDns) -> None: + dns.answers["nowhere.test"] = [[]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool("fetch", {"url": "http://nowhere.test/page"}) + + assert result.is_error is True + assert text_of(result).startswith( + f"{TOOL_ERROR}Failed to fetch http://nowhere.test/page: ConnectError(" + ) + + +async def test_a_proxied_request_is_left_to_the_proxy(dns: FakeDns, nat: Nat) -> None: + """A loopback proxy is reachable, and resolves the destination itself.""" + proxied = "http://only-the-proxy-resolves.test/page" + async with serving(Origin({proxied: (200, {}, b"via proxy")})) as proxy: + # Unresolvable here, so the hook cannot check it either (the README + # says so): the proxy is asked for the name. + dns.answers["only-the-proxy-resolves.test"] = [[]] + async with connect( + ignore_robots_txt=True, proxy_url=f"http://127.0.0.1:{proxy.port}" + ) as (session, _): + result = await session.call_tool("fetch", {"url": proxied}) + + assert result.is_error is False + assert text_of(result).endswith("via proxy") + assert proxy.lines() == [f"GET {proxied} HTTP/1.1"] + # The pinned backend was never used: the proxy transport made the connection. + assert nat.connects == [] + + +async def test_a_proxy_from_the_environment_is_still_used( + dns: FakeDns, nat: Nat, monkeypatch: pytest.MonkeyPatch +) -> None: + proxied = "http://only-the-proxy-resolves.test/page" + async with serving(Origin({proxied: (200, {}, b"via env proxy")})) as proxy: + monkeypatch.setenv("HTTP_PROXY", f"http://127.0.0.1:{proxy.port}") + dns.answers["only-the-proxy-resolves.test"] = [[]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool("fetch", {"url": proxied}) + + assert text_of(result).endswith("via env proxy") + assert proxy.lines() == [f"GET {proxied} HTTP/1.1"] + assert nat.connects == [] + + +async def test_a_proxied_request_to_a_private_name_is_still_refused( + dns: FakeDns, +) -> None: + """With a proxy, a name that resolves here is checked by the hook, as before.""" + async with serving(Origin()) as proxy: + dns.answers["intranet.test"] = [["10.0.0.5"]] + async with connect( + ignore_robots_txt=True, proxy_url=f"http://127.0.0.1:{proxy.port}" + ) as (session, _): + result = await session.call_tool( + "fetch", {"url": "http://intranet.test/page"} + ) + + assert "intranet.test resolves to 10.0.0.5" in text_of(result) + assert proxy.requests == [] + + +async def test_a_host_the_environment_exempts_from_the_proxy_is_pinned( + dns: FakeDns, monkeypatch: pytest.MonkeyPatch +) -> None: + """NO_PROXY sends the request direct, so rebinding is refused there too.""" + async with serving(Origin({"/secret": (200, {}, b"internal secret")})) as origin: + monkeypatch.setenv("HTTP_PROXY", "http://127.0.0.1:9") + monkeypatch.setenv("NO_PROXY", "rebind.test") + dns.answers["rebind.test"] = [[PUBLIC_IP], ["127.0.0.1"]] + async with connect(ignore_robots_txt=True) as (session, _): + result = await session.call_tool( + "fetch", {"url": f"http://rebind.test:{origin.port}/secret"} + ) + + assert "Refused to connect to rebind.test: it resolves to 127.0.0.1" in text_of( + result + ) + assert origin.requests == [] + + +# --- PinnedBackend on its own ------------------------------------------------ + + +class FakeStream(httpcore.AsyncNetworkStream): + def __init__(self, address: str) -> None: + self.address = address + self.closed = False + + async def aclose(self) -> None: + self.closed = True + + +class FakeInner(httpcore.AsyncNetworkBackend): + """Connects by script: an address fails, hangs, or yields a `FakeStream`.""" + + def __init__(self, fail: Sequence[str] = (), hang: Sequence[str] = ()) -> None: + self.fail = fail + self.hang = hang + self.calls: list[tuple[str, int, float | None]] = [] + self.streams: dict[str, FakeStream] = {} + self.cancelled: list[str] = [] + self.slept: list[float] = [] + self.unix: list[str] = [] + + async def connect_tcp( + self, + host: str, + port: int, + timeout: float | None = None, + local_address: str | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + self.calls.append((host, port, timeout)) + if host in self.fail: + raise httpcore.ConnectError(f"cannot reach {host}") + if host in self.hang: + try: + await asyncio.Event().wait() + except asyncio.CancelledError: + self.cancelled.append(host) + raise + self.streams[host] = FakeStream(host) + return self.streams[host] + + async def connect_unix_socket( + self, + path: str, + timeout: float | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + self.unix.append(path) + return FakeStream(path) + + async def sleep(self, seconds: float) -> None: + self.slept.append(seconds) + + +def backend_for( + addresses: Sequence[str], inner: httpcore.AsyncNetworkBackend +) -> tuple[PinnedBackend, list[tuple[str, list[str]]]]: + vetted: list[tuple[str, list[str]]] = [] + + async def resolve(host: str) -> Sequence[str]: + return addresses + + def vet(host: str, found: Sequence[str]) -> None: + vetted.append((host, list(found))) + + return PinnedBackend(resolve, vet, inner), vetted + + +def address_of(stream: httpcore.AsyncNetworkStream) -> str: + assert isinstance(stream, FakeStream) + return stream.address + + +async def test_backend_vets_every_address_once_and_connects_by_address() -> None: + inner = FakeInner() + # getaddrinfo lists an address once per socket type. + backend, vetted = backend_for(["192.0.2.1", "192.0.2.1", "192.0.2.2"], inner) + + stream = await backend.connect_tcp("name.test", 443) + + assert vetted == [("name.test", ["192.0.2.1", "192.0.2.2"])] + assert address_of(stream) == "192.0.2.1" + assert inner.calls == [("192.0.2.1", 443, None)] + + +async def test_backend_does_not_connect_when_the_vetter_refuses() -> None: + inner = FakeInner() + + async def resolve(host: str) -> Sequence[str]: + return ["192.0.2.1"] + + def vet(host: str, found: Sequence[str]) -> None: + raise PermissionError(f"{host} refused") + + with pytest.raises(PermissionError, match="name.test refused"): + await PinnedBackend(resolve, vet, inner).connect_tcp("name.test", 80) + assert inner.calls == [] + + +async def test_backend_reports_an_unresolvable_host_as_a_connect_error() -> None: + async def resolve(host: str) -> Sequence[str]: + raise socket.gaierror(socket.EAI_NONAME, "Name or service not known") + + backend = PinnedBackend(resolve, lambda host, found: None, FakeInner()) + with pytest.raises(httpcore.ConnectError, match="Name or service not known"): + await backend.connect_tcp("name.test", 80) + + +async def test_backend_bounds_the_lookup_by_the_connect_timeout() -> None: + async def resolve(host: str) -> Sequence[str]: + await asyncio.Event().wait() + return [] + + backend = PinnedBackend(resolve, lambda host, found: None, FakeInner()) + with pytest.raises(httpcore.ConnectTimeout, match="Timed out resolving name.test"): + await backend.connect_tcp("name.test", 80, timeout=0.05) + + +async def test_backend_takes_the_lookup_out_of_the_time_left_to_connect() -> None: + inner = FakeInner() + + async def resolve(host: str) -> Sequence[str]: + await asyncio.sleep(0.1) + return ["192.0.2.1"] + + backend = PinnedBackend(resolve, lambda host, found: None, inner) + await backend.connect_tcp("name.test", 80, timeout=30) + + ((_, _, left),) = inner.calls + assert left is not None and 0 < left < 30 + + +async def test_backend_reports_a_host_with_no_addresses_as_a_connect_error() -> None: + backend, _ = backend_for([], FakeInner()) + with pytest.raises(httpcore.ConnectError, match="name.test has no addresses"): + await backend.connect_tcp("name.test", 80) + + +async def test_backend_falls_back_to_the_next_address_when_one_fails() -> None: + inner = FakeInner(fail=["192.0.2.1"]) + backend, _ = backend_for(["192.0.2.1", "192.0.2.2"], inner) + + stream = await backend.connect_tcp("name.test", 80) + + assert address_of(stream) == "192.0.2.2" + assert [host for host, _, _ in inner.calls] == ["192.0.2.1", "192.0.2.2"] + + +async def test_backend_raises_the_first_failure_when_every_address_fails() -> None: + inner = FakeInner(fail=["192.0.2.1", "192.0.2.2"]) + backend, _ = backend_for(["192.0.2.1", "192.0.2.2"], inner) + + with pytest.raises(httpcore.ConnectError, match="cannot reach 192.0.2.1"): + await backend.connect_tcp("name.test", 80) + assert len(inner.calls) == 2 + + +async def test_backend_tries_the_next_address_beside_one_that_does_not_answer( + monkeypatch: pytest.MonkeyPatch, +) -> None: + # Several ticks of Windows' ~16 ms clock, so the second attempt is + # measurably later than the first. + monkeypatch.setattr(pinning, "CONNECTION_ATTEMPT_DELAY", 0.1) + inner = FakeInner(hang=["192.0.2.1"]) + backend, _ = backend_for(["192.0.2.1", "192.0.2.2"], inner) + + stream = await backend.connect_tcp("name.test", 80, timeout=30) + + assert address_of(stream) == "192.0.2.2" + # The attempt that lost the race is cancelled, not left running. + assert inner.cancelled == ["192.0.2.1"] + # Both attempts share the one connect timeout: the later one gets less. + (_, _, first), (_, _, second) = inner.calls + assert first is not None and second is not None + assert 0 < second < first <= 30 + + +async def test_backend_cancels_its_attempts_when_the_caller_gives_up() -> None: + inner = FakeInner(hang=["192.0.2.1"]) + backend, _ = backend_for(["192.0.2.1"], inner) + + with pytest.raises(asyncio.TimeoutError): + await asyncio.wait_for(backend.connect_tcp("name.test", 80), 0.05) + assert inner.cancelled == ["192.0.2.1"] + + +class SimultaneousInner(FakeInner): + """The first address finishes only once the second has, in the same tick.""" + + def __init__(self) -> None: + super().__init__() + self.second_started = asyncio.Event() + + async def connect_tcp( + self, + host: str, + port: int, + timeout: float | None = None, + local_address: str | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + if host == "192.0.2.1": + await self.second_started.wait() + else: + self.second_started.set() + return await super().connect_tcp(host, port, timeout) + + +async def test_backend_closes_a_connection_that_also_won( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(pinning, "CONNECTION_ATTEMPT_DELAY", 0.01) + inner = SimultaneousInner() + backend, _ = backend_for(["192.0.2.1", "192.0.2.2"], inner) + + stream = await backend.connect_tcp("name.test", 80) + + assert set(inner.streams) == {"192.0.2.1", "192.0.2.2"} + spare = [s for s in inner.streams.values() if s is not stream] + assert [s.closed for s in spare] == [True] + assert isinstance(stream, FakeStream) and not stream.closed + + +class StubbornInner(FakeInner): + """The first address answers a cancellation by connecting anyway.""" + + async def connect_tcp( + self, + host: str, + port: int, + timeout: float | None = None, + local_address: str | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + if host == "192.0.2.1": + try: + await asyncio.Event().wait() + except asyncio.CancelledError: + pass + return await super().connect_tcp(host, port, timeout) + + +async def test_backend_closes_a_connection_that_completes_after_losing( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(pinning, "CONNECTION_ATTEMPT_DELAY", 0.01) + inner = StubbornInner() + backend, _ = backend_for(["192.0.2.1", "192.0.2.2"], inner) + + stream = await backend.connect_tcp("name.test", 80) + + assert address_of(stream) == "192.0.2.2" + assert inner.streams["192.0.2.1"].closed is True + + +class SlowLoserInner(FakeInner): + """The first address takes a while to wind down once it is cancelled.""" + + def __init__(self) -> None: + super().__init__() + self.winding_down = asyncio.Event() + + async def connect_tcp( + self, + host: str, + port: int, + timeout: float | None = None, + local_address: str | None = None, + socket_options: Iterable[Any] | None = None, + ) -> httpcore.AsyncNetworkStream: + if host == "192.0.2.1": + try: + await asyncio.Event().wait() + except asyncio.CancelledError: + self.winding_down.set() + await asyncio.sleep(30) + return await super().connect_tcp(host, port, timeout) + + +async def test_backend_closes_the_winner_when_cancelled_while_cleaning_up( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """A connection that was won but never handed over is not leaked.""" + monkeypatch.setattr(pinning, "CONNECTION_ATTEMPT_DELAY", 0.01) + inner = SlowLoserInner() + backend, _ = backend_for(["192.0.2.1", "192.0.2.2"], inner) + + connecting = asyncio.ensure_future(backend.connect_tcp("name.test", 80)) + # The second address has won; the first is still being torn down. + await inner.winding_down.wait() + assert not inner.streams["192.0.2.2"].closed + connecting.cancel() + + with pytest.raises(asyncio.CancelledError): + await connecting + assert inner.streams["192.0.2.2"].closed is True + assert "192.0.2.1" not in inner.streams + + +async def test_backend_passes_unix_sockets_and_sleep_through() -> None: + inner = FakeInner() + backend, vetted = backend_for(["192.0.2.1"], inner) + + stream = await backend.connect_unix_socket("/tmp/socket") + await backend.sleep(0.5) + + assert address_of(stream) == "/tmp/socket" + assert inner.unix == ["/tmp/socket"] + assert inner.slept == [0.5] + assert vetted == [] + + +async def test_backend_defaults_to_the_real_network_backend(dns: FakeDns) -> None: + """With no inner backend given, a real socket is opened to the vetted address.""" + async with serving(Origin()) as origin: + + async def resolve(host: str) -> Sequence[str]: + return ["127.0.0.1"] + + stream = await PinnedBackend(resolve, lambda host, found: None).connect_tcp( + "name.test", origin.port, timeout=5 + ) + await stream.aclose() + + +# --- pin_direct_connections -------------------------------------------------- + + +async def no_addresses(host: str) -> Sequence[str]: + return [] + + +def accept(host: str, found: Sequence[str]) -> None: + return None + + +async def test_pinning_replaces_only_the_direct_transport() -> None: + async with httpx.AsyncClient(proxy="http://127.0.0.1:9") as client: + mounts_before = dict(client._mounts) + pin_direct_connections(client, no_addresses, accept) + assert isinstance(client._transport, PinnedTransport) + assert client._mounts == mounts_before + assert not any(isinstance(t, PinnedTransport) for t in client._mounts.values()) + + +async def test_pinning_refuses_a_client_it_does_not_recognize() -> None: + """Fail loudly, rather than leave a client unpinned, if httpx changes shape.""" + transport = httpx.MockTransport(lambda request: httpx.Response(200)) + async with httpx.AsyncClient(transport=transport) as client: + with pytest.raises(TypeError, match="Cannot pin connections"): + pin_direct_connections(client, no_addresses, accept) + + +async def test_make_client_pins_unless_private_addresses_are_allowed() -> None: + async with server_module.make_client(None) as pinned: + assert isinstance(pinned._transport, PinnedTransport) + async with server_module.make_client(None, allow_private_ips=True) as unpinned: + assert not isinstance(unpinned._transport, PinnedTransport) diff --git a/src/fetch/tests/test_readability_js_opt_out.py b/src/fetch/tests/test_readability_js_opt_out.py index 1a428d04c1..d621c6fee3 100644 --- a/src/fetch/tests/test_readability_js_opt_out.py +++ b/src/fetch/tests/test_readability_js_opt_out.py @@ -79,7 +79,7 @@ def test_flag_is_passed_to_serve(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr(mcp_server_fetch, "serve", serve) monkeypatch.setattr(sys, "argv", ["mcp-server-fetch", "--no-readability-js"]) mcp_server_fetch.main() - serve.assert_awaited_once_with(None, False, None, False, None, False) + serve.assert_awaited_once_with(None, False, None, False, None, False, "stdio") def test_flag_is_in_help( diff --git a/src/fetch/uv.lock b/src/fetch/uv.lock index e7dd78b783..6a2c8ad414 100644 --- a/src/fetch/uv.lock +++ b/src/fetch/uv.lock @@ -1,12 +1,10 @@ version = 1 revision = 5 -requires-python = ">=3.10" +requires-python = ">=3.11.5" resolution-markers = [ "python_full_version >= '3.14'", "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", - "python_full_version < '3.11'", + "python_full_version < '3.12' or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", ] [[package]] @@ -23,7 +21,6 @@ name = "anyio" version = "4.16.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "idna" }, { name = "typing-extensions", marker = "python_full_version < '3.15'" }, ] @@ -41,22 +38,12 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309", size = 67548, upload-time = "2026-03-19T14:22:23.645Z" }, ] -[[package]] -name = "backports-asyncio-runner" -version = "1.2.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/8e/ff/70dca7d7cb1cbc0edb2c6cc0c38b65cba36cccc491eca64cabd5fe7f8670/backports_asyncio_runner-1.2.0.tar.gz", hash = "sha256:a5aa7b2b7d8f8bfcaa2b57313f70792df84e32a2a746f585213373f900b42162", size = 69893, upload-time = "2025-07-02T02:27:15.685Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/a0/59/76ab57e3fe74484f48a53f8e337171b4a2349e506eabe136d7e01d059086/backports_asyncio_runner-1.2.0-py3-none-any.whl", hash = "sha256:0da0a936a8aeb554eccb426dc55af3ba63bcdc69fa1a600b5bb305413a4477b5", size = 12313, upload-time = "2025-07-02T02:27:14.263Z" }, -] - [[package]] name = "beautifulsoup4" version = "4.15.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "soupsieve", version = "2.10", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11.5'" }, - { name = "soupsieve", version = "4.0.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11.5'" }, + { name = "soupsieve" }, { name = "typing-extensions" }, ] sdist = { url = "https://files.pythonhosted.org/packages/43/65/318323f98dbee45d42dff61d8f047181bc6f2268a9068cfad035a46be5af/beautifulsoup4-4.15.0.tar.gz", hash = "sha256:288e3ca7d54b06f2ac191970bc275c1939cb46d450b255bf6718b04aa37ab4f7", size = 632571, upload-time = "2026-06-07T16:44:20.453Z" } @@ -78,23 +65,10 @@ name = "cffi" version = "2.1.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "pycparser", version = "3.11", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11' and implementation_name != 'PyPy'" }, - { name = "pycparser", version = "3.12", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11' and implementation_name != 'PyPy'" }, + { name = "pycparser", marker = "implementation_name != 'PyPy'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/b6/d2/2cde336b375f55c76ca670f0be3978cc048e31e24f3b4d7ce8473150a388/cffi-2.1.1-cp310-cp310-macosx_10_15_x86_64.whl", hash = "sha256:baed1e86cc735622097354b9d1281406caf42ff42a886d29faa8e8d1630333be", size = 183779, upload-time = "2026-08-03T21:19:15.602Z" }, - { url = "https://files.pythonhosted.org/packages/94/1a/4b2f7c92293ba05cbd4a9a1b28faaf0326272d9488e6354657571c48a7aa/cffi-2.1.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ca82be1a1d406ecfe1d25dc16cb33488e5a16bf4438c9fb590484ea29d92478b", size = 184178, upload-time = "2026-08-03T21:19:16.67Z" }, - { url = "https://files.pythonhosted.org/packages/17/0b/ba385d8ccedf926c3cd06e8e2f327027da5afe5f0eb30f1f7bc43ac55125/cffi-2.1.1-cp310-cp310-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:42e2f76b9455f5a9a844f770bf3e200ed3da0e15f5df3db9c31fe80b04b3d004", size = 211037, upload-time = "2026-08-03T21:19:17.705Z" }, - { url = "https://files.pythonhosted.org/packages/a3/b9/0f2e58b2cefa33255bff36935d42b13180fe559bba82596540eb404bde7d/cffi-2.1.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:5a59cc1c4442bc3d5c703bf720b51138d0bfc173618807c9ee2490a7541dd3d9", size = 218652, upload-time = "2026-08-03T21:19:18.735Z" }, - { url = "https://files.pythonhosted.org/packages/37/15/180e0dab27b9312c7479003d14c9e547634b7dcb934e2cc4650e1b131a7a/cffi-2.1.1-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:9f8d177621de5cb38ee3e731eda45d421db093ec0739f46a5594babda7987a98", size = 205422, upload-time = "2026-08-03T21:19:19.96Z" }, - { url = "https://files.pythonhosted.org/packages/18/d4/03026f0c850cbbaa9030750490225b4a7f4d524ea4df72c3cc740a90f4ef/cffi-2.1.1-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:75f80557d1389eddbd0de2681f6a390a0c5338c31ddaa821381c203fc3fd50d9", size = 205444, upload-time = "2026-08-03T21:19:21.246Z" }, - { url = "https://files.pythonhosted.org/packages/75/77/60bebf6f818bec84210ac5b6979ce4eeadce6fbbaabc9c7ab23e506d1ce5/cffi-2.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:194cffa889098ced9976c3fc6340305e43f6303657d298da55366907c05c22d6", size = 218742, upload-time = "2026-08-03T21:19:22.523Z" }, - { url = "https://files.pythonhosted.org/packages/b0/ae/679bf47e73fd77b352171727f07de559a003f14de5d02b904a6ec1fa73ca/cffi-2.1.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:5bb4e7ea95dcd6a014a6fef62e62467d67d8e582326443f3d68e71d6320a9fcf", size = 221054, upload-time = "2026-08-03T21:19:23.694Z" }, - { url = "https://files.pythonhosted.org/packages/09/b8/eefc0e06913b70aa153bf74c946094a18f58fd4aff11b7f372bfdfdca050/cffi-2.1.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:3d22a20b1fb1632cc72c22f95f7b0d2961c3e1c235f245ba4c606c4771035659", size = 213489, upload-time = "2026-08-03T21:19:24.922Z" }, - { url = "https://files.pythonhosted.org/packages/6f/13/4e56852824a03cdf68523a35686f1c28eacd4bd30a7b0a78e682e6e6e1d3/cffi-2.1.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:1dea0e4d7d4f11f619fe8c1d76caf49e24405b4b5743c0e3be16a500ecd930c9", size = 220241, upload-time = "2026-08-03T21:19:26.214Z" }, - { url = "https://files.pythonhosted.org/packages/99/7f/040f9e163e4acac3ee3d85b02d00b2576e7ca980d8785f0a3a5f1a9bf7f5/cffi-2.1.1-cp310-cp310-win32.whl", hash = "sha256:7ce713ace7c0e4520535b42b77eaa742c16dab813978064913e5a3cf82973b41", size = 174578, upload-time = "2026-08-03T21:19:27.338Z" }, - { url = "https://files.pythonhosted.org/packages/ba/0b/644a2ec1a4eaba49c2939410bb1eb1d25b09d6d0582f5d2f95c537043725/cffi-2.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:a48d62ab9d6f4f98c983223a547af44be6ca3691074c31cecced6facd3ba2dc1", size = 185082, upload-time = "2026-08-03T21:19:28.409Z" }, { url = "https://files.pythonhosted.org/packages/70/d2/16d99a0c4948febc0ebd133a13b2f688ff7f8cb04da971e1128872ce0c03/cffi-2.1.1-cp311-cp311-macosx_10_15_x86_64.whl", hash = "sha256:c8d2c9fd1f2d16f780d15127abb050d13d1a76c03a4bd87d7e4980e45e511e12", size = 183838, upload-time = "2026-08-03T21:19:29.637Z" }, { url = "https://files.pythonhosted.org/packages/cd/95/31b535a9f0220ae9f357de4a08d57ce89cb417653c2fd9f075f50822a388/cffi-2.1.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:398aff33cee2767e3e781d2554c54bd0dff386bb437581e0d8011fde1a942ec1", size = 184168, upload-time = "2026-08-03T21:19:30.764Z" }, { url = "https://files.pythonhosted.org/packages/ad/5a/4707a0dc1f203f5dde5a907b0d4e3c25d71120241048bd5bc6f1bb9d4e71/cffi-2.1.1-cp311-cp311-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl", hash = "sha256:154852545011f779917b11c78db2358d095da62a9a172b78ad0a583ee5adc0d0", size = 211805, upload-time = "2026-08-03T21:19:31.867Z" }, @@ -190,22 +164,6 @@ version = "3.5.2" source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/33/1c/f41d4e74c28ab327ff3acd36053f7ea506c55872d7a90b0fa71aa3ab0c89/charset_normalizer-3.5.2.tar.gz", hash = "sha256:39de2a259fc954455c57274dc94c79d5842774e1247a016aff30bc0efed0f4ef", size = 172659, upload-time = "2026-09-30T04:39:23.398Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/98/77/46e87bcfc45d25ab4db7cfc9bb544bfa3ffd302289ed31ae93f5433eb899/charset_normalizer-3.5.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:195c26fb65950f8fce54e26349852b7bdd7c5f120aeefbcc440b8a20faaed4a3", size = 373348, upload-time = "2026-09-30T04:34:42.843Z" }, - { url = "https://files.pythonhosted.org/packages/52/fc/e518013affcc43c9f919c3ba41bffe9b4ee4aceb0a6462a6243efcca5f2d/charset_normalizer-3.5.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9373ad13ef0d2c0fb761e04e55bfdee5a08b52cef2c882c8fbe9935b1517152e", size = 260860, upload-time = "2026-09-30T04:34:44.817Z" }, - { url = "https://files.pythonhosted.org/packages/d5/ad/2a895c945ee61988dfd9ccee64f0b78dc09f29c9b34d1dd545246d78e0ad/charset_normalizer-3.5.2-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:ddf19c062bea7a0cc80f519243d2c01dd091be0cf952a0750d4ad576709559f5", size = 246491, upload-time = "2026-09-30T04:34:46.227Z" }, - { url = "https://files.pythonhosted.org/packages/c9/05/5d958bc8ea503e26be25ada5430fd409cfb45dc22ff33f9f96e649613c99/charset_normalizer-3.5.2-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3d14b50de6bf4d0edf857a9386836846f982b8f524e188e2e68b96d702bcf4aa", size = 290875, upload-time = "2026-09-30T04:34:47.691Z" }, - { url = "https://files.pythonhosted.org/packages/55/e2/06bad57dfdb49cad92c0ba85b6b4fa5827a67df37897287cfef0553843c2/charset_normalizer-3.5.2-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:28a15fdad492a99b6eccfaaed66ef3f74050680545ea61ec8b2f4c538f1f1320", size = 286987, upload-time = "2026-09-30T04:34:49.356Z" }, - { url = "https://files.pythonhosted.org/packages/c4/9f/9f52d2886d52645987d603425482c63c5045a3005db1354a7097e5ed1ae9/charset_normalizer-3.5.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8a893cc101149f80a653f82062ebc95b34525a2614382e1da5458fe7c6997249", size = 271105, upload-time = "2026-09-30T04:34:50.957Z" }, - { url = "https://files.pythonhosted.org/packages/4a/41/e05e19578b7b87e7db2c3ecb884bd09d065274ab41e1f535542e8bae9b06/charset_normalizer-3.5.2-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:619799369eeef6366ed3e8755a5670f4f2f0fb6b30a0fd7264dc0fdc2357058e", size = 269833, upload-time = "2026-09-30T04:34:52.623Z" }, - { url = "https://files.pythonhosted.org/packages/c2/cd/fc7152414561ff78f9c61a4a627025f65fd244abaefc99ac4e75c6169b33/charset_normalizer-3.5.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:447441e76ec720b15e64418d32e092297340387053047c7c694f579efb0ee1d9", size = 263048, upload-time = "2026-09-30T04:34:54.013Z" }, - { url = "https://files.pythonhosted.org/packages/71/71/fb379e399b1013962716a059d551e03bd80b3e02f05d81246886af6c0958/charset_normalizer-3.5.2-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:62588a277bfb59def052abd940703fa35107152bf479781a878617d60faf8fb5", size = 249237, upload-time = "2026-09-30T04:34:55.373Z" }, - { url = "https://files.pythonhosted.org/packages/33/4f/aeadccd6d20882909eb2597ec40eccc05d505e2262f14dc76d7620700657/charset_normalizer-3.5.2-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:44bd4fbb29dfbeba60e7d2bd000c59e4b21ddb3cc53912b14048d37092706d7c", size = 290756, upload-time = "2026-09-30T04:34:56.867Z" }, - { url = "https://files.pythonhosted.org/packages/b9/7b/e8a92613236b257d3b75d532496eb21f68ad8231d7d56df94497e460112e/charset_normalizer-3.5.2-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:30fcd120b732aa79317f08dee04d7de0847822e4cf7ee0e9f445bb958832252c", size = 269026, upload-time = "2026-09-30T04:34:58.278Z" }, - { url = "https://files.pythonhosted.org/packages/ff/ac/21d5c6b972285c5f095ff78afdc99f3539e3985dfcf7ff1cfbe9e772f529/charset_normalizer-3.5.2-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:50e3adfb96fc189eb27b1cf62d3b598b89b4bb0420d93a3d3e42e137409011be", size = 287601, upload-time = "2026-09-30T04:34:59.703Z" }, - { url = "https://files.pythonhosted.org/packages/59/72/263491ec1494a194b16fcbff88a0220f2af633738c79e92b4d7189226322/charset_normalizer-3.5.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:b736353c0a625bbd5fcec108576e2385db3496f4f771f785ff32e108d3c3bc45", size = 272660, upload-time = "2026-09-30T04:35:01.26Z" }, - { url = "https://files.pythonhosted.org/packages/38/7a/81f1186c57e406233969ae96b5fd0c907254ab8b6e47da8ae24cd20fb9d7/charset_normalizer-3.5.2-cp310-cp310-win32.whl", hash = "sha256:f5833ad231be5eb6553de524a70f48d71b2c8563101750531e0b80184e175cd4", size = 187301, upload-time = "2026-09-30T04:35:02.659Z" }, - { url = "https://files.pythonhosted.org/packages/ae/ab/fb8b5178fdf7bf68efa61cbe892286bc9f73846f26147d4725fb89388475/charset_normalizer-3.5.2-cp310-cp310-win_amd64.whl", hash = "sha256:1461ac396c4fdb983a675f20aa555624f0ee18ac83d832b9244ffff3d8055275", size = 215446, upload-time = "2026-09-30T04:35:04.011Z" }, - { url = "https://files.pythonhosted.org/packages/36/40/e270b74e0d3f583d78d902960845a149e80eb7c737ee5613ccc6efc7264b/charset_normalizer-3.5.2-cp310-cp310-win_arm64.whl", hash = "sha256:c6708715abcf3c73b99508253e961a9967f02fe536532834149574eda6de0d1c", size = 203389, upload-time = "2026-09-30T04:35:05.577Z" }, { url = "https://files.pythonhosted.org/packages/22/67/6a0b94a7960d5e1b5eacd2fb529f3fccc47db4644f7f0a7cfdcfc3be578a/charset_normalizer-3.5.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:3d21b8b13c7592db2ac5e544a6d83187b995257472b0c9e8351b6d507ae37ed6", size = 370642, upload-time = "2026-09-30T04:35:06.91Z" }, { url = "https://files.pythonhosted.org/packages/fb/94/01009e13b94041599004edf32e56e382c24e570f60f79bab8efe45cfe1eb/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d760fe2a4d7c3b226cb9026d6a842868d52a7901bd98420e1baf14e80da85cf5", size = 259280, upload-time = "2026-09-30T04:35:08.448Z" }, { url = "https://files.pythonhosted.org/packages/66/85/3b5358f60a13210f0b67d3755c168ef758701b021e655d88d4da28554467/charset_normalizer-3.5.2-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c9790464842f85f437dbbb54417eda1e0e6bfc52dd8d22d6fd1c994b73b2dc74", size = 245335, upload-time = "2026-09-30T04:35:10.104Z" }, @@ -365,152 +323,10 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, ] -[[package]] -name = "coverage" -version = "7.16.2" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -sdist = { url = "https://files.pythonhosted.org/packages/2f/55/d1eaf3e73781174340a00dc1ba2aee8a65f82fadb18e2797b192b6b3925b/coverage-7.16.2.tar.gz", hash = "sha256:ca64d9f1f384f151b9511bec01126072acd2f313439f8ed015a22d8790aab6fa", size = 971999, upload-time = "2026-09-27T12:29:01.118Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/60/72/db17bf5f87568ab524413693385be2eeb03e652ab56c54ea05fa85515675/coverage-7.16.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:23219888477edd736b6fcaec1272d47d93b926e999641ffea7e53a1738e70b2b", size = 223670, upload-time = "2026-09-27T12:25:34.675Z" }, - { url = "https://files.pythonhosted.org/packages/d1/e1/285727a8a74d48de256e8605413ee4cf82301228253ea58e5ab4270138b0/coverage-7.16.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:40c0f00899fe6181ae7f434ceb200e51f5ee4b8ed10e3b5f0b605f0cae15da87", size = 224191, upload-time = "2026-09-27T12:25:36.476Z" }, - { url = "https://files.pythonhosted.org/packages/50/c7/c737b73bac9bf5034f5ff45a4237b7a189d417a4e36751faf5d10c082cbe/coverage-7.16.2-cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:a4624f80732f6b427ac58f1f59c577a0994a12e8174b5af6a027b4b58795d4c3", size = 250921, upload-time = "2026-09-27T12:25:37.857Z" }, - { url = "https://files.pythonhosted.org/packages/29/4e/e1d38d27817d91776ca543d01276a67eace3df675a673cac32b12c167d58/coverage-7.16.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:191803c4996b499fcd78c2ad5e5f767dcc53cb4dc6de6d6a741b443a1821ef02", size = 252751, upload-time = "2026-09-27T12:25:39.291Z" }, - { url = "https://files.pythonhosted.org/packages/0e/19/14a8e44cbb2ad36ae62aaa03c5eec4a06a7f7df220ea3776af26927acbe2/coverage-7.16.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9fd670ac43b709c575aefc25bf52d8a598a3bc5017bddfd0a179152ab06a2deb", size = 254616, upload-time = "2026-09-27T12:25:40.506Z" }, - { url = "https://files.pythonhosted.org/packages/f9/72/f5bcad0d9a9b450080032344fbff7ec60c1b0e3d38019f7735dee2b69645/coverage-7.16.2-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:705e5af11d34647efdc170c7840b6857c81cf74be96419a553f237e68e62cb72", size = 256541, upload-time = "2026-09-27T12:25:41.785Z" }, - { url = "https://files.pythonhosted.org/packages/ae/9a/8c735234e8abb52bf5d063f98c780fa942e77c4c0225f9fcb9b33effc346/coverage-7.16.2-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8afd9bf35cc6a1f22eb3634808fa8e0b91902459c5721ef2e4461dfe771d7f08", size = 251589, upload-time = "2026-09-27T12:25:43.269Z" }, - { url = "https://files.pythonhosted.org/packages/35/6a/1bf6d32e55642d6972aa842640e0a8850e612d19ac7d05e2c32fa59dfd34/coverage-7.16.2-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:3f43bac1856ba269b905302778d4df433d6006489a192174ad77ac528e395032", size = 252660, upload-time = "2026-09-27T12:25:45.051Z" }, - { url = "https://files.pythonhosted.org/packages/53/5b/05b1c0d0e9495cb056155a16066259adc1e935e7411a82a62779bf729975/coverage-7.16.2-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:f8475460aa33ee28ac896ab1156d0bb3b6c639f7f8383c2677d3359eb35f8205", size = 250660, upload-time = "2026-09-27T12:25:46.51Z" }, - { url = "https://files.pythonhosted.org/packages/05/33/5bc3db57fc9c56b4ef055725c38c34faa818a27d17d65e251371f7f0e3a0/coverage-7.16.2-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:d6276d78f6fca7d0ac066d5da4165c5acd07829e8305c2cb900b738fb3a75a72", size = 254479, upload-time = "2026-09-27T12:25:47.819Z" }, - { url = "https://files.pythonhosted.org/packages/f6/0f/4a5de66daef26eb919213f63b84f45d5065ab2df94cd767fc7c1174ac5e2/coverage-7.16.2-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:736fde09ea39646d11f8e3b76bd3425c075aa4dd45f24891970bb77c14ff20f5", size = 250940, upload-time = "2026-09-27T12:25:49.227Z" }, - { url = "https://files.pythonhosted.org/packages/57/d3/84cd6a11e707e422194739e9734d947746efa5e5b3358ff2d601f823ee45/coverage-7.16.2-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:c85d54e7e8a2ca932fe8399301af9b8d5907ea2a455ffaff6e7d1208db83b943", size = 251543, upload-time = "2026-09-27T12:25:50.554Z" }, - { url = "https://files.pythonhosted.org/packages/ab/bc/3d84c2e2a95f38e346ce3730d9f0e53114f4e8aace72e6e51e014afb9992/coverage-7.16.2-cp310-cp310-win32.whl", hash = "sha256:5139009b5efd2194fc168ee9362f0e191ba612ef5d29242f9269c22f9b8f80c7", size = 225732, upload-time = "2026-09-27T12:25:51.945Z" }, - { url = "https://files.pythonhosted.org/packages/07/86/31f1f3170571a345ab9d8361a7b2f8e0c5698173fbecd1f7149b6e2089ee/coverage-7.16.2-cp310-cp310-win_amd64.whl", hash = "sha256:c3305c38a2fa21a4254f2ace7dd9ef5fc569c9a558b66e7017650b3d637fb95e", size = 226357, upload-time = "2026-09-27T12:25:53.272Z" }, - { url = "https://files.pythonhosted.org/packages/58/fa/ce3baf63d85b730398d92a7162f486f3a5e4e2cc3382a02488b3943725ba/coverage-7.16.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:732d950e51f3ba4fb6209c73250f3e8924fefca42953ee04a9e65d8c02414d7d", size = 223797, upload-time = "2026-09-27T12:25:54.756Z" }, - { url = "https://files.pythonhosted.org/packages/7a/57/9ba29c2aac7f756d479f03d45762120060f0f988788001001bf36e0e6fca/coverage-7.16.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5dca0bb66b4c3d624ba047887bf70270030c150692d543cb501293dc38a9f4b5", size = 224303, upload-time = "2026-09-27T12:25:56.214Z" }, - { url = "https://files.pythonhosted.org/packages/5d/7b/0d6d60906dca7d28cc1e3fce12a9861801c4fbb6cbf220ad78cd059c9467/coverage-7.16.2-cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:af2a2a8c7c74de0559e0c368d94c8def9e16c58faaee33a0bf081057c4227e3b", size = 254715, upload-time = "2026-09-27T12:25:57.755Z" }, - { url = "https://files.pythonhosted.org/packages/cd/b8/9198b865679379fb165c689c64f6e11105ef380f6bd1c7673e83f73d9f5c/coverage-7.16.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:db5f8394e17f877a625b257f2ba0ce8e728a499c2c1579ad66220272cd3df510", size = 256627, upload-time = "2026-09-27T12:25:59.131Z" }, - { url = "https://files.pythonhosted.org/packages/98/79/9521462cb6072fe394701bc8974b74afd576c9c9355156c7844e1a86a42b/coverage-7.16.2-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5b3146d2317c75f70df2509066d979dadd941f7021cdf9b5db4bcd8568258e25", size = 258724, upload-time = "2026-09-27T12:26:00.691Z" }, - { url = "https://files.pythonhosted.org/packages/a6/76/8d7d5d633db9fe0f3182fedc731bf09f9bcf2366055735152504ad614677/coverage-7.16.2-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9e1d0ced76318bab499693ff25f64faa343415187cb2e4d7befdfdd391a1cf6a", size = 260692, upload-time = "2026-09-27T12:26:02.083Z" }, - { url = "https://files.pythonhosted.org/packages/4e/a7/76cb09c89ba46d74d37428bf93251fc14fb0bbe9e05cc2a5ef61773d318a/coverage-7.16.2-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:af98ad5ed9d6daaca956201e00bb429a7eb2b080426686f70a20353e0f9839f5", size = 254800, upload-time = "2026-09-27T12:26:03.369Z" }, - { url = "https://files.pythonhosted.org/packages/72/b6/2351c1979aaeb5b4a8091a75b90ca997ad60de36e181ddba267cf61dac97/coverage-7.16.2-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1d56e4d21c56d2046447733f8b118409597db48c01efe898ee9ac24e858ec2d6", size = 256423, upload-time = "2026-09-27T12:26:04.751Z" }, - { url = "https://files.pythonhosted.org/packages/0f/f4/ad9a4f8b5cb2d494fa9452b546fe742ed2f9d3847cc14c05e36279a3e649/coverage-7.16.2-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:1d5d0e3b660506fb84f995814e3118a21efdc0c8eb80127da1be627d90093c17", size = 254487, upload-time = "2026-09-27T12:26:06.082Z" }, - { url = "https://files.pythonhosted.org/packages/6c/1f/a520470472f3e8b01169bf42162b1470c9ba992230432f62ca36269bf3a0/coverage-7.16.2-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:17228fbca0f22976f797be94e975dcd237799c657d49551c7de1e0654d1202e9", size = 258259, upload-time = "2026-09-27T12:26:07.513Z" }, - { url = "https://files.pythonhosted.org/packages/09/d2/ff26d5938274745855fa61cfcba0245c88ccc10d98d2cbd96064f16cd5a7/coverage-7.16.2-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:bc0b0ac781d489304b741269857f1f8338b7a26b1b89c06c0344658001ec0035", size = 254216, upload-time = "2026-09-27T12:26:08.982Z" }, - { url = "https://files.pythonhosted.org/packages/a4/1d/5d832d3b06785d9f53267e4f2724a9f60c312eee6ebed9063a461d0d3b45/coverage-7.16.2-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:bf1bd822ec4e387ed245bed0d71151582cf7be9e5309bc4145eefe36083d5878", size = 255125, upload-time = "2026-09-27T12:26:10.35Z" }, - { url = "https://files.pythonhosted.org/packages/55/4d/1d33edbc2fcf7d99e384e393e712aa5a2ebbbd8409825357815982207976/coverage-7.16.2-cp311-cp311-win32.whl", hash = "sha256:7ed238d227e23cc300c3d464babdaf9f6ddc740aa1b15a77ae96136e6a7c4516", size = 225898, upload-time = "2026-09-27T12:26:11.7Z" }, - { url = "https://files.pythonhosted.org/packages/6f/7c/676df4882118756c4f8f560c954eddb93e166d84dda8c5f0b6a829689bde/coverage-7.16.2-cp311-cp311-win_amd64.whl", hash = "sha256:a90700f743e29aa3d75a6ff5f01953176a889c00e526194bc4d281731b88d99d", size = 226369, upload-time = "2026-09-27T12:26:13.375Z" }, - { url = "https://files.pythonhosted.org/packages/7a/0e/a457f4a461b3c5610d845137fdd45fa465e011a64c25af440518ab1f4e41/coverage-7.16.2-cp311-cp311-win_arm64.whl", hash = "sha256:a336eec40e3520d369b8a6cdabb4f596e69a8b42927ca074aa1452fed943238a", size = 226344, upload-time = "2026-09-27T12:26:15.127Z" }, - { url = "https://files.pythonhosted.org/packages/5e/2c/f8296c63c5d542f3d21aed685e56b7031a419037d155bb3382fc0940d249/coverage-7.16.2-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:218d742afca2b5ad5ca759e93eddedfbcc6eadf8322f080dcefc40b7bd4e2d48", size = 223969, upload-time = "2026-09-27T12:26:16.753Z" }, - { url = "https://files.pythonhosted.org/packages/90/23/6f3dcb1423a0d43216e402ea1746e4a7c7c44f38896b97dd573790f56a40/coverage-7.16.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a9a638be322a8d76a41cdb17781c7f82aaee6a66493d8ffb7e2c09ee22423d99", size = 224328, upload-time = "2026-09-27T12:26:18.15Z" }, - { url = "https://files.pythonhosted.org/packages/ac/7d/8f3b6dc920e3fc6732f7678785a2091db439f186afbec30dbf2214d9b1f7/coverage-7.16.2-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:724bd0f1e81856b35e59fc98cf7b4e544a3cb662e4e0864dca73d4326ee9d808", size = 255832, upload-time = "2026-09-27T12:26:19.799Z" }, - { url = "https://files.pythonhosted.org/packages/d1/36/6c45f15be4eca4ac1062c6a55a323286494c99726a7e58951fe85967ac08/coverage-7.16.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:5375ebd99038021b35e99dc88255022912c06565d316212f4a576e4b08d30f5d", size = 258571, upload-time = "2026-09-27T12:26:21.199Z" }, - { url = "https://files.pythonhosted.org/packages/34/fb/b54cbeba3ad89082c2e441278681859e538322cc34b84b2af7ebff00080f/coverage-7.16.2-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:7a076277ca9f5750cc230f0f578ebd2620cec60255b25707361699fef6fb465c", size = 259680, upload-time = "2026-09-27T12:26:22.822Z" }, - { url = "https://files.pythonhosted.org/packages/6e/a2/0dc65ec3d61930e1e4c2e371763b15eb4290896eb343a12d5d3091308116/coverage-7.16.2-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:58d4a54c6ea672afef66d49be922a2c69826c5ae1a42a9cd94f0c9c2bacdf800", size = 261945, upload-time = "2026-09-27T12:26:24.336Z" }, - { url = "https://files.pythonhosted.org/packages/d6/93/5fad7a61f2c14e08e98946fc31c1c7ffc1195061bf3fdc351db3be77a863/coverage-7.16.2-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0dcbcfcc059117284c603ff8cb61a65872512882f84a8cf0339241f7f7c2f148", size = 256191, upload-time = "2026-09-27T12:26:25.89Z" }, - { url = "https://files.pythonhosted.org/packages/2d/47/74e5de9227b939ece9f64e729645ddc4296bea10dbfa98721c1333c8be2e/coverage-7.16.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:afdf43b72ef3876c1fe66423b91466e37877c9e81e8cec70542b7e8525b9d1b7", size = 257610, upload-time = "2026-09-27T12:26:27.35Z" }, - { url = "https://files.pythonhosted.org/packages/13/fe/2cf28d40b43645d1b72388fe3ee7f7c747533a6a9557bb8c24a7ae74fe1a/coverage-7.16.2-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:9acc7f7ec4a1b5f89bd929fde5b8a714f6fafdc6cc18725413d510aa082b47ad", size = 255757, upload-time = "2026-09-27T12:26:28.949Z" }, - { url = "https://files.pythonhosted.org/packages/d7/3d/7c149fd99fc8bbc39c80db5e688d1d39fd040be2ecb78b8335a51a55b9c0/coverage-7.16.2-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:80d3f7b48d43ee8fc5e8707a8adb43d743a5a1a85256c25a24f9d6d0e2238fa6", size = 259822, upload-time = "2026-09-27T12:26:30.515Z" }, - { url = "https://files.pythonhosted.org/packages/e6/3f/b283fce09d5995e227bd8e513358dd7471bedc0f78abc85a925ebdb0a2f6/coverage-7.16.2-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:126d1af8804d7224421fe991ff65d3ce649081560df7a98b1a5ffff07f9923bd", size = 255325, upload-time = "2026-09-27T12:26:32.037Z" }, - { url = "https://files.pythonhosted.org/packages/bf/91/f3325edf0c4223fb1fe1532b8dbef2a1d2f729459a9a7d1a44d073bae534/coverage-7.16.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c19cd6d025c1673f22afcd22c7df8a662d779e05d8e3fa6820c22afb895b0206", size = 257191, upload-time = "2026-09-27T12:26:33.525Z" }, - { url = "https://files.pythonhosted.org/packages/c4/89/21eb5e83ecf2eed523c4eb3d65ae513cd082c8fd1b6deb34c4cb6c332f97/coverage-7.16.2-cp312-cp312-win32.whl", hash = "sha256:152877cdc8a07264882cfcd503ba56a3ef6cba56a70e8c70f6eb8ffd7384789a", size = 226034, upload-time = "2026-09-27T12:26:35.021Z" }, - { url = "https://files.pythonhosted.org/packages/db/de/e3ad6d864c0833624b4f1f9b53f9e58e116c945e5e965c3f1e172c5e84cd/coverage-7.16.2-cp312-cp312-win_amd64.whl", hash = "sha256:e6c52d3307824ff93b39efd99e4185d557db40bd841452abfb32e5d9151ca162", size = 226569, upload-time = "2026-09-27T12:26:36.604Z" }, - { url = "https://files.pythonhosted.org/packages/3e/c1/bccc58ebe5489cc70628f635c1932fd371f5d7da850dbcf960f95f4c4afc/coverage-7.16.2-cp312-cp312-win_arm64.whl", hash = "sha256:a678c0b6b22086ec2427359d22e37445d4a792f5fdbbc744112c7dade65cad02", size = 226372, upload-time = "2026-09-27T12:26:38.406Z" }, - { url = "https://files.pythonhosted.org/packages/f0/f6/8eb4f220ef24f84fb27d852d4f9bf83e0c73ec1a4a08dd9a87e3f4529739/coverage-7.16.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1a37c6e478cf687e1aa30a593d19c92c02fad9d122b51ab73f51b8dc7a0c0fc9", size = 223993, upload-time = "2026-09-27T12:26:40.164Z" }, - { url = "https://files.pythonhosted.org/packages/40/23/d4bbaf0c154e0b0c2b5264890dbf6ef098dcb50ec8f2469be9490d191660/coverage-7.16.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:0993d0e90858c03943d3cb152e068a20dd4707924deec84dd2230261baae3b1b", size = 224368, upload-time = "2026-09-27T12:26:41.762Z" }, - { url = "https://files.pythonhosted.org/packages/7f/48/fc1e88fd571ec5cb38150b7f89f7696ca1bdf9920e01432febb69774cc85/coverage-7.16.2-cp313-cp313-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:bb2fc905bbf4e6b7f40806ea79e31515abf6349594cdf0adf27c4215f0463204", size = 255358, upload-time = "2026-09-27T12:26:43.442Z" }, - { url = "https://files.pythonhosted.org/packages/1d/56/6785397d07c29c8e70fbb9a07e97d062b43c21ffc5f12385917847f09f63/coverage-7.16.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:4358b9c8c0125b460407f3017c6cce8156e904b32772c5630d27112f52bdbfe5", size = 257955, upload-time = "2026-09-27T12:26:45.725Z" }, - { url = "https://files.pythonhosted.org/packages/27/3b/c8cdd07721e5f99abd81cea970d971997f99bf158c0b85f51bd284179c8b/coverage-7.16.2-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1f15254427c9b33eedac4f198eaf9e356eb4f6214551afb43da6194a2c088ad7", size = 259183, upload-time = "2026-09-27T12:26:47.208Z" }, - { url = "https://files.pythonhosted.org/packages/9b/11/606b192fe43d32574ec6238549d48de588fdcc18485682a5ec0a8ac357f2/coverage-7.16.2-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9a75a4704ff640e46170042eec1f984385a121227c505d5a16ad8e495f452541", size = 261325, upload-time = "2026-09-27T12:26:49.084Z" }, - { url = "https://files.pythonhosted.org/packages/67/90/eea481f8b0305ceeb33f081a5f47e298391dbd1b589de0c4b3b3aa50d3f2/coverage-7.16.2-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:14253fc7bb15749b849795a06f5d3b6d8bc3fb8a4b5ddc341faf7a89dce205fc", size = 255531, upload-time = "2026-09-27T12:26:50.509Z" }, - { url = "https://files.pythonhosted.org/packages/6b/be/dedbf9aea1457b120c27ac10b8fc2a357f37fa2b54c3e7286d42980a0a2a/coverage-7.16.2-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:921415102a90637fcc2e3f169f61dad7699ecf690e8639fc21b813acbedc0967", size = 257329, upload-time = "2026-09-27T12:26:52.005Z" }, - { url = "https://files.pythonhosted.org/packages/fa/cb/b25c19d5bb2bd0f2e4e27fe8e2ffcae80c7a91ae181c0dc749ed60e9b1a4/coverage-7.16.2-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:cce2bc991293f15cc4084ca116827b5900c5f34e1a54dfe83f10ab5c43162eb7", size = 255294, upload-time = "2026-09-27T12:26:53.634Z" }, - { url = "https://files.pythonhosted.org/packages/5f/a2/892c5c5f4ad44b7b2ca009aee705191f3f268f15052244f2f9e3539b2e35/coverage-7.16.2-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:e1fa594c887365b69745f25a416806e61085dd07b94c9eae68a6e20730629b23", size = 259444, upload-time = "2026-09-27T12:26:55.243Z" }, - { url = "https://files.pythonhosted.org/packages/ed/99/a562537deba0a3e370182ae71c149be796c39d8087365f17a09188f27145/coverage-7.16.2-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:11e597173af1dc33d5f8a7332ada544199269a223af1ee1770ddd5e245ad0fe8", size = 255111, upload-time = "2026-09-27T12:26:56.851Z" }, - { url = "https://files.pythonhosted.org/packages/2d/20/854ec68641a9b3362ff068a32dfa41637299761617ef253791dbade6fc76/coverage-7.16.2-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:3e7f99698ba3a7d13988bdd984b7ebf13af4dbe2166dc8502eef90d77603b0a4", size = 256882, upload-time = "2026-09-27T12:26:58.41Z" }, - { url = "https://files.pythonhosted.org/packages/db/0d/748e4518b0ac0f9ff2687c248a6e5f8c0737306e709372632a2556f84443/coverage-7.16.2-cp313-cp313-win32.whl", hash = "sha256:f80bd9f9633eafc73d0a913ba2645c96ba58bba1befc30590f7c0fbfde59d865", size = 226045, upload-time = "2026-09-27T12:26:59.983Z" }, - { url = "https://files.pythonhosted.org/packages/31/fa/6e46edba66a183fe4d99d4bb52c173287e9b8dddabe0888d24cb8210e580/coverage-7.16.2-cp313-cp313-win_amd64.whl", hash = "sha256:8be099e979fc42559328a21828281b4578304191ae46ed4e80a407048a82eee6", size = 226581, upload-time = "2026-09-27T12:27:01.494Z" }, - { url = "https://files.pythonhosted.org/packages/1b/d9/9ef6845367600b336ff75d000444a0d32497d6972c833141bd39356abf68/coverage-7.16.2-cp313-cp313-win_arm64.whl", hash = "sha256:28ff850182a67d117990fa2ce5ea1032836d8c9630dae867e8bdd3bff4533b79", size = 226409, upload-time = "2026-09-27T12:27:03.116Z" }, - { url = "https://files.pythonhosted.org/packages/59/4c/577fc0803dab4155dcf808faffbdd7b159256781c0874a8586e17b81b149/coverage-7.16.2-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:4ee546b9e4872ffa194bf07ac87bfa1202ebb824d0795dc1ef22f175545ca90a", size = 224138, upload-time = "2026-09-27T12:27:05.141Z" }, - { url = "https://files.pythonhosted.org/packages/75/9e/e3785ba3ecba2bd11efc74bfe2801ca4b78c4480b15a375648d809a59da3/coverage-7.16.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:a2fac6895eb299a2e52d7bbb8fb3903502b9da8d3f5309ceb16ec40c646b58ee", size = 224445, upload-time = "2026-09-27T12:27:06.805Z" }, - { url = "https://files.pythonhosted.org/packages/f0/d0/963ff22d3fd27117da3b8cc442f5bdc91196f783321e1a8ff0ec43476772/coverage-7.16.2-cp314-cp314-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:57ff3783f99d75a1e81dd56a9737eb5665e6736a5d93258ba596b6dcad8fd05b", size = 256112, upload-time = "2026-09-27T12:27:08.43Z" }, - { url = "https://files.pythonhosted.org/packages/a8/d4/a306940c81c6ae759e82fff27d20b7fdc6896e422b821f51313cce212b6c/coverage-7.16.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:35f37886699cb9abd29958247d718628d5bc6f39e623dff66a09e546c42a7e03", size = 258727, upload-time = "2026-09-27T12:27:09.927Z" }, - { url = "https://files.pythonhosted.org/packages/b9/a3/d3d99d93b02517087aa05bc0cf2d04d372956b849e5443e059079901429b/coverage-7.16.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0fd7a86fdda7cb6d616d178654bd0ad6bc0f3f33c2e478aa598500a1a9e34eda", size = 259909, upload-time = "2026-09-27T12:27:11.55Z" }, - { url = "https://files.pythonhosted.org/packages/08/44/39dd599181726758dd185ae4dc0c0ab3aeabf7ca70e68e145060feeaaa16/coverage-7.16.2-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:ac0f3b379c94acc2f7dce5f5f0b24d44fa1cc6a509717ef83dfee07450c2117c", size = 262481, upload-time = "2026-09-27T12:27:13.17Z" }, - { url = "https://files.pythonhosted.org/packages/99/e8/91ee43f6ded411460c359d7e1aebde4d6fd8f00a2e5394182d9d212eb23c/coverage-7.16.2-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:7d0732c83746bc24123c581a85d9dd96b70ddb538c9076020aa1a041790361e9", size = 256012, upload-time = "2026-09-27T12:27:14.91Z" }, - { url = "https://files.pythonhosted.org/packages/11/8c/e9499ddc33197bd7eabcb1118ca81756fc874457b324e2b479a4804b2ad2/coverage-7.16.2-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7b451c68218c150f616bc9649783ec8de76a59792c759b43aa0c9c0466a465e4", size = 257898, upload-time = "2026-09-27T12:27:16.588Z" }, - { url = "https://files.pythonhosted.org/packages/5f/6e/c081cb5991a0afba99f9c4ad6c74a5fce9513a38ddc64e3e6680c6fed9af/coverage-7.16.2-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:a56ac4fa5a75c7e182e8f62600cfb4aff43c5ed7356a034f3557659c3bec1d90", size = 255938, upload-time = "2026-09-27T12:27:18.19Z" }, - { url = "https://files.pythonhosted.org/packages/b2/42/1c3d819e8f9b6eb01c2fe90874d67a8882adb9507e0bbb09361ed131ea89/coverage-7.16.2-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:4cc4f73aa3fabc36e32046d6cd2971405948d8a903636508a3d3b2f9128b3a95", size = 260368, upload-time = "2026-09-27T12:27:19.903Z" }, - { url = "https://files.pythonhosted.org/packages/19/4f/d70eac07901fd587b6ab05e659b52afe13959992aa5113bf6cce059cc572/coverage-7.16.2-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:723dcdab91357159b722935b500ee8abc0a66c8c432e1e9fabf4cc7598952de8", size = 255620, upload-time = "2026-09-27T12:27:21.621Z" }, - { url = "https://files.pythonhosted.org/packages/34/5e/6d87af88317d3d9a9b18a9ca1bc1673eb516917f296e579d0d4a55cb3490/coverage-7.16.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5397e21a90dde0e9c6896b77ded8f0be26b66f8b22b33aed41f6043ed95d55e6", size = 257521, upload-time = "2026-09-27T12:27:23.358Z" }, - { url = "https://files.pythonhosted.org/packages/79/bb/90c2641170d2fa1a6757b3f8450ba2740197317b0ddd749e9604b914e886/coverage-7.16.2-cp314-cp314-win32.whl", hash = "sha256:848893e1d361448c113dc2f0913503522a6f7be231d0e38333d2a22d9698a011", size = 226248, upload-time = "2026-09-27T12:27:25.153Z" }, - { url = "https://files.pythonhosted.org/packages/30/08/d8d0478bb02c8eb0ae20a496fc80c40fcf4d3450bd184300d682ba2d28a6/coverage-7.16.2-cp314-cp314-win_amd64.whl", hash = "sha256:5a27b731c171e43dc8b5f32b76a5051dde2ec9b9366c87028f08a7088ebc2c7b", size = 226732, upload-time = "2026-09-27T12:27:26.907Z" }, - { url = "https://files.pythonhosted.org/packages/32/3f/0001da22155b0a8ce063ec0f7e64ecbe17b373f306e7a74435f6d6accb72/coverage-7.16.2-cp314-cp314-win_arm64.whl", hash = "sha256:1c569a9fd25505f1cd6bea90588818f90373ce90e2632e2cacf19ddbd6e14fdb", size = 226645, upload-time = "2026-09-27T12:27:28.588Z" }, - { url = "https://files.pythonhosted.org/packages/d7/85/6d8813aff9b8b8586691a9d33c43c5604f7227622574da7cdc3d91a86861/coverage-7.16.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:d93db87adb6b1c1b408dce4763314b55d76a9f589e96783a84ac9e7689e48bdf", size = 224871, upload-time = "2026-09-27T12:27:30.32Z" }, - { url = "https://files.pythonhosted.org/packages/5c/70/444f3a4981ac2cda40fdcf4cc9b56a4e1a33c222abeb33e51ed3e3eb2a6b/coverage-7.16.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:aa62c85046473959c13ba9edca9dc90a77d5c1095b1ba313556314d77fe5b036", size = 225123, upload-time = "2026-09-27T12:27:32.33Z" }, - { url = "https://files.pythonhosted.org/packages/d0/c1/980681cd7b33eb66ac835044116ef0a92e11fcc7bdd866cc89d10b1130b9/coverage-7.16.2-cp314-cp314t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:db76506aa5416081f3e8974ae0f7965c58ada0bb0ef7339ac86099588dbb20d3", size = 265049, upload-time = "2026-09-27T12:27:34.085Z" }, - { url = "https://files.pythonhosted.org/packages/b2/e3/87679875c33bb2191f0f05544a1cc9adcc940fe0c35443a10f2df753dde5/coverage-7.16.2-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:a0f2285329dac10ab08f79cb11f5692c497018e6c7c511f95e6fd63a70b8f831", size = 267717, upload-time = "2026-09-27T12:27:36.025Z" }, - { url = "https://files.pythonhosted.org/packages/76/64/5d372776d6eb523d4e93bafba2253f96984e3b18261c4cc56a50863c6d0d/coverage-7.16.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:382d3346d56b0eec1b793d53a4c88799c8053f516aa3a8d7c44315696954bacf", size = 270047, upload-time = "2026-09-27T12:27:37.96Z" }, - { url = "https://files.pythonhosted.org/packages/be/c1/44082ff0cbf9f97d0043f57970a71204097ec7ba606361a9fd2065393669/coverage-7.16.2-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:648352b94507179d82637292e7ae8802508d95f78e2f00a705a50b6c48011681", size = 271360, upload-time = "2026-09-27T12:27:39.766Z" }, - { url = "https://files.pythonhosted.org/packages/b8/17/9a215efe25b5e0ecc87c89dbe525c4a87d14d87c8c0c7316ef140a5f6f3e/coverage-7.16.2-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fb2bde05838fffae1a1bf75e5d411a6cac3e4e9bb97e6640fed8cd47888b33f0", size = 264736, upload-time = "2026-09-27T12:27:42.072Z" }, - { url = "https://files.pythonhosted.org/packages/a2/da/7f0a31af8e448107d4d32844bd684757f51ea907bc0c68c8fd537b2123ff/coverage-7.16.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:6a75180829efb8ae62b4aded25be6ddca1c888d138d2d82e21d93bfbd88f41cb", size = 267600, upload-time = "2026-09-27T12:27:43.85Z" }, - { url = "https://files.pythonhosted.org/packages/dd/a4/3bfecbd3366b775bacdcb3330394d356cf384b5d8f5b2146ac4b14b252b5/coverage-7.16.2-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:99704f73721e23859112072d522076e11c31744fc96b5652e5dd2018aa4359f7", size = 264767, upload-time = "2026-09-27T12:27:45.768Z" }, - { url = "https://files.pythonhosted.org/packages/b8/3f/5d62163732d87e4a0c4710a0eab30f0fd6a2d480112abe2029f014fe8c9d/coverage-7.16.2-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:29309ccc86b7f33df7db12813c299f215bbbc470ed6292d0bedd63ffae1ebf64", size = 269026, upload-time = "2026-09-27T12:27:47.787Z" }, - { url = "https://files.pythonhosted.org/packages/49/4d/8e4579f225426535085a9be371cc75e3b026d058d679b80affbdfb4c3ef0/coverage-7.16.2-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:30c1b65d529e46569899fadca59e4a87c1faf2886923f1307ba61e654d4f3c20", size = 264147, upload-time = "2026-09-27T12:27:49.681Z" }, - { url = "https://files.pythonhosted.org/packages/d1/36/ef1f77e2c3f7bb03c2b13b9a2006f88700fdd75535ef158d70049f425c1c/coverage-7.16.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:dcf4bc2aab4e16b1c4c0c2005918f23a7dd5d7821ddae82caed9e3342dc2fcce", size = 266376, upload-time = "2026-09-27T12:27:51.551Z" }, - { url = "https://files.pythonhosted.org/packages/be/79/0cb2bf4428830dec971c718c2c841a039c084415c99e67281f5a72841aab/coverage-7.16.2-cp314-cp314t-win32.whl", hash = "sha256:a9cd3de0a5bfe7b0e21ee10e1a14e3d61bf52efc88217ab1d95d6ace6970bd46", size = 226585, upload-time = "2026-09-27T12:27:53.945Z" }, - { url = "https://files.pythonhosted.org/packages/3c/f9/da17121c16667fd84998e972200ae226a41540f6ea4795776c6d99e8976f/coverage-7.16.2-cp314-cp314t-win_amd64.whl", hash = "sha256:611a44e5229a59d7483ce830160e1a0e85f700562c7a5651c7c63fb8f4eb528c", size = 227378, upload-time = "2026-09-27T12:27:55.778Z" }, - { url = "https://files.pythonhosted.org/packages/74/89/01179c62d1b7e6e33bd5001566b02d7f778cf33d3ec1e81e94ca170c517f/coverage-7.16.2-cp314-cp314t-win_arm64.whl", hash = "sha256:22957cef43ce038641de78ba995de7568d2d6a37c6ddbf7fa0fd7d1ae2344d91", size = 227064, upload-time = "2026-09-27T12:27:57.496Z" }, - { url = "https://files.pythonhosted.org/packages/4c/57/52935003c3f627ba6e5203d7179aad32448c10899663a30336aba8e81a2c/coverage-7.16.2-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:414c26dfdb96aac2d570a54e03008f001e32eb2d413705365503648c6bd361d8", size = 224140, upload-time = "2026-09-27T12:27:59.343Z" }, - { url = "https://files.pythonhosted.org/packages/31/38/df472520f3e626524d7e2fc9d6da0afe7895a2f1489d36b48af8ca40bb41/coverage-7.16.2-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:00d3eb96e9988c45f50cccd1f1496571ac5c1f91386ac02c4d55516eeda19a24", size = 224449, upload-time = "2026-09-27T12:28:01.299Z" }, - { url = "https://files.pythonhosted.org/packages/0c/aa/3be084d5b82e63ccdad4ed751e4acbae294673573e30481d29f8b7402eec/coverage-7.16.2-cp315-cp315-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:4dbbd1155ca46e6e0b6b89d204428c56ef6a459af21333f365d135a2820e5a09", size = 256060, upload-time = "2026-09-27T12:28:03.185Z" }, - { url = "https://files.pythonhosted.org/packages/de/29/48fca82a7ebf7ff7b2e35019cc9537e7f65e4d2aa1215cc5a8792c989251/coverage-7.16.2-cp315-cp315-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:8fc15cc8d0d06e873c00ef18e1372d605f9aaf3de27d8c24e50782e75bc8b843", size = 259106, upload-time = "2026-09-27T12:28:05.15Z" }, - { url = "https://files.pythonhosted.org/packages/06/3d/b2d5986f2dd53fe201aa1be2e4ab204fa1aed5101e67c0dbbb419b850aee/coverage-7.16.2-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9c6afdd69218202bc1758c9a14b86b8cf1084f37ed2ca143e567a103772b16d1", size = 260674, upload-time = "2026-09-27T12:28:06.868Z" }, - { url = "https://files.pythonhosted.org/packages/ce/7e/b50160be3506ead12e6480d14279af7f0f17627694300a2d1fd2c42d2ff5/coverage-7.16.2-cp315-cp315-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:aba5c63b7afdc749cc9eae943d5b868cba2b261a176378fa1c5a30bc8bc89982", size = 263139, upload-time = "2026-09-27T12:28:08.771Z" }, - { url = "https://files.pythonhosted.org/packages/14/5e/7c805ac9a32606de1399bd7e9bd375aa2f973dc61b12680d9e6403c2e891/coverage-7.16.2-cp315-cp315-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9174f0af24e5eff248b9dbfe76ec5275a3d19d37edbc2810543f12cf97347a34", size = 256591, upload-time = "2026-09-27T12:28:10.842Z" }, - { url = "https://files.pythonhosted.org/packages/ab/9e/76f1ed129a2daf658a3ea17122824cf2e3b91fea0460d8d3664fc5a61018/coverage-7.16.2-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:80e9fdb4c3d926b6ba721d4bf7435bdb869c3527ae7803290361d0ab73db13b6", size = 258708, upload-time = "2026-09-27T12:28:12.962Z" }, - { url = "https://files.pythonhosted.org/packages/5a/b7/8d62e75f48b527619239a65294f842d4b7fd02a0839d43ae1de80184e2df/coverage-7.16.2-cp315-cp315-musllinux_1_2_i686.whl", hash = "sha256:7b3bce4a0d05401d70b7d0d5ca783e686bc9d30e81dbd7d980d532609bf809e4", size = 256562, upload-time = "2026-09-27T12:28:14.934Z" }, - { url = "https://files.pythonhosted.org/packages/b8/8d/0a15f95c3afb78e947c52644786ba4bc9de259905687dd720d5e6fae2e76/coverage-7.16.2-cp315-cp315-musllinux_1_2_ppc64le.whl", hash = "sha256:44f21e407b278efdfc1ee5e481e00518bd1d500310a30a5fbf2bcbedfef4aaf0", size = 261077, upload-time = "2026-09-27T12:28:17.215Z" }, - { url = "https://files.pythonhosted.org/packages/25/00/88389987305a47d732866c07c8a500000ab574df9505e3114ac69c8d027f/coverage-7.16.2-cp315-cp315-musllinux_1_2_riscv64.whl", hash = "sha256:59c3926585e1cd1f2190f4b2ac9014de1bbeaf0d5d0587b0dc6b0aa90d17896a", size = 256034, upload-time = "2026-09-27T12:28:19.08Z" }, - { url = "https://files.pythonhosted.org/packages/92/02/34d079d4952ad461bde037d353f9a6e037a7edc45fe0f9ee8781ff73f028/coverage-7.16.2-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:066429634299e14dd2d511e1e85f8f9cecc500781f6b41907c0dd6f1baea7e63", size = 258034, upload-time = "2026-09-27T12:28:21.242Z" }, - { url = "https://files.pythonhosted.org/packages/f6/d8/3e59a62879285b464ec1b10fd824fbc1af9ce66e842cd39974f80a0becc4/coverage-7.16.2-cp315-cp315-win32.whl", hash = "sha256:893ea9cf86cb8d2546812ac93d973aaf2ee1fb45110a873b014214fd23e3725e", size = 226252, upload-time = "2026-09-27T12:28:23.102Z" }, - { url = "https://files.pythonhosted.org/packages/f4/e1/128026e1b2836e9ad6b219207ba9edf1c5e0088a7869e23088aee7fbbe7a/coverage-7.16.2-cp315-cp315-win_amd64.whl", hash = "sha256:01c6908bc613b420c26c818fe948e1b97dfd041a53c98b01c63bd8321f5c9aae", size = 226728, upload-time = "2026-09-27T12:28:25.21Z" }, - { url = "https://files.pythonhosted.org/packages/a8/f4/c9fa8e7cf525ca7748ac52b0ee89331d13fe09808e45c679830708782e90/coverage-7.16.2-cp315-cp315-win_arm64.whl", hash = "sha256:967d72c835d7a8cf0af99ec813a2d06e3db6df706402f1fe85b31b437645f495", size = 226648, upload-time = "2026-09-27T12:28:27.136Z" }, - { url = "https://files.pythonhosted.org/packages/a2/13/e96b045447a856666f36f9c653e2a80bdaa732aaaf72412b19aa2c26a473/coverage-7.16.2-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:98d9c97f51b334b0adce7b964442a9af33c1a00c6ac856984cc5dc8d18f81c75", size = 224858, upload-time = "2026-09-27T12:28:29.169Z" }, - { url = "https://files.pythonhosted.org/packages/23/90/087f6ad1bd3df059632ca3407a4e6552ed1053ee35354de0a771acf35423/coverage-7.16.2-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:3e861f1071dcc2fec1e88bef0920f6b1eaa66a143555b4f8ab79ba2b0f30ef55", size = 225139, upload-time = "2026-09-27T12:28:31.131Z" }, - { url = "https://files.pythonhosted.org/packages/7e/8e/285dcef0184358044e7cbcd810a1bdc9566bc620f54702d605477155df4a/coverage-7.16.2-cp315-cp315t-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:fb9d92ecfe2d5b494367c67f7446f8b75b68d8d0c8cf3bc3e6997478be25d9e2", size = 265090, upload-time = "2026-09-27T12:28:33.04Z" }, - { url = "https://files.pythonhosted.org/packages/06/b2/cc83f3a6e5789a4e89059c69555bc641c2efcde568405a1c06fc702951ab/coverage-7.16.2-cp315-cp315t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:eb57acff4a74246ae513c142d4b36e18c389c3aed8661914a53f7cd0071031b2", size = 268254, upload-time = "2026-09-27T12:28:35.135Z" }, - { url = "https://files.pythonhosted.org/packages/ac/41/f548c19530f5d66ac6e3c92bbcbc49da7261de3a458b9f3e54a3efb1a0b2/coverage-7.16.2-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:444889f7f66b74e4455c0a97e0e166dd41177f1dca8c0239a47cff25e05ba7e1", size = 270695, upload-time = "2026-09-27T12:28:36.959Z" }, - { url = "https://files.pythonhosted.org/packages/94/61/4dc27cf82ef96434d2874110ad0cc10ea4621025705dc5049862bd3bd181/coverage-7.16.2-cp315-cp315t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a740ea6f083c6db7b926534d159508f80ba275ab35e722522de0d18d0f56e55f", size = 271853, upload-time = "2026-09-27T12:28:38.821Z" }, - { url = "https://files.pythonhosted.org/packages/38/29/bf8072b1b8bd5f2de8b21460a404460b1a2b97e80a9464c78ec0271f6199/coverage-7.16.2-cp315-cp315t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:8e209591f7c41ae4a9171335cf6156afda0b21de73b02f73f5aa95b2d5fbb08d", size = 265644, upload-time = "2026-09-27T12:28:40.815Z" }, - { url = "https://files.pythonhosted.org/packages/7c/2f/0aecb8721be5cdeb8afd9d6d9f6b463f074e4d8d37f00f4c42442522709f/coverage-7.16.2-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:396bb16e04ce04efbb3df91456ae4e3da918e69ecdf67fb711b0a0fdf35ccce0", size = 268530, upload-time = "2026-09-27T12:28:42.725Z" }, - { url = "https://files.pythonhosted.org/packages/ab/0b/92b4b7628268ee711249958e68fc0328779bd3d9a7ab4715379465aedb84/coverage-7.16.2-cp315-cp315t-musllinux_1_2_i686.whl", hash = "sha256:9cdf19874e0d247f32f03609200370343c3c7aa260b191d8c2bb251d36198283", size = 265154, upload-time = "2026-09-27T12:28:44.684Z" }, - { url = "https://files.pythonhosted.org/packages/7b/d9/41c95c1ab29b3dcd357cd1227181d1c98185632aca41ce670ce671b23a43/coverage-7.16.2-cp315-cp315t-musllinux_1_2_ppc64le.whl", hash = "sha256:fd3d72233eb8b48acc94fa57d44e2d32ce8e7abed02882ccb6d855ccc4ed33ec", size = 269799, upload-time = "2026-09-27T12:28:46.672Z" }, - { url = "https://files.pythonhosted.org/packages/80/07/ebeb259aa5362b033a137b86d7274ff4b109d59be8cc9913889b783bf75a/coverage-7.16.2-cp315-cp315t-musllinux_1_2_riscv64.whl", hash = "sha256:bb4ffe96aa663cee727659db5a2afeb38c95f8677b747d447b90d6d4874ea2c5", size = 265196, upload-time = "2026-09-27T12:28:48.996Z" }, - { url = "https://files.pythonhosted.org/packages/b2/18/8437620f90d023680a072eee02f968055f3658bbfb7d386d0ea34cfb7f30/coverage-7.16.2-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:dba2edfb054f6d4a08df9d1637c39a5aa3865bca6617c13c86be21e45658a59c", size = 267266, upload-time = "2026-09-27T12:28:51.361Z" }, - { url = "https://files.pythonhosted.org/packages/28/6c/f08e8ee4293e6434035424180bef4d45e028e8ecc006c61bf9453e74405e/coverage-7.16.2-cp315-cp315t-win32.whl", hash = "sha256:251aed777c47c77aba047096d4542889db089227655711dfc2b9c54ef0e15e35", size = 226583, upload-time = "2026-09-27T12:28:53.33Z" }, - { url = "https://files.pythonhosted.org/packages/f7/fd/3f939c2847f4a72c20cff8b1ac33da78ea91a2d38d9b43336e60db719103/coverage-7.16.2-cp315-cp315t-win_amd64.whl", hash = "sha256:2aca0bdfa9e91621d5b09d815357bf63def4fc0e9cb66da67bf2cf93f3b1a6f5", size = 227374, upload-time = "2026-09-27T12:28:55.158Z" }, - { url = "https://files.pythonhosted.org/packages/5a/35/b98cdc354c952402132e675a87f2cc3227fb68f959c84aaa491fbe15933d/coverage-7.16.2-cp315-cp315t-win_arm64.whl", hash = "sha256:b88841e654f09732804809e435b3e005a929ffd9998b872b7b213957b8759cb8", size = 227064, upload-time = "2026-09-27T12:28:57.075Z" }, - { url = "https://files.pythonhosted.org/packages/3f/0c/7a64e1ac90541a8edf50daef0914848011fb057a5bf55284a4811e21939a/coverage-7.16.2-py3-none-any.whl", hash = "sha256:11d28e9123a9156cb405d8d27b44256c9a58fb5decc2073a8f17862057e3aa0f", size = 215754, upload-time = "2026-09-27T12:28:59.075Z" }, -] - -[package.optional-dependencies] -toml = [ - { name = "tomli" }, -] - [[package]] name = "coverage" version = "7.17.2" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] sdist = { url = "https://files.pythonhosted.org/packages/78/4a/740c3134227763ebc30a226d7f2f29b25e35898d162dd8b2dd792be83fb2/coverage-7.17.2.tar.gz", hash = "sha256:d05a1bef52f4d7f1b484a1cf46a8929e50963f910e51396373f06cd3b6248f38", size = 996756, upload-time = "2026-11-04T19:52:34.313Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/5e/9d/e3db9071ebeda48e47e5be0fd0404219954e7888f64e7c37df324a79dc3a/coverage-7.17.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a3f49ac9c9e5fd4b450677eb44f4b14ea9ab71950b2896888c9f6a22d5cd1773", size = 227732, upload-time = "2026-11-04T19:49:22.217Z" }, @@ -639,7 +455,6 @@ version = "50.0.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "cffi", marker = "platform_python_implementation != 'PyPy'" }, - { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/9d/af/182eb91b0df3fe75c4d9f26fe70684569566745f6ba7e5c9c73a862c5252/cryptography-50.0.2.tar.gz", hash = "sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5", size = 880623, upload-time = "2026-09-30T15:30:04.884Z" } wheels = [ @@ -703,18 +518,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ca/1d/1271f287ff7170ddafc2aad36260c4eec20ccd2fea70f38455e9d56d427b/cryptography-50.0.2-pp311-pypy311_pp80-win_amd64.whl", hash = "sha256:7b75de3c8b3be1cdb1052747c929440c3eea46c1bc2cb8a6e3a48388e9b7b452", size = 3805376, upload-time = "2026-09-30T15:29:58.729Z" }, ] -[[package]] -name = "exceptiongroup" -version = "1.3.1" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/50/79/66800aadf48771f6b62f7eb014e352e5d06856655206165d775e675a02c9/exceptiongroup-1.3.1.tar.gz", hash = "sha256:8b412432c6055b0b7d14c310000ae93352ed6754f70fa8f7c34141f91c4e3219", size = 30371, upload-time = "2025-11-21T23:01:54.787Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/8a/0e/97c33bf5009bdbac74fd2beace167cab3f978feb69cc36f1ef79360d6c4e/exceptiongroup-1.3.1-py3-none-any.whl", hash = "sha256:a7a39a3bd276781e98394987d3a5701d0c4edffb633bb7a5144577f82c773598", size = 16740, upload-time = "2025-11-21T23:01:53.443Z" }, -] - [[package]] name = "h11" version = "0.16.0" @@ -750,31 +553,10 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, ] -[[package]] -name = "httpcore2" -version = "2.14.0" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -dependencies = [ - { name = "h11" }, - { name = "truststore" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/30/ff/b53af1b49bb2cb5fa97c92215614b173ca5c1a99ded80e2d52f15a94fa6d/httpcore2-2.14.0.tar.gz", hash = "sha256:4f57a1a8249fe6af589d935cfd456f1d13bbdcb0f0fc72af9142368fc94811d7", size = 69096, upload-time = "2026-10-18T16:29:21.898Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/02/06/a8d6a8f90d11b76d9086242b6bb0ee4b503473bfc8be34c2d5b067275c22/httpcore2-2.14.0-py3-none-any.whl", hash = "sha256:4c4f64f4b544afeb778c42c0ffb5941b29e671157e90ed3f6dc787c4bca90cd1", size = 84291, upload-time = "2026-10-18T16:29:19.743Z" }, -] - [[package]] name = "httpcore2" version = "2.16.0" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] dependencies = [ { name = "h11" }, { name = "truststore" }, @@ -804,38 +586,13 @@ socks = [ { name = "socksio" }, ] -[[package]] -name = "httpx2" -version = "2.14.0" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -dependencies = [ - { name = "anyio", marker = "sys_platform != 'emscripten'" }, - { name = "httpcore2", version = "2.14.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'emscripten'" }, - { name = "idna" }, - { name = "truststore", marker = "sys_platform != 'emscripten'" }, - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/e8/67/58353f1848b4ba568e1ec22ea1e0d8e039f0bca5fde7e2d1f07739fd83e7/httpx2-2.14.0.tar.gz", hash = "sha256:47ad61a3c40282cd8d0dc96311531f00f5bfc71a066c6fe3b36d8f63fb9e4f6e", size = 102036, upload-time = "2026-10-18T16:29:22.627Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/69/5a/469616aa8c2cbb0bb9dd67a3c18d07c01ab604cc0b236ee1c47d260c7f6e/httpx2-2.14.0-py3-none-any.whl", hash = "sha256:9d20c13a10bae1773a0be3b0f1e5beeb4bdd549bc3a2ba18efa32897c65403e4", size = 96901, upload-time = "2026-10-18T16:29:20.819Z" }, -] - [[package]] name = "httpx2" version = "2.16.0" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] dependencies = [ { name = "anyio", marker = "sys_platform != 'emscripten'" }, - { name = "httpcore2", version = "2.16.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'emscripten'" }, + { name = "httpcore2", marker = "sys_platform != 'emscripten'" }, { name = "httpx2-jsfetch", marker = "python_full_version >= '3.12' and sys_platform == 'emscripten'" }, { name = "idna" }, { name = "truststore", marker = "sys_platform != 'emscripten'" }, @@ -881,8 +638,7 @@ dependencies = [ { name = "attrs" }, { name = "jsonschema-specifications" }, { name = "referencing" }, - { name = "rpds-py", version = "0.30.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "rpds-py", version = "2026.9.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "rpds-py" }, ] sdist = { url = "https://files.pythonhosted.org/packages/b3/fc/e067678238fa451312d4c62bf6e6cf5ec56375422aee02f9cb5f909b3047/jsonschema-4.26.0.tar.gz", hash = "sha256:0c26707e2efad8aa1bfc5b7ce170f3fccc2e4918ff85989ba9ffa9facb2be326", size = 366583, upload-time = "2026-01-07T13:41:07.246Z" } wheels = [ @@ -907,22 +663,6 @@ version = "6.1.3" source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/23/ad/28ecd7cb894d172f3c9c80a075eeeb2017ac62e3632cee05a5f9493547eb/lxml-6.1.3.tar.gz", hash = "sha256:45222d94ddd511536f3b2f7d9deae3b2339b4ce0f075f1ca25703b07cad9dd21", size = 4211198, upload-time = "2026-09-02T14:48:02.287Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/29/6b/a7d5c08e19a8e69887ed722fffaefdbaffc8959d5ef5c370a65e52c895ac/lxml-6.1.3-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:40bcbd9f94166ffe925811e730607385cec959f42fb1bb7dad83748680465221", size = 8575497, upload-time = "2026-09-02T14:46:05.131Z" }, - { url = "https://files.pythonhosted.org/packages/96/dd/c25a32f9f6039a96cfd52296a4630075868aa16e71858b3076699a059201/lxml-6.1.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:05f5bce9af14fd1506997594bd81cee6d9c6b58ea80a39c058327aa6371ed9e9", size = 4619233, upload-time = "2026-09-02T14:46:08.898Z" }, - { url = "https://files.pythonhosted.org/packages/3e/f0/d49375a47644369d84f90a9fe4ff1924faad58d4f95563831eca84ca29ae/lxml-6.1.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ff88a92cafde90888511242d1c54afcc1a8adbb6dc0a88fa7f87e29e92400d4a", size = 5015387, upload-time = "2026-09-02T14:46:10.797Z" }, - { url = "https://files.pythonhosted.org/packages/76/0f/d1b1f52925442f7b4b1abd81a41905987322f6df6a5dd42fab8579415828/lxml-6.1.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:c00e26288784460885fe76e4d4b293573e0f791f52e6d60e27b42edf005922eb", size = 5168571, upload-time = "2026-09-02T14:46:12.989Z" }, - { url = "https://files.pythonhosted.org/packages/b2/13/e5d8291a68a27e564e4e1eefba08c3844c6800bcb43f3e72a32b20971132/lxml-6.1.3-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:773062aec2f2e56b2b22d37054123f0de8a22a4688a0c3376c3fe42685f975cf", size = 5068024, upload-time = "2026-09-02T14:46:15.325Z" }, - { url = "https://files.pythonhosted.org/packages/a1/ce/dbea34cd115ae9b8ef53816daa912563615adf4daed42531878a2fb29c77/lxml-6.1.3-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f6449672f9c93316deb5e2839e18931f468670e44d5bd9b1301a5a9655d45c07", size = 5296830, upload-time = "2026-09-02T14:46:17.52Z" }, - { url = "https://files.pythonhosted.org/packages/20/f6/12a2ab6e8c8afecb82a3f0e9a518952b6a1cddf405ad8542883bd71e6096/lxml-6.1.3-cp310-cp310-manylinux_2_28_i686.whl", hash = "sha256:ec295280f4b37769256da025acf5890370355ac589c27e89caae0b5e9eedc702", size = 5424696, upload-time = "2026-09-02T14:46:19.706Z" }, - { url = "https://files.pythonhosted.org/packages/02/3f/5670e198266c764595687a234fdaed33837f487b95a596262b2548e48933/lxml-6.1.3-cp310-cp310-manylinux_2_31_armv7l.whl", hash = "sha256:5929d9df5e7e3379183be0e21f7d559618a5b61cb63280df6164019242e337ed", size = 4783635, upload-time = "2026-09-02T14:46:21.63Z" }, - { url = "https://files.pythonhosted.org/packages/70/24/007ce6b7bffb61a6ca88c3a8f21b26f3f0aa3b3f6bb648a56e328c994a14/lxml-6.1.3-cp310-cp310-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:6e1eb8a4cbffd5553680ad96be6680e364710656eced73d1dc90ec489df599a3", size = 5373212, upload-time = "2026-09-02T14:46:23.572Z" }, - { url = "https://files.pythonhosted.org/packages/4e/00/cf09f38cf9005bd5cfa4fd452b03b290b1c48c403fe0319a8013f4b3cae0/lxml-6.1.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:16148acd77ed1d8836a56db883af2f5eed720f9723088110b16a0d08582130a6", size = 5116476, upload-time = "2026-09-02T14:46:26.262Z" }, - { url = "https://files.pythonhosted.org/packages/15/83/eb021e5db4336f0bb1438cba6f053ea135aa00b9f4ef0439473d6b986308/lxml-6.1.3-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:23c366231259cd75ad06495174701afb3fcb36a92917fa47de2d1f1bd9d95739", size = 4814172, upload-time = "2026-09-02T14:46:28.3Z" }, - { url = "https://files.pythonhosted.org/packages/c8/4e/147b6f9088cc191713249ac547b0af2fece489c8cdff1f2801ab47dda8a9/lxml-6.1.3-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:da85db328e507da922d586c3c7416ec360ec22e9cd9e0700691afacde0c81f53", size = 5361711, upload-time = "2026-09-02T14:46:31.035Z" }, - { url = "https://files.pythonhosted.org/packages/b7/d9/8cfdac0d7d771e25af2c1f4bc874032f025a4b59e0b6917c3c7858070795/lxml-6.1.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:0f17d83c48ee9dfd96abae3ac3e2108c76d2fc86ce96355e37b8da9f7f4ecc08", size = 5321598, upload-time = "2026-09-02T14:46:33.165Z" }, - { url = "https://files.pythonhosted.org/packages/f3/5b/d2413c71f312dccdd07ed985be356657fc624d822ba7e2c87e8722646156/lxml-6.1.3-cp310-cp310-win32.whl", hash = "sha256:7dd624c1eaa629ad44b59a1a0145fdf2d67895592dce94c9358b938b3d075e65", size = 3604471, upload-time = "2026-09-02T14:46:35.245Z" }, - { url = "https://files.pythonhosted.org/packages/7a/bf/74b6785beac6488fd395e78796339bc197fbad6fd6103b41b15a4009dc4b/lxml-6.1.3-cp310-cp310-win_amd64.whl", hash = "sha256:18a4db52b5a7b53a3540b0b0f4123319334621ee8083d496de314d0bf06ff59a", size = 4029086, upload-time = "2026-09-02T14:46:37.744Z" }, - { url = "https://files.pythonhosted.org/packages/f9/a5/ddf6e1744cd76fc9f0ce11cb16b117d6eaac46ebaeca01968e9014e8770c/lxml-6.1.3-cp310-cp310-win_arm64.whl", hash = "sha256:0feebef8d0521188d0157f758356072e840173aa61ca45b8b3f87959ac283dd5", size = 3674608, upload-time = "2026-09-02T14:46:39.802Z" }, { url = "https://files.pythonhosted.org/packages/96/f1/95133bde7af7afb1f5ba6090b674d826b7a518318bba54bbbb633b27865a/lxml-6.1.3-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:c66f858b82497173f73366795fc6ee8171620e75a338506d6b2e7bc16f5fca11", size = 8563141, upload-time = "2026-09-02T14:46:42.334Z" }, { url = "https://files.pythonhosted.org/packages/80/54/5a79ee2181ac773ee13e48205411845feec69e1c3d097e985c1343171712/lxml-6.1.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:032a0a97eed428bd143c75a11118238546424ceb2fa311cca5f073aa44658dc4", size = 4613690, upload-time = "2026-09-02T14:46:45.253Z" }, { url = "https://files.pythonhosted.org/packages/ab/29/8c24672f56807f119312f073f24204368574bd16b384ede861b5104b3a2b/lxml-6.1.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:4a579dfb9c835f8ab47f4b8ed33440cbc75b806b73297208e6ec2a33e903740b", size = 4935630, upload-time = "2026-09-02T14:46:48.071Z" }, @@ -1041,12 +781,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b8/d7/ed6ee6186a89e69ca4ea9658b2a278f46a5efe8b5d4db56c7197f18653fe/lxml-6.1.3-cp315-cp315t-win32.whl", hash = "sha256:ace1d2c83b2bd24db5940600541140e87a325e119cb32d5fa9ad720d7e76648e", size = 3901093, upload-time = "2026-09-02T14:51:37.234Z" }, { url = "https://files.pythonhosted.org/packages/67/9d/11d10257a4a048d04195d638bb61f0246ce2448eb05f682bcbab25a257a8/lxml-6.1.3-cp315-cp315t-win_amd64.whl", hash = "sha256:b49638355ea3bebba70da783ccbc630fd72afa16bc46c54474bfa1f9a915bbc6", size = 4395446, upload-time = "2026-09-02T14:51:39.884Z" }, { url = "https://files.pythonhosted.org/packages/f8/b7/44edd7de434181c582892e68d1ffe6775ca403ce14aea07cb5a218a936cf/lxml-6.1.3-cp315-cp315t-win_arm64.whl", hash = "sha256:5a721a98c649855963811b59b55755b30566e7f7fc40bdc9803d66dee9f811cf", size = 3822836, upload-time = "2026-09-02T14:51:42.471Z" }, - { url = "https://files.pythonhosted.org/packages/ad/23/dc1fdf3a53f84ca88b6e942277ddb47954844a0ececea8cc5fa3c1324831/lxml-6.1.3-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:4b061064b4a2fe8598a466d723d43dbcd5a610a5d5cfe02fb6226f5c17349f75", size = 3947704, upload-time = "2026-09-02T14:46:22.27Z" }, - { url = "https://files.pythonhosted.org/packages/f0/ed/e36d547d6c958b5693b873504735cb4d0388d545945d66a7aed8983a720b/lxml-6.1.3-pp310-pypy310_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:8499d464de86fab0f102313cce32a9bed9ab1f06ec813cf025cb790964fbb765", size = 4220149, upload-time = "2026-09-02T14:46:24.907Z" }, - { url = "https://files.pythonhosted.org/packages/98/54/7f51e6b6cc0755f9b5fc6637748279e9f48289d917b3a47ac9fedf3318d3/lxml-6.1.3-pp310-pypy310_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:9e67324961ac9bbe616cce5100514d2e34d88665aeb07071e8b16eac55d06d94", size = 4329391, upload-time = "2026-09-02T14:46:27.111Z" }, - { url = "https://files.pythonhosted.org/packages/eb/9e/840b0d2e25c10c491b010d555b46e6e5264d3ad73a91557405fceb738c35/lxml-6.1.3-pp310-pypy310_pp73-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5d12669a2c419b0e8dc423d23dea24bb82f6f9cb829f32e04674b0ba40322a7c", size = 4262125, upload-time = "2026-09-02T14:46:29.199Z" }, - { url = "https://files.pythonhosted.org/packages/69/8f/42a41571dfc772c12628747f883d24c978053856825b99d7a187117b8079/lxml-6.1.3-pp310-pypy310_pp73-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:97acecb11cbc411473f15b8d780df06d7a9f3a2aad9aca78364f56640c8fb70e", size = 4410104, upload-time = "2026-09-02T14:46:32.102Z" }, - { url = "https://files.pythonhosted.org/packages/f3/aa/27d93812be916f1f674b2035edd86d41c77745ff2ad84f58c25a7445a397/lxml-6.1.3-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:f8b9c8ceebae6387d0dc77f7f4dbbfbfc962dba2efbfe6877486075a480726b4", size = 3510724, upload-time = "2026-09-02T14:46:34.122Z" }, { url = "https://files.pythonhosted.org/packages/ec/c1/2433176de263cc3f51fd2c303f993d5bb7f1da3139a0f7d168116c0bfa7a/lxml-6.1.3-pp311-pypy311_pp73-macosx_10_15_x86_64.whl", hash = "sha256:d2765c18ce303149ee804b1f3dad11232726dd0a702d73a15cf19179ac8cc962", size = 3942969, upload-time = "2026-09-02T14:46:36.55Z" }, { url = "https://files.pythonhosted.org/packages/7c/71/de7759096f480180fd9e43ff7c017860e2d2a9a43741ab093cbdf1820f07/lxml-6.1.3-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:7d5a748d12dd9b535e0a130f60dae9ddf0adafbabe61e7864f55c7436c84547a", size = 4213008, upload-time = "2026-09-02T14:46:38.784Z" }, { url = "https://files.pythonhosted.org/packages/b8/9b/c2d09af47a34fa6c0c27473083812b449a411680bd04bbe609cde291ddc8/lxml-6.1.3-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:41096ec0740a58dad03d3ae0c7486d306d20becefb13ceb1649835ab3eb64167", size = 4322012, upload-time = "2026-09-02T14:46:41.031Z" }, @@ -1074,20 +808,16 @@ version = "2.3.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" }, - { name = "httpx2", version = "2.14.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "httpx2", version = "2.16.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "httpx2" }, { name = "jsonschema" }, { name = "mcp-types" }, { name = "opentelemetry-api" }, { name = "pydantic" }, { name = "pyjwt", extra = ["crypto"] }, - { name = "python-multipart", version = "0.0.32", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "python-multipart", version = "0.0.33", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "python-multipart" }, { name = "pywin32", marker = "sys_platform == 'win32'" }, - { name = "sse-starlette", version = "3.5.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "sse-starlette", version = "3.6.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, - { name = "starlette", version = "1.7.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "starlette", version = "1.10.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "sse-starlette" }, + { name = "starlette" }, { name = "typing-extensions" }, { name = "typing-inspection" }, { name = "uvicorn", marker = "sys_platform != 'emscripten'" }, @@ -1099,7 +829,7 @@ wheels = [ [[package]] name = "mcp-server-fetch" -version = "2026.11.11" +version = "2026.11.18" source = { editable = "." } dependencies = [ { name = "beautifulsoup4" }, @@ -1203,28 +933,10 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/c0/20/e4382a85e4cf4746d11746481f83360b990165725dd36ba73d55e029e6a9/protego-0.7.0-py3-none-any.whl", hash = "sha256:944638aaee608f6c83fcad442695f3f9381a60be8d5007248f46b00f201fa5fc", size = 13714, upload-time = "2026-09-21T10:53:58.812Z" }, ] -[[package]] -name = "pycparser" -version = "3.11" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -sdist = { url = "https://files.pythonhosted.org/packages/da/a8/c5fdbeee588bb8ada9458774f43adf1bdd30bd59157055142183e769a024/pycparser-3.11.tar.gz", hash = "sha256:d875f09c3507d00e1aba0eecc6dcadc1352f30fff09dc6bff2f1c2935e97c2bc", size = 113796, upload-time = "2026-10-09T12:56:59.539Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/90/11/0e6f11117525ff0eec40ebac3d313376f102df93ca44ad9e893ee85e4f89/pycparser-3.11-py3-none-any.whl", hash = "sha256:51d5a8ba2be0bbe440b99d2112604c95bbbc3c2748a64260186c541e1729cd80", size = 51178, upload-time = "2026-10-09T12:56:58.131Z" }, -] - [[package]] name = "pycparser" version = "3.12" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] sdist = { url = "https://files.pythonhosted.org/packages/cb/27/eeb9f307bf07060f3d9f9aa0fb8c15b01bdfded0a941e4b2719c7f94cacd/pycparser-3.12.tar.gz", hash = "sha256:f03387877eab82ce01bbdfd0ba7252ee55a90b1c708d5129e2ce915475cf1db6", size = 158785, upload-time = "2026-10-22T13:40:03.56Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/b6/ae/315bbeee126a769cbde43cf4908acb4b40408d8bf8bbf334dd7368d8dadf/pycparser-3.12-py3-none-any.whl", hash = "sha256:a076f3f489b39b43ed13563a1dafe42447445bec2e294154ec5c57fcdda4c85e", size = 62600, upload-time = "2026-10-22T13:40:02.021Z" }, @@ -1254,20 +966,6 @@ dependencies = [ ] sdist = { url = "https://files.pythonhosted.org/packages/af/8e/23ec1021834e35041fbb2f10946141e6acdfd39379c45cc4d65a4e8a1d98/pydantic_core-2.50.2.tar.gz", hash = "sha256:1b0e8dc3932cf4e9ed5727570325cacc716b9409ffc794a221c0ccc72e8eb775", size = 518711, upload-time = "2026-10-29T16:34:57.465Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/00/46/5fabd45007e53349fa9ff22c95968cb451acbc7d912dd8a9980ffa2325c1/pydantic_core-2.50.2-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:6258754c473b3045a7aa30b833a8a331a1ab36c6147cb230789861d80bb26f83", size = 2163662, upload-time = "2026-10-29T16:31:28.258Z" }, - { url = "https://files.pythonhosted.org/packages/a4/d5/6ec0fb1ccf75a8d6b42164f8e9440012416546f9badb683850c58167a5a8/pydantic_core-2.50.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a786cf782ebb2e45a43c7118d75d452aac982b79577dfe804d8dbf2878f0b589", size = 2119060, upload-time = "2026-10-29T16:31:29.959Z" }, - { url = "https://files.pythonhosted.org/packages/64/54/39be898ef4811df54687e71f1bdb77095c7d792c36f98b20027602ab012a/pydantic_core-2.50.2-cp310-cp310-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:ea71b94a2eb5d2fc102926321f56d2ee8eddfad2673eadb1d23e9f287a492715", size = 2276387, upload-time = "2026-10-29T16:31:31.239Z" }, - { url = "https://files.pythonhosted.org/packages/b9/9d/99fcf55e44eab0436cf0e49e34eee7393a9f737ab830018d67cdda7a02bc/pydantic_core-2.50.2-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:71615edeaf1ae70f5f3f558426072eede0168b7e5190fd9633878e29a0b85732", size = 2119441, upload-time = "2026-10-29T16:31:32.577Z" }, - { url = "https://files.pythonhosted.org/packages/e0/fe/b51d611621963172900b8c2a6242c2d7a1ffb2a2026f5798449da6b211f3/pydantic_core-2.50.2-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.whl", hash = "sha256:1a5e859f5a8a6d834b0a13acaa0eaddf1a9b4b015fcda13bab7b471e18299d32", size = 2206739, upload-time = "2026-10-29T16:31:33.758Z" }, - { url = "https://files.pythonhosted.org/packages/95/08/cd920fdfd19d32aa93a815bd81a43cb892cf38ce96420157092935e1633c/pydantic_core-2.50.2-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:d71a9a9352acbcb5c73d39dd003383599428067b6eda5cf7c5d335a7a0da37e1", size = 2394581, upload-time = "2026-10-29T16:31:35.306Z" }, - { url = "https://files.pythonhosted.org/packages/be/cf/40f2b1a7c5cee35a59fac898bc39e43283547cdedf4ffe152f1504104843/pydantic_core-2.50.2-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:bf7f99a0e6616cea754e2334d129091f3260d011369d9b8c658522bfb2427619", size = 2446325, upload-time = "2026-10-29T16:31:36.498Z" }, - { url = "https://files.pythonhosted.org/packages/30/b0/5aae06bbe58fac7cf5c6aac6dc11b04a9beeb5e50bd74f6e4f724ac91c4e/pydantic_core-2.50.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:5c12a5a080570a91bbcbf6d10db008b80e3f5dea015ef2f0137bbec70f24f3f3", size = 2238710, upload-time = "2026-10-29T16:31:37.999Z" }, - { url = "https://files.pythonhosted.org/packages/33/41/fa31929c6d3b9c91048abd486ac94ceb402a8a3e145b5abf1ef87300b781/pydantic_core-2.50.2-cp310-cp310-manylinux_2_31_riscv64.whl", hash = "sha256:89213368eef163350af37127939ace099010e8102757905c3e329f1175950ed8", size = 2274879, upload-time = "2026-10-29T16:31:39.349Z" }, - { url = "https://files.pythonhosted.org/packages/27/00/f9cf3893c6a4c5f785888c3842d837a01067f4795978c6d56c798d0434ca/pydantic_core-2.50.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d93c066a38f83376b5bc020e563666784d1b680a70d6ceb625fdb541af7a312e", size = 2313505, upload-time = "2026-10-29T16:31:40.742Z" }, - { url = "https://files.pythonhosted.org/packages/9a/48/c780d27b9d622301bac0700746ceb65f8e647d8319b509fea3acdf85b329/pydantic_core-2.50.2-cp310-cp310-musllinux_1_1_armv7l.whl", hash = "sha256:eec187d2876abb6a74203efbe2aa796455c1809334acf4e739dde35da8cfb69f", size = 2483718, upload-time = "2026-10-29T16:31:42.525Z" }, - { url = "https://files.pythonhosted.org/packages/2c/fe/8acdea280a53ac5e9fefdcd6b4f01fed612980029d343d0202c044e245a3/pydantic_core-2.50.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:701bc55d08c22f981973ca4f6fdf4ea102ee1ee3a21b818b66fdb161ea711a4a", size = 2490576, upload-time = "2026-10-29T16:31:43.836Z" }, - { url = "https://files.pythonhosted.org/packages/9a/b7/48d74ed20d415e43ead485f7b149270afa98fe6acf3d4c895100c9332073/pydantic_core-2.50.2-cp310-cp310-win32.whl", hash = "sha256:7f9821dfc0c473c96ad55ce4189c7cb4f9c94e7d4f563afb874173243dec1162", size = 2123629, upload-time = "2026-10-29T16:31:45.348Z" }, - { url = "https://files.pythonhosted.org/packages/b1/3d/77d3eca0db83968efe5142dce85fdf050cf4b3a3b1e92ea3eb7525cbe143/pydantic_core-2.50.2-cp310-cp310-win_amd64.whl", hash = "sha256:3939538e640c94ab779a05f2d45dafedd01d65d93e1290797f3ac5b59fcb6455", size = 2242044, upload-time = "2026-10-29T16:31:46.664Z" }, { url = "https://files.pythonhosted.org/packages/8d/0f/1043d3840b7859cc19abede795e058a785ebc1fa011b022b0a69514dd5c5/pydantic_core-2.50.2-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:2115d7ca6d58554af8a14da3dd32d361a4fe999fae52f115a6155679b5b00e72", size = 2160886, upload-time = "2026-10-29T16:31:48.009Z" }, { url = "https://files.pythonhosted.org/packages/d8/95/6211dfe1794bde5ce14f3de2212551196784c67411ac5249d8aa627e3e23/pydantic_core-2.50.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2dd65864aad38dbcc57c3d0e2c978d4286e063378137d8fc0c9fcd558943285", size = 2115730, upload-time = "2026-10-29T16:31:49.449Z" }, { url = "https://files.pythonhosted.org/packages/67/42/50a1a9721cfc21d360916754096c90467fa21386ef16875445ea06a4cf6e/pydantic_core-2.50.2-cp311-cp311-manylinux1_i686.manylinux_2_5_i686.whl", hash = "sha256:26b778d4ebb75f181d36220ff0f54a513fc46f053d9b09ce79993c2f00bc45cc", size = 2274234, upload-time = "2026-10-29T16:31:50.668Z" }, @@ -1409,9 +1107,6 @@ wheels = [ name = "pyjwt" version = "2.15.1" source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "typing-extensions", marker = "python_full_version < '3.11'" }, -] sdist = { url = "https://files.pythonhosted.org/packages/43/ea/5194e52748b0da83d71e082d75496eaec6e58f419f5e184786ded517e6a9/pyjwt-2.15.1.tar.gz", hash = "sha256:4f259e80cdfb6b3fc18a7de51fd1ef9ec79652f25019bae68975ca2468a34df8", size = 121252, upload-time = "2026-09-28T18:40:42.598Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/50/ca/44de4e75f8aadc457f0634be3b542815078ded46dca30efb960edeecad6e/pyjwt-2.15.1-py3-none-any.whl", hash = "sha256:42d59d631f7768a1028a64c7ff581a9bf7519804daf91fc5b6c56e30eec5e193", size = 33860, upload-time = "2026-09-28T18:40:41.429Z" }, @@ -1441,12 +1136,10 @@ version = "9.2.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, - { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, { name = "iniconfig" }, { name = "packaging" }, { name = "pluggy" }, { name = "pygments" }, - { name = "tomli", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/79/42/bb4641652e58dedeac2ec51abc1f8cae4fee4ec63899a0999016229a0f2a/pytest-9.2.0.tar.gz", hash = "sha256:97c4f3b1f3c7414aa36465e09b8220f1d03627993bd51b1282e193753c80557b", size = 1797555, upload-time = "2026-10-27T21:30:20.728Z" } wheels = [ @@ -1458,7 +1151,6 @@ name = "pytest-asyncio" version = "1.4.1.post1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "backports-asyncio-runner", marker = "python_full_version < '3.11'" }, { name = "pytest" }, { name = "typing-extensions", marker = "python_full_version < '3.13'" }, ] @@ -1472,8 +1164,7 @@ name = "pytest-cov" version = "7.1.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "coverage", version = "7.16.2", source = { registry = "https://pypi.org/simple" }, extra = ["toml"], marker = "python_full_version < '3.11'" }, - { name = "coverage", version = "7.17.2", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "coverage" }, { name = "pluggy" }, { name = "pytest" }, ] @@ -1482,28 +1173,10 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/9d/7a/d968e294073affff457b041c2be9868a40c1c71f4a35fcc1e45e5493067b/pytest_cov-7.1.0-py3-none-any.whl", hash = "sha256:a0461110b7865f9a271aa1b51e516c9a95de9d696734a2f71e3e78f46e1d4678", size = 22876, upload-time = "2026-03-21T20:11:14.438Z" }, ] -[[package]] -name = "python-multipart" -version = "0.0.32" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -sdist = { url = "https://files.pythonhosted.org/packages/5b/42/55c32bb9b12693c092ad250a0e82edb5b31ddeda6eb772de5f308b3804ad/python_multipart-0.0.32.tar.gz", hash = "sha256:be54b7f3fa167bb83e4fcd936b887b708f4e57fe75911c02aebf53efaf8d938e", size = 46881, upload-time = "2026-06-04T16:18:58.647Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/e1/04/e8135ebd1ad02c56ec633277529b2602ff99ff634be76cdba5744cf554fd/python_multipart-0.0.32-py3-none-any.whl", hash = "sha256:ff6d3f776f16878c894e52e107296ffc890e913c611b1a4ec6c44e2821fe2e23", size = 30042, upload-time = "2026-06-04T16:18:57.319Z" }, -] - [[package]] name = "python-multipart" version = "0.0.33" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] sdist = { url = "https://files.pythonhosted.org/packages/9f/b7/15b905f6142a9a8a68f66900788da1a32e4d4254452783b37ad1eccb0506/python_multipart-0.0.33.tar.gz", hash = "sha256:b8112424a6abd162ec08d390565dd113ad699f2fe6fef3c987b8bbcbfe9e390d", size = 50499, upload-time = "2026-10-31T14:23:47.461Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/dd/1b/6b1b4164ec734cac911460ab599bfbe46afedd42c5c9627fe4235942c314/python_multipart-0.0.33-py3-none-any.whl", hash = "sha256:8f16c07b36add9da6b2ee87d3efcaf0a45a6de9c3d0a5dd94e9ccf7675a7bc45", size = 32253, upload-time = "2026-10-31T14:23:46.33Z" }, @@ -1514,9 +1187,6 @@ name = "pywin32" version = "312" source = { registry = "https://pypi.org/simple" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fe/1b/9cfdeac80ee45bebbbcb31f1b7b99a0d81a1c72de48d837be984e0e88b1d/pywin32-312-cp310-cp310-win32.whl", hash = "sha256:772235332b5d1024c696f11cea1ae4be7930f0a8b894bb43db14e3f435f1ff7e", size = 6361387, upload-time = "2026-06-04T07:49:14.329Z" }, - { url = "https://files.pythonhosted.org/packages/33/b1/7afc96d041d982c27bc2df6f853d43f01fd273e3d39d04be3647ddeb533d/pywin32-312-cp310-cp310-win_amd64.whl", hash = "sha256:5dbc35d2b5320dc07f25fa31269cfb767471002b17de5eb067d03da68c7cb2db", size = 6926780, upload-time = "2026-06-04T07:49:16.881Z" }, - { url = "https://files.pythonhosted.org/packages/ce/3a/4140da9ad54108e517f4a16b2d83da3033e08662144623e1239587cb7db6/pywin32-312-cp310-cp310-win_arm64.whl", hash = "sha256:3020656e34f1cf7faeb7bccd2b84653a607c6ff0c55ada85e6487d61716deabd", size = 4307203, upload-time = "2026-06-04T07:49:18.993Z" }, { url = "https://files.pythonhosted.org/packages/1f/f5/10a6e845a00fc5e7afd0a988b744f403d4d57162a28d160a093c4d9322f0/pywin32-312-cp311-cp311-win32.whl", hash = "sha256:17948aeadbdb091f0ced6ef0841620794e68327b94ee415571c1203594b7215c", size = 6362659, upload-time = "2026-06-04T07:49:21.349Z" }, { url = "https://files.pythonhosted.org/packages/35/c4/dcd2d62b5944b6d5db53413a5899016ccd57ffcb7278f3f81655d25d2027/pywin32-312-cp311-cp311-win_amd64.whl", hash = "sha256:d11417d84412f859b722fad0841b3614459ed0047f7542d8362e77884f6b6e8a", size = 6928825, upload-time = "2026-06-04T07:49:23.934Z" }, { url = "https://files.pythonhosted.org/packages/b7/56/3cbb433fe4501cdba2eb9040f56a4e1a8243faa4186b25295564d1a7a79d/pywin32-312-cp311-cp311-win_arm64.whl", hash = "sha256:b2200a054ca6d6625c4842fc56a4976a4b47f96b73dbe5538c3f813a80359f47", size = 6721875, upload-time = "2026-06-04T07:49:26.416Z" }, @@ -1555,8 +1225,7 @@ version = "0.37.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "attrs" }, - { name = "rpds-py", version = "0.30.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, - { name = "rpds-py", version = "2026.9.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, + { name = "rpds-py" }, { name = "typing-extensions", marker = "python_full_version < '3.13'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/22/f5/df4e9027acead3ecc63e50fe1e36aca1523e1719559c499951bb4b53188f/referencing-0.37.0.tar.gz", hash = "sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8", size = 78036, upload-time = "2025-10-13T15:30:48.871Z" } @@ -1570,23 +1239,6 @@ version = "2026.9.29" source = { registry = "https://pypi.org/simple" } sdist = { url = "https://files.pythonhosted.org/packages/fc/f2/af1da9d3ceed77bfcdce40427d49ba0be94e4fe84245e3bfef68c10e75b6/regex-2026.9.29.tar.gz", hash = "sha256:8b5fcc4771732191b2b7d1dd68d8f0353f47f8d90b6150f6dce58bf1112442cb", size = 419199, upload-time = "2026-09-29T00:49:58.298Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/f6/37/404442e7296554792e2de4c0c8f8b95ee491a3c227d6ff90d4cebf2dbde3/regex-2026.9.29-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:9916fda742cd4eede63b286f58c06718324265d727ce0856eb1aac86d0d150d6", size = 495402, upload-time = "2026-09-29T00:45:50.322Z" }, - { url = "https://files.pythonhosted.org/packages/72/6d/116db2946888bd60db8e2033739471be6d80aa47c833afd952c9ed40654c/regex-2026.9.29-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:8873c4a11c50b9989168881aeb3f08859f469d809941866aa1feefd8be5431f6", size = 295139, upload-time = "2026-09-29T00:45:51.826Z" }, - { url = "https://files.pythonhosted.org/packages/9d/1d/aefd12fb5cd62b748aa6ed28725b375c71102853fcbf15fb6481f806a2ba/regex-2026.9.29-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1d9fe8091b2e89d470df68a9331111ed008ae8aae6bf1e8e1fba4086a495c84e", size = 292130, upload-time = "2026-09-29T00:45:53.017Z" }, - { url = "https://files.pythonhosted.org/packages/7c/98/41fe60ae6ccf3e166fe7bc73495aa15e9a1a7fe3a1f9f0f95a3d64a2df0f/regex-2026.9.29-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fb00027a09a8f9f08028b40dce4c933cf73e4833240ed356583fdc9cfa721566", size = 793080, upload-time = "2026-09-29T00:45:54.331Z" }, - { url = "https://files.pythonhosted.org/packages/45/0d/944b13e8286ecba61a3baeca28b375550821a279800bdb18fac41ade6637/regex-2026.9.29-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:14e953ff3607c92d7675bf79c4d4509ef6782aa8c08509f179f9b3d6d0679e86", size = 865241, upload-time = "2026-09-29T00:45:56.065Z" }, - { url = "https://files.pythonhosted.org/packages/2a/b4/e1c32fdee0462f1373c52a73325cafbde653fac0b0cc1e9badac74154f4a/regex-2026.9.29-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:0476e5bcbe6e1ba3d1c4cc7bbb1c3ba78e3b979b5c8a88d0a6a8cdd4992b8c84", size = 905496, upload-time = "2026-09-29T00:45:57.491Z" }, - { url = "https://files.pythonhosted.org/packages/ec/99/eae371ca63f7ea1f1eac025021527adb57ce3a4b67ff608b896fd31ea447/regex-2026.9.29-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4fb41211d2333eb930a51e0546a65999761cf1f572a4da56ef9b8a62966c06f2", size = 797643, upload-time = "2026-09-29T00:45:58.746Z" }, - { url = "https://files.pythonhosted.org/packages/dc/26/9e4f158459e37e41633c96f49766a465f801c5daba9507260609ed76d783/regex-2026.9.29-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:edf06545875f3efa31560d94121e95c7fd70d98b1dfedc0157097d79b13b52ea", size = 797591, upload-time = "2026-09-29T00:46:00.2Z" }, - { url = "https://files.pythonhosted.org/packages/86/60/5e1c5c6e85132e757ae77bd7693f1809046edb2c8853658c9200f4c8593c/regex-2026.9.29-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:6398d5145689503412cc1748895242598d8846b8967b851133b20dc2ed1e21e8", size = 774874, upload-time = "2026-09-29T00:46:01.491Z" }, - { url = "https://files.pythonhosted.org/packages/e5/13/301b394f32a8db86ae3280533c9186229595fed766376f18e87959f92f96/regex-2026.9.29-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:45010bcfe66df41522d56c9b6114e87ecc597a08970ff6a2ced24415c141ae5f", size = 780168, upload-time = "2026-09-29T00:46:02.817Z" }, - { url = "https://files.pythonhosted.org/packages/f6/27/0c647127db32760b2dfc4c38da9ca509a3c4a8d3d93a586121a10fef2701/regex-2026.9.29-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:a5758353650079898dc1b2b0e95aa51fa23a30d020e06f62c430dd08ee56cdd8", size = 856604, upload-time = "2026-09-29T00:46:04.152Z" }, - { url = "https://files.pythonhosted.org/packages/4f/18/cac15fb2829c33218ececf76333b66869a96e4f973480ec32494921750f0/regex-2026.9.29-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:6f7121a8914ed13fcfe2099f895341bfb789f004d4c5a0bdece8fa667da10849", size = 760602, upload-time = "2026-09-29T00:46:05.794Z" }, - { url = "https://files.pythonhosted.org/packages/b8/55/967676e4089a25d5f54b9d62522f9fe09b87677d1db58f207888d4ccfbe3/regex-2026.9.29-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:b9d74e4eee9ddb64c2e92d5d61472c59c21684c059eb7b68767be9628e977859", size = 846830, upload-time = "2026-09-29T00:46:07.258Z" }, - { url = "https://files.pythonhosted.org/packages/f1/8d/bb4165d61860ed443da5fb0fafe629c1ee9202526394eead7925bdee2be4/regex-2026.9.29-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:143533cc4b6fbc5b95aca0a5b8d541088d374831593def000ec89322c220221d", size = 785445, upload-time = "2026-09-29T00:46:08.89Z" }, - { url = "https://files.pythonhosted.org/packages/86/a6/a5cfc2560e063f8e6871373d3b719f573d7e7fcaa09db43e7c8aaeb51bd5/regex-2026.9.29-cp310-cp310-win32.whl", hash = "sha256:b84f186a7f0536fe4ff9a9fa12d06d007b9b71d4b5352ddcc41f59ad6522a312", size = 268950, upload-time = "2026-09-29T00:46:10.331Z" }, - { url = "https://files.pythonhosted.org/packages/0c/f6/b127312ebc8092357f435c9e4594fd8cf50abb85f8b4b16ab8d262abab2a/regex-2026.9.29-cp310-cp310-win_amd64.whl", hash = "sha256:23ae6fdad9e63e54038f5ef78aba2933faca61e24d432786589e737bc5522ebb", size = 280629, upload-time = "2026-09-29T00:46:11.638Z" }, - { url = "https://files.pythonhosted.org/packages/c6/e4/ab36f3c26f2374d16d525dd5a7fb4997f3c6e6bb7c6722821b84f9ea35b1/regex-2026.9.29-cp310-cp310-win_arm64.whl", hash = "sha256:c0094897d7d01f184b2d7fe8c56c66d64efe01b31f4b7d34205b391387df1111", size = 279407, upload-time = "2026-09-29T00:46:13.248Z" }, { url = "https://files.pythonhosted.org/packages/e8/6b/6dea87689c3a06a6e79d254bf824e6f3e3d724b5ba027c6112559aa6cd2c/regex-2026.9.29-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6abb75ab16bc3281714a5b99548a2225db70dba1f995f6d7f7419b76eb5a8fbe", size = 495413, upload-time = "2026-09-29T00:46:14.51Z" }, { url = "https://files.pythonhosted.org/packages/3a/a5/0c791a0e83ad1013d262c13247c4c77e0f4a8d05bdc167df96aba6681c0d/regex-2026.9.29-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b7b893976e7fe42053da64f2aa27239c24252fd2ec6df471e1be197c0addc3b1", size = 295145, upload-time = "2026-09-29T00:46:16.292Z" }, { url = "https://files.pythonhosted.org/packages/b1/07/9bf3607d8d13a12e436ab9d63f9791e10706827d535695b23964ad79fd79/regex-2026.9.29-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:066d0e3dbfdd739bce2bf8c2a41dd16f73e3d8adc2eb06dd803a36a307f56075", size = 292123, upload-time = "2026-09-29T00:46:17.646Z" }, @@ -1716,141 +1368,10 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/a0/f4/c67b0b3f1b9245e8d266f0f112c500d50e5b4e83cb6f3b71b6528104182a/requests-2.34.2-py3-none-any.whl", hash = "sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0", size = 73075, upload-time = "2026-05-14T19:25:26.443Z" }, ] -[[package]] -name = "rpds-py" -version = "0.30.0" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -sdist = { url = "https://files.pythonhosted.org/packages/20/af/3f2f423103f1113b36230496629986e0ef7e199d2aa8392452b484b38ced/rpds_py-0.30.0.tar.gz", hash = "sha256:dd8ff7cf90014af0c0f787eea34794ebf6415242ee1d6fa91eaba725cc441e84", size = 69469, upload-time = "2025-11-30T20:24:38.837Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/06/0c/0c411a0ec64ccb6d104dcabe0e713e05e153a9a2c3c2bd2b32ce412166fe/rpds_py-0.30.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:679ae98e00c0e8d68a7fda324e16b90fd5260945b45d3b824c892cec9eea3288", size = 370490, upload-time = "2025-11-30T20:21:33.256Z" }, - { url = "https://files.pythonhosted.org/packages/19/6a/4ba3d0fb7297ebae71171822554abe48d7cab29c28b8f9f2c04b79988c05/rpds_py-0.30.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4cc2206b76b4f576934f0ed374b10d7ca5f457858b157ca52064bdfc26b9fc00", size = 359751, upload-time = "2025-11-30T20:21:34.591Z" }, - { url = "https://files.pythonhosted.org/packages/cd/7c/e4933565ef7f7a0818985d87c15d9d273f1a649afa6a52ea35ad011195ea/rpds_py-0.30.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:389a2d49eded1896c3d48b0136ead37c48e221b391c052fba3f4055c367f60a6", size = 389696, upload-time = "2025-11-30T20:21:36.122Z" }, - { url = "https://files.pythonhosted.org/packages/5e/01/6271a2511ad0815f00f7ed4390cf2567bec1d4b1da39e2c27a41e6e3b4de/rpds_py-0.30.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:32c8528634e1bf7121f3de08fa85b138f4e0dc47657866630611b03967f041d7", size = 403136, upload-time = "2025-11-30T20:21:37.728Z" }, - { url = "https://files.pythonhosted.org/packages/55/64/c857eb7cd7541e9b4eee9d49c196e833128a55b89a9850a9c9ac33ccf897/rpds_py-0.30.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f207f69853edd6f6700b86efb84999651baf3789e78a466431df1331608e5324", size = 524699, upload-time = "2025-11-30T20:21:38.92Z" }, - { url = "https://files.pythonhosted.org/packages/9c/ed/94816543404078af9ab26159c44f9e98e20fe47e2126d5d32c9d9948d10a/rpds_py-0.30.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:67b02ec25ba7a9e8fa74c63b6ca44cf5707f2fbfadae3ee8e7494297d56aa9df", size = 412022, upload-time = "2025-11-30T20:21:40.407Z" }, - { url = "https://files.pythonhosted.org/packages/61/b5/707f6cf0066a6412aacc11d17920ea2e19e5b2f04081c64526eb35b5c6e7/rpds_py-0.30.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c0e95f6819a19965ff420f65578bacb0b00f251fefe2c8b23347c37174271f3", size = 390522, upload-time = "2025-11-30T20:21:42.17Z" }, - { url = "https://files.pythonhosted.org/packages/13/4e/57a85fda37a229ff4226f8cbcf09f2a455d1ed20e802ce5b2b4a7f5ed053/rpds_py-0.30.0-cp310-cp310-manylinux_2_31_riscv64.whl", hash = "sha256:a452763cc5198f2f98898eb98f7569649fe5da666c2dc6b5ddb10fde5a574221", size = 404579, upload-time = "2025-11-30T20:21:43.769Z" }, - { url = "https://files.pythonhosted.org/packages/f9/da/c9339293513ec680a721e0e16bf2bac3db6e5d7e922488de471308349bba/rpds_py-0.30.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e0b65193a413ccc930671c55153a03ee57cecb49e6227204b04fae512eb657a7", size = 421305, upload-time = "2025-11-30T20:21:44.994Z" }, - { url = "https://files.pythonhosted.org/packages/f9/be/522cb84751114f4ad9d822ff5a1aa3c98006341895d5f084779b99596e5c/rpds_py-0.30.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:858738e9c32147f78b3ac24dc0edb6610000e56dc0f700fd5f651d0a0f0eb9ff", size = 572503, upload-time = "2025-11-30T20:21:46.91Z" }, - { url = "https://files.pythonhosted.org/packages/a2/9b/de879f7e7ceddc973ea6e4629e9b380213a6938a249e94b0cdbcc325bb66/rpds_py-0.30.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:da279aa314f00acbb803da1e76fa18666778e8a8f83484fba94526da5de2cba7", size = 598322, upload-time = "2025-11-30T20:21:48.709Z" }, - { url = "https://files.pythonhosted.org/packages/48/ac/f01fc22efec3f37d8a914fc1b2fb9bcafd56a299edbe96406f3053edea5a/rpds_py-0.30.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:7c64d38fb49b6cdeda16ab49e35fe0da2e1e9b34bc38bd78386530f218b37139", size = 560792, upload-time = "2025-11-30T20:21:50.024Z" }, - { url = "https://files.pythonhosted.org/packages/e2/da/4e2b19d0f131f35b6146425f846563d0ce036763e38913d917187307a671/rpds_py-0.30.0-cp310-cp310-win32.whl", hash = "sha256:6de2a32a1665b93233cde140ff8b3467bdb9e2af2b91079f0333a0974d12d464", size = 221901, upload-time = "2025-11-30T20:21:51.32Z" }, - { url = "https://files.pythonhosted.org/packages/96/cb/156d7a5cf4f78a7cc571465d8aec7a3c447c94f6749c5123f08438bcf7bc/rpds_py-0.30.0-cp310-cp310-win_amd64.whl", hash = "sha256:1726859cd0de969f88dc8673bdd954185b9104e05806be64bcd87badbe313169", size = 235823, upload-time = "2025-11-30T20:21:52.505Z" }, - { url = "https://files.pythonhosted.org/packages/4d/6e/f964e88b3d2abee2a82c1ac8366da848fce1c6d834dc2132c3fda3970290/rpds_py-0.30.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:a2bffea6a4ca9f01b3f8e548302470306689684e61602aa3d141e34da06cf425", size = 370157, upload-time = "2025-11-30T20:21:53.789Z" }, - { url = "https://files.pythonhosted.org/packages/94/ba/24e5ebb7c1c82e74c4e4f33b2112a5573ddc703915b13a073737b59b86e0/rpds_py-0.30.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:dc4f992dfe1e2bc3ebc7444f6c7051b4bc13cd8e33e43511e8ffd13bf407010d", size = 359676, upload-time = "2025-11-30T20:21:55.475Z" }, - { url = "https://files.pythonhosted.org/packages/84/86/04dbba1b087227747d64d80c3b74df946b986c57af0a9f0c98726d4d7a3b/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:422c3cb9856d80b09d30d2eb255d0754b23e090034e1deb4083f8004bd0761e4", size = 389938, upload-time = "2025-11-30T20:21:57.079Z" }, - { url = "https://files.pythonhosted.org/packages/42/bb/1463f0b1722b7f45431bdd468301991d1328b16cffe0b1c2918eba2c4eee/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:07ae8a593e1c3c6b82ca3292efbe73c30b61332fd612e05abee07c79359f292f", size = 402932, upload-time = "2025-11-30T20:21:58.47Z" }, - { url = "https://files.pythonhosted.org/packages/99/ee/2520700a5c1f2d76631f948b0736cdf9b0acb25abd0ca8e889b5c62ac2e3/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:12f90dd7557b6bd57f40abe7747e81e0c0b119bef015ea7726e69fe550e394a4", size = 525830, upload-time = "2025-11-30T20:21:59.699Z" }, - { url = "https://files.pythonhosted.org/packages/e0/ad/bd0331f740f5705cc555a5e17fdf334671262160270962e69a2bdef3bf76/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:99b47d6ad9a6da00bec6aabe5a6279ecd3c06a329d4aa4771034a21e335c3a97", size = 412033, upload-time = "2025-11-30T20:22:00.991Z" }, - { url = "https://files.pythonhosted.org/packages/f8/1e/372195d326549bb51f0ba0f2ecb9874579906b97e08880e7a65c3bef1a99/rpds_py-0.30.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:33f559f3104504506a44bb666b93a33f5d33133765b0c216a5bf2f1e1503af89", size = 390828, upload-time = "2025-11-30T20:22:02.723Z" }, - { url = "https://files.pythonhosted.org/packages/ab/2b/d88bb33294e3e0c76bc8f351a3721212713629ffca1700fa94979cb3eae8/rpds_py-0.30.0-cp311-cp311-manylinux_2_31_riscv64.whl", hash = "sha256:946fe926af6e44f3697abbc305ea168c2c31d3e3ef1058cf68f379bf0335a78d", size = 404683, upload-time = "2025-11-30T20:22:04.367Z" }, - { url = "https://files.pythonhosted.org/packages/50/32/c759a8d42bcb5289c1fac697cd92f6fe01a018dd937e62ae77e0e7f15702/rpds_py-0.30.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:495aeca4b93d465efde585977365187149e75383ad2684f81519f504f5c13038", size = 421583, upload-time = "2025-11-30T20:22:05.814Z" }, - { url = "https://files.pythonhosted.org/packages/2b/81/e729761dbd55ddf5d84ec4ff1f47857f4374b0f19bdabfcf929164da3e24/rpds_py-0.30.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d9a0ca5da0386dee0655b4ccdf46119df60e0f10da268d04fe7cc87886872ba7", size = 572496, upload-time = "2025-11-30T20:22:07.713Z" }, - { url = "https://files.pythonhosted.org/packages/14/f6/69066a924c3557c9c30baa6ec3a0aa07526305684c6f86c696b08860726c/rpds_py-0.30.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:8d6d1cc13664ec13c1b84241204ff3b12f9bb82464b8ad6e7a5d3486975c2eed", size = 598669, upload-time = "2025-11-30T20:22:09.312Z" }, - { url = "https://files.pythonhosted.org/packages/5f/48/905896b1eb8a05630d20333d1d8ffd162394127b74ce0b0784ae04498d32/rpds_py-0.30.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:3896fa1be39912cf0757753826bc8bdc8ca331a28a7c4ae46b7a21280b06bb85", size = 561011, upload-time = "2025-11-30T20:22:11.309Z" }, - { url = "https://files.pythonhosted.org/packages/22/16/cd3027c7e279d22e5eb431dd3c0fbc677bed58797fe7581e148f3f68818b/rpds_py-0.30.0-cp311-cp311-win32.whl", hash = "sha256:55f66022632205940f1827effeff17c4fa7ae1953d2b74a8581baaefb7d16f8c", size = 221406, upload-time = "2025-11-30T20:22:13.101Z" }, - { url = "https://files.pythonhosted.org/packages/fa/5b/e7b7aa136f28462b344e652ee010d4de26ee9fd16f1bfd5811f5153ccf89/rpds_py-0.30.0-cp311-cp311-win_amd64.whl", hash = "sha256:a51033ff701fca756439d641c0ad09a41d9242fa69121c7d8769604a0a629825", size = 236024, upload-time = "2025-11-30T20:22:14.853Z" }, - { url = "https://files.pythonhosted.org/packages/14/a6/364bba985e4c13658edb156640608f2c9e1d3ea3c81b27aa9d889fff0e31/rpds_py-0.30.0-cp311-cp311-win_arm64.whl", hash = "sha256:47b0ef6231c58f506ef0b74d44e330405caa8428e770fec25329ed2cb971a229", size = 229069, upload-time = "2025-11-30T20:22:16.577Z" }, - { url = "https://files.pythonhosted.org/packages/03/e7/98a2f4ac921d82f33e03f3835f5bf3a4a40aa1bfdc57975e74a97b2b4bdd/rpds_py-0.30.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:a161f20d9a43006833cd7068375a94d035714d73a172b681d8881820600abfad", size = 375086, upload-time = "2025-11-30T20:22:17.93Z" }, - { url = "https://files.pythonhosted.org/packages/4d/a1/bca7fd3d452b272e13335db8d6b0b3ecde0f90ad6f16f3328c6fb150c889/rpds_py-0.30.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:6abc8880d9d036ecaafe709079969f56e876fcf107f7a8e9920ba6d5a3878d05", size = 359053, upload-time = "2025-11-30T20:22:19.297Z" }, - { url = "https://files.pythonhosted.org/packages/65/1c/ae157e83a6357eceff62ba7e52113e3ec4834a84cfe07fa4b0757a7d105f/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ca28829ae5f5d569bb62a79512c842a03a12576375d5ece7d2cadf8abe96ec28", size = 390763, upload-time = "2025-11-30T20:22:21.661Z" }, - { url = "https://files.pythonhosted.org/packages/d4/36/eb2eb8515e2ad24c0bd43c3ee9cd74c33f7ca6430755ccdb240fd3144c44/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:a1010ed9524c73b94d15919ca4d41d8780980e1765babf85f9a2f90d247153dd", size = 408951, upload-time = "2025-11-30T20:22:23.408Z" }, - { url = "https://files.pythonhosted.org/packages/d6/65/ad8dc1784a331fabbd740ef6f71ce2198c7ed0890dab595adb9ea2d775a1/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f8d1736cfb49381ba528cd5baa46f82fdc65c06e843dab24dd70b63d09121b3f", size = 514622, upload-time = "2025-11-30T20:22:25.16Z" }, - { url = "https://files.pythonhosted.org/packages/63/8e/0cfa7ae158e15e143fe03993b5bcd743a59f541f5952e1546b1ac1b5fd45/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d948b135c4693daff7bc2dcfc4ec57237a29bd37e60c2fabf5aff2bbacf3e2f1", size = 414492, upload-time = "2025-11-30T20:22:26.505Z" }, - { url = "https://files.pythonhosted.org/packages/60/1b/6f8f29f3f995c7ffdde46a626ddccd7c63aefc0efae881dc13b6e5d5bb16/rpds_py-0.30.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47f236970bccb2233267d89173d3ad2703cd36a0e2a6e92d0560d333871a3d23", size = 394080, upload-time = "2025-11-30T20:22:27.934Z" }, - { url = "https://files.pythonhosted.org/packages/6d/d5/a266341051a7a3ca2f4b750a3aa4abc986378431fc2da508c5034d081b70/rpds_py-0.30.0-cp312-cp312-manylinux_2_31_riscv64.whl", hash = "sha256:2e6ecb5a5bcacf59c3f912155044479af1d0b6681280048b338b28e364aca1f6", size = 408680, upload-time = "2025-11-30T20:22:29.341Z" }, - { url = "https://files.pythonhosted.org/packages/10/3b/71b725851df9ab7a7a4e33cf36d241933da66040d195a84781f49c50490c/rpds_py-0.30.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a8fa71a2e078c527c3e9dc9fc5a98c9db40bcc8a92b4e8858e36d329f8684b51", size = 423589, upload-time = "2025-11-30T20:22:31.469Z" }, - { url = "https://files.pythonhosted.org/packages/00/2b/e59e58c544dc9bd8bd8384ecdb8ea91f6727f0e37a7131baeff8d6f51661/rpds_py-0.30.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:73c67f2db7bc334e518d097c6d1e6fed021bbc9b7d678d6cc433478365d1d5f5", size = 573289, upload-time = "2025-11-30T20:22:32.997Z" }, - { url = "https://files.pythonhosted.org/packages/da/3e/a18e6f5b460893172a7d6a680e86d3b6bc87a54c1f0b03446a3c8c7b588f/rpds_py-0.30.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:5ba103fb455be00f3b1c2076c9d4264bfcb037c976167a6047ed82f23153f02e", size = 599737, upload-time = "2025-11-30T20:22:34.419Z" }, - { url = "https://files.pythonhosted.org/packages/5c/e2/714694e4b87b85a18e2c243614974413c60aa107fd815b8cbc42b873d1d7/rpds_py-0.30.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:7cee9c752c0364588353e627da8a7e808a66873672bcb5f52890c33fd965b394", size = 563120, upload-time = "2025-11-30T20:22:35.903Z" }, - { url = "https://files.pythonhosted.org/packages/6f/ab/d5d5e3bcedb0a77f4f613706b750e50a5a3ba1c15ccd3665ecc636c968fd/rpds_py-0.30.0-cp312-cp312-win32.whl", hash = "sha256:1ab5b83dbcf55acc8b08fc62b796ef672c457b17dbd7820a11d6c52c06839bdf", size = 223782, upload-time = "2025-11-30T20:22:37.271Z" }, - { url = "https://files.pythonhosted.org/packages/39/3b/f786af9957306fdc38a74cef405b7b93180f481fb48453a114bb6465744a/rpds_py-0.30.0-cp312-cp312-win_amd64.whl", hash = "sha256:a090322ca841abd453d43456ac34db46e8b05fd9b3b4ac0c78bcde8b089f959b", size = 240463, upload-time = "2025-11-30T20:22:39.021Z" }, - { url = "https://files.pythonhosted.org/packages/f3/d2/b91dc748126c1559042cfe41990deb92c4ee3e2b415f6b5234969ffaf0cc/rpds_py-0.30.0-cp312-cp312-win_arm64.whl", hash = "sha256:669b1805bd639dd2989b281be2cfd951c6121b65e729d9b843e9639ef1fd555e", size = 230868, upload-time = "2025-11-30T20:22:40.493Z" }, - { url = "https://files.pythonhosted.org/packages/ed/dc/d61221eb88ff410de3c49143407f6f3147acf2538c86f2ab7ce65ae7d5f9/rpds_py-0.30.0-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:f83424d738204d9770830d35290ff3273fbb02b41f919870479fab14b9d303b2", size = 374887, upload-time = "2025-11-30T20:22:41.812Z" }, - { url = "https://files.pythonhosted.org/packages/fd/32/55fb50ae104061dbc564ef15cc43c013dc4a9f4527a1f4d99baddf56fe5f/rpds_py-0.30.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:e7536cd91353c5273434b4e003cbda89034d67e7710eab8761fd918ec6c69cf8", size = 358904, upload-time = "2025-11-30T20:22:43.479Z" }, - { url = "https://files.pythonhosted.org/packages/58/70/faed8186300e3b9bdd138d0273109784eea2396c68458ed580f885dfe7ad/rpds_py-0.30.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2771c6c15973347f50fece41fc447c054b7ac2ae0502388ce3b6738cd366e3d4", size = 389945, upload-time = "2025-11-30T20:22:44.819Z" }, - { url = "https://files.pythonhosted.org/packages/bd/a8/073cac3ed2c6387df38f71296d002ab43496a96b92c823e76f46b8af0543/rpds_py-0.30.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:0a59119fc6e3f460315fe9d08149f8102aa322299deaa5cab5b40092345c2136", size = 407783, upload-time = "2025-11-30T20:22:46.103Z" }, - { url = "https://files.pythonhosted.org/packages/77/57/5999eb8c58671f1c11eba084115e77a8899d6e694d2a18f69f0ba471ec8b/rpds_py-0.30.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:76fec018282b4ead0364022e3c54b60bf368b9d926877957a8624b58419169b7", size = 515021, upload-time = "2025-11-30T20:22:47.458Z" }, - { url = "https://files.pythonhosted.org/packages/e0/af/5ab4833eadc36c0a8ed2bc5c0de0493c04f6c06de223170bd0798ff98ced/rpds_py-0.30.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:692bef75a5525db97318e8cd061542b5a79812d711ea03dbc1f6f8dbb0c5f0d2", size = 414589, upload-time = "2025-11-30T20:22:48.872Z" }, - { url = "https://files.pythonhosted.org/packages/b7/de/f7192e12b21b9e9a68a6d0f249b4af3fdcdff8418be0767a627564afa1f1/rpds_py-0.30.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9027da1ce107104c50c81383cae773ef5c24d296dd11c99e2629dbd7967a20c6", size = 394025, upload-time = "2025-11-30T20:22:50.196Z" }, - { url = "https://files.pythonhosted.org/packages/91/c4/fc70cd0249496493500e7cc2de87504f5aa6509de1e88623431fec76d4b6/rpds_py-0.30.0-cp313-cp313-manylinux_2_31_riscv64.whl", hash = "sha256:9cf69cdda1f5968a30a359aba2f7f9aa648a9ce4b580d6826437f2b291cfc86e", size = 408895, upload-time = "2025-11-30T20:22:51.87Z" }, - { url = "https://files.pythonhosted.org/packages/58/95/d9275b05ab96556fefff73a385813eb66032e4c99f411d0795372d9abcea/rpds_py-0.30.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a4796a717bf12b9da9d3ad002519a86063dcac8988b030e405704ef7d74d2d9d", size = 422799, upload-time = "2025-11-30T20:22:53.341Z" }, - { url = "https://files.pythonhosted.org/packages/06/c1/3088fc04b6624eb12a57eb814f0d4997a44b0d208d6cace713033ff1a6ba/rpds_py-0.30.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:5d4c2aa7c50ad4728a094ebd5eb46c452e9cb7edbfdb18f9e1221f597a73e1e7", size = 572731, upload-time = "2025-11-30T20:22:54.778Z" }, - { url = "https://files.pythonhosted.org/packages/d8/42/c612a833183b39774e8ac8fecae81263a68b9583ee343db33ab571a7ce55/rpds_py-0.30.0-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:ba81a9203d07805435eb06f536d95a266c21e5b2dfbf6517748ca40c98d19e31", size = 599027, upload-time = "2025-11-30T20:22:56.212Z" }, - { url = "https://files.pythonhosted.org/packages/5f/60/525a50f45b01d70005403ae0e25f43c0384369ad24ffe46e8d9068b50086/rpds_py-0.30.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:945dccface01af02675628334f7cf49c2af4c1c904748efc5cf7bbdf0b579f95", size = 563020, upload-time = "2025-11-30T20:22:58.2Z" }, - { url = "https://files.pythonhosted.org/packages/0b/5d/47c4655e9bcd5ca907148535c10e7d489044243cc9941c16ed7cd53be91d/rpds_py-0.30.0-cp313-cp313-win32.whl", hash = "sha256:b40fb160a2db369a194cb27943582b38f79fc4887291417685f3ad693c5a1d5d", size = 223139, upload-time = "2025-11-30T20:23:00.209Z" }, - { url = "https://files.pythonhosted.org/packages/f2/e1/485132437d20aa4d3e1d8b3fb5a5e65aa8139f1e097080c2a8443201742c/rpds_py-0.30.0-cp313-cp313-win_amd64.whl", hash = "sha256:806f36b1b605e2d6a72716f321f20036b9489d29c51c91f4dd29a3e3afb73b15", size = 240224, upload-time = "2025-11-30T20:23:02.008Z" }, - { url = "https://files.pythonhosted.org/packages/24/95/ffd128ed1146a153d928617b0ef673960130be0009c77d8fbf0abe306713/rpds_py-0.30.0-cp313-cp313-win_arm64.whl", hash = "sha256:d96c2086587c7c30d44f31f42eae4eac89b60dabbac18c7669be3700f13c3ce1", size = 230645, upload-time = "2025-11-30T20:23:03.43Z" }, - { url = "https://files.pythonhosted.org/packages/ff/1b/b10de890a0def2a319a2626334a7f0ae388215eb60914dbac8a3bae54435/rpds_py-0.30.0-cp313-cp313t-macosx_10_12_x86_64.whl", hash = "sha256:eb0b93f2e5c2189ee831ee43f156ed34e2a89a78a66b98cadad955972548be5a", size = 364443, upload-time = "2025-11-30T20:23:04.878Z" }, - { url = "https://files.pythonhosted.org/packages/0d/bf/27e39f5971dc4f305a4fb9c672ca06f290f7c4e261c568f3dea16a410d47/rpds_py-0.30.0-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:922e10f31f303c7c920da8981051ff6d8c1a56207dbdf330d9047f6d30b70e5e", size = 353375, upload-time = "2025-11-30T20:23:06.342Z" }, - { url = "https://files.pythonhosted.org/packages/40/58/442ada3bba6e8e6615fc00483135c14a7538d2ffac30e2d933ccf6852232/rpds_py-0.30.0-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cdc62c8286ba9bf7f47befdcea13ea0e26bf294bda99758fd90535cbaf408000", size = 383850, upload-time = "2025-11-30T20:23:07.825Z" }, - { url = "https://files.pythonhosted.org/packages/14/14/f59b0127409a33c6ef6f5c1ebd5ad8e32d7861c9c7adfa9a624fc3889f6c/rpds_py-0.30.0-cp313-cp313t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:47f9a91efc418b54fb8190a6b4aa7813a23fb79c51f4bb84e418f5476c38b8db", size = 392812, upload-time = "2025-11-30T20:23:09.228Z" }, - { url = "https://files.pythonhosted.org/packages/b3/66/e0be3e162ac299b3a22527e8913767d869e6cc75c46bd844aa43fb81ab62/rpds_py-0.30.0-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1f3587eb9b17f3789ad50824084fa6f81921bbf9a795826570bda82cb3ed91f2", size = 517841, upload-time = "2025-11-30T20:23:11.186Z" }, - { url = "https://files.pythonhosted.org/packages/3d/55/fa3b9cf31d0c963ecf1ba777f7cf4b2a2c976795ac430d24a1f43d25a6ba/rpds_py-0.30.0-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:39c02563fc592411c2c61d26b6c5fe1e51eaa44a75aa2c8735ca88b0d9599daa", size = 408149, upload-time = "2025-11-30T20:23:12.864Z" }, - { url = "https://files.pythonhosted.org/packages/60/ca/780cf3b1a32b18c0f05c441958d3758f02544f1d613abf9488cd78876378/rpds_py-0.30.0-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:51a1234d8febafdfd33a42d97da7a43f5dcb120c1060e352a3fbc0c6d36e2083", size = 383843, upload-time = "2025-11-30T20:23:14.638Z" }, - { url = "https://files.pythonhosted.org/packages/82/86/d5f2e04f2aa6247c613da0c1dd87fcd08fa17107e858193566048a1e2f0a/rpds_py-0.30.0-cp313-cp313t-manylinux_2_31_riscv64.whl", hash = "sha256:eb2c4071ab598733724c08221091e8d80e89064cd472819285a9ab0f24bcedb9", size = 396507, upload-time = "2025-11-30T20:23:16.105Z" }, - { url = "https://files.pythonhosted.org/packages/4b/9a/453255d2f769fe44e07ea9785c8347edaf867f7026872e76c1ad9f7bed92/rpds_py-0.30.0-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6bdfdb946967d816e6adf9a3d8201bfad269c67efe6cefd7093ef959683c8de0", size = 414949, upload-time = "2025-11-30T20:23:17.539Z" }, - { url = "https://files.pythonhosted.org/packages/a3/31/622a86cdc0c45d6df0e9ccb6becdba5074735e7033c20e401a6d9d0e2ca0/rpds_py-0.30.0-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:c77afbd5f5250bf27bf516c7c4a016813eb2d3e116139aed0096940c5982da94", size = 565790, upload-time = "2025-11-30T20:23:19.029Z" }, - { url = "https://files.pythonhosted.org/packages/1c/5d/15bbf0fb4a3f58a3b1c67855ec1efcc4ceaef4e86644665fff03e1b66d8d/rpds_py-0.30.0-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:61046904275472a76c8c90c9ccee9013d70a6d0f73eecefd38c1ae7c39045a08", size = 590217, upload-time = "2025-11-30T20:23:20.885Z" }, - { url = "https://files.pythonhosted.org/packages/6d/61/21b8c41f68e60c8cc3b2e25644f0e3681926020f11d06ab0b78e3c6bbff1/rpds_py-0.30.0-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:4c5f36a861bc4b7da6516dbdf302c55313afa09b81931e8280361a4f6c9a2d27", size = 555806, upload-time = "2025-11-30T20:23:22.488Z" }, - { url = "https://files.pythonhosted.org/packages/f9/39/7e067bb06c31de48de3eb200f9fc7c58982a4d3db44b07e73963e10d3be9/rpds_py-0.30.0-cp313-cp313t-win32.whl", hash = "sha256:3d4a69de7a3e50ffc214ae16d79d8fbb0922972da0356dcf4d0fdca2878559c6", size = 211341, upload-time = "2025-11-30T20:23:24.449Z" }, - { url = "https://files.pythonhosted.org/packages/0a/4d/222ef0b46443cf4cf46764d9c630f3fe4abaa7245be9417e56e9f52b8f65/rpds_py-0.30.0-cp313-cp313t-win_amd64.whl", hash = "sha256:f14fc5df50a716f7ece6a80b6c78bb35ea2ca47c499e422aa4463455dd96d56d", size = 225768, upload-time = "2025-11-30T20:23:25.908Z" }, - { url = "https://files.pythonhosted.org/packages/86/81/dad16382ebbd3d0e0328776d8fd7ca94220e4fa0798d1dc5e7da48cb3201/rpds_py-0.30.0-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:68f19c879420aa08f61203801423f6cd5ac5f0ac4ac82a2368a9fcd6a9a075e0", size = 362099, upload-time = "2025-11-30T20:23:27.316Z" }, - { url = "https://files.pythonhosted.org/packages/2b/60/19f7884db5d5603edf3c6bce35408f45ad3e97e10007df0e17dd57af18f8/rpds_py-0.30.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:ec7c4490c672c1a0389d319b3a9cfcd098dcdc4783991553c332a15acf7249be", size = 353192, upload-time = "2025-11-30T20:23:29.151Z" }, - { url = "https://files.pythonhosted.org/packages/bf/c4/76eb0e1e72d1a9c4703c69607cec123c29028bff28ce41588792417098ac/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f251c812357a3fed308d684a5079ddfb9d933860fc6de89f2b7ab00da481e65f", size = 384080, upload-time = "2025-11-30T20:23:30.785Z" }, - { url = "https://files.pythonhosted.org/packages/72/87/87ea665e92f3298d1b26d78814721dc39ed8d2c74b86e83348d6b48a6f31/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ac98b175585ecf4c0348fd7b29c3864bda53b805c773cbf7bfdaffc8070c976f", size = 394841, upload-time = "2025-11-30T20:23:32.209Z" }, - { url = "https://files.pythonhosted.org/packages/77/ad/7783a89ca0587c15dcbf139b4a8364a872a25f861bdb88ed99f9b0dec985/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3e62880792319dbeb7eb866547f2e35973289e7d5696c6e295476448f5b63c87", size = 516670, upload-time = "2025-11-30T20:23:33.742Z" }, - { url = "https://files.pythonhosted.org/packages/5b/3c/2882bdac942bd2172f3da574eab16f309ae10a3925644e969536553cb4ee/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4e7fc54e0900ab35d041b0601431b0a0eb495f0851a0639b6ef90f7741b39a18", size = 408005, upload-time = "2025-11-30T20:23:35.253Z" }, - { url = "https://files.pythonhosted.org/packages/ce/81/9a91c0111ce1758c92516a3e44776920b579d9a7c09b2b06b642d4de3f0f/rpds_py-0.30.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47e77dc9822d3ad616c3d5759ea5631a75e5809d5a28707744ef79d7a1bcfcad", size = 382112, upload-time = "2025-11-30T20:23:36.842Z" }, - { url = "https://files.pythonhosted.org/packages/cf/8e/1da49d4a107027e5fbc64daeab96a0706361a2918da10cb41769244b805d/rpds_py-0.30.0-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:b4dc1a6ff022ff85ecafef7979a2c6eb423430e05f1165d6688234e62ba99a07", size = 399049, upload-time = "2025-11-30T20:23:38.343Z" }, - { url = "https://files.pythonhosted.org/packages/df/5a/7ee239b1aa48a127570ec03becbb29c9d5a9eb092febbd1699d567cae859/rpds_py-0.30.0-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4559c972db3a360808309e06a74628b95eaccbf961c335c8fe0d590cf587456f", size = 415661, upload-time = "2025-11-30T20:23:40.263Z" }, - { url = "https://files.pythonhosted.org/packages/70/ea/caa143cf6b772f823bc7929a45da1fa83569ee49b11d18d0ada7f5ee6fd6/rpds_py-0.30.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:0ed177ed9bded28f8deb6ab40c183cd1192aa0de40c12f38be4d59cd33cb5c65", size = 565606, upload-time = "2025-11-30T20:23:42.186Z" }, - { url = "https://files.pythonhosted.org/packages/64/91/ac20ba2d69303f961ad8cf55bf7dbdb4763f627291ba3d0d7d67333cced9/rpds_py-0.30.0-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:ad1fa8db769b76ea911cb4e10f049d80bf518c104f15b3edb2371cc65375c46f", size = 591126, upload-time = "2025-11-30T20:23:44.086Z" }, - { url = "https://files.pythonhosted.org/packages/21/20/7ff5f3c8b00c8a95f75985128c26ba44503fb35b8e0259d812766ea966c7/rpds_py-0.30.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:46e83c697b1f1c72b50e5ee5adb4353eef7406fb3f2043d64c33f20ad1c2fc53", size = 553371, upload-time = "2025-11-30T20:23:46.004Z" }, - { url = "https://files.pythonhosted.org/packages/72/c7/81dadd7b27c8ee391c132a6b192111ca58d866577ce2d9b0ca157552cce0/rpds_py-0.30.0-cp314-cp314-win32.whl", hash = "sha256:ee454b2a007d57363c2dfd5b6ca4a5d7e2c518938f8ed3b706e37e5d470801ed", size = 215298, upload-time = "2025-11-30T20:23:47.696Z" }, - { url = "https://files.pythonhosted.org/packages/3e/d2/1aaac33287e8cfb07aab2e6b8ac1deca62f6f65411344f1433c55e6f3eb8/rpds_py-0.30.0-cp314-cp314-win_amd64.whl", hash = "sha256:95f0802447ac2d10bcc69f6dc28fe95fdf17940367b21d34e34c737870758950", size = 228604, upload-time = "2025-11-30T20:23:49.501Z" }, - { url = "https://files.pythonhosted.org/packages/e8/95/ab005315818cc519ad074cb7784dae60d939163108bd2b394e60dc7b5461/rpds_py-0.30.0-cp314-cp314-win_arm64.whl", hash = "sha256:613aa4771c99f03346e54c3f038e4cc574ac09a3ddfb0e8878487335e96dead6", size = 222391, upload-time = "2025-11-30T20:23:50.96Z" }, - { url = "https://files.pythonhosted.org/packages/9e/68/154fe0194d83b973cdedcdcc88947a2752411165930182ae41d983dcefa6/rpds_py-0.30.0-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:7e6ecfcb62edfd632e56983964e6884851786443739dbfe3582947e87274f7cb", size = 364868, upload-time = "2025-11-30T20:23:52.494Z" }, - { url = "https://files.pythonhosted.org/packages/83/69/8bbc8b07ec854d92a8b75668c24d2abcb1719ebf890f5604c61c9369a16f/rpds_py-0.30.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:a1d0bc22a7cdc173fedebb73ef81e07faef93692b8c1ad3733b67e31e1b6e1b8", size = 353747, upload-time = "2025-11-30T20:23:54.036Z" }, - { url = "https://files.pythonhosted.org/packages/ab/00/ba2e50183dbd9abcce9497fa5149c62b4ff3e22d338a30d690f9af970561/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d08f00679177226c4cb8c5265012eea897c8ca3b93f429e546600c971bcbae7", size = 383795, upload-time = "2025-11-30T20:23:55.556Z" }, - { url = "https://files.pythonhosted.org/packages/05/6f/86f0272b84926bcb0e4c972262f54223e8ecc556b3224d281e6598fc9268/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5965af57d5848192c13534f90f9dd16464f3c37aaf166cc1da1cae1fd5a34898", size = 393330, upload-time = "2025-11-30T20:23:57.033Z" }, - { url = "https://files.pythonhosted.org/packages/cb/e9/0e02bb2e6dc63d212641da45df2b0bf29699d01715913e0d0f017ee29438/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9a4e86e34e9ab6b667c27f3211ca48f73dba7cd3d90f8d5b11be56e5dbc3fb4e", size = 518194, upload-time = "2025-11-30T20:23:58.637Z" }, - { url = "https://files.pythonhosted.org/packages/ee/ca/be7bca14cf21513bdf9c0606aba17d1f389ea2b6987035eb4f62bd923f25/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e5d3e6b26f2c785d65cc25ef1e5267ccbe1b069c5c21b8cc724efee290554419", size = 408340, upload-time = "2025-11-30T20:24:00.2Z" }, - { url = "https://files.pythonhosted.org/packages/c2/c7/736e00ebf39ed81d75544c0da6ef7b0998f8201b369acf842f9a90dc8fce/rpds_py-0.30.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:626a7433c34566535b6e56a1b39a7b17ba961e97ce3b80ec62e6f1312c025551", size = 383765, upload-time = "2025-11-30T20:24:01.759Z" }, - { url = "https://files.pythonhosted.org/packages/4a/3f/da50dfde9956aaf365c4adc9533b100008ed31aea635f2b8d7b627e25b49/rpds_py-0.30.0-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:acd7eb3f4471577b9b5a41baf02a978e8bdeb08b4b355273994f8b87032000a8", size = 396834, upload-time = "2025-11-30T20:24:03.687Z" }, - { url = "https://files.pythonhosted.org/packages/4e/00/34bcc2565b6020eab2623349efbdec810676ad571995911f1abdae62a3a0/rpds_py-0.30.0-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fe5fa731a1fa8a0a56b0977413f8cacac1768dad38d16b3a296712709476fbd5", size = 415470, upload-time = "2025-11-30T20:24:05.232Z" }, - { url = "https://files.pythonhosted.org/packages/8c/28/882e72b5b3e6f718d5453bd4d0d9cf8df36fddeb4ddbbab17869d5868616/rpds_py-0.30.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:74a3243a411126362712ee1524dfc90c650a503502f135d54d1b352bd01f2404", size = 565630, upload-time = "2025-11-30T20:24:06.878Z" }, - { url = "https://files.pythonhosted.org/packages/3b/97/04a65539c17692de5b85c6e293520fd01317fd878ea1995f0367d4532fb1/rpds_py-0.30.0-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:3e8eeb0544f2eb0d2581774be4c3410356eba189529a6b3e36bbbf9696175856", size = 591148, upload-time = "2025-11-30T20:24:08.445Z" }, - { url = "https://files.pythonhosted.org/packages/85/70/92482ccffb96f5441aab93e26c4d66489eb599efdcf96fad90c14bbfb976/rpds_py-0.30.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:dbd936cde57abfee19ab3213cf9c26be06d60750e60a8e4dd85d1ab12c8b1f40", size = 556030, upload-time = "2025-11-30T20:24:10.956Z" }, - { url = "https://files.pythonhosted.org/packages/20/53/7c7e784abfa500a2b6b583b147ee4bb5a2b3747a9166bab52fec4b5b5e7d/rpds_py-0.30.0-cp314-cp314t-win32.whl", hash = "sha256:dc824125c72246d924f7f796b4f63c1e9dc810c7d9e2355864b3c3a73d59ade0", size = 211570, upload-time = "2025-11-30T20:24:12.735Z" }, - { url = "https://files.pythonhosted.org/packages/d0/02/fa464cdfbe6b26e0600b62c528b72d8608f5cc49f96b8d6e38c95d60c676/rpds_py-0.30.0-cp314-cp314t-win_amd64.whl", hash = "sha256:27f4b0e92de5bfbc6f86e43959e6edd1425c33b5e69aab0984a72047f2bcf1e3", size = 226532, upload-time = "2025-11-30T20:24:14.634Z" }, - { url = "https://files.pythonhosted.org/packages/69/71/3f34339ee70521864411f8b6992e7ab13ac30d8e4e3309e07c7361767d91/rpds_py-0.30.0-pp311-pypy311_pp73-macosx_10_12_x86_64.whl", hash = "sha256:c2262bdba0ad4fc6fb5545660673925c2d2a5d9e2e0fb603aad545427be0fc58", size = 372292, upload-time = "2025-11-30T20:24:16.537Z" }, - { url = "https://files.pythonhosted.org/packages/57/09/f183df9b8f2d66720d2ef71075c59f7e1b336bec7ee4c48f0a2b06857653/rpds_py-0.30.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl", hash = "sha256:ee6af14263f25eedc3bb918a3c04245106a42dfd4f5c2285ea6f997b1fc3f89a", size = 362128, upload-time = "2025-11-30T20:24:18.086Z" }, - { url = "https://files.pythonhosted.org/packages/7a/68/5c2594e937253457342e078f0cc1ded3dd7b2ad59afdbf2d354869110a02/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3adbb8179ce342d235c31ab8ec511e66c73faa27a47e076ccc92421add53e2bb", size = 391542, upload-time = "2025-11-30T20:24:20.092Z" }, - { url = "https://files.pythonhosted.org/packages/49/5c/31ef1afd70b4b4fbdb2800249f34c57c64beb687495b10aec0365f53dfc4/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:250fa00e9543ac9b97ac258bd37367ff5256666122c2d0f2bc97577c60a1818c", size = 404004, upload-time = "2025-11-30T20:24:22.231Z" }, - { url = "https://files.pythonhosted.org/packages/e3/63/0cfbea38d05756f3440ce6534d51a491d26176ac045e2707adc99bb6e60a/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9854cf4f488b3d57b9aaeb105f06d78e5529d3145b1e4a41750167e8c213c6d3", size = 527063, upload-time = "2025-11-30T20:24:24.302Z" }, - { url = "https://files.pythonhosted.org/packages/42/e6/01e1f72a2456678b0f618fc9a1a13f882061690893c192fcad9f2926553a/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:993914b8e560023bc0a8bf742c5f303551992dcb85e247b1e5c7f4a7d145bda5", size = 413099, upload-time = "2025-11-30T20:24:25.916Z" }, - { url = "https://files.pythonhosted.org/packages/b8/25/8df56677f209003dcbb180765520c544525e3ef21ea72279c98b9aa7c7fb/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:58edca431fb9b29950807e301826586e5bbf24163677732429770a697ffe6738", size = 392177, upload-time = "2025-11-30T20:24:27.834Z" }, - { url = "https://files.pythonhosted.org/packages/4a/b4/0a771378c5f16f8115f796d1f437950158679bcd2a7c68cf251cfb00ed5b/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_31_riscv64.whl", hash = "sha256:dea5b552272a944763b34394d04577cf0f9bd013207bc32323b5a89a53cf9c2f", size = 406015, upload-time = "2025-11-30T20:24:29.457Z" }, - { url = "https://files.pythonhosted.org/packages/36/d8/456dbba0af75049dc6f63ff295a2f92766b9d521fa00de67a2bd6427d57a/rpds_py-0.30.0-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:ba3af48635eb83d03f6c9735dfb21785303e73d22ad03d489e88adae6eab8877", size = 423736, upload-time = "2025-11-30T20:24:31.22Z" }, - { url = "https://files.pythonhosted.org/packages/13/64/b4d76f227d5c45a7e0b796c674fd81b0a6c4fbd48dc29271857d8219571c/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:dff13836529b921e22f15cb099751209a60009731a68519630a24d61f0b1b30a", size = 573981, upload-time = "2025-11-30T20:24:32.934Z" }, - { url = "https://files.pythonhosted.org/packages/20/91/092bacadeda3edf92bf743cc96a7be133e13a39cdbfd7b5082e7ab638406/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_i686.whl", hash = "sha256:1b151685b23929ab7beec71080a8889d4d6d9fa9a983d213f07121205d48e2c4", size = 599782, upload-time = "2025-11-30T20:24:35.169Z" }, - { url = "https://files.pythonhosted.org/packages/d1/b7/b95708304cd49b7b6f82fdd039f1748b66ec2b21d6a45180910802f1abf1/rpds_py-0.30.0-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:ac37f9f516c51e5753f27dfdef11a88330f04de2d564be3991384b2f3535d02e", size = 562191, upload-time = "2025-11-30T20:24:36.853Z" }, -] - [[package]] name = "rpds-py" version = "2026.9.1" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] sdist = { url = "https://files.pythonhosted.org/packages/42/68/3bd46b8a5e01d3c2ebdf9c5e9497912e3fe0cde02bac21a7130ca866e403/rpds_py-2026.9.1.tar.gz", hash = "sha256:4793ef7f78268b124b73fa933440f01d258bbae01de9fa53e9080c9ab0425a12", size = 63948, upload-time = "2026-10-04T16:32:36.469Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/f5/6d/ddb8dfcf41892ba9c672d27988592c038d30db61708230313831b6780a1b/rpds_py-2026.9.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:2711d29b653b3bce48a63d18b9c6b53274669e6d6c4094dddeb4d9a0e45128b2", size = 344947, upload-time = "2026-10-04T16:28:55.207Z" }, @@ -2025,94 +1546,32 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/37/c3/6eeb6034408dac0fa653d126c9204ade96b819c936e136c5e8a6897eee9c/socksio-1.0.0-py3-none-any.whl", hash = "sha256:95dc1f15f9b34e8d7b16f06d74b8ccf48f609af32ab33c608d08761c5dcbb1f3", size = 12763, upload-time = "2020-04-17T15:50:31.878Z" }, ] -[[package]] -name = "soupsieve" -version = "2.10" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.11' and python_full_version < '3.11.5'", - "python_full_version < '3.11'", -] -sdist = { url = "https://files.pythonhosted.org/packages/71/c3/1b817965ac12dc002d7c9cd7dfffdd7d4fbf9b45763ef2ffe7b86ee94670/soupsieve-2.10.tar.gz", hash = "sha256:49e9380d7d2905463583bafe285e818c7366a9ed7b3aee221c1ac79c905d8bc0", size = 124337, upload-time = "2026-09-24T02:36:35.048Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/66/87/5ed59e1d0290564e2027ed066c52b059892c4637741337fc0967183c8d4d/soupsieve-2.10-py3-none-any.whl", hash = "sha256:8596eb8967d744174820280fa62b4542a2e955bfaccca73ed8a13c6eb8e9b502", size = 38019, upload-time = "2026-09-24T02:36:33.709Z" }, -] - [[package]] name = "soupsieve" version = "4.0.1" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", -] sdist = { url = "https://files.pythonhosted.org/packages/01/7c/a64eedae0b7776cb9602d2da9cb8f8caae8e1b4c1da5e8e87bf1e68121ec/soupsieve-4.0.1.tar.gz", hash = "sha256:7621e3c5f6b371ed2c5eabaac5de300ac3d66d05e6d7f34783e31b63c4f90c75", size = 153302, upload-time = "2026-11-04T16:36:27.749Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/2c/5c/4f68370847b561a389dd9a2d7eb3d19fd8cbb8acbae543a0c6b8d0d9700b/soupsieve-4.0.1-py3-none-any.whl", hash = "sha256:2e68cf7dd5a0f29d81f9d485275ccf294e6475f615e211895d91cb81f8614f04", size = 50688, upload-time = "2026-11-04T16:36:26.158Z" }, ] -[[package]] -name = "sse-starlette" -version = "3.5.1" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -dependencies = [ - { name = "anyio" }, - { name = "starlette", version = "1.7.0", source = { registry = "https://pypi.org/simple" } }, -] -sdist = { url = "https://files.pythonhosted.org/packages/af/2e/16b9cce59c2eebd2f944b41b01df119f8ee65535ce839c462f1b2c9ae2e0/sse_starlette-3.5.1.tar.gz", hash = "sha256:dbb1461cd53c1e284537c3ddcf92f54f24178519a3f1e335e49e5283993db0f7", size = 38356, upload-time = "2026-10-24T08:45:12.444Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/61/98/658d1681bc6dc0b0f7f695aee4337de79decd0ccaec6d000a76b5cbdca6d/sse_starlette-3.5.1-py3-none-any.whl", hash = "sha256:a6cdcfec47b952911b1d99a7b8056429b5984039b875bf6575174220364b551f", size = 17538, upload-time = "2026-10-24T08:45:10.981Z" }, -] - [[package]] name = "sse-starlette" version = "3.6.0" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] dependencies = [ { name = "anyio" }, - { name = "starlette", version = "1.10.0", source = { registry = "https://pypi.org/simple" } }, + { name = "starlette" }, ] sdist = { url = "https://files.pythonhosted.org/packages/71/7f/3b8ec4f27833f7b8c270a3ef960b6d435e1065439847bc0fcd1e58ae898b/sse_starlette-3.6.0.tar.gz", hash = "sha256:623151d6c20dc0eebf1b3379c27faae91fff883bac7ab6665f16f46440a88b3a", size = 41174, upload-time = "2026-10-25T20:31:59.372Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/cf/49/35053078cdfcf639237e8bee6dc6f34f1b3a3cc8d01800a1e213e1660ff6/sse_starlette-3.6.0-py3-none-any.whl", hash = "sha256:e4dfa4d237d2712cb2b4d4918eda9b457cd6b44bbecdc838af75de836565bafd", size = 17985, upload-time = "2026-10-25T20:31:58.134Z" }, ] -[[package]] -name = "starlette" -version = "1.7.0" -source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version < '3.11'", -] -dependencies = [ - { name = "anyio" }, - { name = "typing-extensions" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/7b/2b/3850dc6bf7ef71b088962eba31dafc6cffd2f96e577ebb0bb316df96da3e/starlette-1.7.0.tar.gz", hash = "sha256:c79f74ea63cff761804fbbfb182f1e0b440c2d07b164d24700c5a1bab5d6ff5d", size = 2736246, upload-time = "2026-09-23T07:30:26.35Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/4e/d6/1ec1b290f9e0fb067899b61e1d37a30c923068bad260b216dbe37a7d2967/starlette-1.7.0-py3-none-any.whl", hash = "sha256:67f8e99895493dd2911a03f11314af6ceebeae4e704bb9f43dfc6a9db151c93e", size = 78980, upload-time = "2026-09-23T07:30:24.567Z" }, -] - [[package]] name = "starlette" version = "1.10.0" source = { registry = "https://pypi.org/simple" } -resolution-markers = [ - "python_full_version >= '3.14'", - "python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform == 'emscripten'", - "(python_full_version >= '3.11.5' and python_full_version < '3.12') or (python_full_version >= '3.12' and python_full_version < '3.14' and sys_platform != 'emscripten')", - "python_full_version >= '3.11' and python_full_version < '3.11.5'", -] dependencies = [ { name = "anyio" }, { name = "typing-extensions", marker = "python_full_version < '3.13'" }, @@ -2122,78 +1581,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/88/2e/947cfe02def9371c07cd5bf5b6b61c829e9aecb9904db02a66cfafbc1eec/starlette-1.10.0-py3-none-any.whl", hash = "sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4", size = 80571, upload-time = "2026-10-24T15:04:10.371Z" }, ] -[[package]] -name = "tomli" -version = "2.5.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/b0/78/9ad63712633ed3ab5cc1a648d863d7e7da371e9425e209555a0fe711b695/tomli-2.5.0.tar.gz", hash = "sha256:264507556cd8b8c8e7c6ee037cdf443a463f03f4c958e57195e3d369711b8ff6", size = 17662, upload-time = "2026-10-07T12:23:37.892Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/22/a6/ab99b60ee52acd949684febabc3005d0045d0f66bebd9cdebd67372d26dd/tomli-2.5.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c4dc1c1781f2f716de763d1e9a7b34c6a894e167e291c7c5d16c72f7a9538545", size = 163901, upload-time = "2026-10-07T12:22:15.601Z" }, - { url = "https://files.pythonhosted.org/packages/bc/00/ee01b7ed4579180fff07142d290257f25ba786f23f3ec6005f620933c2f5/tomli-2.5.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:eff8babca5a7999bc137acbc7482a8b7e17ffca5075ab41f5d770ab408c7bfef", size = 163756, upload-time = "2026-10-07T12:22:16.957Z" }, - { url = "https://files.pythonhosted.org/packages/72/c2/4efebf65372f6583185f79799312109dddb61102d47e5c33dcfd1a297aca/tomli-2.5.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:86665cee9c4835b7a7f1e8ec2c719b5258d4dc782887aded5a8ae7352a96843b", size = 268038, upload-time = "2026-10-07T12:22:18.135Z" }, - { url = "https://files.pythonhosted.org/packages/53/07/5850468e925d898abb36038666f9c333a94d2a223e802a8ba5b6d319d23f/tomli-2.5.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d7e369fd63331746182360977b1892bfc215476a30d61612d732425311639f56", size = 276422, upload-time = "2026-10-07T12:22:19.567Z" }, - { url = "https://files.pythonhosted.org/packages/b4/87/f293984cdcf83c054196d4fd3dad44fc68ae55b4b8c44bc76cef360c3150/tomli-2.5.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:7ad1ea345759240d6463efa0ed1c704402752e49aa21476620738d74d72d8aa1", size = 272616, upload-time = "2026-10-07T12:22:20.794Z" }, - { url = "https://files.pythonhosted.org/packages/ce/ce/db582886b3c1219d3fec93ebd669332482e5aee7a91e0f7838d84f2d1759/tomli-2.5.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:96243987194634bd411066ce40c952e108f86af04db533ecd8ac3ff2a85b1885", size = 276593, upload-time = "2026-10-07T12:22:22.12Z" }, - { url = "https://files.pythonhosted.org/packages/bf/72/7619b87dea4261fc27dd7b54c4461c129c1f7d9bb7ba3aec89c797a431b8/tomli-2.5.0-cp311-cp311-win32.whl", hash = "sha256:610b27d99f28ec5f191c7064a48f3ddb179a1fe6ca73d571483ae859f57b605e", size = 101830, upload-time = "2026-10-07T12:22:23.651Z" }, - { url = "https://files.pythonhosted.org/packages/1e/74/220106da34502304b6751a2a9b8a9fbca6c3fd47e737a2e2e3da7c61c9db/tomli-2.5.0-cp311-cp311-win_amd64.whl", hash = "sha256:c804ae44fe7b4bab5da295e4f980a1ff04670bca9d23fe0a4e887e08ebd741a8", size = 112742, upload-time = "2026-10-07T12:22:24.972Z" }, - { url = "https://files.pythonhosted.org/packages/27/99/7d9c8b41837a7773613e169504147375c157a290167aa59ad74a085f521f/tomli-2.5.0-cp311-cp311-win_arm64.whl", hash = "sha256:cfac177ebd6236003846ea339981f71457cb6eb748f23381eb257e45092e3980", size = 109332, upload-time = "2026-10-07T12:22:26.117Z" }, - { url = "https://files.pythonhosted.org/packages/52/ed/7baa86f87493646a594de388c7c1c40a39dd0461f7e9c0359cbeefc91fe8/tomli-2.5.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:1f4a40d03fb9f63424f0979855bdeaf44dd7696b8d59501822c10ed30ba532df", size = 164854, upload-time = "2026-10-07T12:22:27.444Z" }, - { url = "https://files.pythonhosted.org/packages/a5/b1/44c0341f2224397855723c7a8a39f718ea6fcbcc3dacc66e5aeca0f334e3/tomli-2.5.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:9ebf8d19b17bd0daeb7b7dec81a946a439b753942fd0210d6e96c532249eea6b", size = 164074, upload-time = "2026-10-07T12:22:28.679Z" }, - { url = "https://files.pythonhosted.org/packages/23/04/e2d5b7d3fba47adedb23de616c16d428ea076c79a3d8e1d95d649ffe197e/tomli-2.5.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bf0b5e8e0f68ebb494356e577c06c139161efd8d3b9050f93b39b7c26cc54ff0", size = 274274, upload-time = "2026-10-07T12:22:29.804Z" }, - { url = "https://files.pythonhosted.org/packages/43/90/6090e706ff27a6f89f4a40578e3324b95c3cd8c4150868aabf33a8f414c3/tomli-2.5.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6cf74416bdc94ae458b14e37286c1073081850ac8459a00d0c5efef5d44294c6", size = 286435, upload-time = "2026-10-07T12:22:31.297Z" }, - { url = "https://files.pythonhosted.org/packages/0a/9e/a2c40768df16c408f22430afb0a73e9d7e5f79c950884954649d1146b74d/tomli-2.5.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:61ea1ebe1e55a34ea8199cc8dbff398d35027b82271c8ac4802fd3a1fd5b1bcc", size = 278119, upload-time = "2026-10-07T12:22:32.601Z" }, - { url = "https://files.pythonhosted.org/packages/12/25/3c0cb485b98e9cfac495629b1c93c87ccf0b72fbe9d2689fd8fe62c6d5a3/tomli-2.5.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:ed53f7e89bb04f6d9e8e7799112360b0c4d5cbff067de0814c98c37c39b920f7", size = 286177, upload-time = "2026-10-07T12:22:33.745Z" }, - { url = "https://files.pythonhosted.org/packages/77/8b/0144c65f0e37e51c18d04ae15c21b19431c165002d0131fe9aa8b0b8b1e8/tomli-2.5.0-cp312-cp312-win32.whl", hash = "sha256:e7ad033e27a516a233bea839cdb77b80146facb3b4f40bf02cd0cac165cdd5c2", size = 102760, upload-time = "2026-10-07T12:22:34.887Z" }, - { url = "https://files.pythonhosted.org/packages/de/32/5d6d8f42fc9a05fce69354e00ff256484192f5f2fc9a2165718fa0de61ec/tomli-2.5.0-cp312-cp312-win_amd64.whl", hash = "sha256:bd05de8c1698f8413dd7d869492693a0bf2211543b787ac78cd5e7536af1a6d7", size = 112722, upload-time = "2026-10-07T12:22:36.162Z" }, - { url = "https://files.pythonhosted.org/packages/30/65/df18032218db0fb9b769fb23c8039a051f15c811993995ea04c350273a32/tomli-2.5.0-cp312-cp312-win_arm64.whl", hash = "sha256:069435bd5480429b98c5e5afb02ab21c219b6f0064680671c6dc0d46817346ea", size = 109534, upload-time = "2026-10-07T12:22:37.296Z" }, - { url = "https://files.pythonhosted.org/packages/42/e5/51736d70da209350969e15aca5c5ab6e2ce1ea87a0a892a6c13aec172a86/tomli-2.5.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:943276cf269e0071948d9ff697159c1735e623c1151d88abb09b74659ef0cbea", size = 163328, upload-time = "2026-10-07T12:22:38.373Z" }, - { url = "https://files.pythonhosted.org/packages/ec/55/086f80dab4ab497602644274e6dea7ec5dd0b4e262e443a8ad3bb7edee2d/tomli-2.5.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:463b16086865b97facd8d0b3fb4cb7c544e3f58d2a69dc3113d6db9653fdb043", size = 162246, upload-time = "2026-10-07T12:22:39.673Z" }, - { url = "https://files.pythonhosted.org/packages/aa/eb/3ecc94459f3635c92321f4e7bde571323fdb2267c50e19e3188a281eae3b/tomli-2.5.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1245a6638fc4bb0a60af38a7d45413db34a13842027c77597c712c998c62fdf0", size = 272655, upload-time = "2026-10-07T12:22:41.08Z" }, - { url = "https://files.pythonhosted.org/packages/c0/d7/494fd1f0c37a621f1ad9975c2efadb523e8101f144ed6edb2e7fe64738f2/tomli-2.5.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5d8bac3d603c97e6854424e5b2b5b741bdbde387e09f162fb0446812b4a8362b", size = 283595, upload-time = "2026-10-07T12:22:42.222Z" }, - { url = "https://files.pythonhosted.org/packages/70/51/bb8d62b1317e6640866f6949b2d5855e5300f2c99d46de1cd245570bba65/tomli-2.5.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:21e4cae4114aba25aa0d4f85cdf486d290fb35c0954d7bba536248da64d43066", size = 276253, upload-time = "2026-10-07T12:22:43.625Z" }, - { url = "https://files.pythonhosted.org/packages/66/f4/f46bd7f0763cd47de2db697dca9257c6a4adfd1a93b018cc75c8190ed5a8/tomli-2.5.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:bbaefc84548d754be821bba7c4141c4787dda182f9e77f2f87b71213529efa7b", size = 283582, upload-time = "2026-10-07T12:22:44.983Z" }, - { url = "https://files.pythonhosted.org/packages/ac/03/70f2bcb2923a6db37818d917e124270a7f4cfd38ea576f5aa753a91c0ef5/tomli-2.5.0-cp313-cp313-win32.whl", hash = "sha256:abdbf6313b8d9efe157edeb7ab6eae4de064b1300ad31abf73755154b30abe68", size = 102628, upload-time = "2026-10-07T12:22:46.508Z" }, - { url = "https://files.pythonhosted.org/packages/dc/98/d52024bb5b0ff68b4f0d276d867f634c84a67319a7e9f6b7708a37742333/tomli-2.5.0-cp313-cp313-win_amd64.whl", hash = "sha256:fd4dc129784e0c5335bd4e61dfcc4487499a013419e655cf2da1d091b7e0efdc", size = 113301, upload-time = "2026-10-07T12:22:47.647Z" }, - { url = "https://files.pythonhosted.org/packages/6f/f2/540db3a70572a8c23a28aba3e9c358ce0ffffbafc990905c1343aa265b31/tomli-2.5.0-cp313-cp313-win_arm64.whl", hash = "sha256:69491c143d2fe063046e0301e62a810bed338fa4d1ce0fd870c27dc1e09b0d84", size = 109744, upload-time = "2026-10-07T12:22:48.925Z" }, - { url = "https://files.pythonhosted.org/packages/e4/49/caf6b307766eb9567664a8707e9d6be5fcc0e8903f18781c6677a60d80c7/tomli-2.5.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d3182ee2d887e507bd67319a0a61105d1dd33facc111329559a233b772c1a105", size = 162899, upload-time = "2026-10-07T12:22:50.088Z" }, - { url = "https://files.pythonhosted.org/packages/d3/c8/68cfce773a2733a49c74f99d627fb461bd990756860099eac25617889585/tomli-2.5.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:521345fd1f19d45b8df87657aaa38b6f2ca3800059fadf428e7ebf479a383646", size = 162080, upload-time = "2026-10-07T12:22:51.558Z" }, - { url = "https://files.pythonhosted.org/packages/7e/b2/e5bb8651fdad593f670501a7d718b1a7f73f064d44dea15e04c04dfef45d/tomli-2.5.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e95c7614e705bfe2b04b27aa124adec59752d15813df37e2156747cab3a006b", size = 273380, upload-time = "2026-10-07T12:22:52.918Z" }, - { url = "https://files.pythonhosted.org/packages/8d/d2/9e2d7f8b1dfe0e2b34c245986ebd55c4c553ea4ce6c47c443b332673253f/tomli-2.5.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7ac2027d37c3afbdf4bdd377f2676f6f1d2122a5be1f1137b49dced590b37e75", size = 283228, upload-time = "2026-10-07T12:22:54.173Z" }, - { url = "https://files.pythonhosted.org/packages/ba/df/ec7b876b7b1a2718bd74a3743c076fff565b04029ba33e8f61fac262739f/tomli-2.5.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c414be4ed9d3cac80c42e348fa5a956117d1a48227f48026e31f59cb4a7671eb", size = 277189, upload-time = "2026-10-07T12:22:55.342Z" }, - { url = "https://files.pythonhosted.org/packages/7d/7b/e192d9eed0b9cb80da799f4d77052297fb9a2c3cc9b19f571f56ea88add6/tomli-2.5.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:9b03d7dc168353b4132965bde20feceabaa470e570c6f59660dfae59b1f9eeb3", size = 283632, upload-time = "2026-10-07T12:22:56.735Z" }, - { url = "https://files.pythonhosted.org/packages/84/50/ff94454e75461d75623e47401ed323d65c10aab8fe9033242c20cd2fdf32/tomli-2.5.0-cp314-cp314-win32.whl", hash = "sha256:6f041843c4d3a37245c0c056fd955b186bf8b1fb85690cbe40b81230891dc34b", size = 103535, upload-time = "2026-10-07T12:22:58.084Z" }, - { url = "https://files.pythonhosted.org/packages/54/0b/bdacf05f963bd6026ebf6eeb0beda847d1d60e03e440725c64a4e08a0afd/tomli-2.5.0-cp314-cp314-win_amd64.whl", hash = "sha256:f4b653094e18f9031102d3a1da5c729c8f222d85225b18037dac621695e46e1a", size = 114621, upload-time = "2026-10-07T12:22:59.2Z" }, - { url = "https://files.pythonhosted.org/packages/61/99/53f438fa6ae4f9d4ed0ddde3e7242b3bdc34b48c8f9948b72b9e9b127676/tomli-2.5.0-cp314-cp314-win_arm64.whl", hash = "sha256:3f89d10c1ff6a38d992c27fc8a4816af71a909e08a40ec66934240b1e74347c3", size = 111572, upload-time = "2026-10-07T12:23:00.479Z" }, - { url = "https://files.pythonhosted.org/packages/b9/20/1f88f19427d380a40e90a770e087489eaafe4aeee070ae88ed2bbec00acd/tomli-2.5.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:e9e15b4a6c7dd6b85b5fbab29488a73f1f70de516942308daa266bf0e0aeb0d4", size = 171814, upload-time = "2026-10-07T12:23:01.914Z" }, - { url = "https://files.pythonhosted.org/packages/d0/56/cbe5079c9f9a54b9b3e27fc82f08f3cb36edee75561679f53d2380c801d6/tomli-2.5.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:e12bbcd32897272fb05929110362ae9ff4c1b9bb26bd9e971e71dcd3275b4c3d", size = 171324, upload-time = "2026-10-07T12:23:03.18Z" }, - { url = "https://files.pythonhosted.org/packages/2b/30/1d53fd3b0f1cb3ba542e345ec32c26aefdddc4e829e4f3429af8a4f27782/tomli-2.5.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:20aa36de8f2cf87237143bc1fa1aae8d6612c09118f4da21c6a684db5dd1f6f9", size = 297441, upload-time = "2026-10-07T12:23:04.345Z" }, - { url = "https://files.pythonhosted.org/packages/66/d9/0800acb6a111686f764c1b91ef15cc42a20a66a46013bb42220f1d2c61c1/tomli-2.5.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22185fad8a1e622f064e78008018a0dd3323550dcb479cb7a1d296888d74024f", size = 307476, upload-time = "2026-10-07T12:23:05.671Z" }, - { url = "https://files.pythonhosted.org/packages/e8/63/30a8f3cd51b5bec37f04744bad0b0dc6160df84aad4f27b0e9283d66f221/tomli-2.5.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:984012f71908165449a951de2050d52f276bfe3aa5d5f570f63ddad814370374", size = 296113, upload-time = "2026-10-07T12:23:07.202Z" }, - { url = "https://files.pythonhosted.org/packages/ab/18/0b9ffc597e69c5a1e20a7823cb60d54b39a9f54e91edcb8574f022186758/tomli-2.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f79203b3965b4000e91808aaa7c040206093f2b8bf86f455982f2274c9ccf442", size = 307725, upload-time = "2026-10-07T12:23:08.508Z" }, - { url = "https://files.pythonhosted.org/packages/ab/c7/18f8baae0b5607a60e8e19b4a7fedee43a8ff6458e3896dcbbadeeac9c22/tomli-2.5.0-cp314-cp314t-win32.whl", hash = "sha256:91294a9fb94a75542f6e46e4a2ae709bd8d9b51134098cae5cf3bea5478b6d03", size = 108546, upload-time = "2026-10-07T12:23:09.956Z" }, - { url = "https://files.pythonhosted.org/packages/72/34/4cca9739254130627bde87500b3f2b512154fe2f278efa7e2a5e10ad4bcb/tomli-2.5.0-cp314-cp314t-win_amd64.whl", hash = "sha256:f15e3e0b835a6d68b10c86bf80a3149780498d6911c93c3ffd1861d19f9200f1", size = 117814, upload-time = "2026-10-07T12:23:11.486Z" }, - { url = "https://files.pythonhosted.org/packages/7d/fb/afa530d47dd80a78fce43beac6bc6e00f84558eafcffbc6f37b21e80d056/tomli-2.5.0-cp314-cp314t-win_arm64.whl", hash = "sha256:6664b7ae7af7294256c53960a6103077f4914cec8ff98479c352f622c6f6b2f0", size = 115188, upload-time = "2026-10-07T12:23:12.728Z" }, - { url = "https://files.pythonhosted.org/packages/66/98/316fdc00f8c0939e6fe50461dd343c162d3ad51d1286eb25b7db54361d50/tomli-2.5.0-cp315-cp315-macosx_10_15_x86_64.whl", hash = "sha256:a525685c2f97da40762b8695eb7aa0af4c8344ca1905c73e4e29cb04d34607dc", size = 162775, upload-time = "2026-10-07T12:23:13.941Z" }, - { url = "https://files.pythonhosted.org/packages/c5/22/7b10fa5bb01c9539f53f69b619361b19350acc73657772ea7ac70ba309a8/tomli-2.5.0-cp315-cp315-macosx_11_0_arm64.whl", hash = "sha256:9dbb18c1cfb2f6517942fc9314437f66aa06d94436ffb1f06102ef3572f35276", size = 161406, upload-time = "2026-10-07T12:23:15.215Z" }, - { url = "https://files.pythonhosted.org/packages/9c/e7/1a069d86dfd20f1f84f71c63faed9f83c1d890bc06c27d82dc7d888fb573/tomli-2.5.0-cp315-cp315-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:752e8b1aa6a4367ef8bf6a1a1e005540f7ed055ba36d7193796812ca5404eb52", size = 273855, upload-time = "2026-10-07T12:23:16.471Z" }, - { url = "https://files.pythonhosted.org/packages/ae/83/d1ef43d1687d092ab9c235455c76e6e709483b346b056f086095c7c263a5/tomli-2.5.0-cp315-cp315-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c47300f9bf791808f77d82747691c4bb09cb14bdf3060cca99b42cdc4361d5a7", size = 284910, upload-time = "2026-10-07T12:23:18.166Z" }, - { url = "https://files.pythonhosted.org/packages/cc/05/f4d9cf7de61822ece0c3873f30d291e324911c71a378b8bfe5ced13fd9f5/tomli-2.5.0-cp315-cp315-musllinux_1_2_aarch64.whl", hash = "sha256:19b0dd8749f4ea2f112c5fcfb3c5248390c899d7e2e173f1d91abee1fa0ff391", size = 277723, upload-time = "2026-10-07T12:23:19.355Z" }, - { url = "https://files.pythonhosted.org/packages/42/28/78262493141fa543151cf005760c3cb01d09fc28a11f993c05109902cb8c/tomli-2.5.0-cp315-cp315-musllinux_1_2_x86_64.whl", hash = "sha256:57b1c3b01fab802e2899bc3d168dca320e14165e2fd9fd584760fb4ca5826859", size = 285115, upload-time = "2026-10-07T12:23:20.698Z" }, - { url = "https://files.pythonhosted.org/packages/1a/b9/e1dab9a30bcb677b5cc5cee810609cfd64f24306a3055767dd3fda00b1e0/tomli-2.5.0-cp315-cp315-win32.whl", hash = "sha256:667e521b37a6c5ccaa044202c235b530f90177ffe2cd4a64ecc213c7dd535feb", size = 103475, upload-time = "2026-10-07T12:23:21.941Z" }, - { url = "https://files.pythonhosted.org/packages/4c/bd/31a3790c11d6ea95fcf5e6022ac0f8d0543c9b61120b730fc481bd43d3b4/tomli-2.5.0-cp315-cp315-win_amd64.whl", hash = "sha256:d747252933c8a65ef6bd8da0fbb7ce28a90eb6119d8cd00772cd528aa07b68d5", size = 114589, upload-time = "2026-10-07T12:23:23.098Z" }, - { url = "https://files.pythonhosted.org/packages/47/a2/4f6310fa699364f0e3af7ee3af88dddd9af066d33e716a0265bbe2b3ea84/tomli-2.5.0-cp315-cp315-win_arm64.whl", hash = "sha256:75dbcde8751b0a960aa3de173aa5e894d590755c6d7758b7e774c06f1dc3cbdd", size = 111493, upload-time = "2026-10-07T12:23:24.233Z" }, - { url = "https://files.pythonhosted.org/packages/68/14/00853f0b396d8971107ae1921bb5b322fdee1650d2f16bf06c20adb532e5/tomli-2.5.0-cp315-cp315t-macosx_10_15_x86_64.whl", hash = "sha256:2419c2a189551987b59d80e63ec355671283336f41c6b9b89462df679c7d0c57", size = 171380, upload-time = "2026-10-07T12:23:25.512Z" }, - { url = "https://files.pythonhosted.org/packages/89/ad/fa6949321dadee46b27363974fb197b94c911c3b0f7a5fd26d7dc18fc2a0/tomli-2.5.0-cp315-cp315t-macosx_11_0_arm64.whl", hash = "sha256:0dc598040da8d42cf20f0be588ed7004f46db12a0ac6c32e03a59dccedaaadcd", size = 170553, upload-time = "2026-10-07T12:23:26.855Z" }, - { url = "https://files.pythonhosted.org/packages/53/aa/3056c919eb3e084df3752b2cf5f865dcc04af0b27dba2f66d7b28af4633a/tomli-2.5.0-cp315-cp315t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:49096930c8d886c9bbdab62d2d0d17ce823ddeea522309a190b36245d5b49e01", size = 294428, upload-time = "2026-10-07T12:23:28.132Z" }, - { url = "https://files.pythonhosted.org/packages/96/b2/faeeb5d8769ea3832021d73e892c8391eae7b4b4f8b55a789127bd8b18a9/tomli-2.5.0-cp315-cp315t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8ade5023067f99fe72b88accd30d0ea05a158e9e32a11f124e731ea9695313f", size = 304909, upload-time = "2026-10-07T12:23:29.381Z" }, - { url = "https://files.pythonhosted.org/packages/f6/52/f094c09e73fb654b621716d019acb5d29bdfd1be01df80c281d552bda48d/tomli-2.5.0-cp315-cp315t-musllinux_1_2_aarch64.whl", hash = "sha256:b69564772b5c8f22ea5f498dff08cfa825045b4d4c4400529000bdf818aa3b2a", size = 293220, upload-time = "2026-10-07T12:23:30.608Z" }, - { url = "https://files.pythonhosted.org/packages/86/f5/0c30541078ca4b505ce3bd76ed931facbfec524dd018535d691d1af0a6d2/tomli-2.5.0-cp315-cp315t-musllinux_1_2_x86_64.whl", hash = "sha256:8ff3a2ca028c7eee0c777f9a092038d0a594a9fa04e215f929a22c329e2cb142", size = 305705, upload-time = "2026-10-07T12:23:32.181Z" }, - { url = "https://files.pythonhosted.org/packages/05/74/590e7d19d6a118fc5cc5704ff358e21d95b8573f6b9443b1519f29ca8825/tomli-2.5.0-cp315-cp315t-win32.whl", hash = "sha256:62fc1bc8eb03e3a9cadfca713d65614ed8e09d974a283295ffe3a831976b4dc5", size = 108432, upload-time = "2026-10-07T12:23:33.496Z" }, - { url = "https://files.pythonhosted.org/packages/1c/b8/63a75cfb27a17c38550e44025d3a6e7be64516fd8608a3b75703bf37d81b/tomli-2.5.0-cp315-cp315t-win_amd64.whl", hash = "sha256:f3fcbc57b1791fa6cbe5d8434179d51de12be1a4811469529f47f6e7487a2571", size = 117281, upload-time = "2026-10-07T12:23:34.648Z" }, - { url = "https://files.pythonhosted.org/packages/72/01/e8c1debb2173973372934c68fc8e46170ab60ef23ed4592dff4dec6e8993/tomli-2.5.0-cp315-cp315t-win_arm64.whl", hash = "sha256:d2ba24db8a9376921b5e87b4762b9adb0f3f1deaea68f2b8b0bb2c11efb9c3e7", size = 115069, upload-time = "2026-10-07T12:23:35.77Z" }, - { url = "https://files.pythonhosted.org/packages/60/3f/3e3f8fd0919249b0200c80fbc4f9a1e70be19f9883da71dfb7f8b9ab8aca/tomli-2.5.0-py3-none-any.whl", hash = "sha256:32a7b79ac57a2e83670ce329ccf675798bc5a2094783a63676866b70503f2e2b", size = 14765, upload-time = "2026-10-07T12:23:36.875Z" }, -] - [[package]] name = "truststore" version = "0.10.5" @@ -2240,7 +1627,6 @@ source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "click" }, { name = "h11" }, - { name = "typing-extensions", marker = "python_full_version < '3.11'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/da/34/30e9280707135d2cfc589dfff3cb796bd07a3aeb1a3e415ba09dd89d7bb4/uvicorn-0.54.0.tar.gz", hash = "sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620", size = 112283, upload-time = "2026-09-25T06:52:37.601Z" } wheels = [ diff --git a/src/filesystem/CHANGELOG.md b/src/filesystem/CHANGELOG.md index be32e0b302..c48aaf6ccc 100644 --- a/src/filesystem/CHANGELOG.md +++ b/src/filesystem/CHANGELOG.md @@ -1,5 +1,15 @@ # @modelcontextprotocol/server-filesystem +## 2.4.0 + +### Minor Changes + +- [#5536](https://github.com/modelcontextprotocol/servers/pull/5536) [`311c0fd`](https://github.com/modelcontextprotocol/servers/commit/311c0fdc953f38da08153fd2e8d134d03c8e168b) [@cliffhall](https://github.com/cliffhall) - Serve Streamable HTTP as well as stdio ([#576](https://github.com/modelcontextprotocol/servers/issues/576)). `--transport streamable-http` serves the server on one `/mcp` endpoint, for 2026-07-28 and 2025-era clients alike, at `HOST`:`PORT` (`127.0.0.1:3001` by default); stdio stays the default. Over HTTP the filesystem server requires its allowed directories on the command line, since it cannot ask a client for its Roots, and the sequential-thinking history belongs to the server process rather than to one connection. + +### Patch Changes + +- [#5584](https://github.com/modelcontextprotocol/servers/pull/5584) [`89b1152`](https://github.com/modelcontextprotocol/servers/commit/89b1152805e832371219d27fb9ef885e5a325dfb) [@cliffhall](https://github.com/cliffhall) - Fix GHSA-rq2p-q7c4-6g27. + ## 2.3.0 ### Minor Changes diff --git a/src/filesystem/README.md b/src/filesystem/README.md index 829cc9d03c..0335ff5551 100644 --- a/src/filesystem/README.md +++ b/src/filesystem/README.md @@ -125,8 +125,13 @@ The server's directory access control follows this flow: /Users/username/project ``` - Server requires at least ONE allowed directory to operate + - A path is checked and then used, so on macOS and Linux each write, each read of a file's content or metadata, and each directory listing (`list_directory`, `list_directory_with_sizes`, `directory_tree`, `search_files`) acts from inside the directory that was checked. If a directory on the path is replaced in between, the call is refused with "Access denied - a directory on the path changed during the operation" rather than following the replacement. A listing therefore needs to enter the directory it lists: a directory the server can read but not enter (read permission without execute) is refused with `EACCES`, as an unreadable one is - On Windows, a path naming an NTFS alternate data stream (`file.txt:stream`, `file.txt::$DATA`) is refused with "Access denied - NTFS alternate data stream paths are not supported", even inside an allowed directory: a colon is accepted only as a drive letter's (`C:\`, `\\?\C:\`). A stream holds data that no directory listing or diff of the file shows. On macOS and Linux a colon is an ordinary file-name character and is not refused - On Windows, a path any of whose components is a reserved device name (`CON`, `PRN`, `AUX`, `NUL`, `COM1`-`COM9`, `LPT1`-`LPT9`, in any case and with or without an extension, such as `NUL.txt`) is refused with "Access denied - Windows reserved device names ... are not supported", and one any of whose components ends in a dot or a space (`file.txt.`, `dir \file.txt`) with "Access denied - Windows path components ending in a dot or a space are not supported". Windows opens the device rather than a file in the directory, and strips trailing dots and spaces so the name refers to a different file. `.` and `..` are not affected. On macOS and Linux these are ordinary file names and are not refused + - **Limit on Windows: a parent directory swapped during an operation.** A path is checked and then used, and a directory on it could be replaced in between. On Linux and macOS the server anchors every write, and every read of a file's content or metadata, to the directory it validated, so a directory replaced with a symlink after the check cannot redirect the operation. **On Windows it cannot do that, and the operation is not protected**: a second local process that can already write inside an allowed directory can replace a parent directory with a junction (or a directory symlink) between the server's check and its open, and so redirect a read or a write outside the allowed directories. The server still checks the final component there (a write refuses a symlink or junction at the file's own name, and the file opened must be the one the directory holds at that name afterwards), which narrows the window without closing it + - **What it takes**: a concurrent local process with write access inside an allowed directory, winning a race against the server. No tool of this server creates a junction or a symlink, so it cannot be set up through the server alone + - **Guidance**: on Windows, do not allow a directory that untrusted local processes or users can write to + - **Why it is not fixed**: closing the window needs opens relative to a directory handle, which Node does not expose, so it would take native code, and that is out of scope for a reference server ([#5260](https://github.com/modelcontextprotocol/servers/issues/5260)). It may be revisited when Node ships a stable built-in FFI under this package's `engines` floor **Note**: The server will only allow operations within directories specified either via `args` or, for a 2025-era client, via Roots. @@ -402,6 +407,33 @@ The mapping for filesystem tools is: Node.js 24 or later, when the server runs through `npx` or from source. +## Streamable HTTP + +The server talks over stdio by default. With `--transport streamable-http` it +runs on its own as an HTTP service instead, serving one MCP endpoint, `/mcp`, +to any number of clients of either protocol era: + +```sh +npx -y @modelcontextprotocol/server-filesystem --transport streamable-http /Users/username/Desktop +``` + +It listens on `127.0.0.1:3001` unless `HOST` and `PORT` say otherwise (for +example `PORT=8080`); `HOST=0.0.0.0` exposes it to every machine that can reach +this one, so set it deliberately. A request from a browser page on any +origin but localhost is refused with `403`, and the endpoint sends no CORS +headers, so it serves clients that are not browser pages. Point a client at the URL, such as +`http://127.0.0.1:3001/mcp`, instead of giving it a command: + +```json +{ + "mcpServers": { + "filesystem": { "type": "http", "url": "http://127.0.0.1:3001/mcp" } + } +} +``` + +Over HTTP each request is served by a fresh server, and a 2025-era client gets no session (GET and DELETE on `/mcp` answer `405`), so the server cannot send it requests or notifications between its own requests. That is why **over HTTP the allowed directories must be given on the command line**: the server cannot ask a client for its [Roots](#method-2-mcp-roots-deprecated-2025-era-clients-only), on either protocol era, and it refuses to start without a directory. `--read-only`, `--read-only-dir` and the other options work as they do over stdio; `--confine-roots` has nothing to confine. + ## Usage with Claude Desktop Add this to your `claude_desktop_config.json`: diff --git a/src/filesystem/__tests__/bounded-walk.test.ts b/src/filesystem/__tests__/bounded-walk.test.ts index 53ec949489..96759d3b74 100644 --- a/src/filesystem/__tests__/bounded-walk.test.ts +++ b/src/filesystem/__tests__/bounded-walk.test.ts @@ -7,6 +7,7 @@ // they do not single out goes to the real filesystem. import fs from "fs/promises"; +import fsSync from "fs"; import type { Dirent, PathLike } from "fs"; import path from "path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; @@ -23,6 +24,7 @@ import { FS_CALL_TIMEOUT_MS, MAX_WALK_ENTRIES } from "../lib.js"; const realReaddir = fs.readdir.bind(fs); const realRealpath = fs.realpath.bind(fs); +const realReaddirSync = fsSync.readdirSync.bind(fsSync); // The cap tests walk MAX_WALK_ENTRIES + 1 entries on purpose, so their cost is // the bound they check and scales with the runner: about 1 s locally, near @@ -110,6 +112,29 @@ function fileEntries(parent: string, count: number): Dirent[] { ); } +/** + * Make `dir` list MAX_WALK_ENTRIES + 1 plain files that are not on disk, both + * in the bounded first read (fs.readdir) and in the anchored listing that + * follows it, which reads "." from inside the directory (pinned-directory.ts). + */ +function listManyFiles(): void { + const entries = fileEntries(dir, MAX_WALK_ENTRIES + 1); + vi.spyOn(fs, "readdir").mockImplementation(((target: PathLike) => + target.toString() === dir + ? Promise.resolve(entries) + : realReaddir(target)) as typeof fs.readdir); + vi.spyOn(fsSync, "readdirSync").mockImplementation((( + target: PathLike, + ...rest: unknown[] + ) => + target.toString() === "." && process.cwd() === dir + ? entries + : (realReaddirSync as (target: PathLike, ...rest: unknown[]) => unknown)( + target, + ...rest, + )) as typeof fsSync.readdirSync); +} + describe("search_files", () => { it("applies excludePatterns before touching an entry: an excluded subtree is never realpath'd or read", async () => { const realpath = vi.spyOn(fs, "realpath"); @@ -154,10 +179,7 @@ describe("search_files", () => { `stops with an error after visiting ${MAX_WALK_ENTRIES} entries`, WALK_CAP, async () => { - vi.spyOn(fs, "readdir").mockImplementation(((target: PathLike) => - target.toString() === dir - ? Promise.resolve(fileEntries(dir, MAX_WALK_ENTRIES + 1)) - : realReaddir(target)) as typeof fs.readdir); + listManyFiles(); // The listed names do not exist on disk; resolve them as themselves so // each entry costs a string check rather than a real lookup. vi.spyOn(fs, "realpath").mockImplementation(((target: PathLike) => @@ -203,10 +225,7 @@ describe("directory_tree", () => { `stops with an error after visiting ${MAX_WALK_ENTRIES} entries`, WALK_CAP, async () => { - vi.spyOn(fs, "readdir").mockImplementation(((target: PathLike) => - target.toString() === dir - ? Promise.resolve(fileEntries(dir, MAX_WALK_ENTRIES + 1)) - : realReaddir(target)) as typeof fs.readdir); + listManyFiles(); const result = await call(client, "directory_tree", { path: dir }); expect(result.isError).toBe(true); expect(textOf(result)).toContain( @@ -216,10 +235,7 @@ describe("directory_tree", () => { ); it("does not count excluded entries toward the cap", WALK_CAP, async () => { - vi.spyOn(fs, "readdir").mockImplementation(((target: PathLike) => - target.toString() === dir - ? Promise.resolve(fileEntries(dir, MAX_WALK_ENTRIES + 1)) - : realReaddir(target)) as typeof fs.readdir); + listManyFiles(); const result = await call(client, "directory_tree", { path: dir, excludePatterns: ["f*"], diff --git a/src/filesystem/__tests__/confine-roots.test.ts b/src/filesystem/__tests__/confine-roots.test.ts index 09d9b40108..09f4748a5b 100644 --- a/src/filesystem/__tests__/confine-roots.test.ts +++ b/src/filesystem/__tests__/confine-roots.test.ts @@ -228,12 +228,14 @@ describe("the command line", () => { readOnly: false, confineRoots: true, readOnlyDirectories: [], + transport: "stdio", }); expect(parseArgs(["--", "--confine-roots"])).toEqual({ directories: ["--confine-roots"], readOnly: false, confineRoots: false, readOnlyDirectories: [], + transport: "stdio", }); }); diff --git a/src/filesystem/__tests__/http.test.ts b/src/filesystem/__tests__/http.test.ts new file mode 100644 index 0000000000..3c10a13e5e --- /dev/null +++ b/src/filesystem/__tests__/http.test.ts @@ -0,0 +1,260 @@ +// The Streamable HTTP transport (#576): main() started with +// `--transport streamable-http` on a free loopback port and driven by the SDK +// Client over real HTTP in both protocol eras, plus the pieces it is built +// from: `parseArgs()` reading `--transport`, `httpEndpoint()` reading HOST and +// PORT, and `startHttpServer()`'s own refusals. Over HTTP a client's Roots +// cannot reach the server, so the command-line directories are what both eras +// get, and main() refuses to start without one. + +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { connect as connectTcp } from "node:net"; +import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { + Client, + StreamableHTTPClientTransport, +} from "@modelcontextprotocol/client"; +import { + DEFAULT_HOST, + DEFAULT_PORT, + endpointUrl, + httpEndpoint, + startHttpServer, + type RunningHttpServer, +} from "../http.js"; +import { HTTP_NEEDS_DIRECTORIES_ERROR, main, parseArgs } from "../index.js"; +import { createServer } from "../server.js"; + +const ERAS = [ + ["2026-07-28", { mode: { pin: "2026-07-28" } }, "modern"], + ["2025-11-25", { mode: "legacy" }, "legacy"], +] as const; + +async function connect( + url: string, + versionNegotiation: (typeof ERAS)[number][1], +): Promise { + const client = new Client( + { name: "http-test", version: "0.0.0" }, + // A client that offers Roots: over HTTP the server never asks for them. + { versionNegotiation, capabilities: { roots: { listChanged: true } } }, + ); + await client.connect(new StreamableHTTPClientTransport(new URL(url))); + return client; +} + +describe("main() over Streamable HTTP", () => { + const saved = { HOST: process.env.HOST, PORT: process.env.PORT }; + let dir: string; + let running: RunningHttpServer | undefined; + + beforeEach(async () => { + vi.spyOn(console, "error").mockImplementation(() => {}); + dir = await realpath(await mkdtemp(path.join(tmpdir(), "fs-http-"))); + await writeFile(path.join(dir, "hello.txt"), "hello over http"); + process.env.HOST = "127.0.0.1"; + process.env.PORT = "0"; + }); + + afterEach(async () => { + await running?.close(); + running = undefined; + await rm(dir, { recursive: true, force: true }); + for (const [key, value] of Object.entries(saved)) { + if (value === undefined) delete process.env[key]; + else process.env[key] = value; + } + vi.restoreAllMocks(); + }); + + /** main() on HTTP with `args`, kept for the afterEach to close. */ + async function start(...args: string[]): Promise { + running = (await main([ + "--transport", + "streamable-http", + ...args, + ])) as RunningHttpServer; + return running; + } + + it.each(ERAS)( + "serves a %s client within the command-line directories", + async (_, negotiation, era) => { + const client = await connect((await start(dir)).url, negotiation); + try { + expect(client.getProtocolEra()).toBe(era); + const result = await client.callTool({ + name: "read_text_file", + arguments: { path: path.join(dir, "hello.txt") }, + }); + expect(result.isError).toBeFalsy(); + expect(JSON.stringify(result.content)).toContain("hello over http"); + const outside = await client.callTool({ + name: "read_text_file", + arguments: { path: path.join(tmpdir(), "elsewhere.txt") }, + }); + expect(outside.isError).toBe(true); + } finally { + await client.close(); + } + }, + ); + + it("announces the URL, the options and the directories on stderr", async () => { + const url = (await start("--read-only", dir)).url; + expect(console.error).toHaveBeenCalledWith( + `Secure MCP Filesystem Server running on Streamable HTTP at ${url}`, + ); + expect(console.error).toHaveBeenCalledWith( + "Read-only mode: only tools that cannot change the filesystem are served", + ); + }); + + it("refuses to start without a usable directory", async () => { + await expect(main(["--transport=streamable-http"])).rejects.toThrow( + HTTP_NEEDS_DIRECTORIES_ERROR, + ); + }); +}); + +describe("startHttpServer", () => { + let running: RunningHttpServer | undefined; + + beforeEach(() => { + vi.spyOn(console, "error").mockImplementation(() => {}); + }); + + afterEach(async () => { + await running?.close(); + running = undefined; + vi.restoreAllMocks(); + }); + + async function start(): Promise { + running = await startHttpServer(() => createServer([tmpdir()]), { + host: "127.0.0.1", + port: 0, + }); + return running; + } + + it("answers a malformed request target 404 and keeps serving", async () => { + const url = new URL((await start()).url); + const reply = await new Promise((resolve, reject) => { + const socket = connectTcp(Number(url.port), url.hostname, () => + socket.write("GET //[ HTTP/1.1\r\nHost: localhost\r\n\r\n"), + ); + socket.setEncoding("utf8"); + socket.once("data", (chunk: string) => { + socket.destroy(); + resolve(chunk); + }); + socket.once("error", reject); + }); + expect(reply).toMatch(/^HTTP\/1\.1 404/); + expect((await fetch(new URL("/other", url))).status).toBe(404); + }); + + it("answers 404 off the MCP path and 403 to a foreign Origin", async () => { + const base = new URL((await start()).url); + expect((await fetch(new URL("/other", base))).status).toBe(404); + const foreign = await fetch(base, { + method: "POST", + headers: { + origin: "https://evil.example", + "content-type": "application/json", + }, + body: "{}", + }); + expect(foreign.status).toBe(403); + }); + + it("reports a request the SDK refuses through onerror", async () => { + // A 2026-07-28 header on a request with no 2026-07-28 envelope. + const response = await fetch((await start()).url, { + method: "POST", + headers: { + "content-type": "application/json", + accept: "application/json, text/event-stream", + "mcp-protocol-version": "2026-07-28", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "tools/list", + params: {}, + }), + }); + expect(response.status).toBe(400); + expect(console.error).toHaveBeenCalledWith( + "Error serving MCP request:", + expect.any(Error), + ); + }); + + it("rejects when the port is already bound", async () => { + const port = Number(new URL((await start()).url).port); + await expect( + startHttpServer(() => createServer([tmpdir()]), { + host: "127.0.0.1", + port, + }), + ).rejects.toThrow(/EADDRINUSE/); + }); +}); + +describe("endpointUrl", () => { + it("brackets an IPv6 literal", () => { + expect(endpointUrl("127.0.0.1", 3001)).toBe("http://127.0.0.1:3001/mcp"); + expect(endpointUrl("::1", 3001)).toBe("http://[::1]:3001/mcp"); + }); +}); + +describe("httpEndpoint", () => { + it("defaults to loopback on the default port", () => { + expect(httpEndpoint({})).toEqual({ + host: DEFAULT_HOST, + port: DEFAULT_PORT, + }); + }); + + it("reads HOST and PORT", () => { + expect(httpEndpoint({ HOST: "0.0.0.0", PORT: "8080" })).toEqual({ + host: "0.0.0.0", + port: 8080, + }); + }); + + it.each(["abc", "-1", "65536", "1.5"])("refuses PORT=%s", (PORT) => { + expect(() => httpEndpoint({ PORT })).toThrow(/Invalid PORT/); + }); +}); + +describe("parseArgs with --transport", () => { + it.each([ + [["/a"], "stdio"], + [["--transport", "stdio", "/a"], "stdio"], + [["/a", "--transport", "streamable-http"], "streamable-http"], + [["--transport=streamable-http", "/a"], "streamable-http"], + ] as const)("reads %j as %s", (args, transport) => { + expect(parseArgs([...args])).toMatchObject({ + directories: ["/a"], + transport, + }); + }); + + it("takes --transport after -- as a directory", () => { + expect(parseArgs(["--", "--transport"])).toMatchObject({ + directories: ["--transport"], + transport: "stdio", + }); + }); + + it("throws on a missing or unknown transport", () => { + expect(() => parseArgs(["--transport"])).toThrow(/needs a value/); + expect(() => parseArgs(["--transport", "sse"])).toThrow( + /Unknown transport "sse"/, + ); + }); +}); diff --git a/src/filesystem/__tests__/lib.test.ts b/src/filesystem/__tests__/lib.test.ts index 0f8317dd85..a04f8393c9 100644 --- a/src/filesystem/__tests__/lib.test.ts +++ b/src/filesystem/__tests__/lib.test.ts @@ -781,6 +781,11 @@ describe("Lib Functions", () => { ]; mockReaddir.mockResolvedValueOnce(mockEntries as Dirent[]); + // The anchored listing the search uses (the readdir above is only + // its bounded first read; see listValidatedDirectory). + mockPinned.readDirectoryInPlace.mockReturnValueOnce( + mockEntries as Dirent[], + ); const testDir = process.platform === "win32" ? "C:\\allowed\\dir" : "/allowed/dir"; @@ -815,6 +820,11 @@ describe("Lib Functions", () => { ]; mockReaddir.mockResolvedValueOnce(mockEntries as Dirent[]); + // The anchored listing the search uses (the readdir above is only + // its bounded first read; see listValidatedDirectory). + mockPinned.readDirectoryInPlace.mockReturnValueOnce( + mockEntries as Dirent[], + ); // Mock validatePath to throw error for invalid_file.txt mockFs.realpath.mockImplementation(async (path: PathLike) => { @@ -852,6 +862,11 @@ describe("Lib Functions", () => { ]; mockReaddir.mockResolvedValueOnce(mockEntries as Dirent[]); + // The anchored listing the search uses (the readdir above is only + // its bounded first read; see listValidatedDirectory). + mockPinned.readDirectoryInPlace.mockReturnValueOnce( + mockEntries as Dirent[], + ); const testDir = process.platform === "win32" ? "C:\\allowed\\dir" : "/allowed/dir"; diff --git a/src/filesystem/__tests__/list-anchored.test.ts b/src/filesystem/__tests__/list-anchored.test.ts new file mode 100644 index 0000000000..1f8b8e4f93 --- /dev/null +++ b/src/filesystem/__tests__/list-anchored.test.ts @@ -0,0 +1,145 @@ +// Protocol-level tests that every directory listing is anchored to the +// directory validation resolved, as every read and write is +// (pinned-directory.ts). The swap an attacker would race is staged +// deterministically, as read-anchored.test.ts stages it: right after +// validation realpath's a directory the tool is about to list, that directory +// is swapped for a symlink to a directory outside the allowed one. Each +// listing must then refuse rather than return the outside directory's entry +// names. Before listings were anchored, each of these returned them. + +import fs from "fs/promises"; +import fsSync from "fs"; +import path from "path"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { Client } from "@modelcontextprotocol/client"; +import { + call, + connect, + makeTempDir, + quietStderr, + textOf, + type Connected, +} from "./helpers.js"; + +// The name is what a listing would leak, so it is the marker. +const OUTSIDE_NAME = "OUTSIDE-NAME-CANARY.txt"; +const INSIDE_NAME = "inside-marker.txt"; + +let dir: string; +let outside: string; +let flip: string; +let flipReal: string; +let conn: Connected; +let client: Client; + +beforeEach(async () => { + quietStderr(); + dir = await makeTempDir("mcp-fs-list-anchor-"); + outside = await makeTempDir("mcp-fs-list-anchor-outside-"); + flip = path.join(dir, "flip"); + flipReal = path.join(dir, "flip-real"); + await fs.mkdir(flip); + await fs.writeFile(path.join(flip, INSIDE_NAME), "inside"); + await fs.writeFile(path.join(outside, OUTSIDE_NAME), "outside"); + conn = await connect([dir]); + client = conn.client; +}); + +afterEach(async () => { + vi.restoreAllMocks(); + await conn.close(); + await fs.rm(dir, { recursive: true, force: true }); + await fs.rm(outside, { recursive: true, force: true }); +}); + +/** Swap `flip` for a symlink to `outside`, once, right after it is realpath'd. */ +function swapAfterRealpath(): void { + const realRealpath = fs.realpath.bind(fs); + let swapped = false; + vi.spyOn(fs, "realpath").mockImplementation(async (p, opts) => { + const resolved = await realRealpath(p, opts); + if (!swapped && p === flip) { + swapped = true; + fsSync.renameSync(flip, flipReal); + fsSync.symlinkSync(outside, flip); + } + return resolved; + }); +} + +const DIRECTORY_CHANGED = + /Access denied - a directory on the path changed during the operation/; + +describe.skipIf(process.platform === "win32")( + "a listed directory swapped for a symlink after validation", + () => { + it.each([ + ["list_directory", {}], + ["list_directory_with_sizes", {}], + ["directory_tree", {}], + ["search_files", { pattern: "**" }], + ])("%s does not list through it", async (tool, extra) => { + swapAfterRealpath(); + const result = await call(client, tool, { path: flip, ...extra }); + expect(result.isError).toBe(true); + expect(textOf(result)).toMatch(DIRECTORY_CHANGED); + expect(JSON.stringify(result)).not.toContain(OUTSIDE_NAME); + }); + + it("directory_tree does not list a subdirectory through it", async () => { + swapAfterRealpath(); + const result = await call(client, "directory_tree", { path: dir }); + expect(result.isError).toBe(true); + expect(textOf(result)).toMatch(DIRECTORY_CHANGED); + expect(JSON.stringify(result)).not.toContain(OUTSIDE_NAME); + }); + + it("search_files does not search a subdirectory through it, and says so", async () => { + swapAfterRealpath(); + const result = await call(client, "search_files", { + path: dir, + pattern: "**", + }); + expect(result.isError).toBeFalsy(); + expect(JSON.stringify(result)).not.toContain(OUTSIDE_NAME); + // The swapped directory is reported as unreadable, not as empty. + expect(textOf(result)).toContain(`${flip}`); + expect(textOf(result)).toMatch(/could not be read/i); + }); + }, +); + +describe("listings that are not swapped", () => { + it("list every tool's way, from the directory validation resolved", async () => { + expect(textOf(await call(client, "list_directory", { path: flip }))).toBe( + `[FILE] ${INSIDE_NAME}`, + ); + expect( + textOf(await call(client, "list_directory_with_sizes", { path: flip })), + ).toContain(`[FILE] ${INSIDE_NAME}`); + expect( + JSON.parse(textOf(await call(client, "directory_tree", { path: dir }))), + ).toEqual([ + { + name: "flip", + type: "directory", + children: [{ name: INSIDE_NAME, type: "file" }], + }, + ]); + expect( + textOf( + await call(client, "search_files", { path: dir, pattern: "**/*.txt" }), + ), + ).toBe(path.join(flip, INSIDE_NAME)); + }); + + it("refuses a static symlink to a directory outside, as before", async () => { + const link = path.join(dir, "link"); + await fs.symlink(outside, link); + for (const tool of ["list_directory", "directory_tree"]) { + const result = await call(client, tool, { path: link }); + expect(result.isError).toBe(true); + expect(JSON.stringify(result)).not.toContain(OUTSIDE_NAME); + } + }); +}); diff --git a/src/filesystem/__tests__/pinned-directory.test.ts b/src/filesystem/__tests__/pinned-directory.test.ts index 98928951ca..db7da2f2cf 100644 --- a/src/filesystem/__tests__/pinned-directory.test.ts +++ b/src/filesystem/__tests__/pinned-directory.test.ts @@ -16,6 +16,7 @@ import { moveFileAcrossDevices, openFileForReading, overwriteFileInDirectory, + readDirectoryInPlace, readFileInDirectory, renameIntoDirectory, statInDirectory, @@ -1395,3 +1396,93 @@ describe("the anchored reads", () => { expect(chdir).not.toHaveBeenCalled(); }); }); + +describe("readDirectoryInPlace", () => { + // Run as root, the process enters a directory without search permission. + const enforcesModes = + process.platform !== "win32" && process.getuid?.() !== 0; + + it("lists the entries with their types, and restores the working directory", () => { + fs.mkdirSync(path.join(dir, "sub")); + fs.writeFileSync(path.join(dir, "f.txt"), ""); + const entries = readDirectoryInPlace(dir) + .map((entry) => `${entry.name}:${entry.isDirectory()}`) + .sort(); + expect(entries).toEqual(["f.txt:false", "sub:true"]); + // parentPath names the directory, as fs.readdir(dir) would, not ".". + expect(readDirectoryInPlace(dir).map((entry) => entry.parentPath)).toEqual([ + dir, + dir, + ]); + expect(process.cwd()).toBe(cwd); + }); + + it.skipIf(!symlinks)( + "refuses a path that no longer leads to the directory validated", + () => { + fs.writeFileSync(path.join(outside, "secret.txt"), ""); + fs.symlinkSync(outside, path.join(dir, "link")); + expect(() => readDirectoryInPlace(path.join(dir, "link"))).toThrow( + /^Access denied - a directory on the path changed during the operation/, + ); + expect(process.cwd()).toBe(cwd); + }, + ); + + it("reports a missing directory as readdir would, without the working directory", () => { + const missing = path.join(dir, "missing"); + let error: NodeJS.ErrnoException | undefined; + try { + readDirectoryInPlace(missing); + } catch (e) { + error = e as NodeJS.ErrnoException; + } + expect(error?.message).toBe( + `ENOENT: no such file or directory, scandir '${missing}'`, + ); + expect(error?.code).toBe("ENOENT"); + expect(error?.message).not.toContain(cwd); + }); + + it("keeps the code of an enter failure that carries no errno", () => { + vi.spyOn(process, "chdir").mockImplementationOnce(() => { + throw errno("EIO"); + }); + expect(() => readDirectoryInPlace(dir)).toThrow( + `EIO: cannot enter directory, scandir '${dir}'`, + ); + }); + + it("names the directory, not '.', when the listing itself fails", () => { + vi.spyOn(fs, "readdirSync").mockImplementationOnce(() => { + throw Object.assign(new Error("EACCES: permission denied, scandir '.'"), { + code: "EACCES", + path: ".", + }); + }); + expect(() => readDirectoryInPlace(dir)).toThrow( + `EACCES: permission denied, scandir '${dir}'`, + ); + expect(process.cwd()).toBe(cwd); + }); + + it.skipIf(!enforcesModes)( + "refuses a directory it can read but not enter (r without x)", + () => { + const locked = path.join(dir, "locked"); + fs.mkdirSync(locked); + fs.writeFileSync(path.join(locked, "f.txt"), ""); + fs.chmodSync(locked, 0o600); + try { + // A plain readdir by path still lists it; the anchored listing + // cannot enter it, and refuses. + expect(fs.readdirSync(locked)).toEqual(["f.txt"]); + expect(() => readDirectoryInPlace(locked)).toThrow( + `EACCES: permission denied, scandir '${locked}'`, + ); + } finally { + fs.chmodSync(locked, 0o755); + } + }, + ); +}); diff --git a/src/filesystem/__tests__/read-only-dirs.test.ts b/src/filesystem/__tests__/read-only-dirs.test.ts index cacb96f657..c1f87b20df 100644 --- a/src/filesystem/__tests__/read-only-dirs.test.ts +++ b/src/filesystem/__tests__/read-only-dirs.test.ts @@ -472,6 +472,7 @@ describe("parseArgs with --read-only-dir", () => { readOnly: false, confineRoots: false, readOnlyDirectories: ["/b", "/c"], + transport: "stdio", }); }); @@ -487,6 +488,7 @@ describe("parseArgs with --read-only-dir", () => { readOnly: false, confineRoots: false, readOnlyDirectories: [], + transport: "stdio", }); }); diff --git a/src/filesystem/__tests__/read-only.test.ts b/src/filesystem/__tests__/read-only.test.ts index bcecf028be..73fa2707fc 100644 --- a/src/filesystem/__tests__/read-only.test.ts +++ b/src/filesystem/__tests__/read-only.test.ts @@ -143,6 +143,7 @@ describe("parseArgs", () => { readOnly: false, confineRoots: false, readOnlyDirectories: [], + transport: "stdio", }); }); @@ -157,6 +158,7 @@ describe("parseArgs", () => { readOnly: true, confineRoots: false, readOnlyDirectories: [], + transport: "stdio", }); } }); @@ -167,6 +169,7 @@ describe("parseArgs", () => { readOnly: true, confineRoots: false, readOnlyDirectories: [], + transport: "stdio", }); }); }); @@ -218,7 +221,7 @@ describe("main() with --read-only", () => { ); closers.push(() => handle.close()); expect(stderr).toHaveBeenCalledWith( - "Usage: mcp-server-filesystem [--read-only] [--confine-roots] [--read-only-dir ]... [allowed-directory] [additional-directories...]", + "Usage: mcp-server-filesystem [--transport stdio|streamable-http] [--read-only] [--confine-roots] [--read-only-dir ]... [allowed-directory] [additional-directories...]", ); }); }); diff --git a/src/filesystem/__tests__/stdio.test.ts b/src/filesystem/__tests__/stdio.test.ts index 42ea1ae7dc..74d6d11079 100644 --- a/src/filesystem/__tests__/stdio.test.ts +++ b/src/filesystem/__tests__/stdio.test.ts @@ -129,7 +129,7 @@ describe("startup", () => { it("prints usage, and waits for roots, when started with no directories", async () => { await session.start([]); expect(stderrText()).toContain( - "Usage: mcp-server-filesystem [--read-only] [--confine-roots] [--read-only-dir ]... [allowed-directory] [additional-directories...]", + "Usage: mcp-server-filesystem [--transport stdio|streamable-http] [--read-only] [--confine-roots] [--read-only-dir ]... [allowed-directory] [additional-directories...]", ); expect(stderrText()).toContain( "At least one directory must be provided by EITHER method for the server to operate.", diff --git a/src/filesystem/http.ts b/src/filesystem/http.ts new file mode 100644 index 0000000000..f4d6b0b79c --- /dev/null +++ b/src/filesystem/http.ts @@ -0,0 +1,119 @@ +// Serves the filesystem server over Streamable HTTP (#576), the alternative to +// stdio that `--transport streamable-http` selects. +// +// One `/mcp` endpoint answers both protocol eras through the SDK's +// `createMcpHandler`: a 2026-07-28 request is served by a fresh server built +// for it, and a 2025-era request by the SDK's stateless fallback (also a fresh +// server per request, with no session, so GET and DELETE are answered 405). +// A stateless request has no channel back to the client, so the server cannot +// ask a 2025-era client for its Roots: over HTTP the allowed directories are +// the command-line ones on both eras, and index.ts refuses to start without +// them. +// +// The listener binds loopback unless `HOST` widens it, and a browser page may +// reach it only from a localhost Origin, the same posture as the everything +// server's HTTP transports (#5371). `startHttpServer()` resolves once the port +// is bound and rejects when it cannot be, so a launcher sees the failure. + +import { createServer as createNodeServer, type Server } from "node:http"; +import type { AddressInfo } from "node:net"; +import { + createMcpHandler, + type McpHttpHandler, + type McpServerFactory, +} from "@modelcontextprotocol/server"; +import { + localhostOriginValidation, + toNodeHandler, +} from "@modelcontextprotocol/node"; + +/** The interface bound when `HOST` is unset: loopback only. */ +export const DEFAULT_HOST = "127.0.0.1"; +/** The port bound when `PORT` is unset. */ +export const DEFAULT_PORT = 3001; +/** The one path the endpoint answers on. */ +export const MCP_PATH = "/mcp"; + +/** Where to listen: `HOST` and `PORT` from the environment, else the defaults. */ +export function httpEndpoint(env: NodeJS.ProcessEnv = process.env): { + host: string; + port: number; +} { + const host = env.HOST || DEFAULT_HOST; + if (!env.PORT) return { host, port: DEFAULT_PORT }; + const port = Number(env.PORT); + if (!Number.isInteger(port) || port < 0 || port > 65535) { + throw new Error( + `Invalid PORT ${JSON.stringify(env.PORT)}: expected a whole number from 0 to 65535`, + ); + } + return { host, port }; +} + +/** The URL of the endpoint bound at `address`:`port`, an IPv6 literal in brackets. */ +export function endpointUrl(address: string, port: number): string { + const host = address.includes(":") ? `[${address}]` : address; + return `http://${host}:${port}${MCP_PATH}`; +} + +/** A running HTTP endpoint: the bound address, and how to stop it. */ +export interface RunningHttpServer { + httpServer: Server; + handler: McpHttpHandler; + /** The URL clients connect to, with the port actually bound. */ + url: string; + /** End in-flight MCP exchanges, then stop listening and drop open sockets. */ + close: () => Promise; +} + +/** + * Bind the endpoint on `host`:`port` (port 0 picks a free one) and serve the + * servers `factory` builds on it, one per request. Rejects when the port + * cannot be bound. + */ +export async function startHttpServer( + factory: McpServerFactory, + { host, port }: { host: string; port: number }, +): Promise { + const onerror = (error: Error) => + console.error("Error serving MCP request:", error); + const handler = createMcpHandler(factory, { onerror }); + const serve = toNodeHandler(handler, { onerror }); + const allowOrigin = localhostOriginValidation(); + + const httpServer = createNodeServer((req, res) => { + // The path, without parsing the target: a malformed one (`//[`) would + // make URL parsing throw here, outside any handler, and end the process. + const path = String(req.url).split("?")[0]; + if (path !== MCP_PATH) { + res.writeHead(404, { "content-type": "text/plain" }).end("Not Found"); + return; + } + if (!allowOrigin(req, res)) return; + // Not awaited: the listener is synchronous. The adapter never rejects; it + // reports a failure through `onerror` and answers it with a 500 itself. + void serve(req, res); + }); + + await new Promise((resolve, reject) => { + httpServer.once("error", reject); + httpServer.listen({ host, port }, () => { + httpServer.off("error", reject); + resolve(); + }); + }); + + const bound = httpServer.address() as AddressInfo; + return { + httpServer, + handler, + url: endpointUrl(bound.address, bound.port), + close: async () => { + await handler.close(); + await new Promise((resolve) => { + httpServer.close(() => resolve()); + httpServer.closeAllConnections(); + }); + }, + }; +} diff --git a/src/filesystem/index.ts b/src/filesystem/index.ts index fa34660ed5..6334a43f34 100644 --- a/src/filesystem/index.ts +++ b/src/filesystem/index.ts @@ -1,10 +1,12 @@ #!/usr/bin/env node -// The stdio entry point of the filesystem server (the package's bin). It +// The entry point of the filesystem server (the package's bin). It // parses the command line (its options, such as --read-only or --read-only-dir, // and the allowed directories), resolves the allowed directories and serves // createServer() on stdio through the SDK's serveStdio entry, which answers // 2026-07-28 clients (server/discover, no handshake) and 2025-era clients -// (initialize, then Roots) from the same factory (#4852). Everything runs inside +// (initialize, then Roots) from the same factory (#4852), or, with +// --transport streamable-http, over Streamable HTTP (http.ts, #576), where +// Roots cannot reach the server and the directories must be given here. Everything runs inside // main(), and main() runs only when this file is the process entry point, so // importing the module (as the tests do) starts nothing (#4854). main() takes // the argv and the stdio streams as parameters so the tests can drive the real @@ -26,6 +28,11 @@ import { realpathWithRetry, } from "./path-utils.js"; import { createServer } from "./server.js"; +import { + httpEndpoint, + startHttpServer, + type RunningHttpServer, +} from "./http.js"; import { describeAllowedDirectories } from "./allowed-directories.js"; import { describeReadOnlyDirectories, @@ -114,6 +121,22 @@ export interface ParsedArgs { * listed twice. */ readOnlyDirectories: string[]; + /** `--transport `: how the server is reached (#576). */ + transport: TransportName; +} + +/** The transports `--transport` can name. */ +export const TRANSPORTS = ["stdio", "streamable-http"] as const; +export type TransportName = (typeof TRANSPORTS)[number]; + +/** `value` as a transport name; throws on any other value. */ +function transportName(value: string): TransportName { + if (!(TRANSPORTS as readonly string[]).includes(value)) { + throw new Error( + `Unknown transport ${JSON.stringify(value)}: expected stdio or streamable-http`, + ); + } + return value as TransportName; } /** @@ -122,7 +145,8 @@ export interface ParsedArgs { * option's can still be given after it. Any other argument is a directory, as * every argument was before options existed. `--read-only-dir` takes the next * argument as its directory, whatever it looks like, and throws when there is - * none. + * none. `--transport` takes the next argument (or `--transport=`) and + * throws when it is missing or names no transport. */ export function parseArgs(args: string[]): ParsedArgs { const parsed: ParsedArgs = { @@ -130,6 +154,7 @@ export function parseArgs(args: string[]): ParsedArgs { readOnly: false, confineRoots: false, readOnlyDirectories: [], + transport: "stdio", }; let options = true; for (let index = 0; index < args.length; index++) { @@ -146,6 +171,14 @@ export function parseArgs(args: string[]): ParsedArgs { throw new Error("--read-only-dir needs a directory after it"); } parsed.readOnlyDirectories.push(args[index]); + } else if (options && arg === "--transport") { + index++; + if (index >= args.length) { + throw new Error("--transport needs a value: stdio or streamable-http"); + } + parsed.transport = transportName(args[index]); + } else if (options && arg.startsWith("--transport=")) { + parsed.transport = transportName(arg.slice("--transport=".length)); } else { parsed.directories.push(arg); } @@ -153,22 +186,64 @@ export function parseArgs(args: string[]): ParsedArgs { return parsed; } +/** Why Streamable HTTP will not start without command-line directories. */ +export const HTTP_NEEDS_DIRECTORIES_ERROR = + "Streamable HTTP needs the allowed directories on the command line: over HTTP the server cannot ask a client for its Roots"; + /** - * Serve the server over stdio with the allowed directories in `args`. The - * first message the client sends picks the connection's protocol era, and the - * factory builds the server for it. A transport error, including one that - * stops the transport from starting, is reported on stderr. + * Serve the server with the allowed directories in `args`: over stdio by + * default, where the first message the client sends picks the connection's + * protocol era and the factory builds the server for it, or over Streamable + * HTTP on `HOST`:`PORT` with `--transport streamable-http`, which needs at + * least one usable directory. A transport error, including one that stops the + * transport from starting, is reported on stderr. */ export async function main( args: string[] = process.argv.slice(2), stdin: Readable = process.stdin, stdout: Writable = process.stdout, -): Promise { - const { directories, readOnly, confineRoots, readOnlyDirectories } = - parseArgs(args); +): Promise { + const { + directories, + readOnly, + confineRoots, + readOnlyDirectories, + transport, + } = parseArgs(args); + if (transport === "streamable-http") { + // Rejects, so the server does not start, on a read-only directory that + // cannot be resolved, as on stdio. + const allowedDirectories = await resolveAllowedDirectories([ + ...directories, + ...readOnlyDirectories, + ]); + if (allowedDirectories.length === 0) { + throw new Error(HTTP_NEEDS_DIRECTORIES_ERROR); + } + const resolvedReadOnlyDirectories = + await resolveReadOnlyDirectories(readOnlyDirectories); + const running = await startHttpServer( + ({ era }) => + createServer(allowedDirectories, { + era, + readOnly, + confineRoots, + readOnlyDirectories: resolvedReadOnlyDirectories, + }), + httpEndpoint(), + ); + console.error( + `Secure MCP Filesystem Server running on Streamable HTTP at ${running.url}`, + ); + announceOptions(readOnly, resolvedReadOnlyDirectories); + console.error( + describeAllowedDirectories(allowedDirectories, { from: "command-line" }), + ); + return running; + } if (directories.length === 0 && readOnlyDirectories.length === 0) { console.error( - "Usage: mcp-server-filesystem [--read-only] [--confine-roots] [--read-only-dir ]... [allowed-directory] [additional-directories...]", + "Usage: mcp-server-filesystem [--transport stdio|streamable-http] [--read-only] [--confine-roots] [--read-only-dir ]... [allowed-directory] [additional-directories...]", ); console.error("Note: Allowed directories can be provided via:"); console.error(" 1. Command-line arguments (shown above)"); @@ -213,14 +288,7 @@ export async function main( }, ); console.error("Secure MCP Filesystem Server running on stdio"); - if (readOnly) { - console.error( - "Read-only mode: only tools that cannot change the filesystem are served", - ); - } - if (resolvedReadOnlyDirectories.length > 0) { - console.error(describeReadOnlyDirectories(resolvedReadOnlyDirectories)); - } + announceOptions(readOnly, resolvedReadOnlyDirectories); if (confineRoots && allowedDirectories.length === 0) { console.error( "Warning: --confine-roots has no effect without command-line directories; a client's Roots will set the allowed directories", @@ -240,6 +308,21 @@ export async function main( return handle; } +/** Announce the options that narrow what the server may do, on stderr. */ +function announceOptions( + readOnly: boolean, + readOnlyDirectories: readonly string[], +): void { + if (readOnly) { + console.error( + "Read-only mode: only tools that cannot change the filesystem are served", + ); + } + if (readOnlyDirectories.length > 0) { + console.error(describeReadOnlyDirectories(readOnlyDirectories)); + } +} + /** * True when `entryPath` (process.argv[1]) is this module. Both sides are * realpath'd, because npm installs the bin as a symlink to dist/index.js. @@ -258,9 +341,23 @@ export function isEntryPoint( /* v8 ignore start -- runs only when node executes this file as the bin, never under vitest; the spawn smoke in __tests__/bin-smoke.test.ts covers it */ if (isEntryPoint(process.argv[1], import.meta.url)) { - main().catch((error) => { - console.error("Fatal error running server:", error); - process.exit(1); - }); + main().then( + (running) => { + // Streamable HTTP keeps the process up on its port; stop it cleanly. + if (!("handler" in running)) return; + const stop = () => { + running.close().then( + () => process.exit(0), + () => process.exit(1), + ); + }; + process.once("SIGINT", stop); + process.once("SIGTERM", stop); + }, + (error) => { + console.error("Fatal error running server:", error); + process.exit(1); + }, + ); } /* v8 ignore stop */ diff --git a/src/filesystem/lib.ts b/src/filesystem/lib.ts index 346f5e6c99..f4821e6f7c 100644 --- a/src/filesystem/lib.ts +++ b/src/filesystem/lib.ts @@ -15,6 +15,7 @@ import { copyFileInDirectory, openFileForReading, overwriteFileInDirectory, + readDirectoryInPlace, readFileInDirectory, renameIntoDirectory, statInDirectory, @@ -132,6 +133,29 @@ export function readdirWithTimeout(target: string): Promise { ); } +/** + * The entries of the directory at `validPath`, a path validatePath returned, + * listed from inside that directory (readDirectoryInPlace in + * pinned-directory.ts), so a directory swapped onto the path after validation + * is refused rather than listed. + * + * The anchored listing is synchronous and cannot time out, so the directory is + * first read asynchronously by path, and that result is discarded: a stalled + * provider (#4162) then times out here (`bounded`, as the recursive walks + * are) or holds only this request (as a single listing always has), rather + * than blocking the process, and a directory that read completes on is + * materialized for the anchored read. Each directory is so read twice. + */ +export async function listValidatedDirectory( + validPath: string, + bounded: boolean, +): Promise { + await (bounded + ? readdirWithTimeout(validPath) + : fs.readdir(validPath, { withFileTypes: true })); + return readDirectoryInPlace(validPath); +} + /** * A counter for a recursive walk: each call records one visited entry and * throws WalkLimitError once the walk has visited more than MAX_WALK_ENTRIES. @@ -1301,10 +1325,13 @@ export async function searchFilesWithValidation( const results: string[] = []; const visit = createEntryBudget("search_files", rootPath); - async function search(currentPath: string) { + // `currentPath` is the path reported, built from the requested root; + // `validPath` is what validatePath resolved it to, which the listing is + // anchored to. + async function search(currentPath: string, validPath: string) { let entries: Dirent[]; try { - entries = await readdirWithTimeout(currentPath); + entries = await listValidatedDirectory(validPath, true); } catch (error) { // The starting path failing is the request failing, and a timeout ends // the whole search (see FsTimeoutError). A subdirectory that cannot be @@ -1333,8 +1360,13 @@ export async function searchFilesWithValidation( // the allowed directories, a dangling link) is skipped silently. A // timeout still ends the whole search rather than returning partial // results as if they were complete. + let validEntryPath: string; try { - await validatePath(fullPath, allowedDirectories, "read"); + validEntryPath = await validatePath( + fullPath, + allowedDirectories, + "read", + ); } catch (error) { if (error instanceof FsTimeoutError) { throw error; @@ -1348,11 +1380,11 @@ export async function searchFilesWithValidation( } if (entry.isDirectory()) { - await search(fullPath); + await search(fullPath, validEntryPath); } } } - await search(rootPath); + await search(rootPath, rootPath); return results; } diff --git a/src/filesystem/package.json b/src/filesystem/package.json index 8c5a6af782..63c6d015ac 100644 --- a/src/filesystem/package.json +++ b/src/filesystem/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/server-filesystem", - "version": "2.3.0", + "version": "2.4.0", "description": "MCP server for filesystem access", "license": "SEE LICENSE IN LICENSE", "mcpName": "io.github.modelcontextprotocol/server-filesystem", @@ -34,6 +34,7 @@ "validate": "npm run format:check && npm run lint && npm run typecheck && npm run build && npm run test" }, "dependencies": { + "@modelcontextprotocol/node": "^2.1.1", "@modelcontextprotocol/server": "^2.3.1", "diff": "^8.0.3", "minimatch": "^11.0.4", diff --git a/src/filesystem/pinned-directory.ts b/src/filesystem/pinned-directory.ts index 7805b4ecee..7374c9b7a9 100644 --- a/src/filesystem/pinned-directory.ts +++ b/src/filesystem/pinned-directory.ts @@ -1,6 +1,6 @@ // Filesystem operations anchored to their directory, so a directory swapped -// out from under them cannot redirect them: every write, and every read that -// returns a file's content or metadata. +// out from under them cannot redirect them: every write, every read that +// returns a file's content or metadata, and every directory listing. // // validatePath() checks a path and returns its canonical form, but the write // or read that follows resolves that path again. A directory on it swapped @@ -22,14 +22,32 @@ // name inside the anchored source directory, renames only that name across, // checks it arrived by identity, and puts the source back if anything fails. // +// A listing enters the listed directory itself and reads ".". Two +// consequences follow. Entering needs search (x) permission on the directory, +// so one the server can read but not enter (r without x) is refused with +// EACCES where a plain readdir listed its names. Falling back to that readdir +// by path would reopen the swap for any directory whose owner clears its x +// bit, and Node has no portable way to list through a descriptor (Linux's +// /proc/self/fd has no macOS equivalent), so it is refused. And the listing +// is synchronous (the cwd invariant at inDirectory), so a directory on a +// provider that stalls (#4162) would block the whole process; callers +// therefore read it once asynchronously first (listValidatedDirectory in +// lib.ts), which a stall times out or holds only that request, and use only +// the anchored listing. +// // On Windows the working directory is a string and relative paths resolve // against it, so reading it back proves nothing; there the leaf is lstat'd // relative to the anchor and must be the file the descriptor opened, which -// narrows the race without closing it. +// narrows the race without closing it. A listing there has no such check, and +// is no more anchored than a readdir by path. +// That gap is a decided limit of the implementation, not pending work: +// closing it needs handle-relative opens, so native code (#5260, closed as +// not planned). The README states it for users, under "Access Control". import { randomBytes } from "crypto"; import fs from "fs"; import path from "path"; +import { getSystemErrorMessage } from "util"; import { isWindowsUncRoot } from "./path-validation.js"; // Descriptor I/O, looked up on fs at call time so tests can stand in for it. @@ -190,11 +208,14 @@ function cannotEnterError(directory: string, error: unknown): Error { return Object.assign(new Error(message), { code }); } -function enterDirectory(directory: string): void { +function enterDirectory( + directory: string, + cannotEnter: (directory: string, error: unknown) => Error = cannotEnterError, +): void { try { process.chdir(directory); } catch (error) { - throw cannotEnterError(directory, error); + throw cannotEnter(directory, error); } verifyWorkingDirectory(directory); } @@ -211,7 +232,11 @@ function enterDirectory(directory: string): void { * it. Only what is done to an anchor-relative path inside `action` uses it; * every other path the server hands to fs is absolute. */ -function inDirectory(directory: string, action: () => T): T { +function inDirectory( + directory: string, + action: () => T, + cannotEnter?: (directory: string, error: unknown) => Error, +): T { let previous: string | undefined; try { previous = process.cwd(); @@ -219,7 +244,7 @@ function inDirectory(directory: string, action: () => T): T { // The working directory was removed; there is nothing to return to. } try { - enterDirectory(directory); + enterDirectory(directory, cannotEnter); return action(); } finally { try { @@ -984,3 +1009,50 @@ export function createDirectoryInPlace(directory: string): void { } }); } + +/** + * The error for a directory a listing could not enter, worded as readdir's own + * (`ENOENT: no such file or directory, scandir ''`), since that is + * the call it stands in for. Like cannotEnterError, it names neither the + * working directory left nor chdir, and keeps the code. + */ +function cannotListError(directory: string, error: unknown): Error { + const { code, errno } = error as NodeJS.ErrnoException; + const description = + errno === undefined + ? "cannot enter directory" + : getSystemErrorMessage(errno); + return Object.assign( + new Error(`${code ?? "Error"}: ${description}, scandir '${directory}'`), + { code }, + ); +} + +/** + * The entries of the directory at `directory`, a path validatePath returned, + * read from inside it: the process enters it, checks it entered the validated + * directory, and lists ".", so a directory swapped onto the path after + * validation is refused rather than listed. Entries come back as + * fs.readdir(directory, { withFileTypes: true }) returns them, and errors in + * its wording. Synchronous; see the module header for what callers do first. + */ +export function readDirectoryInPlace(directory: string): fs.Dirent[] { + return inDirectory( + directory, + () => { + let entries: fs.Dirent[]; + try { + entries = fs.readdirSync(".", { withFileTypes: true }); + } catch (error) { + throw namingPath(error, ".", directory); + } + // Read from ".", so each entry's parentPath is "."; name the directory, + // as a readdir of its path would. + for (const entry of entries) { + entry.parentPath = directory; + } + return entries; + }, + cannotListError, + ); +} diff --git a/src/filesystem/server.ts b/src/filesystem/server.ts index 2517bd7972..f9a80d30be 100644 --- a/src/filesystem/server.ts +++ b/src/filesystem/server.ts @@ -6,7 +6,6 @@ // a module global lets two instances coexist in one process. import { McpServer } from "@modelcontextprotocol/server"; import type { Root } from "@modelcontextprotocol/server"; -import fs from "fs/promises"; import path from "path"; import { pathToFileURL } from "url"; import { z } from "zod"; @@ -30,7 +29,7 @@ import { applyFileEdits, tailFile, headFile, - readdirWithTimeout, + listValidatedDirectory, createEntryBudget, } from "./lib.js"; import { registerFileResources } from "./file-resources.js"; @@ -720,7 +719,7 @@ export function createServer( allowedDirectories, "read", ); - const entries = await fs.readdir(validPath, { withFileTypes: true }); + const entries = await listValidatedDirectory(validPath, false); const formatted = entries .map( (entry) => @@ -759,7 +758,7 @@ export function createServer( allowedDirectories, "read", ); - const entries = await fs.readdir(validPath, { withFileTypes: true }); + const entries = await listValidatedDirectory(validPath, false); // Get detailed information for each entry; size is undefined when the // entry could not be stat'd @@ -894,7 +893,7 @@ export function createServer( allowedDirectories, "read", ); - const entries = await readdirWithTimeout(validPath); + const entries = await listValidatedDirectory(validPath, true); const result: TreeEntry[] = []; for (const entry of entries) { diff --git a/src/git/Dockerfile b/src/git/Dockerfile index 47ffb91322..6b839e622d 100644 --- a/src/git/Dockerfile +++ b/src/git/Dockerfile @@ -55,5 +55,7 @@ USER 999:999 # Place executables in the environment at the front of the path ENV PATH="/app/.venv/bin:$PATH" -# when running the container, add --db-path and a bind mount to the host's db file +# when running the container, bind-mount the host directory holding the Git +# repositories it may use; add --repository with an in-container path to confine +# it to one of them ENTRYPOINT ["mcp-server-git"] diff --git a/src/git/README.md b/src/git/README.md index fab7aa5527..95d5a00875 100644 --- a/src/git/README.md +++ b/src/git/README.md @@ -113,7 +113,7 @@ Please note that mcp-server-git is currently in early development. The functiona - Inputs: - `repo_path` (string): Path to the Git repository. - Returns: One line per remote and direction, `\t (fetch)` or `(push)` (a partial clone's fetch line ends with its filter, such as ` [blob:none]`), or `No remotes configured` - - A credential embedded in a URL is never returned: the whole userinfo of a URL such as `https://user:token@host/...` or `https://token@host/...` is shown as ``. An SSH username (`ssh://git@host/...`) is kept, since it names an account rather than authenticating one; a password after it is redacted. A remote-helper address (`https::https://user:token@host/...`) has its inner URL redacted the same way. scp-style addresses (`git@host:path`) and local paths are shown as configured. A line that cannot be parsed is shown as ``, and if a configured remote URL (or `insteadOf` rewrite) contains a newline, which git itself refuses, the tool returns an error instead of a listing. + - A credential embedded in a URL is never returned: the whole userinfo of a URL such as `https://user:token@host/...` or `https://token@host/...` is shown as ``, and so is every query value (`?private_token=`, keeping the parameter names) and a non-empty fragment (`#`). An SSH username (`ssh://git@host/...`) is kept, since it names an account rather than authenticating one; a password after it is redacted. A remote-helper address (`https::https://user:token@host/...`) has its inner URL redacted the same way. A URL where a `?` or `#` comes before the userinfo's `@` (`https://host?t=a@b`) cannot be split safely, so it is shown as `https://`. A token carried as a path segment (`https://host/token/SECRET/r.git`) is not redacted, since it cannot be told apart from a repository name. scp-style addresses (`git@host:path`) and local paths are shown as configured, and a `file://` URL keeps its `?` and `#` parts, which belong to a local file name. A line that cannot be parsed is shown as ``, and if a configured remote URL (or `insteadOf` rewrite) contains a newline, which git itself refuses, the tool returns an error instead of a listing. ### Protocol versions @@ -178,17 +178,24 @@ A tool call's `repo_path` must be inside that repository, and so must the direct - names alternate object stores (`objects/info/alternates` or `objects/info/http-alternates` with any entry), wherever they are. A clone made with `--reference` or `--shared` therefore cannot be used under `--repository`; `git repack -a -d` and then deleting `objects/info/alternates` makes it self-contained. - holds a symbolic link (at `objects`, `refs`, `index`, `HEAD` or anywhere else in it) that resolves outside both the allowed repository and that Git directory. A link that stays inside is followed, and what it leads to is checked the same way. A `hooks` directory linked elsewhere is allowed, since no hook runs. +It also refuses a repository whose index (`.git/index`) names a path Git would read outside the working tree: an entry that is absolute, or has an empty, `.`, `..` or `.git` component (on Windows also one with a `:`, or with `\` as a separator), which is what `git add` refuses to write. Git reads an index as it finds it, so a hand-written one could otherwise make `git_diff_unstaged`, `git_diff` and `git_status` show files outside the repository. For the same reason, every Git command the server runs, with or without `--repository`, sets `core.untrackedCache` to `false`: the untracked cache is kept in the index and names the directories `git status` lists, so Git scans the working tree instead. + ### A repository's own programs A repository's configuration and hooks travel with it (an unpacked archive, a shared folder, a vendored tree), so the server never runs a program they name, with or without `--repository`. Every Git command it runs overrides, through `GIT_CONFIG_COUNT`, the settings that would start one: - `core.fsmonitor` is `false`, and `core.hooksPath` points at the null device, so no hook runs; `git_commit` also skips the hooks GitPython would run itself (`pre-commit`, `commit-msg`, `post-commit`). - Diffs pass `--no-ext-diff` and `--no-textconv`, so `diff.external`, `diff..command` and `diff..textconv` are ignored. -- Each filter driver (`filter..clean`, `smudge`, `process`) and merge driver (`merge..driver`) that the repository's own configuration defines is emptied: files are staged and checked out unfiltered, and a file a merge driver would have merged is a conflict, which `git_merge` aborts. Drivers from your global or system configuration, such as Git LFS's, keep working. +- Each filter driver (`filter..clean`, `smudge`, `process`) and merge driver (`merge..driver`) that the repository's own configuration defines is emptied, including one with an empty name (`[filter ""]`, selected by `filter=`): files are staged and checked out unfiltered, and a file a merge driver would have merged is a conflict, which `git_merge` aborts. Drivers from your global or system configuration, such as Git LFS's, keep working. +- The repository's configuration can depend on its working tree (an `[include]` or `[includeIf]` path into it, or a `.git/config` linked to a tracked file), so a tool that writes the working tree (`git_checkout`, `git_merge`, and the `git merge --abort` after a conflict) reads the drivers again before it runs any other Git command, and a driver that the files it wrote define is emptied as well. - `commit.gpgSign` and `merge.verifySignatures` are `false`, and `git_merge` passes `--no-gpg-sign` and `--no-verify-signatures`. Each `branch..mergeOptions` the repository's own configuration sets is emptied, since Git reads it as command-line options. `submodule.recurse` and `merge.autoStash` are `false`, and `core.pager` is `cat`. +- Git never fetches a missing object from a promisor remote by itself (`GIT_NO_LAZY_FETCH=1`), since that fetch runs the transport program the repository's configuration names (`remote..uploadpack`, `core.sshCommand`). In a partial clone, or any repository that declares a promisor remote, a tool that needs an object that is not on disk reports it missing. A Git too old to honor the variable (before 2.45.1, other than the maintenance releases 2.39.4, 2.40.2, 2.41.1, 2.42.2, 2.43.4 and 2.44.1 made with it) refuses a repository that declares a promisor remote (`remote..promisor`, `remote..partialCloneFilter` or `extensions.partialClone`, with or without a remote name). +- `maintenance.auto` is `false` and `gc.auto` is `0`, so no tool starts Git's automatic maintenance (which `git merge` runs when it finishes), whose garbage collection would run the commands a repository's `gc.recentObjectsHook` names. Repositories the server works in are not garbage-collected automatically; your own Git commands still do it. - `git_status`, `git_diff_unstaged` and `git_diff` pass `--ignore-submodules=dirty`, because looking for changes inside a submodule runs Git under the submodule's own configuration. A submodule whose checked-out commit moved is still reported; changes inside one are not, so run the tool on the submodule's path to see them. +- `diff.submodule` is `short`, so a diff reports a submodule whose commit moved as a `Subproject commit` line rather than running a nested `git diff` inside it, which would not carry the flags above. +- `git_add` lets Git check whether a checked-out submodule changed, which runs Git inside it under its own configuration, so the filter and merge drivers each checked-out submodule (and each submodule inside one) defines are emptied too, the same way as the repository's own. `git_checkout` passes `--quiet`, which skips that check. -This needs Git 2.31 or later; with an older Git every tool call fails with an error saying so, rather than run unprotected. +This needs Git 2.31 or later, and 2.33 or later for a repository with a checked-out submodule (older Git does not pass the overrides to the Git it runs inside one); with an older Git every tool call on such a repository fails with an error saying so, rather than run unprotected. ### Commit identity @@ -384,6 +391,31 @@ Add to your Zed settings.json: ``` +## Streamable HTTP + +The server talks over stdio by default. With `--transport streamable-http` it +runs on its own as an HTTP service instead, serving one MCP endpoint, `/mcp`, +to any number of clients of either protocol era: + +```sh +uvx mcp-server-git --transport streamable-http --repository path/to/git/repo +``` + +It listens on `127.0.0.1:3001` unless `HOST` and `PORT` say otherwise (for +example `PORT=8080`); `HOST=0.0.0.0` exposes it to every machine that can reach +this one, so set it deliberately. Point a client at the URL, such as +`http://127.0.0.1:3001/mcp`, instead of giving it a command: + +```json +{ + "mcpServers": { + "git": { "type": "http", "url": "http://127.0.0.1:3001/mcp" } + } +} +``` + +Every other option works as it does over stdio; `--repository` matters more here, since any client that can reach the port can use the server. A browser page from any origin but localhost is refused with `403`, whatever `HOST` is, to guard against DNS rebinding; on loopback the SDK also checks each request's `Host` header. + ## Debugging You can use the MCP inspector to debug the server. For uvx installations: diff --git a/src/git/pyproject.toml b/src/git/pyproject.toml index e33c52f070..be0ca1ade9 100644 --- a/src/git/pyproject.toml +++ b/src/git/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mcp-server-git" -version = "2026.11.11" +version = "2026.11.18" description = "A Model Context Protocol server providing tools to read, search, and manipulate Git repositories programmatically via LLMs" readme = "README.md" requires-python = ">=3.10" diff --git a/src/git/src/mcp_server_git/__init__.py b/src/git/src/mcp_server_git/__init__.py index e799b99168..49ad5cb124 100644 --- a/src/git/src/mcp_server_git/__init__.py +++ b/src/git/src/mcp_server_git/__init__.py @@ -5,6 +5,7 @@ import click from .server import serve +from .transport import TRANSPORTS, http_endpoint @click.command() @@ -19,7 +20,17 @@ ), ) @click.option("-v", "--verbose", count=True) -def main(repository: Path | None, verbose: bool) -> None: +@click.option( + "--transport", + type=click.Choice(TRANSPORTS), + default="stdio", + show_default=True, + help=( + "How clients reach the server. streamable-http listens on" + " $HOST:$PORT, 127.0.0.1:3001 by default." + ), +) +def main(repository: Path | None, verbose: bool, transport: str) -> None: """MCP Git Server - Git functionality for MCP""" import asyncio @@ -30,7 +41,13 @@ def main(repository: Path | None, verbose: bool) -> None: logging_level = logging.DEBUG logging.basicConfig(level=logging_level, stream=sys.stderr) - asyncio.run(serve(repository)) + if transport == "streamable-http": + # A bad HOST or PORT stops the server here, as a usage error. + try: + http_endpoint() + except ValueError as e: + raise click.UsageError(str(e)) + asyncio.run(serve(repository, transport)) if ( diff --git a/src/git/src/mcp_server_git/server.py b/src/git/src/mcp_server_git/server.py index cd1d874ece..a6116db44b 100644 --- a/src/git/src/mcp_server_git/server.py +++ b/src/git/src/mcp_server_git/server.py @@ -41,6 +41,8 @@ from mcp.types import INVALID_PARAMS, ToolAnnotations from pydantic import Field +from .transport import run + # The version this server reports in serverInfo, read from the installed # distribution's metadata (pyproject.toml) so it cannot drift from the # published version (#360). Without it the SDK reports its own `mcp` version. @@ -116,7 +118,8 @@ def _git_text(repo: git.Repo, command: str, *args: str) -> str: # honoring it would let the repository run code as the server's user on a # read-only call such as git_status. The overrides go in through # GIT_CONFIG_COUNT (git 2.31+), which outranks every config file and is -# inherited by the git processes git itself starts, submodules included. +# inherited by the git processes git itself starts, inside a submodule only +# from git 2.33 (`_MIN_SUBMODULE_GIT`, required where one is checked out). # # - `core.fsmonitor` is run on every index refresh (status, diff, add). # - `core.hooksPath` pointing at the null device leaves no hook to find, so @@ -128,6 +131,22 @@ def _git_text(repo: git.Repo, command: str, *args: str) -> str: # - `submodule.recurse` would carry checkout and merge into submodules, whose # own configuration this override cannot neutralize (see `_LISTED_KEYS`). # - `merge.autoStash` keeps git_merge from stashing behind the tool's back. +# - `core.untrackedCache` names no program, but the cache it turns on lives +# in the repository's own index and lists directories by name for git +# status to read: a forged one names `..` and lists what is outside the +# working tree. Off, git ignores the cache and scans the working tree. +# - `diff.submodule` set to `diff` makes git diff run a nested git diff inside +# each changed submodule, without `_DIFF_FLAGS`, so the submodule's own +# `diff.external` and textconv drivers would run; `short` starts nothing. +# - `maintenance.auto` keeps a merge (or any other command that ends in +# `git maintenance run --auto`) from starting git's automatic maintenance, +# whose cruft repacks (git 2.42+) run each command the repository's +# `gc.recentObjectsHook` names. Stopping the launch covers every task, +# including a geometric repack the repository enables, which its own +# `maintenance..auto` gates; `gc.auto` is a backstop for the gc task +# only, so it does not replace `maintenance.auto`. +# That hook cannot be emptied like a driver: it is multi-valued, and an +# empty override adds a value rather than replacing the repository's. # # External diff programs and textconv filters are turned off per command # (`_DIFF_FLAGS`), and filter and merge drivers per repository (`_LISTED_KEYS`). @@ -140,6 +159,10 @@ def _git_text(repo: git.Repo, command: str, *args: str) -> str: ("submodule.recurse", "false"), ("status.submoduleSummary", "false"), ("merge.autoStash", "false"), + ("core.untrackedCache", "false"), + ("diff.submodule", "short"), + ("maintenance.auto", "false"), + ("gc.auto", "0"), ) # A filter driver (`filter..clean`/`smudge`/`process`, applied by @@ -153,9 +176,11 @@ def _git_text(repo: git.Repo, command: str, *args: str) -> str: # `commit.gpgSign` says). Drivers and options from the user's global or # system configuration (git-lfs, say) are the user's own and keep working. # `harden_repo` lists these keys, and `core.hooksPath`, whose command-scope -# value shows that git applied the overrides. +# value shows that git applied the overrides. A driver's name may be empty +# (`[filter ""]`, read back as `filter..clean`, selected by `filter=`), so +# the name is matched with `.*`, not `.+`. _LISTED_KEYS = ( - r"^(core\.hookspath|filter\..+\.(clean|smudge|process)|merge\..+\.driver" + r"^(core\.hookspath|filter\..*\.(clean|smudge|process)|merge\..*\.driver" r"|branch\..+\.mergeoptions)$" ) @@ -174,6 +199,50 @@ def _git_text(repo: git.Repo, command: str, *args: str) -> str: # `submodule..ignore`, which the repository could set to `none`. _NO_SUBMODULE_STATUS = "--ignore-submodules=dirty" +# A repository that declares a promisor remote has git fetch any object it is +# missing from that remote, by itself, on a read-only command (git show, git +# status with HEAD's tree gone). The fetch runs a transport program the +# repository's configuration names (`remote..uploadpack`, +# `core.sshCommand`, an `ext::` URL), and no override can pin it by name, +# since the remote's name is the repository's choice; `protocol.allow=never` +# is no help either, as a repository-level `protocol..allow` outranks +# it. GIT_NO_LAZY_FETCH=1 turns the fetch off, so a missing object is an +# error. Git honors it from 2.45.1 and the maintenance releases made with it +# (2.39.4, 2.40.2, ..., 2.44.1), mapped here as minor -> first patch; an +# older git ignores it, so `harden_repo` refuses a repository with a promisor +# remote there. Any of these keys declares one; git also reads a +# `remote.promisor` with no remote name, as a promisor remote named "". +_NO_LAZY_FETCH_SINCE = {39: 4, 40: 2, 41: 1, 42: 2, 43: 4, 44: 1, 45: 1} +_PROMISOR_KEYS = ( + r"^(extensions\.partialclone|remote\.(.+\.)?(promisor|partialclonefilter))$" +) + + +def _honors_no_lazy_fetch(version: tuple[int, ...]) -> bool: + """Whether git at `version` honors GIT_NO_LAZY_FETCH.""" + major, minor, patch = (tuple(version) + (0, 0, 0))[:3] + if (major, minor) > (2, 45): + return True + since = _NO_LAZY_FETCH_SINCE.get(minor) if major == 2 else None + return since is not None and patch >= since + + +def _refuse_promisor_remote(repo: git.Repo) -> None: + """Refuse a repository with a promisor remote, for a git that would fetch.""" + try: + repo.git.config("--get-regexp", _PROMISOR_KEYS) + except git.GitCommandError as e: + # Exit 1 is "nothing matched": no promisor remote, nothing to fetch. + if e.status == 1: + return + raise + raise git.GitError( + "Git 2.45.1 or later (or 2.39.4, 2.40.2, 2.41.1, 2.42.2, 2.43.4, " + "2.44.1) is required for a repository with a promisor remote (a " + "partial clone): an older git fetches missing objects from it, and " + "the fetch runs a program the repository's configuration names" + ) + def _config_env(entries: list[tuple[str, str]]) -> dict[str, str]: """GIT_CONFIG_COUNT variables for `entries`, after any the user set.""" @@ -185,6 +254,81 @@ def _config_env(entries: list[tuple[str, str]]) -> dict[str, str]: return env +# Git 2.31 and 2.32 drop GIT_CONFIG_COUNT from the environment of the git +# they run inside a submodule (fixed upstream in 2.33), so none of the +# overrides would reach it. +_MIN_SUBMODULE_GIT = (2, 33) + + +def _submodule_drivers(repo: git.Repo) -> set[str]: + """The filter and merge driver keys each checked-out submodule defines. + + `git_add ["."]` and `git_checkout` make git run `git status` inside a + checked-out submodule, under the submodule's own configuration, where a + filter driver its `.gitattributes` selects would run. The overrides are + inherited by that nested git, so emptying the drivers by name works there + too once their names are known. A submodule is found at each gitlink in + the index, then inside it at each of its own, the way git descends. + Listing them runs only `git config` and `git ls-files`, which start no + program. Each submodule is opened the way the nested git opens it, with + `GIT_DIR=.git` in its directory, so no upward search or ownership check + makes the two disagree. A submodule whose configuration or index git + cannot read is skipped: the nested git cannot read it either, and stops + before it runs anything there. + + Raises `git.GitError` when a checked-out submodule is found and git is + older than `_MIN_SUBMODULE_GIT`, whose nested git would not inherit the + overrides. Without one, git never runs inside a submodule, so older git + is fine. + """ + drivers: set[str] = set() + if repo.working_tree_dir is None: + return drivers + # The opened repository's own index, then each submodule's. + pending = [(Path(repo.working_tree_dir), repo.git)] + seen: set[Path] = set() + while pending: + top, top_git = pending.pop() + try: + # -z prints ` \t\0` for each entry. + listing = top_git.ls_files("-z", "--stage") + except git.GitCommandError: + continue # an index git cannot read + for entry in listing.split("\0"): + info, _, path = entry.partition("\t") + if not info.startswith("160000 "): + continue + submodule = top / path + if not (submodule / ".git").exists(): + continue # not checked out: git does not look inside + if repo.git.version_info[:2] < _MIN_SUBMODULE_GIT: + raise git.GitError( + "Git 2.33 or later is required for a repository with a " + "checked-out submodule: older git does not pass the " + "configuration overrides to the git it runs inside one" + ) + resolved = submodule.resolve() + if resolved in seen: + continue + seen.add(resolved) + # The nested git runs with GIT_DIR=.git in the submodule. + sub_git = git.Git(submodule) + sub_git.update_environment(**repo.git.environment(), GIT_DIR=".git") + try: + listed = sub_git.config( + "--show-scope", "-z", "--get-regexp", _LISTED_KEYS + ) + except git.GitCommandError: + continue # not a repository git can open, or nothing listed + fields = listed.split("\0") + for scope, field in zip(fields[0::2], fields[1::2]): + key = field.partition("\n")[0] + if key != "core.hookspath" and scope not in _TRUSTED_SCOPES: + drivers.add(key) + pending.append((submodule, sub_git)) + return drivers + + def harden_repo(repo: git.Repo) -> None: """Keep every git command run for `repo` from running a program it names. @@ -193,10 +337,14 @@ def harden_repo(repo: git.Repo) -> None: a worktree's `config.worktree`, and files they include) defines, and overrides each with an empty command. The same read checks that git applied the overrides: git older than 2.31 ignores GIT_CONFIG_COUNT, and - is refused rather than run unprotected. + is refused rather than run unprotected; so is git older than 2.33 for a + repository with a checked-out submodule (`_submodule_drivers`). Lazy + fetching is turned off (GIT_NO_LAZY_FETCH), and a repository with a + promisor remote is refused on a git too old to honor that + (`_PROMISOR_KEYS`). """ entries = list(HARDENED_CONFIG) - repo.git.update_environment(**_config_env(entries)) + repo.git.update_environment(GIT_NO_LAZY_FETCH="1", **_config_env(entries)) try: listed = repo.git.config("--show-scope", "-z", "--get-regexp", _LISTED_KEYS) except git.GitCommandError as e: @@ -221,9 +369,12 @@ def harden_repo(repo: git.Repo) -> None: "overrides that keep a repository's own configuration from running " "programs" ) + drivers |= _submodule_drivers(repo) if drivers: entries += [(key, "") for key in sorted(drivers)] repo.git.update_environment(**_config_env(entries)) + if not _honors_no_lazy_fetch(repo.git.version_info): + _refuse_promisor_remote(repo) def git_status(repo: git.Repo) -> str: @@ -350,7 +501,9 @@ def _apply_merge_autostash(repo: git.Repo) -> str: return "" stash_oid = autostash.read_text().strip() try: - repo.git.stash("apply", stash_oid) + # Through _rewrite_tree although nothing after it runs a driver today + # (`git stash store` runs none): any later git command must be safe. + _rewrite_tree(repo, "stash", "apply", stash_oid) note = "\nApplied autostash." except git.GitCommandError: repo.git.stash("store", "-m", "autostash", "-q", stash_oid) @@ -499,6 +652,40 @@ def git_create_branch( return f"Created branch '{branch_name}' from {base_label}" +def _rewrite_tree(repo: git.Repo, command: str, *args: str) -> str: + """Run `git `, which writes the working tree, then re-harden. + + `harden_repo` reads the repository's configuration when the call opens + the repository, but that configuration can depend on the working tree: an + `[include]` or `[includeIf]` path into it (git skips one whose file is + missing), a `.git/config` that is a link into it, or an `includeIf + "onbranch:..."` that a branch switch satisfies. A command that writes the + tree can so create or change configuration. Git reads configuration once + per process, at start, so the command itself runs under what was read, + but every git command after it in the same call reads afresh, and would + find filter or merge drivers that were never overridden. Every command + that writes the tree therefore goes through here, and the drivers are + read again before any other git command runs, whether or not it failed: + a failed merge has written files too, and its cleanup runs git next. + + If that read fails, the overrides may be incomplete, so the call stops + with a `GitError`, which a caller's `except GitCommandError` cleanup does + not catch, and no further git command runs. + """ + try: + return getattr(repo.git, command)(*args) + finally: + try: + harden_repo(repo) + except git.GitCommandError as e: + raise git.GitError( + "Stopped: the repository's configuration could not be read " + f"again after git {command} changed the working tree. The working " + f"tree was left as git {command} wrote it (a merge may still be in " + f"progress), and no further git command was run: {e}" + ) from e + + def git_checkout(repo: git.Repo, branch_name: str) -> str: # Defense in depth: reject branch names starting with '-' to prevent flag injection, # even if a malicious ref with that name exists (e.g. via filesystem manipulation) @@ -509,7 +696,10 @@ def git_checkout(repo: git.Repo, branch_name: str) -> str: repo.rev_parse( branch_name ) # Validates branch_name is a real git ref, throws BadName if not - repo.git.checkout(branch_name) + # --quiet: without it, git checks each checked-out submodule of the new + # branch for local changes, running git inside it under its own + # configuration; the reply below does not use git's output. + _rewrite_tree(repo, "checkout", "--quiet", branch_name) # rev_parse accepts any revision, so branch_name may have been a sha, tag or # remote-tracking ref rather than a branch. Report what actually happened instead of # claiming a branch switch; a detached HEAD is easy to commit onto by mistake. @@ -545,7 +735,9 @@ def _merge_failure(repo: git.Repo, error: git.GitCommandError, what: str) -> str conflicts = _git_text( repo, "diff", _NO_SUBMODULE_STATUS, "--name-only", "--diff-filter=U" ).splitlines() - repo.git.merge("--abort") + # Through _rewrite_tree although it is the last git command here, so a git + # command added after it reads drivers the restored tree defines. + _rewrite_tree(repo, "merge", "--abort") if conflicts: return ( f"{what} stopped on conflicts in: {', '.join(conflicts)}. {unchanged} " @@ -620,7 +812,9 @@ def git_merge( # names what the caller asked for. mode = "--ff-only" if fast_forward_only else "--ff" try: - repo.git.merge( + _rewrite_tree( + repo, + "merge", mode, "--commit", "--no-squash", @@ -741,7 +935,8 @@ def validate_opened_repo( not apply `core.worktree`, so the two can differ. Git also reaches past those directories from inside them, so - `_check_git_dir_contents` holds what they contain to the same boundary. + `_check_git_dir_contents` holds what they contain to the same boundary, + and `_check_index_entries` the paths the index names in the working tree. """ if allowed_repository is None: return @@ -788,6 +983,51 @@ def outside(used: Path) -> ValueError: for directory in {p.resolve() for p in git_dirs + common_dirs}: _check_git_dir_contents(repo_path, directory, allowed, outside) + if bare != "true": + _check_index_entries(repo, repo_path) + + +def _unsafe_index_entry(entry: bytes, windows: bool = os.name == "nt") -> bool: + """Whether git would read index entry `entry` from outside the working tree. + + Git reads each entry's file at the working tree joined with the entry, and + checks the entry only when it writes one (`git add`), never when it reads + the index. An entry is refused the way `git add` refuses it: absolute, or + with an empty, `.`, `..` or `.git` component. On Windows `\\` separates + components too, a `:` makes a drive or stream path, and a component's + trailing dots and spaces are dropped by the file system, so `...` or + `.git.` count as well. + """ + for component in re.split(rb"[/\\]" if windows else rb"/", entry): + if windows: + if b":" in component: + return True + component = component.rstrip(b". ") + if component in (b"", b".", b"..") or component.lower() == b".git": + return True + return False + + +def _check_index_entries(repo: git.Repo, repo_path: Path) -> None: + """Refuse an index naming a path outside the working tree. + + The index is read through `git ls-files`, so a split index's shared part + and a sparse index's collapsed directories are listed as git uses them. + `:(top)` lists the whole index wherever GitPython runs git from. + """ + listed = repo.git.ls_files( + "-z", "--full-name", "--", ":(top)", stdout_as_string=False + ) + for entry in listed.split(b"\0"): + if entry and _unsafe_index_entry(entry): + # repr: the name is the repository's own, and escaped it carries + # no line breaks or terminal control sequences into the result. + name = entry.decode("utf-8", errors="replace") + raise ValueError( + f"Repository path '{repo_path}' has an index entry {name!r} " + "that git would read outside the working tree" + ) + # Files in a git directory that name more object stores for git to read: an # alternate's objects are read as the repository's own, from wherever it is. @@ -897,6 +1137,10 @@ def git_branch( return branch_info +# A URL with an authority part, `scheme://...`; anything else (an scp-like +# address, a local path) is not a URL and carries no userinfo or query. +_URL_SCHEME = re.compile(r"^(?P[A-Za-z][A-Za-z0-9+.-]*)://") + # A URL with an authority part: `scheme://[userinfo@]host...`. The userinfo is # everything up to the last '@' before the first '/', which is where git itself # stops reading it. @@ -925,32 +1169,75 @@ def git_branch( REDACTED = "" +def _redact_query_and_fragment(rest: str) -> str: + """`rest` (a URL after its userinfo) with query values and fragment redacted. + + A credential can ride in a query parameter (`?private_token=...`) or the + fragment as easily as in the userinfo (#5508). Every query value is + redacted, not only those with credential-like names, since no list of names + is complete; the names stay, so the URL still reads as what it is. A + parameter with no `=` (`?`) is redacted whole, and so is a non-empty + fragment. The fragment starts at the first '#', which also ends the query. + """ + rest, hash_mark, fragment = rest.partition("#") + rest, question_mark, query = rest.partition("?") + if question_mark: + params = [] + for param in query.split("&"): + name, equals, _ = param.partition("=") + if equals: + params.append(f"{name}={REDACTED}") + else: + params.append(REDACTED if param else param) + rest += "?" + "&".join(params) + if hash_mark: + rest += "#" + (REDACTED if fragment else "") + return rest + + def redact_url(url: str) -> str: - """`url` with any credential in its userinfo replaced by `` (#1611). + """`url` with any credential in it replaced by `` (#1611, #5508). A remote URL can carry a credential (`https://user:token@host/...`), and the tool's output goes to the model, so it must not echo one. Over HTTP(S) and every other scheme a token is as often the username as the password (`https://@github.com/...`), so the whole userinfo is redacted. An SSH username names the account and authenticates nothing, so it stays, - with only a password after it redacted. A remote-helper address - (`::`) has its inner URL redacted. An scp-like address - (`git@host:path`) or a local path has no userinfo to carry a password and - is returned as is. + with only a password after it redacted. Query values and the fragment are + redacted too (`_redact_query_and_fragment`), except in a `file://` URL, + where '?' and '#' are characters of a local file name. A path segment is + kept: a token there cannot be told apart from a repository name. A URL + whose userinfo would hold a '?' or '#' cannot be split safely and is + shown as `scheme://`. A remote-helper address (`::`) has its inner URL redacted. + An scp-like address (`git@host:path`) or a local path is not a URL and is + returned as is. """ helper = _REMOTE_HELPER.match(url) if helper is not None: return url[: helper.end()] + redact_url(url[helper.end() :]) + authority = _URL_SCHEME.match(url) + if authority is None: + return url + scheme = authority["scheme"] match = _URL_USERINFO.match(url) if match is None: - return url - scheme, userinfo = match["scheme"], match["userinfo"] - if scheme.lower() in _SSH_SCHEMES: - user, has_password, _ = userinfo.partition(":") - kept = f"{user}:{REDACTED}" if has_password else user + head, rest = url[: authority.end()], url[authority.end() :] else: - kept = REDACTED - return f"{scheme}://{kept}@{url[match.end() :]}" + userinfo = match["userinfo"] + if "?" in userinfo or "#" in userinfo: + # Ambiguous: the '?' or '#' may be in a password or may start a + # query or fragment holding an '@' (`https://host?t=a@SECRET`), so + # no split of it is safe. Only the scheme is shown. + return f"{scheme}://{REDACTED}" + if scheme.lower() in _SSH_SCHEMES: + user, has_password, _ = userinfo.partition(":") + kept = f"{user}:{REDACTED}" if has_password else user + else: + kept = REDACTED + head, rest = f"{scheme}://{kept}@", url[match.end() :] + if scheme.lower() == "file": + return head + rest + return head + _redact_query_and_fragment(rest) # The config values `git remote -v` builds its URLs from: each remote's @@ -1474,8 +1761,9 @@ def branch( name=GitTools.REMOTE.value, description=( "Lists the repository's remotes with their fetch and push URLs, " - "like `git remote -v`. Credentials embedded in a URL are shown as " - "" + "like `git remote -v`. Credentials embedded in a URL's userinfo, " + "query values or fragment are shown as ; path segments " + "are shown as configured" ), annotations=READ_ONLY, structured_output=False, @@ -1489,7 +1777,7 @@ def remote( return server -async def serve(repository: Path | None) -> None: +async def serve(repository: Path | None, transport: str = "stdio") -> None: logger = logging.getLogger(__name__) if repository is not None: @@ -1510,9 +1798,4 @@ async def serve(repository: Path | None) -> None: repository = root logger.info(f"Using repository at {repository}") - # Both eras (#4853): the SDK's dual-era loop lets the client's first - # request decide. `initialize` gets the 2025-11-25 handshake; - # `server/discover` or a request carrying a 2026-07-28 envelope gets the - # modern, sessionless era, with its required result fields (resultType, - # ttlMs, cacheScope) filled in by the SDK. - await create_server(repository).run_stdio_async() + await run(create_server(repository), transport) diff --git a/src/git/src/mcp_server_git/transport.py b/src/git/src/mcp_server_git/transport.py new file mode 100644 index 0000000000..0786cb5fcb --- /dev/null +++ b/src/git/src/mcp_server_git/transport.py @@ -0,0 +1,89 @@ +"""How the git server is reached: stdio (the default) or Streamable HTTP (#576). + +`--transport streamable-http` serves the same server on one `/mcp` endpoint +through the SDK's Streamable HTTP app, which answers 2026-07-28 and 2025-era +clients alike. It listens on `HOST`:`PORT` from the environment, loopback:3001 +by default: the same variables, defaults and loopback-first posture as the +TypeScript servers. + +A browser page may reach it only from a localhost Origin, whatever `HOST` is, +as with the TypeScript servers' `localhostOriginValidation`. The SDK's own +DNS-rebinding protection checks Origin only when it binds loopback, and its +Host check cannot name the addresses of an interface `HOST` widens to, so the +Origin check is this module's middleware; on loopback the SDK's Host and +Origin checks still run behind it. +""" + +import os +from collections.abc import Mapping +from urllib.parse import urlsplit + +import uvicorn +from mcp.server.mcpserver import MCPServer +from starlette.datastructures import Headers +from starlette.responses import PlainTextResponse +from starlette.types import ASGIApp, Receive, Scope, Send + +TRANSPORTS = ("stdio", "streamable-http") +DEFAULT_HOST = "127.0.0.1" +DEFAULT_PORT = 3001 + + +def http_endpoint(env: Mapping[str, str] = os.environ) -> tuple[str, int]: + """The host and port to listen on: `HOST` and `PORT`, else the defaults.""" + host = env.get("HOST") or DEFAULT_HOST + raw = env.get("PORT") + if not raw: + return host, DEFAULT_PORT + if not raw.isascii() or not raw.isdigit() or int(raw) > 65535: + raise ValueError( + f"Invalid PORT {raw!r}: expected a whole number from 0 to 65535" + ) + return host, int(raw) + + +LOCALHOST_NAMES = ("localhost", "127.0.0.1", "::1") + + +def origin_allowed(origin: str | None) -> bool: + """Whether a request with this Origin may proceed: none (a non-browser + client), or one whose host is localhost, 127.0.0.1 or [::1].""" + if origin is None: + return True + try: + hostname = urlsplit(origin).hostname + except ValueError: + return False + return hostname in LOCALHOST_NAMES + + +class LocalhostOriginMiddleware: + """Answer an HTTP request from any other Origin with 403 before `app` sees it.""" + + def __init__(self, app: ASGIApp) -> None: + self.app = app + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + if scope["type"] == "http" and not origin_allowed( + Headers(scope=scope).get("origin") + ): + response = PlainTextResponse("Invalid Origin header", status_code=403) + await response(scope, receive, send) + return + await self.app(scope, receive, send) + + +async def run(server: MCPServer, transport: str) -> None: + """Serve `server` on `transport` until it is stopped.""" + if transport == "streamable-http": + host, port = http_endpoint() + app = LocalhostOriginMiddleware(server.streamable_http_app(host=host)) + config = uvicorn.Config(app, host=host, port=port) + await uvicorn.Server(config).serve() + else: + # Both eras (#4853): the SDK's dual-era loop lets the client's first + # request decide. `initialize` gets the 2025-11-25 handshake; + # `server/discover` or a request carrying a 2026-07-28 envelope gets + # the modern, sessionless era, with its required result fields + # (resultType, ttlMs, cacheScope) filled in by the SDK. + await server.run_stdio_async() diff --git a/src/git/tests/snapshots/list_tools.json b/src/git/tests/snapshots/list_tools.json index 6ef36c2dcd..12953ca0f2 100644 --- a/src/git/tests/snapshots/list_tools.json +++ b/src/git/tests/snapshots/list_tools.json @@ -441,7 +441,7 @@ }, { "name": "git_remote", - "description": "Lists the repository's remotes with their fetch and push URLs, like `git remote -v`. Credentials embedded in a URL are shown as ", + "description": "Lists the repository's remotes with their fetch and push URLs, like `git remote -v`. Credentials embedded in a URL's userinfo, query values or fragment are shown as ; path segments are shown as configured", "inputSchema": { "properties": { "repo_path": { diff --git a/src/git/tests/test_automatic_maintenance.py b/src/git/tests/test_automatic_maintenance.py new file mode 100644 index 0000000000..fba2875050 --- /dev/null +++ b/src/git/tests/test_automatic_maintenance.py @@ -0,0 +1,145 @@ +"""No tool starts git's automatic maintenance in a repository it opens. + +`git merge` ends in `git maintenance run --auto`, which runs `git gc` when +the repository's own configuration says it is due (`gc.auto`, +`gc.autoPackLimit`). That gc's cruft repack runs every command the +repository's `gc.recentObjectsHook` names, so a repository could run a +program as the server's user through git_merge. `HARDENED_CONFIG` pins +`maintenance.auto` and `gc.auto` off; these tests plant a repository that +forces a gc on the next merge, with a hook that records its own run in a +canary file, and assert the canary is never written. + +The hook is a POSIX shell script, so the tests that run it skip on Windows; +the check of the pinned values runs everywhere. +""" + +import os +import shlex +import stat +import subprocess +import sys +from pathlib import Path + +import git +import pytest +from conftest import connect, wire + +from mcp_server_git.server import harden_repo + +posix_only = pytest.mark.skipif( + sys.platform == "win32", reason="the hook is a POSIX shell script" +) +# gc.recentObjectsHook arrived in git 2.42; an older git never runs it. +needs_hook = pytest.mark.skipif( + git.Git().version_info < (2, 42), reason="gc.recentObjectsHook needs git 2.42" +) + + +def root_of(repo: git.Repo) -> Path: + assert repo.working_dir is not None + return Path(repo.working_dir) + + +def commit_file(repo: git.Repo, name: str, content: str) -> None: + (root_of(repo) / name).write_text(content, newline="\n") + repo.git.add(name) + repo.git.commit("-m", f"write {name}") + + +def plant_due_gc(repo: git.Repo, canary: Path, *, diverge: bool) -> None: + """Make the next merge of `feature` run a gc that asks the hook. + + Two packs make gc due under `gc.auto=1` and `gc.autoPackLimit=1`, and + their sizes (6 or 3 objects against 4) are within a factor of two, so a + git whose maintenance repacks geometrically finds them due too. An old + unreachable loose object makes the cruft repack consult + `gc.recentObjectsHook`. `diverge` adds a commit on `main`, so the merge + is not a fast-forward. + """ + # Each commit comes before the pack it lands in: a commit runs automatic + # maintenance too, which could consolidate packs already made. + repo.git.branch("feature") + if diverge: + commit_file(repo, "main.txt", "main\n") + repo.git.repack("-a", "-d") + repo.git.checkout("feature") + (root_of(repo) / "feature-1.txt").write_text("one\n", newline="\n") + (root_of(repo) / "feature-2.txt").write_text("two\n", newline="\n") + repo.git.add("feature-1.txt", "feature-2.txt") + repo.git.commit("-m", "feature") + repo.git.checkout("main") + repo.git.repack("-d") + + hook = canary.parent / "hook.sh" + hook.write_text(f"#!/bin/sh\necho ran >> {shlex.quote(str(canary))}\n") + hook.chmod(hook.stat().st_mode | stat.S_IEXEC) + with repo.config_writer() as config: + config.set_value("gc", "auto", "1") + config.set_value("gc", "autoPackLimit", "1") + config.set_value("gc", "autoDetach", "false") + config.set_value("gc", "recentObjectsHook", shlex.quote(str(hook))) + + sha = ( + subprocess.run( + ["git", "hash-object", "-w", "--stdin"], + cwd=root_of(repo), + input=b"stale\n", + capture_output=True, + check=True, + ) + .stdout.decode() + .strip() + ) + loose = Path(repo.git_dir) / "objects" / sha[:2] / sha[2:] + os.utime(loose, (0, 0)) + + +@posix_only +@pytest.mark.parametrize("fast_forward_only", [True, False]) +@pytest.mark.parametrize("pinned", [False, True], ids=["roots", "repository"]) +async def test_merge_never_runs_the_recent_objects_hook( + tmp_path: Path, repo: git.Repo, fast_forward_only: bool, pinned: bool +): + canary = tmp_path / "canary" + plant_due_gc(repo, canary, diverge=not fast_forward_only) + + async with connect(root_of(repo) if pinned else None) as session: + result = wire( + await session.call_tool( + "git_merge", + { + "repo_path": str(root_of(repo)), + "source_branch": "feature", + "fast_forward_only": fast_forward_only, + }, + ) + ) + + assert result["isError"] is False, result + assert (root_of(repo) / "feature-1.txt").exists() + assert not canary.exists() + + +@posix_only +@needs_hook +@pytest.mark.parametrize("diverge", [False, True], ids=["fast-forward", "merge"]) +def test_the_planted_repository_runs_the_hook_without_the_overrides( + tmp_path: Path, repo: git.Repo, diverge: bool +): + # The control: the same merge under plain git does run the hook, so the + # test above fails if the overrides go missing. + canary = tmp_path / "canary" + plant_due_gc(repo, canary, diverge=diverge) + repo.git.merge("--ff", "--no-edit", "feature") + assert canary.read_text() == "ran\n" + + +def test_harden_repo_turns_automatic_maintenance_off(repo: git.Repo): + with repo.config_writer() as config: + config.set_value("gc", "auto", "1") + config.set_value("maintenance", "auto", "true") + harden_repo(repo) + assert repo.git.config("--show-scope", "--get", "gc.auto") == "command\t0" + assert ( + repo.git.config("--show-scope", "--get", "maintenance.auto") == "command\tfalse" + ) diff --git a/src/git/tests/test_empty_driver_name.py b/src/git/tests/test_empty_driver_name.py new file mode 100644 index 0000000000..2172c8dc45 --- /dev/null +++ b/src/git/tests/test_empty_driver_name.py @@ -0,0 +1,108 @@ +"""A filter or merge driver with an empty name is overridden like any other. + +Git accepts `[filter ""]` and `[merge ""]` sections, whose keys read back as +`filter..clean` and `merge..driver`, and `.gitattributes` selects them with +`filter=` and `merge=`. `harden_repo` must list and blank those keys too, or +the repository's own configuration runs a command on git_status, git_add, +git_checkout or git_merge. The payload and helpers are those of +`test_repository_config.py`, which covers drivers with ordinary names. +""" + +import os +from pathlib import Path +from typing import Any + +import git +import pytest +from conftest import connect, wire +from test_repository_config import Payload, commit_file, posix_only, root_of + +from mcp_server_git.server import harden_repo + + +@pytest.fixture +def payload(tmp_path: Path) -> Payload: + return Payload(tmp_path / "payload") + + +def set_empty_driver(repo: git.Repo, key: str, value: str) -> None: + """Set `
..`, a key in a subsection with an empty name.""" + repo.git.config(key, value) + + +def make_stale(path: Path) -> None: + """Move a tracked file's mtime so git re-hashes it, as after an unpack.""" + stat = path.stat() + os.utime(path, (stat.st_atime, stat.st_mtime + 10)) + + +def test_harden_repo_blanks_an_empty_named_driver(repo: git.Repo): + set_empty_driver(repo, "filter..clean", "false") + set_empty_driver(repo, "filter..smudge", "false") + set_empty_driver(repo, "filter..process", "false") + set_empty_driver(repo, "merge..driver", "false") + + harden_repo(repo) + + for key in ("filter..clean", "filter..smudge", "filter..process", "merge..driver"): + assert repo.git.config("--get", key) == "", key + + +@posix_only +@pytest.mark.parametrize("kind", ["clean", "smudge", "process"]) +async def test_empty_named_filter_driver_never_runs( + repo: git.Repo, payload: Payload, kind: str +): + commit_file(repo, ".gitattributes", "*.txt filter=\n") + repo.git.checkout("-b", "other") + commit_file(repo, "other.txt", "other\n") + repo.git.checkout("main") + set_empty_driver(repo, f"filter..{kind}", payload.command("filter")) + make_stale(root_of(repo) / "test.txt") + (root_of(repo) / "new.txt").write_text("new\n") + path = str(root_of(repo)) + + for repository in (None, root_of(repo)): + async with connect(repository) as session: + for tool, arguments in ( + ("git_status", {}), + ("git_diff_unstaged", {}), + ("git_add", {"files": ["new.txt"]}), + ("git_checkout", {"branch_name": "other"}), + ("git_checkout", {"branch_name": "main"}), + ): + result: dict[str, Any] = wire( + await session.call_tool(tool, {"repo_path": path, **arguments}) + ) + assert result["isError"] is False, (tool, result) + + assert payload.runs() == [] + assert (root_of(repo) / "test.txt").exists() + + +@posix_only +async def test_empty_named_merge_driver_never_runs(repo: git.Repo, payload: Payload): + # With the driver disabled, the conflicting change is a plain conflict, + # which git_merge aborts. + commit_file(repo, ".gitattributes", "*.txt merge=\n") + repo.git.checkout("-b", "feature") + commit_file(repo, "test.txt", "feature\n") + repo.git.checkout("main") + commit_file(repo, "test.txt", "main\n") + set_empty_driver(repo, "merge..driver", payload.command("merge")) + + async with connect(None) as session: + result = wire( + await session.call_tool( + "git_merge", + { + "repo_path": str(root_of(repo)), + "source_branch": "feature", + "fast_forward_only": False, + }, + ) + ) + + assert result["isError"] is True + assert "stopped on conflicts in: test.txt" in result["content"][0]["text"] + assert payload.runs() == [] diff --git a/src/git/tests/test_entrypoints.py b/src/git/tests/test_entrypoints.py index 8346ad96cb..f4c5dcdfe7 100644 --- a/src/git/tests/test_entrypoints.py +++ b/src/git/tests/test_entrypoints.py @@ -122,7 +122,7 @@ def test_main_sets_log_level_and_serves_repository( ): served: list[Path | None] = [] - async def fake_serve(repository: Path | None) -> None: + async def fake_serve(repository: Path | None, transport: str = "stdio") -> None: served.append(repository) with ( @@ -139,7 +139,7 @@ async def fake_serve(repository: Path | None) -> None: def test_main_short_repository_flag(tmp_path: Path): served: list[Path | None] = [] - async def fake_serve(repository: Path | None) -> None: + async def fake_serve(repository: Path | None, transport: str = "stdio") -> None: served.append(repository) with ( @@ -154,7 +154,7 @@ async def fake_serve(repository: Path | None) -> None: def test_main_without_repository_serves_none(): served: list[Path | None] = [] - async def fake_serve(repository: Path | None) -> None: + async def fake_serve(repository: Path | None, transport: str = "stdio") -> None: served.append(repository) with ( diff --git a/src/git/tests/test_http.py b/src/git/tests/test_http.py new file mode 100644 index 0000000000..5c658d8e93 --- /dev/null +++ b/src/git/tests/test_http.py @@ -0,0 +1,166 @@ +# The Streamable HTTP transport (#576): `serve(transport="streamable-http")` +# run in-process on a free loopback port and driven by the SDK `Client` over +# real HTTP in both protocol eras, plus `main()`'s `--transport` flag and +# `http_endpoint()`'s reading of HOST and PORT. + +import socket +from collections.abc import AsyncIterator +from contextlib import asynccontextmanager +from typing import Any +from unittest.mock import AsyncMock, patch + +import anyio +import pytest +from click.testing import CliRunner +from mcp import Client + +import mcp_server_git +from mcp_server_git.server import serve +from mcp_server_git.transport import ( + DEFAULT_HOST, + DEFAULT_PORT, + LocalhostOriginMiddleware, + http_endpoint, + origin_allowed, +) + +ERAS = [ + pytest.param("2026-07-28", "2026-07-28", id="2026-07-28"), + pytest.param("legacy", "2025-11-25", id="2025-11-25"), +] + + +def free_port() -> int: + """A loopback port nothing is listening on right now.""" + with socket.socket() as sock: + sock.bind(("127.0.0.1", 0)) + return sock.getsockname()[1] + + +@asynccontextmanager +async def http_server(monkeypatch: pytest.MonkeyPatch) -> AsyncIterator[str]: + """Run `serve()` over Streamable HTTP and yield its URL once it answers.""" + port = free_port() + monkeypatch.setenv("HOST", "127.0.0.1") + monkeypatch.setenv("PORT", str(port)) + async with anyio.create_task_group() as tg: + tg.start_soon(serve, None, "streamable-http") + with anyio.fail_after(10): + while True: + try: + await (await anyio.connect_tcp("127.0.0.1", port)).aclose() + break + except OSError: + await anyio.sleep(0.05) + yield f"http://127.0.0.1:{port}/mcp" + tg.cancel_scope.cancel() + + +@pytest.mark.parametrize(("mode", "negotiated"), ERAS) +async def test_serves_each_era_over_streamable_http( + monkeypatch: pytest.MonkeyPatch, mode: str, negotiated: str +) -> None: + async with http_server(monkeypatch) as url, Client(url, mode=mode) as client: + assert client.session.protocol_version == negotiated + tools = await client.list_tools() + assert "git_status" in [tool.name for tool in tools.tools] + + +def test_http_endpoint_defaults_to_loopback() -> None: + assert http_endpoint({}) == (DEFAULT_HOST, DEFAULT_PORT) + + +def test_http_endpoint_reads_host_and_port() -> None: + assert http_endpoint({"HOST": "0.0.0.0", "PORT": "8080"}) == ("0.0.0.0", 8080) + + +@pytest.mark.parametrize("port", ["abc", "-1", "65536", "1.5", "٣"]) +def test_http_endpoint_refuses_a_bad_port(port: str) -> None: + with pytest.raises(ValueError, match="Invalid PORT"): + http_endpoint({"PORT": port}) + + +@pytest.mark.parametrize( + "argv,transport", + [ + ([], "stdio"), + (["--transport", "stdio"], "stdio"), + (["--transport", "streamable-http"], "streamable-http"), + ], +) +def test_main_passes_the_transport_to_serve( + monkeypatch: pytest.MonkeyPatch, argv: list[str], transport: str +) -> None: + monkeypatch.delenv("PORT", raising=False) + serve_mock = AsyncMock() + with patch.object(mcp_server_git, "serve", serve_mock): + result = CliRunner().invoke(mcp_server_git.main, argv) + assert result.exit_code == 0, result.output + serve_mock.assert_awaited_once_with(None, transport) + + +@pytest.mark.parametrize( + "argv", [["--transport", "sse"], ["--transport", "streamable-http"]] +) +def test_main_refuses_an_unknown_transport_or_a_bad_port( + monkeypatch: pytest.MonkeyPatch, argv: list[str] +) -> None: + monkeypatch.setenv("PORT", "not-a-port") + serve_mock = AsyncMock() + with patch.object(mcp_server_git, "serve", serve_mock): + result = CliRunner().invoke(mcp_server_git.main, argv) + assert result.exit_code == 2 + serve_mock.assert_not_awaited() + assert "Error" in result.output + + +@pytest.mark.parametrize( + "origin,allowed", + [ + (None, True), + ("http://localhost:6274", True), + ("http://127.0.0.1", True), + ("http://[::1]:3000", True), + ("https://evil.example", False), + ("http://localhost.evil.example", False), + ("http://[::1", False), + ("null", False), + ], +) +def test_origin_allowed(origin: str | None, allowed: bool) -> None: + assert origin_allowed(origin) is allowed + + +async def test_middleware_refuses_a_foreign_origin_whatever_the_host() -> None: + """The check does not depend on the bind address, so it holds under HOST=0.0.0.0.""" + reached: list[str] = [] + + async def app(scope: Any, receive: Any, send: Any) -> None: + reached.append(scope["type"]) + + sent: list[Any] = [] + + async def send(message: Any) -> None: + sent.append(message) + + async def receive() -> Any: + return {"type": "http.request", "body": b"", "more_body": False} + + middleware = LocalhostOriginMiddleware(app) + foreign = { + "type": "http", + "method": "POST", + "path": "/mcp", + "headers": [ + (b"host", b"192.168.1.20:3001"), + (b"origin", b"https://evil.example"), + ], + } + await middleware(foreign, receive, send) + assert reached == [] + assert sent[0]["status"] == 403 + + local = {**foreign, "headers": [(b"origin", b"http://localhost:6274")]} + await middleware(local, receive, send) + await middleware({"type": "lifespan"}, receive, send) + assert reached == ["http", "lifespan"] diff --git a/src/git/tests/test_index_entries.py b/src/git/tests/test_index_entries.py new file mode 100644 index 0000000000..6127b525ef --- /dev/null +++ b/src/git/tests/test_index_entries.py @@ -0,0 +1,261 @@ +# What the index names, held to the --repository boundary. +# +# Git checks an index entry's path only when it writes one (`git add`); when +# it reads the index it joins each entry to the working tree as it stands. An +# index written by hand, which travels with the repository like the rest of +# `.git`, can therefore name `../outside/secret`, and git_diff_unstaged and +# git_diff would return that file's content. The index's untracked cache +# names directories the same way, for git status to list. These tests forge +# both in temporary directories and drive the server through the protocol; +# every outside file is a marker in the test's own tmp_path. + +import hashlib +import os +import struct +import subprocess +import time +from pathlib import Path +from typing import Any + +import git +import pytest +from conftest import connect, make_repo, wire +from mcp.shared.exceptions import MCPError +from mcp.types import INVALID_PARAMS +from test_eras import MODERN +from test_eras import connect as connect_era + +from mcp_server_git.server import _unsafe_index_entry + +MARKER = "MARKER-OUTSIDE-THE-REPOSITORY" +REFUSED = "that git would read outside the working tree" + + +def forge_index(index: Path, paths: list[str]) -> None: + """Write an index (version 2) whose entries are `paths`, as is. + + Each entry points at the empty blob, which the caller writes. `git + update-index` refuses such paths, so the file is written byte by byte. + """ + blob = hashlib.sha1(b"blob 0\0").digest() + body = b"" + for path in sorted(p.encode() for p in paths): + entry = struct.pack(">10I", 0, 0, 0, 0, 0, 0, 0o100644, 0, 0, 0) + blob + entry += struct.pack(">H", min(len(path), 0xFFF)) + path + body += entry + b"\0" * (8 - len(entry) % 8) + data = b"DIRC" + struct.pack(">II", 2, len(paths)) + body + index.write_bytes(data + hashlib.sha1(data).digest()) + + +def forged_repo(path: Path, entries: list[str]) -> git.Repo: + repo = make_repo(path) + repo.git.hash_object("-w", "--stdin", istream=subprocess.DEVNULL) + forge_index(Path(repo.git_dir) / "index", entries) + return repo + + +def outside_marker(tmp_path: Path) -> None: + (tmp_path / "outside").mkdir() + (tmp_path / "outside" / "secret.txt").write_text(MARKER + "\n") + + +async def call( + repository: Path | None, name: str, arguments: dict[str, Any] +) -> dict[str, Any]: + async with connect(repository) as session: + return wire(await session.call_tool(name, arguments)) + + +TOOLS = [ + ("git_diff_unstaged", {}), + ("git_diff", {"target": "HEAD"}), + ("git_diff_staged", {}), + ("git_status", {}), +] + + +@pytest.mark.parametrize(("tool", "extra"), TOOLS) +async def test_index_entry_outside_the_working_tree_is_refused( + tmp_path: Path, tool: str, extra: dict[str, Any] +): + outside_marker(tmp_path) + root = tmp_path / "repo" + forged_repo(root, ["../outside/secret.txt", "../outside/absent.txt"]).close() + result = await call(root, tool, {"repo_path": str(root), **extra}) + assert result["isError"] is True + text = result["content"][0]["text"] + assert f"has an index entry '../outside/absent.txt' {REFUSED}" in text + assert MARKER not in text + + +async def test_index_entry_in_a_nested_repository_is_refused(tmp_path: Path): + # A repository vendored inside the allowed one, received with its .git. + outside_marker(tmp_path) + root = tmp_path / "repo" + make_repo(root).close() + nested = root / "vendor" / "lib" + forged_repo(nested, ["../../../outside/secret.txt"]).close() + result = await call(root, "git_diff_unstaged", {"repo_path": str(nested)}) + assert result["isError"] is True + text = result["content"][0]["text"] + assert f"'../../../outside/secret.txt' {REFUSED}" in text + assert MARKER not in text + + +async def test_index_is_checked_whole_when_the_worktree_is_a_parent( + tmp_path: Path, +): + # GitPython runs git from the directory holding `.git`, ignoring + # `core.worktree`. With the working tree a parent of it, a bare `ls-files` + # would list only the entries under that subdirectory, and miss one that + # git joins to the parent: the check lists the index from its top. + outside_marker(tmp_path) + root = tmp_path / "repo" + make_repo(root).close() + nested = root / "sub" + repo = forged_repo(nested, ["../outside/secret.txt"]) + try: + with repo.config_writer() as config: + config.set_value("core", "worktree", "../..") + finally: + repo.close() + result = await call(root, "git_diff_unstaged", {"repo_path": str(nested)}) + assert result["isError"] is True + text = result["content"][0]["text"] + assert f"'../outside/secret.txt' {REFUSED}" in text + assert MARKER not in text + + +async def test_refusal_escapes_the_entry_name(tmp_path: Path): + # The name is the repository's own: no line break or escape sequence of it + # reaches the result as is. + root = tmp_path / "repo" + forged_repo(root, ["../x\n\x1b[31mred"]).close() + result = await call(root, "git_status", {"repo_path": str(root)}) + assert result["isError"] is True + text = result["content"][0]["text"] + assert "'../x\\n\\x1b[31mred'" in text + assert "\n" not in text and "\x1b" not in text + + +@pytest.mark.parametrize( + "entry", ["/abs/path", "./test.txt", "a//b", ".git/config", "sub/.GIT/x"] +) +async def test_every_entry_git_add_refuses_is_refused(tmp_path: Path, entry: str): + root = tmp_path / "repo" + forged_repo(root, [entry, "test.txt"]).close() + result = await call(root, "git_status", {"repo_path": str(root)}) + assert result["isError"] is True + assert f"'{entry}' {REFUSED}" in result["content"][0]["text"] + + +@pytest.mark.parametrize("prompt", ["git_commit_message", "git_summarize_changes"]) +async def test_prompts_refuse_a_forged_index(tmp_path: Path, prompt: str): + # The prompts embed the repository's changes, through the same open_repo. + outside_marker(tmp_path) + root = tmp_path / "repo" + forged_repo(root, ["../outside/secret.txt"]).close() + async with connect_era(MODERN, root) as client: + with pytest.raises(MCPError) as excinfo: + await client.get_prompt(prompt, {"repo_path": str(root)}) + assert excinfo.value.error.code == INVALID_PARAMS + assert REFUSED in excinfo.value.error.message + assert MARKER not in excinfo.value.error.message + + +async def test_forged_index_is_read_without_repository(tmp_path: Path): + # Without --repository there is no boundary to hold: the check is part of + # the confinement, as the README says, and a forged index is git's to read. + outside_marker(tmp_path) + root = tmp_path / "repo" + forged_repo(root, ["../outside/secret.txt"]).close() + result = await call(None, "git_status", {"repo_path": str(root)}) + assert result["isError"] is False + + +async def test_split_and_sparse_indexes_are_accepted(tmp_path: Path): + # Both are listed through git, so their entries are checked as git reads + # them, and a well-formed one passes. + root = tmp_path / "repo" + repo = make_repo(root) + try: + (root / "dir").mkdir() + (root / "dir" / "inner.txt").write_text("inner\n") + repo.git.add("dir") + repo.git.commit("-m", "dir") + repo.git.update_index("--split-index") + assert list(Path(repo.git_dir).glob("sharedindex.*")) + result = await call(root, "git_diff_unstaged", {"repo_path": str(root)}) + assert result["isError"] is False + repo.git.update_index("--no-split-index") + repo.git.sparse_checkout("set", "--cone", "--sparse-index", "other") + assert "dir/" in repo.git.ls_files("--sparse").splitlines() + assert not (root / "dir").exists() + result = await call(root, "git_status", {"repo_path": str(root)}) + assert result["isError"] is False + finally: + repo.close() + + +async def test_untracked_cache_naming_outside_is_ignored(tmp_path: Path): + # The untracked cache, an index extension, lists directories by name. One + # renamed to `..` makes git status list the directory above the working + # tree, recursively, unless the server turns the cache off. + outside_marker(tmp_path) + root = tmp_path / "repo" + repo = make_repo(root) + try: + (root / "zz").mkdir() + (root / "zz" / "q").write_text("q\n") + own = ("-c", "core.fsmonitor=false", "-c", "core.untrackedCache=true") + # A directory changed in the second git writes the cache is racy, and + # git rescans it rather than trust the cache. + past = time.time() - 100 + for directory in (root, root / "zz"): + os.utime(directory, (past, past)) + repo.git.update_index("--untracked-cache") + for _ in range(2): + repo.git.execute(["git", *own, "status", "--porcelain"]) + index = Path(repo.git_dir) / "index" + data = index.read_bytes()[:-20] + at = data.index(b"zz\0", data.index(b"UNTR")) + data = data[:at] + b"..\0" + data[at + 3 :] + forged = data + hashlib.sha1(data).digest() + index.write_bytes(forged) + # Git honors the forged cache by default: the precondition. It names + # the directory above the working tree either whole (`../`) or file + # by file, depending on the git, so the check is on the `../` prefix. + plain = repo.git.execute(["git", *own, "status", "--porcelain"]) + assert any(line[3:].startswith("../") for line in str(plain).splitlines()) + index.write_bytes(forged) + finally: + repo.close() + result = await call(root, "git_status", {"repo_path": str(root)}) + assert result["isError"] is False + text = result["content"][0]["text"] + assert "zz/" in text + assert "outside" not in text + assert "../" not in text + + +@pytest.mark.parametrize( + ("entry", "posix", "windows"), + [ + (b"src/main.py", False, False), + (b"a.git/b..c/.gitignore", False, False), + (b"..", True, True), + (b"../x", True, True), + (b"/x", True, True), + (b"x/", True, True), + (b".Git/config", True, True), + (b"..\\x", False, True), + (b"sub\\.git\\config", False, True), + (b"C:x", False, True), + (b"a/.../b", False, True), + (b"a/.. /b", False, True), + (b"a/.git./b", False, True), + ], +) +def test_unsafe_index_entry(entry: bytes, posix: bool, windows: bool): + assert _unsafe_index_entry(entry, windows=False) is posix + assert _unsafe_index_entry(entry, windows=True) is windows diff --git a/src/git/tests/test_lazy_fetch.py b/src/git/tests/test_lazy_fetch.py new file mode 100644 index 0000000000..9ad95ef186 --- /dev/null +++ b/src/git/tests/test_lazy_fetch.py @@ -0,0 +1,358 @@ +"""A repository's promisor remote never makes the server fetch, or run a program. + +A repository that declares a promisor remote (`remote..promisor`, +`extensions.partialClone`, a partial clone) has git fetch any object it is +missing from that remote on its own, from a read-only command. The fetch runs +the transport program the repository's configuration names +(`remote..uploadpack`, `core.sshCommand`). The server sets +GIT_NO_LAZY_FETCH for every git command (`harden_repo`), so a missing object +is an error and nothing runs; on a git too old to honor that, it refuses such +a repository instead. + +Each protocol-level test plants a transport program that records its run in a +canary file, makes an object the tool needs absent, drives the real server +through a client (`conftest.connect`), and asserts the canary was never +written. The payloads are POSIX shell commands, so those tests skip on +Windows; the tests of the version rule run everywhere. +""" + +import secrets +import shlex +import subprocess +import sys +from pathlib import Path +from typing import Any +from unittest import mock + +import git +import pytest +from conftest import connect, make_repo, wire + +from mcp_server_git.server import _honors_no_lazy_fetch, harden_repo + +posix_only = pytest.mark.skipif( + sys.platform == "win32", reason="the payloads are POSIX shell commands" +) + +# The protocol tests check what GIT_NO_LAZY_FETCH stops. A git that ignores +# it (by its version; a distribution backport reads as old) refuses these +# repositories instead, which the tests of `harden_repo` below cover, so +# there the protocol tests would pass without testing the variable. +lazy_fetch_off = pytest.mark.skipif( + not _honors_no_lazy_fetch(git.Git().version_info), + reason="this git does not honor GIT_NO_LAZY_FETCH", +) + + +def root_of(repo: git.Repo) -> Path: + assert repo.working_dir is not None + return Path(repo.working_dir) + + +def run_git(*args: str) -> None: + subprocess.run(["git", *args], check=True, capture_output=True) + + +def two_commits(path: Path) -> git.Repo: + """A repository whose `test.txt` changed in a second commit.""" + repo = make_repo(path) + (path / "test.txt").write_text("changed\n", newline="\n") + repo.git.commit("-qam", "second") + return repo + + +def drop(repo: git.Repo, revision: str) -> None: + """Delete the loose object `revision` names from the object store.""" + sha = repo.git.rev_parse(revision) + (Path(repo.git_dir) / "objects" / sha[:2] / sha[2:]).unlink() + + +def absent_sha() -> str: + return secrets.token_hex(20) + + +class Canary: + """Transport programs that record their run in one file.""" + + def __init__(self, path: Path) -> None: + self.path = path + + def uploadpack(self) -> str: + # Then hands over to the real upload-pack, so a fetch that is not + # stopped completes and the tool would answer normally. + return f"sh -c 'echo uploadpack >> {shlex.quote(str(self.path))}; exec git-upload-pack \"$@\"' --" + + def ssh(self) -> str: + return f"sh -c 'echo ssh >> {shlex.quote(str(self.path))}; exit 1'" + + def ran(self) -> bool: + return self.path.exists() + + +@pytest.fixture +def canary(tmp_path: Path) -> Canary: + return Canary(tmp_path / "canary") + + +def promisor_uploadpack(repo: git.Repo, canary: Canary, url: str) -> None: + with repo.config_writer() as config: + config.set_value('remote "origin"', "url", url) + config.set_value('remote "origin"', "promisor", "true") + config.set_value('remote "origin"', "uploadpack", canary.uploadpack()) + + +def promisor_ssh(repo: git.Repo, canary: Canary) -> None: + with repo.config_writer() as config: + config.set_value('remote "origin"', "url", "ssh://git@host.invalid/x.git") + config.set_value('remote "origin"', "promisor", "true") + config.set_value("core", "sshCommand", canary.ssh()) + + +async def call( + name: str, arguments: dict[str, Any], repository: Path | None = None +) -> dict[str, Any]: + async with connect(repository) as session: + return wire(await session.call_tool(name, arguments)) + + +# -------------------------------------------------------------------------- +# A missing object in a plain repository with a promisor remote +# -------------------------------------------------------------------------- + + +@posix_only +@lazy_fetch_off +@pytest.mark.parametrize("transport", ["uploadpack", "ssh"]) +async def test_show_of_a_missing_blob_runs_nothing( + tmp_path: Path, canary: Canary, transport: str +): + repo = two_commits(tmp_path / "repo") + drop(repo, "HEAD~1:test.txt") + if transport == "uploadpack": + promisor_uploadpack(repo, canary, str(tmp_path / "nothing")) + else: + promisor_ssh(repo, canary) + repo.close() + + await call("git_show", {"repo_path": str(tmp_path / "repo"), "revision": "HEAD"}) + + assert not canary.ran() + + +@posix_only +@lazy_fetch_off +@pytest.mark.parametrize("transport", ["uploadpack", "ssh"]) +@pytest.mark.parametrize( + ("tool", "arguments"), + [ + ("git_branch", lambda sha: {"branch_type": "all", "contains": sha}), + ("git_diff", lambda sha: {"target": sha}), + ("git_show", lambda sha: {"revision": sha}), + ], +) +async def test_an_absent_object_id_runs_nothing( + tmp_path: Path, canary: Canary, transport: str, tool: str, arguments: Any +): + # A complete repository: an object id that names nothing is enough. + repo = two_commits(tmp_path / "repo") + if transport == "uploadpack": + promisor_uploadpack(repo, canary, str(tmp_path / "nothing")) + else: + promisor_ssh(repo, canary) + repo.close() + + await call(tool, {"repo_path": str(tmp_path / "repo"), **arguments(absent_sha())}) + + assert not canary.ran() + + +@posix_only +@lazy_fetch_off +@pytest.mark.parametrize("transport", ["uploadpack", "ssh"]) +@pytest.mark.parametrize("tool", ["git_status", "git_diff_staged", "git_diff_unstaged"]) +async def test_a_missing_head_tree_runs_nothing( + tmp_path: Path, canary: Canary, transport: str, tool: str +): + repo = two_commits(tmp_path / "repo") + drop(repo, "HEAD^{tree}") + if transport == "uploadpack": + # A bare copy inside the repository's own .git: a fetch that is not + # stopped succeeds, and the tool would answer as if nothing happened. + source = Path(repo.git_dir) / "source.git" + run_git("clone", "-q", "--bare", str(tmp_path / "repo"), str(source)) + promisor_uploadpack(repo, canary, str(source)) + else: + promisor_ssh(repo, canary) + repo.close() + + await call(tool, {"repo_path": str(tmp_path / "repo")}) + + assert not canary.ran() + + +# -------------------------------------------------------------------------- +# A genuine partial clone, and the same under --repository +# -------------------------------------------------------------------------- + + +@posix_only +@lazy_fetch_off +async def test_partial_clone_runs_nothing(tmp_path: Path, canary: Canary): + upstream = two_commits(tmp_path / "upstream") + upstream.git.config("uploadpack.allowFilter", "true") + upstream.close() + clone = tmp_path / "clone" + run_git( + "clone", + "-q", + "--filter=blob:none", + f"file://{tmp_path / 'upstream'}", + str(clone), + ) + run_git("-C", str(clone), "config", "remote.origin.uploadpack", canary.uploadpack()) + + await call("git_show", {"repo_path": str(clone), "revision": "HEAD"}) + + assert not canary.ran() + + +@posix_only +@lazy_fetch_off +async def test_nested_repository_runs_nothing_under_repository( + tmp_path: Path, canary: Canary +): + workspace = make_repo(tmp_path / "workspace") + nested = two_commits(root_of(workspace) / "vendor" / "lib") + drop(nested, "HEAD^{tree}") + promisor_uploadpack(nested, canary, str(tmp_path / "nothing")) + nested.close() + + for tool, arguments in [("git_status", {}), ("git_show", {"revision": "HEAD"})]: + await call( + tool, + {"repo_path": str(root_of(workspace) / "vendor" / "lib"), **arguments}, + root_of(workspace), + ) + workspace.close() + + assert not canary.ran() + + +@posix_only +@lazy_fetch_off +async def test_partial_clone_extension_runs_nothing_under_repository( + tmp_path: Path, canary: Canary +): + # A modified file whose committed blob is gone, in a repository that + # declares itself a partial clone, opened as the --repository itself. + repo = make_repo(tmp_path / "repo") + (tmp_path / "repo" / "test.txt").write_text("modified\n", newline="\n") + drop(repo, "HEAD:test.txt") + promisor_uploadpack(repo, canary, str(tmp_path / "nothing")) + repo.git.config("extensions.partialClone", "origin") + repo.close() + + await call( + "git_diff_unstaged", {"repo_path": str(tmp_path / "repo")}, tmp_path / "repo" + ) + + assert not canary.ran() + + +@posix_only +@lazy_fetch_off +async def test_a_complete_repository_with_a_promisor_still_works( + tmp_path: Path, canary: Canary +): + # Nothing is missing, so nothing would be fetched: the tools answer. + repo = two_commits(tmp_path / "repo") + promisor_uploadpack(repo, canary, str(tmp_path / "nothing")) + repo.close() + + result = await call( + "git_show", {"repo_path": str(tmp_path / "repo"), "revision": "HEAD"} + ) + + assert result["isError"] is False, result + assert "second" in result["content"][0]["text"] + assert not canary.ran() + + +# -------------------------------------------------------------------------- +# A git too old to honor GIT_NO_LAZY_FETCH +# -------------------------------------------------------------------------- + + +@pytest.mark.parametrize( + ("version", "honors"), + [ + ((2, 31, 0), False), + ((2, 39, 3), False), + ((2, 39, 4), True), + ((2, 39, 5), True), + ((2, 40, 1), False), + ((2, 40, 2), True), + ((2, 41, 1), True), + ((2, 42, 2), True), + ((2, 43, 3), False), + ((2, 43, 4), True), + ((2, 44, 0), False), + ((2, 44, 1), True), + ((2, 45, 0), False), + ((2, 45, 1), True), + ((2, 46), True), + ((2, 53, 0, 1), True), + ((3, 0), True), + ], +) +def test_which_git_honors_no_lazy_fetch(version: tuple[int, ...], honors: bool): + assert _honors_no_lazy_fetch(version) is honors + + +def old_git() -> Any: + return mock.patch.object( + git.Git, "version_info", new_callable=mock.PropertyMock, return_value=(2, 44, 0) + ) + + +@pytest.mark.parametrize( + ("key", "value"), + [ + ("remote.origin.promisor", "true"), + ("remote.promisor", "true"), + ("remote.partialCloneFilter", "blob:none"), + ("remote.origin.partialCloneFilter", "blob:none"), + ("extensions.partialClone", "origin"), + ], +) +def test_old_git_refuses_a_repository_with_a_promisor_remote( + tmp_path: Path, key: str, value: str +): + repo = make_repo(tmp_path / "repo") + repo.git.config(key, value) + with old_git(), pytest.raises(git.GitError, match="Git 2.45.1 or later"): + harden_repo(repo) + repo.close() + + +def test_old_git_opens_a_repository_without_one(repo: git.Repo): + with old_git(): + harden_repo(repo) + + +def test_old_git_reports_a_failing_git(repo: git.Repo): + # Any failure but "nothing matched" (exit 1) is git's own, reported as is. + real = repo.git.config + failure = git.GitCommandError(["git", "config"], 128, "fatal: bad config") + + def config(*args: str, **kwargs: Any) -> Any: + if "--get-regexp" in args and "--show-scope" not in args: + raise failure + return real(*args, **kwargs) + + with ( + old_git(), + mock.patch.object(git.Git, "config", side_effect=config, create=True), + pytest.raises(git.GitCommandError, match="bad config"), + ): + harden_repo(repo) diff --git a/src/git/tests/test_remote.py b/src/git/tests/test_remote.py index 9d193d50f0..f887cfa56c 100644 --- a/src/git/tests/test_remote.py +++ b/src/git/tests/test_remote.py @@ -3,7 +3,7 @@ The tool's output goes to the model, and a remote URL can carry a credential (`https://user:token@host/...`), so most of these pin `redact_url`'s rule: the whole userinfo is redacted except an SSH username, which names an account and -authenticates nothing. The protocol tests drive the real server through +authenticates nothing, and so are query values and the fragment (#5508). The protocol tests drive the real server through `conftest.connect`; the unit tests cover URL shapes git would not let a test configure as easily. """ @@ -117,6 +117,60 @@ async def test_not_a_repository(tmp_path: Path): ), ("ext::ssh://git:pw@example.com/r", "ext::ssh://git:@example.com/r"), ("https::https://example.com/r.git", "https::https://example.com/r.git"), + # Query values and the fragment (#5508): every value, whatever its + # parameter's name, with the names kept; a bare parameter whole. + ( + "https://git.example.com/g/r.git?private_token=SECRET", + "https://git.example.com/g/r.git?private_token=", + ), + ( + "https://example.com/r?a=1&token=SECRET&&flag", + "https://example.com/r?a=&token=&&", + ), + ("https://example.com/r?SECRET", "https://example.com/r?"), + ("https://example.com/r?", "https://example.com/r?"), + ( + "https://git.example.com/g/r.git#SECRET", + "https://git.example.com/g/r.git#", + ), + ("https://example.com/r#", "https://example.com/r#"), + # The fragment starts at the first '#', which also ends the query. + ("https://example.com/r#a?b=c", "https://example.com/r#"), + ( + "https://example.com/r?a=b#c", + "https://example.com/r?a=#", + ), + # Userinfo, query and fragment together; an '@' inside a query value. + ( + "https://u:p@example.com/r?t=x#y", + "https://@example.com/r?t=#", + ), + ("https://example.com/r?e=a@b.com", "https://example.com/r?e="), + ("ssh://git@example.com/r?t=x", "ssh://git@example.com/r?t="), + # A '?' or '#' before the userinfo's '@' may be in a password or may + # start a query or fragment holding an '@': nothing after the scheme + # can be shown safely. + ("https://user:p?ss@example.com", "https://"), + ("https://user:p#ss@example.com", "https://"), + ("https://example.com?token=left@SECRET", "https://"), + ("https://example.com#left@SECRET", "https://"), + ("ssh://example.com?token=left@SECRET", "ssh://"), + ("https://example.com?t=a@SECRET/x", "https://"), + ("https://u:p?ss@example.com/r", "https://"), + ("https://example.com?t=SECRET", "https://example.com?t="), + # A remote-helper address: the inner URL's query is redacted. + ( + "https::https://example.com/r?t=SECRET", + "https::https://example.com/r?t=", + ), + # A path segment cannot be told apart from a repository name: kept. + ( + "https://git.example.com/token/SECRET/r.git", + "https://git.example.com/token/SECRET/r.git", + ), + # A file:// URL names a local file, whose name may hold '?' or '#'. + ("file:///srv/r?x#y.git", "file:///srv/r?x#y.git"), + ("file://u:p@host/srv/r?x", "file://@host/srv/r?x"), # A password holding a line separator other than '\n'. ("https://u:s3cret\u2028tok@example.com/r", "https://@example.com/r"), ], @@ -194,3 +248,16 @@ async def test_remote_helper_url_is_redacted(repo: git.Repo): "origin\thttps::https://@example.com/r.git (fetch)\n" "origin\thttps::https://@example.com/r.git (push)" ) + + +async def test_query_and_fragment_credentials_are_redacted_over_the_wire( + repo: git.Repo, +): + # The issue's examples (#5508): a token in a query value or the fragment. + repo.create_remote("origin", "https://git.example.com/g/r.git?private_token=S1") + repo.git.remote("set-url", "--push", "origin", "https://git.example.com/g/r.git#S2") + result = await call_remote(None, repo) + assert result == text_result( + "origin\thttps://git.example.com/g/r.git?private_token= (fetch)\n" + "origin\thttps://git.example.com/g/r.git# (push)" + ) diff --git a/src/git/tests/test_submodule_config.py b/src/git/tests/test_submodule_config.py new file mode 100644 index 0000000000..14ab8e62eb --- /dev/null +++ b/src/git/tests/test_submodule_config.py @@ -0,0 +1,407 @@ +"""A submodule's own configuration never makes the server run a program. + +Git runs some commands inside a checked-out submodule, under the submodule's +own configuration, which the opened repository's `harden_repo` does not read +by itself: a nested `git diff` when `diff.submodule` is `diff`, and a nested +`git status` when `git_add ["."]` or `git_checkout` checks whether the +submodule changed. The server pins `diff.submodule` to `short` so the nested +diff never starts, and empties the filter and merge drivers each checked-out +submodule defines, as it does for the opened repository's own. + +Each test plants a program in a submodule's configuration that records its +run in a canary file, drives the real server through a client +(`conftest.connect`), and asserts the canary was never written. The payload +is a POSIX shell script, so those tests skip on Windows; the tests of the +submodule listing itself run everywhere. +""" + +import os +import shlex +import stat +import sys +from pathlib import Path +from typing import Any + +import git +import pytest +from conftest import connect, make_repo, wire + +from mcp_server_git.server import _submodule_drivers, harden_repo + +posix_only = pytest.mark.skipif( + sys.platform == "win32", reason="the payload is a POSIX shell script" +) + + +class Canary: + """A program that appends its first argument to a canary file. + + As a filter it passes its input through, and as a textconv it prints the + file it is given, so a run that is not stopped still behaves normally. + """ + + def __init__(self, directory: Path) -> None: + directory.mkdir() + self.file = directory / "canary" + self.script = directory / "payload.sh" + self.script.write_text( + "#!/bin/sh\n" + f'echo "$1" >> {shlex.quote(str(self.file))}\n' + 'case "$1" in\n' + " filter) exec cat ;;\n" + ' textconv) exec cat "$2" ;;\n' + "esac\n" + "exit 0\n" + ) + self.script.chmod(self.script.stat().st_mode | stat.S_IEXEC) + + def command(self, tag: str) -> str: + return f"{shlex.quote(str(self.script))} {tag}" + + def runs(self) -> list[str]: + return self.file.read_text().split() if self.file.exists() else [] + + +@pytest.fixture +def canary(tmp_path: Path) -> Canary: + return Canary(tmp_path / "canary") + + +def root_of(repo: git.Repo) -> Path: + assert repo.working_dir is not None + return Path(repo.working_dir) + + +def commit_file(repo: git.Repo, name: str, content: str) -> None: + (root_of(repo) / name).write_text(content, newline="\n") + repo.git.add(name) + repo.git.commit("-m", f"write {name}") + + +def record_gitlink(repo: git.Repo, path: str, sha: str) -> None: + """Record `path` as a gitlink at `sha`, as a vendored tree carries one. + + No `.gitmodules` entry is needed for git to treat it as a submodule. + """ + repo.git.update_index("--add", "--cacheinfo", f"160000,{sha},{path}") + + +def embed(repo: git.Repo, path: str) -> git.Repo: + """A repository checked out at `path` inside `repo`, committed as a gitlink.""" + inner = make_repo(root_of(repo) / path) + record_gitlink(repo, path, inner.head.commit.hexsha) + repo.git.commit("-m", f"add {path}") + return inner + + +async def call( + name: str, arguments: dict[str, Any], repository: Path | None = None +) -> dict[str, Any]: + async with connect(repository) as session: + return wire(await session.call_tool(name, arguments)) + + +# -------------------------------------------------------------------------- +# A nested git diff (diff.submodule=diff) +# -------------------------------------------------------------------------- + + +def moved_submodule(repo: git.Repo, tool: str) -> git.Repo: + """A submodule `sm` whose commit differs where `tool` compares. + + The working tree's submodule is always at its second commit. The index + records the first for git_diff_unstaged and git_diff (against HEAD); for + git_diff_staged the index records the second and HEAD the first. + """ + sm = embed(repo, "sm") # HEAD and the index record the first commit + commit_file(sm, "test.txt", "changed\n") + if tool == "git_diff_staged": + record_gitlink(repo, "sm", sm.head.commit.hexsha) + repo.git.config("diff.submodule", "diff") + return sm + + +DIFF_TOOLS = [ + ("git_diff_unstaged", {}), + ("git_diff_staged", {}), + ("git_diff", {"target": "HEAD"}), +] + + +@posix_only +@pytest.mark.parametrize("program", ["external", "textconv"]) +@pytest.mark.parametrize("with_repository", [False, True]) +@pytest.mark.parametrize(("tool", "arguments"), DIFF_TOOLS) +async def test_submodule_diff_programs_never_run( + repo: git.Repo, + canary: Canary, + tool: str, + arguments: dict[str, Any], + with_repository: bool, + program: str, +): + sm = moved_submodule(repo, tool) + if program == "external": + sm.git.config("diff.external", canary.command("external")) + else: + (root_of(sm) / ".git" / "info" / "attributes").write_text("*.txt diff=evil\n") + sm.git.config("diff.evil.textconv", canary.command("textconv")) + sm.close() + path = root_of(repo) + + result = await call( + tool, + {"repo_path": str(path), **arguments}, + path if with_repository else None, + ) + + assert result["isError"] is False, result + # The submodule is still reported, as a moved commit. + assert "Subproject commit" in result["content"][0]["text"], result + assert canary.runs() == [] + + +@posix_only +async def test_git_diff_between_commits_never_runs_submodule_programs( + repo: git.Repo, canary: Canary +): + # The report's own case: a range over a commit that moved the submodule. + sm = moved_submodule(repo, "git_diff") + record_gitlink(repo, "sm", sm.head.commit.hexsha) + repo.git.commit("-m", "bump sm") + sm.git.config("diff.external", canary.command("external")) + sm.close() + + result = await call( + "git_diff", {"repo_path": str(root_of(repo)), "target": "HEAD~1"} + ) + + assert result["isError"] is False, result + assert canary.runs() == [] + + +# -------------------------------------------------------------------------- +# A nested git status (git_add ["."], git_checkout) +# -------------------------------------------------------------------------- + + +def filtered_submodule(repo: git.Repo, canary: Canary, path: str) -> None: + """A checked-out submodule at `path` whose own config defines a filter. + + Its `.gitattributes` applies the filter to `test.txt`, whose mtime is then + changed so git must read the file again, through the filter, to see + whether the submodule is dirty. + """ + sm = embed(repo, path) + commit_file(sm, ".gitattributes", "*.txt filter=evil\n") + record_gitlink(repo, path, sm.head.commit.hexsha) + repo.git.commit("-m", f"bump {path}") + sm.git.config("filter.evil.clean", canary.command("filter")) + sm.git.config("filter.evil.smudge", canary.command("filter")) + sm.close() + os.utime(root_of(repo) / path / "test.txt", (1_000_000_000, 1_000_000_000)) + + +@posix_only +@pytest.mark.parametrize( + ("tool", "arguments"), + [ + ("git_add", {"files": ["."]}), + ("git_checkout", {"branch_name": "same"}), + ], +) +async def test_submodule_filters_never_run( + repo: git.Repo, canary: Canary, tool: str, arguments: dict[str, Any] +): + filtered_submodule(repo, canary, "sm") + repo.git.branch("same") + path = root_of(repo) + + result = await call(tool, {"repo_path": str(path), **arguments}, path) + + assert result["isError"] is False, result + assert canary.runs() == [] + + +@posix_only +async def test_nested_submodule_filters_never_run(repo: git.Repo, canary: Canary): + # A submodule inside a submodule: git descends, and so does the listing. + outer = embed(repo, "outer") + filtered_submodule(outer, canary, "inner") + record_gitlink(repo, "outer", outer.head.commit.hexsha) + repo.git.commit("-m", "bump outer") + outer.close() + + result = await call("git_add", {"repo_path": str(root_of(repo)), "files": ["."]}) + + assert result["isError"] is False, result + assert canary.runs() == [] + + +@posix_only +async def test_checkout_never_looks_inside_a_submodule_the_branch_adds( + repo: git.Repo, canary: Canary +): + # The current branch has no gitlink at `vendor`, so hardening does not + # list its drivers; the target branch records one. git_checkout must not + # look inside it once the new index is written. + vendor = make_repo(root_of(repo) / "vendor") + commit_file(vendor, ".gitattributes", "*.txt filter=evil\n") + vendor.git.config("filter.evil.clean", canary.command("filter")) + sha = vendor.head.commit.hexsha + vendor.close() + repo.git.checkout("-q", "-b", "with-vendor") + record_gitlink(repo, "vendor", sha) + repo.git.commit("-m", "add vendor") + repo.git.checkout("-q", "main") + os.utime(root_of(repo) / "vendor" / "test.txt", (1_000_000_000, 1_000_000_000)) + path = root_of(repo) + + result = await call( + "git_checkout", {"repo_path": str(path), "branch_name": "with-vendor"}, path + ) + + assert result["isError"] is False, result + assert canary.runs() == [] + + +async def test_git_add_still_stages_a_moved_submodule(repo: git.Repo): + sm = embed(repo, "sm") + commit_file(sm, "test.txt", "changed\n") + moved = sm.head.commit.hexsha + sm.close() + + result = await call("git_add", {"repo_path": str(root_of(repo)), "files": ["."]}) + + assert result["isError"] is False, result + assert repo.git.ls_files("--stage", "sm").split()[1] == moved + + +# -------------------------------------------------------------------------- +# _submodule_drivers +# -------------------------------------------------------------------------- + + +def test_lists_the_drivers_of_each_checked_out_submodule( + tmp_path: Path, repo: git.Repo, monkeypatch: pytest.MonkeyPatch +): + global_config = tmp_path / "global-config" + global_config.write_text('[filter "lfs"]\n\tclean = lfs-clean\n') + monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(global_config)) + sm = embed(repo, "sm") + sm.git.config("filter.evil.clean", "x") + sm.git.config("merge.evil.driver", "x") + sm.git.config("core.hooksPath", "hooks") + sm.close() + + # The user's own driver and the submodule's hooksPath are not listed. + assert _submodule_drivers(repo) == {"filter.evil.clean", "merge.evil.driver"} + + harden_repo(repo) + sm = git.Repo(root_of(repo) / "sm") + sm.git.update_environment(**repo.git.environment()) + assert sm.git.config("--get", "filter.evil.clean") == "" + assert sm.git.config("--get", "merge.evil.driver") == "" + assert sm.git.config("--get", "filter.lfs.clean") == "lfs-clean" + sm.close() + + +def test_skips_gitlinks_git_does_not_look_inside(repo: git.Repo): + sha = repo.head.commit.hexsha + # Not checked out: an empty directory, and no directory at all. + (root_of(repo) / "empty").mkdir() + record_gitlink(repo, "empty", sha) + record_gitlink(repo, "absent", sha) + # A `.git` that names no repository: git cannot open it, nor can the + # nested git, so nothing runs there. + (root_of(repo) / "broken").mkdir() + (root_of(repo) / "broken" / ".git").write_text("gitdir: /nonexistent\n") + record_gitlink(repo, "broken", sha) + + assert _submodule_drivers(repo) == set() + + +def test_visits_a_submodule_once(repo: git.Repo): + # A gitlink that resolves to a repository already visited (here, through + # a symlink to the submodule) is not listed again, so a link back to an + # ancestor cannot loop. + sm = embed(repo, "sm") + sm.git.config("filter.evil.clean", "x") + sm.close() + try: + (root_of(repo) / "again").symlink_to(root_of(repo) / "sm") + except OSError: + pytest.skip("symlinks are not available") + record_gitlink(repo, "again", repo.head.commit.hexsha) + + assert _submodule_drivers(repo) == {"filter.evil.clean"} + + +def test_bare_repository_has_no_submodules(tmp_path: Path): + bare = git.Repo.init(tmp_path / "bare.git", bare=True) + assert _submodule_drivers(bare) == set() + bare.close() + + +def test_skips_a_submodule_whose_index_git_cannot_read(repo: git.Repo): + # One broken submodule does not stop every tool: the nested git cannot + # read that index either, so it runs nothing there. + sm = embed(repo, "sm") + sm.git.config("filter.evil.clean", "x") + sm.close() + (root_of(repo) / "sm" / ".git" / "index").write_bytes(b"not an index") + + assert _submodule_drivers(repo) == {"filter.evil.clean"} + + +async def test_tools_still_work_beside_a_broken_submodule(repo: git.Repo): + embed(repo, "sm").close() + (root_of(repo) / "sm" / ".git" / "index").write_bytes(b"not an index") + + result = await call("git_status", {"repo_path": str(root_of(repo))}) + + assert result["isError"] is False, result + + +def test_opens_a_submodule_as_the_nested_git_does( + tmp_path: Path, repo: git.Repo, monkeypatch: pytest.MonkeyPatch +): + # The nested git opens a submodule with GIT_DIR=.git, which skips the + # ownership check; so does the listing. Simulated here: every repository + # is taken to belong to someone else, and only the opened one is trusted. + sm = embed(repo, "sm") + sm.git.config("filter.evil.clean", "x") + sm.close() + global_config = tmp_path / "global-config" + global_config.write_text(f"[safe]\n\tdirectory = {root_of(repo).as_posix()}\n") + monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(global_config)) + # The system configuration can trust every directory (GitHub's runner + # images set `safe.directory = *` there), which would hide the check. + monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1") + monkeypatch.setenv("GIT_TEST_ASSUME_DIFFERENT_OWNER", "1") + with pytest.raises(git.GitCommandError, match="dubious ownership"): + git.Git(root_of(repo) / "sm").ls_files() + + assert _submodule_drivers(repo) == {"filter.evil.clean"} + + +def test_refuses_git_older_than_2_33_with_a_checked_out_submodule( + repo: git.Repo, monkeypatch: pytest.MonkeyPatch +): + # Git 2.31 and 2.32 do not pass GIT_CONFIG_COUNT to the git they run + # inside a submodule, so the overrides would not reach it. + embed(repo, "sm").close() + monkeypatch.setattr(git.Git, "version_info", property(lambda self: (2, 32, 0))) + with pytest.raises(git.GitError, match="Git 2.33 or later is required"): + harden_repo(repo) + + +def test_older_git_works_without_a_checked_out_submodule( + repo: git.Repo, monkeypatch: pytest.MonkeyPatch +): + # Without a checked-out submodule git never runs inside one, so 2.31 and + # 2.32 are still served; a gitlink with nothing checked out is fine too. + record_gitlink(repo, "absent", repo.head.commit.hexsha) + monkeypatch.setattr(git.Git, "version_info", property(lambda self: (2, 32, 0))) + harden_repo(repo) + assert repo.git.config("--get", "core.hooksPath") == os.devnull diff --git a/src/git/tests/test_tree_config.py b/src/git/tests/test_tree_config.py new file mode 100644 index 0000000000..ce57f7e29c --- /dev/null +++ b/src/git/tests/test_tree_config.py @@ -0,0 +1,207 @@ +"""Configuration a tool call's own writes create is overridden like the rest. + +`harden_repo` reads the repository's filter and merge drivers when a call +opens the repository, but the configuration can depend on the working tree: +an `[include]` path into it that git skips while the file is missing, a +`.git/config` that is a link to a tracked file, or an `includeIf +"onbranch:..."` that a checkout satisfies. A tool that writes the tree (a +merge, a checkout) can so define a driver mid-call, and the git commands it +runs next (a conflicting merge's `git diff` and `git merge --abort`) would run +it. Every tree-writing command goes through `_rewrite_tree`, which reads the +drivers again before anything else runs. + +Each attack test plants a filter that records its run in a canary file +(`Payload`, shared with test_repository_config.py), drives the real server +through a client, and asserts the canary stays empty. The payloads are POSIX +shell scripts, so those tests skip on Windows. +""" + +import os +import sys +from pathlib import Path +from unittest import mock + +import git +import pytest +from conftest import connect, make_repo, wire +from test_repository_config import Payload, root_of + +from mcp_server_git import server +from mcp_server_git.server import _rewrite_tree, git_checkout, git_merge, harden_repo + +posix_only = pytest.mark.skipif( + sys.platform == "win32", reason="the payloads are POSIX shell scripts" +) + +CONFLICT = ( + "Error executing tool git_merge: Merge of 'feature' into 'main' stopped on " + "conflicts in: m.txt. The merge was aborted and the repository is " + "unchanged. Resolve the conflicts by hand." +) + + +def filter_config(payload: Payload) -> str: + command = payload.command("filter") + return f'[filter "x"]\n\tsmudge = {command}\n\tclean = {command}\n' + + +def diverged( + repo: git.Repo, + feature_files: dict[str, str], + base_files: dict[str, str] | None = None, +) -> None: + """`feature` writes `feature_files` and conflicts with `main` in m.txt. + + Both branches start from a commit of `base_files`. Every file is under + `* filter=x`, which is harmless while `x` is undefined. + """ + root = root_of(repo) + base_files = base_files or {} + (root / ".gitattributes").write_text("* filter=x\n") + (root / "m.txt").write_text("base\n") + for name, text in base_files.items(): + (root / name).write_text(text) + repo.index.add([".gitattributes", "m.txt", *base_files]) + repo.index.commit("base") + repo.git.checkout("-b", "feature") + (root / "m.txt").write_text("theirs\n") + for name, text in feature_files.items(): + (root / name).write_text(text) + repo.index.add(["m.txt", *feature_files]) + repo.index.commit("theirs") + repo.git.checkout("main") + (root / "m.txt").write_text("ours\n") + repo.index.add(["m.txt"]) + repo.index.commit("ours") + + +def include_evil_cfg(repo: git.Repo) -> None: + """Add `[include] path = ../evil.cfg` to the repository's own config.""" + with open(Path(repo.git_dir) / "config", "a") as config: + config.write("[include]\n\tpath = ../evil.cfg\n") + + +async def merge(repo: git.Repo, repository: Path | None) -> dict[str, object]: + async with connect(repository) as session: + result = await session.call_tool( + "git_merge", + { + "repo_path": str(root_of(repo)), + "source_branch": "feature", + "fast_forward_only": False, + }, + ) + return wire(result) + + +@posix_only +@pytest.mark.parametrize("confined", [False, True]) +@pytest.mark.anyio +async def test_include_created_by_a_conflicting_merge_runs_nothing( + tmp_path: Path, confined: bool +) -> None: + payload = Payload(tmp_path / "payload") + repo = make_repo(tmp_path / "repo") + diverged(repo, {"evil.cfg": filter_config(payload)}) + # The include names a file that only the merged branch adds. + include_evil_cfg(repo) + + result = await merge(repo, root_of(repo) if confined else None) + + assert payload.runs() == [] + assert result["isError"] is True + assert result["content"] == [{"type": "text", "text": CONFLICT}] + assert not (root_of(repo) / "evil.cfg").exists() + repo.close() + + +@posix_only +@pytest.mark.anyio +async def test_config_linked_into_the_tree_and_rewritten_by_a_merge_runs_nothing( + tmp_path: Path, +) -> None: + payload = Payload(tmp_path / "payload") + repo = make_repo(tmp_path / "repo") + root = root_of(repo) + config = Path(repo.git_dir) / "config" + # The repository's configuration is a tracked file; the merged branch + # adds a filter to it. + original = config.read_text() + diverged( + repo, + {"repo.cfg": original + filter_config(payload)}, + {"repo.cfg": original}, + ) + config.unlink() + os.symlink(root / "repo.cfg", config) + + result = await merge(repo, None) + + assert payload.runs() == [] + assert result["content"] == [{"type": "text", "text": CONFLICT}] + repo.close() + + +@posix_only +def test_drivers_a_checkout_defines_are_overridden_for_the_rest_of_the_call( + tmp_path: Path, +) -> None: + payload = Payload(tmp_path / "payload") + repo = make_repo(tmp_path / "repo") + root = root_of(repo) + (root / ".gitattributes").write_text("* filter=x\n") + repo.index.add([".gitattributes"]) + repo.index.commit("attributes") + repo.git.checkout("-b", "feature") + (root / "evil.cfg").write_text(filter_config(payload)) + repo.index.add(["evil.cfg"]) + repo.index.commit("config") + repo.git.checkout("main") + include_evil_cfg(repo) + harden_repo(repo) + + assert git_checkout(repo, "feature") == "Switched to branch 'feature'" + # A later command in the same call, on a file the filter applies to. + (root / "test.txt").write_text("changed\n") + repo.git.add("test.txt") + + assert payload.runs() == [] + repo.close() + + +def test_a_failed_re_read_stops_the_call(repo: git.Repo) -> None: + failure = git.GitCommandError(["git", "config"], 128) + with ( + mock.patch.object(server, "harden_repo", side_effect=failure), + pytest.raises(git.GitError) as raised, + ): + _rewrite_tree(repo, "status") + # Not a GitCommandError, which git_merge's cleanup would catch and then + # run more git commands under incomplete overrides. + assert not isinstance(raised.value, git.GitCommandError) + assert "could not be read again after git status" in str(raised.value) + + +def test_a_failed_re_read_after_a_conflicting_merge_runs_no_cleanup( + tmp_path: Path, +) -> None: + repo = make_repo(tmp_path / "repo") + diverged(repo, {}) + failure = git.GitCommandError(["git", "config"], 128) + with ( + mock.patch.object(server, "harden_repo", side_effect=failure), + pytest.raises(git.GitError) as raised, + ): + git_merge(repo, "feature", fast_forward_only=False) + # Not git_merge's cleanup (`_merge_failure`, a ValueError), which would + # run more git commands under incomplete overrides. + assert not isinstance(raised.value, (git.GitCommandError, ValueError)) + # The failed re-read, raised while the merge's own failure propagated. + assert raised.value.__cause__ is failure + merge_failure = failure.__context__ + assert isinstance(merge_failure, git.GitCommandError) + assert "merge" in merge_failure.command + assert "a merge may still be in progress" in str(raised.value) + # `git merge --abort` never ran. + assert (Path(repo.git_dir) / "MERGE_HEAD").exists() + repo.close() diff --git a/src/git/uv.lock b/src/git/uv.lock index 89e2f6d111..31f128c409 100644 --- a/src/git/uv.lock +++ b/src/git/uv.lock @@ -720,7 +720,7 @@ wheels = [ [[package]] name = "mcp-server-git" -version = "2026.11.11" +version = "2026.11.18" source = { editable = "." } dependencies = [ { name = "click" }, diff --git a/src/memory/CHANGELOG.md b/src/memory/CHANGELOG.md index 70aa2bdac7..e72798e421 100644 --- a/src/memory/CHANGELOG.md +++ b/src/memory/CHANGELOG.md @@ -1,5 +1,25 @@ # @modelcontextprotocol/server-memory +## 2.2.1 + +### Patch Changes + +- [#5596](https://github.com/modelcontextprotocol/servers/pull/5596) [`af86b99`](https://github.com/modelcontextprotocol/servers/commit/af86b99080b0f4af52ca6a8f4f1e043921ec6140) [@cliffhall](https://github.com/cliffhall) - Remove the memory file lock when the server is stopped while serving Streamable HTTP: a write still in flight at shutdown no longer leaves its lock behind for the next writer, and a second SIGINT or SIGTERM exits at once instead of waiting for the listener to close. + +## 2.2.0 + +### Minor Changes + +- [#5536](https://github.com/modelcontextprotocol/servers/pull/5536) [`311c0fd`](https://github.com/modelcontextprotocol/servers/commit/311c0fdc953f38da08153fd2e8d134d03c8e168b) [@cliffhall](https://github.com/cliffhall) - Serve Streamable HTTP as well as stdio ([#576](https://github.com/modelcontextprotocol/servers/issues/576)). `--transport streamable-http` serves the server on one `/mcp` endpoint, for 2026-07-28 and 2025-era clients alike, at `HOST`:`PORT` (`127.0.0.1:3001` by default); stdio stays the default. Over HTTP the filesystem server requires its allowed directories on the command line, since it cannot ask a client for its Roots, and the sequential-thinking history belongs to the server process rather than to one connection. + +- [#5534](https://github.com/modelcontextprotocol/servers/pull/5534) [`1c00bfa`](https://github.com/modelcontextprotocol/servers/commit/1c00bfa0f3a38faee6be46631f95928726e37ab1) [@cliffhall](https://github.com/cliffhall) - Add opt-in write limits: `MEMORY_MAX_ENTITIES`, `MEMORY_MAX_RELATIONS` and `MEMORY_MAX_FILE_BYTES` cap how large the write tools may grow the graph, and the README now documents that every write rewrites the whole memory file. + +### Patch Changes + +- [#5530](https://github.com/modelcontextprotocol/servers/pull/5530) [`37bff57`](https://github.com/modelcontextprotocol/servers/commit/37bff572435208d09b5b7403edf638c88871cc14) [@cliffhall](https://github.com/cliffhall) - Remove the memory file lock the server holds when it is stopped by SIGINT or SIGTERM, or exits, so the next writer does not wait for it to go stale. + +- [#5563](https://github.com/modelcontextprotocol/servers/pull/5563) [`d57917b`](https://github.com/modelcontextprotocol/servers/commit/d57917bc0661f7342a50272be572e04f8962a6ca) [@cliffhall](https://github.com/cliffhall) - Stop a server breaking a stale memory file lock from deleting a live lock that replaced it in the meantime, which let two writers change the memory file at once and lose a write. The stale lock is now moved aside, checked to be the file that was judged stale, and only then deleted. + ## 2.1.1 ### Patch Changes diff --git a/src/memory/Dockerfile b/src/memory/Dockerfile index 27eca1f8b6..b024edb016 100644 --- a/src/memory/Dockerfile +++ b/src/memory/Dockerfile @@ -72,4 +72,10 @@ WORKDIR /app # not root, and refuses to start the container under `runAsNonRoot`. USER 1000:1000 +# The server handles SIGTERM itself, removing any lock it holds before it +# exits (#5485). Node running as PID 1 would otherwise ignore `docker stop`'s +# SIGTERM, leaving it to wait out its timeout and SIGKILL the server. SIGINT +# is handled the same way; it is the stop signal everything's image uses. +STOPSIGNAL SIGINT + ENTRYPOINT ["node", "dist/index.js"] diff --git a/src/memory/README.md b/src/memory/README.md index d519f14f3e..b4226ff278 100644 --- a/src/memory/README.md +++ b/src/memory/README.md @@ -7,12 +7,15 @@ Published on npm as [`@modelcontextprotocol/server-memory`](https://www.npmjs.co ## Core Concepts ### Entities + Entities are the primary nodes in the knowledge graph. Each entity has: + - A unique name (identifier) - An entity type (e.g., "person", "organization", "event") - A list of observations Example: + ```json { "name": "John_Smith", @@ -22,9 +25,11 @@ Example: ``` ### Relations + Relations define directed connections between entities. They are always stored in active voice and describe how entities interact or relate to each other. Example: + ```json { "from": "John_Smith", @@ -32,7 +37,9 @@ Example: "relationType": "works_at" } ``` + ### Observations + Observations are discrete pieces of information about an entity. They are: - Stored as strings @@ -41,6 +48,7 @@ Observations are discrete pieces of information about an entity. They are: - Should be atomic (one fact per observation) Example: + ```json { "entityName": "John_Smith", @@ -55,6 +63,7 @@ Example: ## API ### Tools + - **create_entities** - Create multiple new entities in the knowledge graph - Input: `entities` (array of objects) @@ -155,6 +164,33 @@ The server serves both protocol eras on stdio from the same process. The client' Node.js 24 or later, when the server runs through `npx` or from source. +# Streamable HTTP + +The server talks over stdio by default. With `--transport streamable-http` it +runs on its own as an HTTP service instead, serving one MCP endpoint, `/mcp`, +to any number of clients of either protocol era: + +```sh +npx -y @modelcontextprotocol/server-memory --transport streamable-http +``` + +It listens on `127.0.0.1:3001` unless `HOST` and `PORT` say otherwise (for +example `PORT=8080`); `HOST=0.0.0.0` exposes it to every machine that can reach +this one, so set it deliberately. A request from a browser page on any +origin but localhost is refused with `403`, and the endpoint sends no CORS +headers, so it serves clients that are not browser pages. Point a client at the URL, such as +`http://127.0.0.1:3001/mcp`, instead of giving it a command: + +```json +{ + "mcpServers": { + "memory": { "type": "http", "url": "http://127.0.0.1:3001/mcp" } + } +} +``` + +Over HTTP each request is served by a fresh server, and a 2025-era client gets no session (GET and DELETE on `/mcp` answer `405`), so the server cannot send it requests or notifications between its own requests. The graph lives in its file, so nothing is lost between requests. A 2026-07-28 client that names `memory://knowledge-graph` in its `subscriptions/listen` filter is told of every change any client makes; `resources/subscribe` from a 2025-era client lasts only for its own request, so over HTTP it hears of none. + # Usage with Claude Desktop ### Setup @@ -168,22 +204,27 @@ Add this to your claude_desktop_config.json: "mcpServers": { "memory": { "command": "docker", - "args": ["run", "-i", "-v", "claude-memory:/app/dist", "--rm", "mcp/memory"] + "args": [ + "run", + "-i", + "-v", + "claude-memory:/app/dist", + "--rm", + "mcp/memory" + ] } } } ``` #### NPX + ```json { "mcpServers": { "memory": { "command": "npx", - "args": [ - "-y", - "@modelcontextprotocol/server-memory" - ] + "args": ["-y", "@modelcontextprotocol/server-memory"] } } } @@ -196,12 +237,7 @@ On Windows, use `cmd /c` to launch `npx`: "mcpServers": { "memory": { "command": "cmd", - "args": [ - "/c", - "npx", - "-y", - "@modelcontextprotocol/server-memory" - ] + "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"] } } } @@ -216,10 +252,7 @@ The server can be configured using the following environment variables: "mcpServers": { "memory": { "command": "npx", - "args": [ - "-y", - "@modelcontextprotocol/server-memory" - ], + "args": ["-y", "@modelcontextprotocol/server-memory"], "env": { "MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl" } @@ -235,12 +268,7 @@ On Windows, use: "mcpServers": { "memory": { "command": "cmd", - "args": [ - "/c", - "npx", - "-y", - "@modelcontextprotocol/server-memory" - ], + "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"], "env": { "MEMORY_FILE_PATH": "/path/to/custom/memory.jsonl" } @@ -250,6 +278,11 @@ On Windows, use: ``` - `MEMORY_FILE_PATH`: Path to the memory storage JSONL file (default: `memory.jsonl` in the server directory). A leading `~` expands to your home directory; a relative path resolves against the server directory. Set it to an absolute path you own; see [Choosing where the graph is stored](#choosing-where-the-graph-is-stored). +- `MEMORY_MAX_ENTITIES`: The most entities the graph may hold. Unset by default (no limit). +- `MEMORY_MAX_RELATIONS`: The most relations the graph may hold. Unset by default (no limit). +- `MEMORY_MAX_FILE_BYTES`: The most bytes the memory file may hold. Unset by default (no limit). + +The three limits are opt-in, and each is described under [Limiting how large the graph grows](#limiting-how-large-the-graph-grows). A variable that is set must hold a positive whole number; any other value, an empty one included, stops the server at startup with an error naming the variable. When `MEMORY_FILE_PATH` is not set and the server directory still holds a legacy `memory.json` but no `memory.jsonl`, the server renames `memory.json` to `memory.jsonl` at startup. If that rename fails, the server exits with an error naming both paths and the cause, rather than starting on an empty graph; fix the cause (a permission problem, say) and restart, or set `MEMORY_FILE_PATH` to choose a file explicitly. @@ -267,10 +300,22 @@ Saves are atomic. Every write tool writes the whole graph to a temporary file in Each MCP client starts its own server process, so two clients using the same `MEMORY_FILE_PATH` (or both using the default) are two processes writing one file. Every write tool takes an exclusive lock file, `.lock`, next to the memory file while it reads, changes and saves the graph, so writes from different processes take turns and none is lost. The lock file exists only while a write is in progress, so the directory holding the memory file must be writable (it already must be, for the atomic save). -- A lock left behind by a server that crashed mid-write is removed automatically: at once if its process is known to have exited on the same machine, otherwise once it has gone 30 seconds without being refreshed (a server holding the lock refreshes it every 15 seconds while it works). Only one waiting server breaks a stale lock at a time, guarded by a momentary `.lock.break` file. +- A server stopped mid-write by `SIGINT` or `SIGTERM` (Ctrl-C, `docker stop`, a client shutting it down), or exiting normally, removes the lock it holds before it exits, so the next writer does not wait on it. +- A lock left behind by a server that crashed mid-write is removed automatically: at once if its process is known to have exited on the same machine, otherwise once it has gone 30 seconds without being refreshed (a server holding the lock refreshes it every 15 seconds while it works). Only one waiting server breaks a stale lock at a time, guarded by a momentary `.lock.break` file. It never deletes the lock where it stands: it renames it aside to a momentary `.lock..stale` file, checks that what it took is the very file it judged stale, and only then deletes it. A live lock that replaced the stale one in between is put straight back, untouched, and the breaker goes on waiting. - A write that cannot get the lock within 60 seconds fails with a tool error rather than overwriting the file. - The lock relies on exclusive file creation, which local filesystems provide; a network filesystem that does not honour it cannot be shared safely this way. +#### Limiting how large the graph grows + +Every write tool reads the whole memory file, changes the graph and writes the whole file back, holding the lock throughout. Its cost, and how long other servers sharing the file wait for the lock, therefore grow linearly with the file, however small the change: adding one entity to a graph of 100,000 entities rewrites the whole file, about 24 MB at around 240 bytes per entity, in roughly 0.4 seconds on a laptop (#5525). The read tools load the whole file too. Size a shared file with that in mind. + +By default nothing caps the graph. Set `MEMORY_MAX_ENTITIES`, `MEMORY_MAX_RELATIONS` or `MEMORY_MAX_FILE_BYTES` to put a ceiling on it: + +- `create_entities`, `create_relations` and `add_observations` refuse a call that would leave the graph over a limit, with a tool error naming the variable. The whole call is refused and nothing is saved, not just the part past the limit. +- A call that adds nothing new (every entity or relation already exists, say) is still answered, even when the graph is at or over a limit. +- The delete tools are never refused, so a graph over a limit (one that grew before the limit was set, or lowered) can always be shrunk. While it is over, calls that would grow it further on that dimension are refused. +- `MEMORY_MAX_FILE_BYTES` counts the bytes of the file as it would be saved, unreadable lines included, so it bounds the cost of each write directly. The counts are easier to reason about but do not bound how long each entity's observations grow. + # VS Code Installation Instructions For quick installation, use one of the one-click installation buttons below: @@ -296,10 +341,7 @@ Alternatively, you can add the configuration to a file called `.vscode/mcp.json` "servers": { "memory": { "command": "npx", - "args": [ - "-y", - "@modelcontextprotocol/server-memory" - ] + "args": ["-y", "@modelcontextprotocol/server-memory"] } } } @@ -312,12 +354,7 @@ On Windows, use: "servers": { "memory": { "command": "cmd", - "args": [ - "/c", - "npx", - "-y", - "@modelcontextprotocol/server-memory" - ] + "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"] } } } @@ -347,7 +384,7 @@ On Windows, use: The prompt for utilizing memory depends on the use case. Changing the prompt will help the model determine the frequency and types of memories created. -Here is an example prompt for chat personalization. You could use this prompt in the "Custom Instructions" field of a [Claude.ai Project](https://www.anthropic.com/news/projects). +Here is an example prompt for chat personalization. You could use this prompt in the "Custom Instructions" field of a [Claude.ai Project](https://www.anthropic.com/news/projects). ``` Follow these steps for each interaction: @@ -380,7 +417,7 @@ Follow these steps for each interaction: Docker: ```sh -docker build -t mcp/memory -f src/memory/Dockerfile . +docker build -t mcp/memory -f src/memory/Dockerfile . ``` ### Upgrading a Docker install @@ -407,7 +444,16 @@ Mounting a volume on a directory of its own and pointing `MEMORY_FILE_PATH` at i "mcpServers": { "memory": { "command": "docker", - "args": ["run", "-i", "-v", "claude-memory-data:/data", "-e", "MEMORY_FILE_PATH=/data/memory.jsonl", "--rm", "mcp/memory"] + "args": [ + "run", + "-i", + "-v", + "claude-memory-data:/data", + "-e", + "MEMORY_FILE_PATH=/data/memory.jsonl", + "--rm", + "mcp/memory" + ] } } } diff --git a/src/memory/__tests__/file-lock.test.ts b/src/memory/__tests__/file-lock.test.ts index db55503c9c..e1f049a094 100644 --- a/src/memory/__tests__/file-lock.test.ts +++ b/src/memory/__tests__/file-lock.test.ts @@ -1,12 +1,20 @@ // Unit tests for withFileLock, the lock file that orders mutations from // separate server processes sharing one graph file (#4797): mutual exclusion, -// release, breaking an abandoned lock, and giving up on a held one. +// release, breaking an abandoned lock, and giving up on a held one; and the +// exit-time release of the locks this process still holds (#5485). import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; import { promises as fs } from "fs"; import os from "os"; import path from "path"; -import { spawnSync } from "child_process"; -import { KnowledgeGraphManager, withFileLock } from "../index.js"; +import { spawn, spawnSync } from "child_process"; +import { fileURLToPath, pathToFileURL } from "url"; +import { + KnowledgeGraphManager, + heldLockPaths, + installLockCleanup, + releaseHeldLocks, + withFileLock, +} from "../index.js"; import { makeTempGraph } from "./helpers.js"; const fast = { staleMs: 60_000, timeoutMs: 100, retryMs: 5 }; @@ -176,6 +184,85 @@ describe("withFileLock", () => { expect(await fs.readdir(dir)).toEqual(["memory.jsonl.lock"]); }); + // Run hook once, just before the breaker moves the lock it judged stale + // aside: after its staleness re-check, before the removal (#5560). + function onceBeforeRemoval(hook: () => Promise): void { + const realRename = fs.rename; + let fired = false; + vi.spyOn(fs, "rename").mockImplementation(async (from, to) => { + if (!fired && from === lockPath) { + fired = true; + await hook(); + } + return realRename(from, to); + }); + } + + it("keeps a successor's lock placed between the staleness re-check and the removal (#5560)", async () => { + await writeStaleLock(); + vi.spyOn(console, "error").mockImplementation(() => {}); + let successor: { ino: bigint; mtimeMs: bigint } | undefined; + // The stale lock's holder comes back and releases it, and a successor + // takes a live lock at the same path, after the breaker's re-check under + // its guard and before the breaker removes what it judged. + onceBeforeRemoval(async () => { + await fs.unlink(lockPath); + await fs.writeFile(lockPath, "successor"); + successor = await fs.stat(lockPath, { bigint: true }); + }); + const operation = vi.fn(async () => "ran"); + + await expect(withFileLock(lockPath, operation, fast)).rejects.toThrow( + "Timed out", + ); + + // The breaker did not acquire the lock, and broke nothing. + expect(operation).not.toHaveBeenCalled(); + expect(console.error).not.toHaveBeenCalled(); + // The successor's lock is the same file, untouched: not a copy, and not + // refreshed or aged by its trip aside. + expect(successor).toBeDefined(); + expect(await fs.readFile(lockPath, "utf-8")).toBe("successor"); + const kept = await fs.stat(lockPath, { bigint: true }); + expect(kept.ino).toBe(successor?.ino); + expect(kept.mtimeMs).toBe(successor?.mtimeMs); + // Neither the breaking guard nor the aside file is left behind. + expect(await fs.readdir(dir)).toEqual(["memory.jsonl.lock"]); + }); + + it("acquires the lock at once when its holder releases it between the re-check and the removal", async () => { + await writeStaleLock(); + const error = vi.spyOn(console, "error").mockImplementation(() => {}); + onceBeforeRemoval(() => fs.unlink(lockPath)); + + expect(await withFileLock(lockPath, async () => "ran", fast)).toBe("ran"); + // Nothing was broken: the lock was gone before the breaker could take it. + expect(error).not.toHaveBeenCalled(); + expect(await fs.readdir(dir)).toEqual([]); + }); + + it("removes the stale lock itself, leaving no aside file", async () => { + await writeStaleLock(); + vi.spyOn(console, "error").mockImplementation(() => {}); + const unlink = vi.spyOn(fs, "unlink"); + + await withFileLock( + lockPath, + async () => { + // The lock path was never unlinked while the stale lock stood there: + // the stale file was moved aside and deleted under its own name. + const removed = unlink.mock.calls.map(([file]) => String(file)); + expect(removed).not.toContain(lockPath); + expect( + removed.filter((file) => /\.lock\.[0-9a-f]{16}\.stale$/.test(file)), + ).toHaveLength(1); + expect(await fs.readdir(dir)).toEqual(["memory.jsonl.lock"]); + }, + fast, + ); + expect(await fs.readdir(dir)).toEqual([]); + }); + it("leaves a stale lock to the waiter already breaking it", async () => { await writeStaleLock(); await fs.writeFile(`${lockPath}.break`, ""); @@ -401,3 +488,214 @@ describe("withFileLock", () => { expect(await fs.readdir(dir)).toEqual(["memory.jsonl"]); }); }); + +describe("releasing held locks on exit (#5485)", () => { + let dir: string; + let cleanup: () => Promise; + + beforeEach(async () => { + ({ dir, cleanup } = await makeTempGraph()); + }); + + afterEach(async () => { + vi.restoreAllMocks(); + await cleanup(); + }); + + async function exists(file: string): Promise { + return fs.access(file).then( + () => true, + () => false, + ); + } + + it("tracks a lock only while it is held", async () => { + const lockPath = path.join(dir, "memory.jsonl.lock"); + await withFileLock(lockPath, async () => { + expect(heldLockPaths()).toEqual([lockPath]); + }); + expect(heldLockPaths()).toEqual([]); + }); + + it("removes each lock still held, and only those still ours", async () => { + const ours = path.join(dir, "ours.lock"); + const taken = path.join(dir, "taken.lock"); + const gone = path.join(dir, "gone.lock"); + await withFileLock(ours, () => + withFileLock(taken, () => + withFileLock(gone, async () => { + // Another process broke and re-took one lock, and another vanished. + await fs.writeFile(taken, "someone else"); + await fs.unlink(gone); + + releaseHeldLocks(); + + expect(heldLockPaths()).toEqual([]); + expect(await exists(ours)).toBe(false); + expect(await fs.readFile(taken, "utf-8")).toBe("someone else"); + }), + ), + ); + expect(await fs.readFile(taken, "utf-8")).toBe("someone else"); + }); + + it("removes a lock whose token was still being written at exit", async () => { + const lockPath = path.join(dir, "memory.jsonl.lock"); + const realOpen = fs.open; + let finishWrite!: () => void; + let writing!: () => void; + const writeStarted = new Promise((resolve) => (writing = resolve)); + vi.spyOn(fs, "open").mockImplementationOnce(async (...args) => { + const handle = await realOpen(...args); + const realWrite = handle.writeFile.bind(handle); + // Hold the token write open, with nothing written yet. + handle.writeFile = async (data) => { + writing(); + await new Promise((resolve) => (finishWrite = resolve)); + return realWrite(data); + }; + return handle; + }); + + const held = withFileLock(lockPath, async () => "ran"); + await writeStarted; + expect(await fs.readFile(lockPath, "utf-8")).toBe(""); + + releaseHeldLocks(); + + expect(await exists(lockPath)).toBe(false); + finishWrite(); + expect(await held).toBe("ran"); + }); + + it("leaves another writer's empty replacement of a written lock in place", async () => { + const lockPath = path.join(dir, "memory.jsonl.lock"); + await withFileLock(lockPath, async () => { + // Our lock was broken as stale, and a new writer has created its own + // but not yet written its token. + await fs.writeFile(lockPath, ""); + + releaseHeldLocks(); + + expect(await exists(lockPath)).toBe(true); + }); + }); + + it("still tracks a lock while its release is in progress", async () => { + const lockPath = path.join(dir, "memory.jsonl.lock"); + const realUnlink = fs.unlink; + let trackedDuringRelease: string[] = []; + await withFileLock(lockPath, async () => { + // The release's removal of the lock is the next unlink. + vi.spyOn(fs, "unlink").mockImplementationOnce(async (file) => { + trackedDuringRelease = heldLockPaths(); + return realUnlink(file); + }); + }); + expect(trackedDuringRelease).toEqual([lockPath]); + expect(heldLockPaths()).toEqual([]); + expect(await exists(lockPath)).toBe(false); + }); + + it("keeps tracking a lock the same process re-took after breaking it", async () => { + const lockPath = path.join(dir, "memory.jsonl.lock"); + let releaseFirst!: () => void; + const firstHolds = new Promise((resolve) => (releaseFirst = resolve)); + let firstStarted!: () => void; + const started = new Promise((resolve) => (firstStarted = resolve)); + vi.spyOn(console, "error").mockImplementation(() => {}); + + const first = withFileLock( + lockPath, + async () => { + firstStarted(); + await firstHolds; + }, + { staleMs: 60_000 }, + ); + await started; + // Age the first holder's lock past a short staleMs, so a second holder in + // this process breaks it and takes it over. + const old = new Date(Date.now() - 10_000); + await fs.utimes(lockPath, old, old); + await withFileLock( + lockPath, + async () => { + releaseFirst(); + await first; + // The first holder's release left the second's lock, and its entry. + expect(heldLockPaths()).toEqual([lockPath]); + expect(await exists(lockPath)).toBe(true); + }, + { staleMs: 1_000, timeoutMs: 1_000, retryMs: 5 }, + ); + expect(heldLockPaths()).toEqual([]); + }); + + it("installs an exit hook and SIGINT and SIGTERM handlers, once", () => { + const handlers = new Map void>(); + const on = vi.spyOn(process, "on").mockImplementation((event, listener) => { + handlers.set(event, listener as () => void); + return process; + }); + const exit = vi + .spyOn(process, "exit") + .mockImplementation((() => undefined) as typeof process.exit); + + installLockCleanup(); + installLockCleanup(); + + expect(on).toHaveBeenCalledTimes(3); + expect(handlers.get("exit")).toBe(releaseHeldLocks); + handlers.get("SIGINT")?.(); + expect(exit).toHaveBeenLastCalledWith(130); + handlers.get("SIGTERM")?.(); + expect(exit).toHaveBeenLastCalledWith(143); + }); + + // A real signal, sent to a real process holding a lock mid-operation. + // Windows has no SIGTERM to deliver: process.kill() there ends the process + // outright, so no handler can run. + it.skipIf(process.platform === "win32")( + "removes the lock when SIGTERM stops a process mid-mutation", + async () => { + const lockPath = path.join(dir, "memory.jsonl.lock"); + const distIndex = pathToFileURL( + path.join( + path.dirname(fileURLToPath(import.meta.url)), + "..", + "dist", + "index.js", + ), + ).href; + const script = ` + const { installLockCleanup, withFileLock } = await import(${JSON.stringify(distIndex)}); + installLockCleanup(); + await withFileLock(${JSON.stringify(lockPath)}, () => { + console.log("held"); + return new Promise(() => setInterval(() => {}, 1000)); + }); + `; + const child = spawn( + process.execPath, + ["--input-type=module", "-e", script], + { stdio: ["ignore", "pipe", "inherit"] }, + ); + const exited = new Promise((resolve) => + child.on("exit", (code) => resolve(code)), + ); + await new Promise((resolve, reject) => { + child.stdout.on("data", (data: Buffer) => { + if (data.toString().includes("held")) resolve(); + }); + child.on("exit", () => reject(new Error("exited before holding"))); + }); + expect(await exists(lockPath)).toBe(true); + + child.kill("SIGTERM"); + + expect(await exited).toBe(143); + expect(await exists(lockPath)).toBe(false); + }, + ); +}); diff --git a/src/memory/__tests__/helpers.ts b/src/memory/__tests__/helpers.ts index 4be893f7c4..0615304ea8 100644 --- a/src/memory/__tests__/helpers.ts +++ b/src/memory/__tests__/helpers.ts @@ -10,6 +10,7 @@ import { InMemoryTransport } from "@modelcontextprotocol/server"; import type { McpServer, CallToolResult } from "@modelcontextprotocol/server"; import { Client } from "@modelcontextprotocol/client"; import { createServer } from "../index.js"; +import type { GraphLimits } from "../index.js"; export interface Connection { client: Client; @@ -18,9 +19,13 @@ export interface Connection { close: () => Promise; } -// Connect a fresh client to a fresh server over the graph file at filePath. -export async function connect(filePath: string): Promise { - const server = createServer(filePath); +// Connect a fresh client to a fresh server over the graph file at filePath, +// with the write limits given (none by default). +export async function connect( + filePath: string, + limits: GraphLimits = {}, +): Promise { + const server = createServer(filePath, "legacy", undefined, limits); const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair(); const client = new Client({ name: "memory-test-client", version: "0.0.0" }); diff --git a/src/memory/__tests__/http.test.ts b/src/memory/__tests__/http.test.ts new file mode 100644 index 0000000000..70af182f6c --- /dev/null +++ b/src/memory/__tests__/http.test.ts @@ -0,0 +1,366 @@ +// The Streamable HTTP transport (#576): `http.ts` bound on a free loopback +// port and driven by the SDK Client over real HTTP in both protocol eras, plus +// `run()`'s transport selection and `httpEndpoint()`'s reading of HOST and +// PORT. Over HTTP every request gets a fresh server, so the graph is asserted +// across requests, and a 2026-07-28 listen stream across clients. + +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { spawn } from "node:child_process"; +import { existsSync } from "node:fs"; +import { connect as connectTcp } from "node:net"; +import path from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { + Client, + StreamableHTTPClientTransport, +} from "@modelcontextprotocol/client"; +import { + DEFAULT_HOST, + DEFAULT_PORT, + endpointUrl, + httpEndpoint, + startHttpServer, + type RunningHttpServer, +} from "../http.js"; +import { + parseTransport, + releaseHeldLocks, + RESOURCE_URI, + run, +} from "../index.js"; +import { call, makeTempGraph } from "./helpers.js"; + +const alice = { name: "Alice", entityType: "person", observations: [] }; + +const ERAS = [ + ["2026-07-28", { mode: { pin: "2026-07-28" } }, "modern"], + ["2025-11-25", { mode: "legacy" }, "legacy"], +] as const; + +async function connect( + url: string, + versionNegotiation: (typeof ERAS)[number][1], +): Promise { + const client = new Client( + { name: "http-test", version: "0.0.0" }, + { versionNegotiation }, + ); + await client.connect(new StreamableHTTPClientTransport(new URL(url))); + return client; +} + +describe("Streamable HTTP", () => { + let running: RunningHttpServer | undefined; + let graph: Awaited>; + + beforeEach(async () => { + vi.spyOn(console, "error").mockImplementation(() => {}); + graph = await makeTempGraph(); + }); + + afterEach(async () => { + await running?.close(); + running = undefined; + await graph.cleanup(); + vi.restoreAllMocks(); + }); + + /** Bind the endpoint on a free loopback port over the test's graph. */ + async function start(): Promise { + running = await startHttpServer(graph.filePath, { + host: "127.0.0.1", + port: 0, + }); + return running; + } + + it.each(ERAS)( + "serves a %s client and keeps the graph across its requests", + async (_, negotiation, era) => { + const client = await connect((await start()).url, negotiation); + try { + expect(client.getProtocolEra()).toBe(era); + const { tools } = await client.listTools(); + expect(tools).toHaveLength(9); + await call(client, "create_entities", { entities: [alice] }); + const read = await call(client, "open_nodes", { names: ["Alice"] }); + expect(read.structuredContent).toMatchObject({ + entities: [{ name: "Alice" }], + }); + } finally { + await client.close(); + } + }, + ); + + it.each(ERAS)( + "sends a 2026-07-28 listener the updates a %s writer makes", + async (_, negotiation) => { + const url = (await start()).url; + const listener = await connect(url, ERAS[0][1]); + const writer = await connect(url, negotiation); + try { + const updated = new Promise((resolve) => { + listener.setNotificationHandler( + "notifications/resources/updated", + (notification) => resolve(notification.params.uri), + ); + }); + const subscription = await listener.listen({ + resourceSubscriptions: [RESOURCE_URI], + }); + await call(writer, "create_entities", { entities: [alice] }); + expect(await updated).toBe(RESOURCE_URI); + await subscription.close(); + } finally { + await listener.close(); + await writer.close(); + } + }, + ); + + it("answers a malformed request target 404 and keeps serving", async () => { + const url = new URL((await start()).url); + const reply = await new Promise((resolve, reject) => { + const socket = connectTcp(Number(url.port), url.hostname, () => + socket.write("GET //[ HTTP/1.1\r\nHost: localhost\r\n\r\n"), + ); + socket.setEncoding("utf8"); + socket.once("data", (chunk: string) => { + socket.destroy(); + resolve(chunk); + }); + socket.once("error", reject); + }); + expect(reply).toMatch(/^HTTP\/1\.1 404/); + expect((await fetch(new URL("/other", url))).status).toBe(404); + }); + + it("answers 404 off the MCP path and 403 to a foreign Origin", async () => { + const base = new URL((await start()).url); + expect((await fetch(new URL("/other", base))).status).toBe(404); + const foreign = await fetch(base, { + method: "POST", + headers: { + origin: "https://evil.example", + "content-type": "application/json", + }, + body: "{}", + }); + expect(foreign.status).toBe(403); + }); + + it("reports a request the SDK refuses through onerror", async () => { + // A 2026-07-28 header on a request with no 2026-07-28 envelope. + const response = await fetch((await start()).url, { + method: "POST", + headers: { + "content-type": "application/json", + accept: "application/json, text/event-stream", + "mcp-protocol-version": "2026-07-28", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "tools/list", + params: {}, + }), + }); + expect(response.status).toBe(400); + expect(console.error).toHaveBeenCalledWith( + "Error serving MCP request:", + expect.any(Error), + ); + }); + + it("rejects when the port is already bound", async () => { + const port = Number(new URL((await start()).url).port); + await expect( + startHttpServer(graph.filePath, { host: "127.0.0.1", port }), + ).rejects.toThrow(/EADDRINUSE/); + }); +}); + +describe("endpointUrl", () => { + it("brackets an IPv6 literal", () => { + expect(endpointUrl("127.0.0.1", 3001)).toBe("http://127.0.0.1:3001/mcp"); + expect(endpointUrl("::1", 3001)).toBe("http://[::1]:3001/mcp"); + }); +}); + +describe("httpEndpoint", () => { + it("defaults to loopback on the default port", () => { + expect(httpEndpoint({})).toEqual({ + host: DEFAULT_HOST, + port: DEFAULT_PORT, + }); + }); + + it("reads HOST and PORT", () => { + expect(httpEndpoint({ HOST: "0.0.0.0", PORT: "8080" })).toEqual({ + host: "0.0.0.0", + port: 8080, + }); + }); + + it.each(["abc", "-1", "65536", "1.5"])("refuses PORT=%s", (PORT) => { + expect(() => httpEndpoint({ PORT })).toThrow(/Invalid PORT/); + }); +}); + +describe("parseTransport", () => { + it.each([ + [[], "stdio"], + [["--transport", "stdio"], "stdio"], + [["--transport", "streamable-http"], "streamable-http"], + [["--transport=streamable-http"], "streamable-http"], + ] as const)("reads %j as %s", (args, expected) => { + expect(parseTransport([...args])).toBe(expected); + }); + + it("throws on a missing or unknown transport", () => { + expect(() => parseTransport(["--transport"])).toThrow(/needs a value/); + expect(() => parseTransport(["--transport", "sse"])).toThrow( + /Unknown transport "sse"/, + ); + }); +}); + +describe("run", () => { + const saved = { + HOST: process.env.HOST, + PORT: process.env.PORT, + MEMORY_FILE_PATH: process.env.MEMORY_FILE_PATH, + }; + let graph: Awaited>; + const signals = ["SIGINT", "SIGTERM"] as const; + let before: Record<(typeof signals)[number], unknown[]>; + + /** The signal listeners `run()` added since the test began. */ + function added(signal: (typeof signals)[number]) { + return process + .listeners(signal) + .filter((listener) => !before[signal].includes(listener)); + } + + beforeEach(async () => { + graph = await makeTempGraph(); + process.env.MEMORY_FILE_PATH = graph.filePath; + vi.spyOn(console, "error").mockImplementation(() => {}); + vi.spyOn(process, "exit").mockImplementation((() => undefined) as never); + before = { + SIGINT: process.listeners("SIGINT"), + SIGTERM: process.listeners("SIGTERM"), + }; + process.env.HOST = "127.0.0.1"; + process.env.PORT = "0"; + }); + + afterEach(async () => { + await graph.cleanup(); + for (const signal of signals) { + for (const listener of added(signal)) process.off(signal, listener); + } + for (const [key, value] of Object.entries(saved)) { + if (value === undefined) delete process.env[key]; + else process.env[key] = value; + } + vi.restoreAllMocks(); + }); + + it("starts Streamable HTTP on HOST:PORT and stops it on SIGINT", async () => { + await run(["--transport", "streamable-http"]); + expect(added("SIGINT")).toHaveLength(1); + expect(added("SIGTERM")).toHaveLength(1); + const announced = vi + .mocked(console.error) + .mock.calls.flat() + .map(String) + .find((line) => line.includes("running on Streamable HTTP")); + const url = announced!.match(/http:\/\/\S+/)![0]; + // A 2025-era session operation, which the stateless endpoint refuses. + expect((await fetch(url)).status).toBe(405); + + added("SIGINT")[0]("SIGINT"); + await vi.waitFor(() => expect(process.exit).toHaveBeenCalledWith(0)); + await expect(fetch(url)).rejects.toThrow(); + }); + + it("exits at once on a second signal, with that signal's status (#5595)", async () => { + const running = await run(["--transport=streamable-http"]); + const close = running.close; + // A shutdown that never finishes, as when a request is still in flight. + running.close = vi.fn().mockReturnValue(new Promise(() => {})); + added("SIGINT")[0]("SIGINT"); + expect(process.exit).not.toHaveBeenCalled(); + added("SIGTERM")[0]("SIGTERM"); + expect(process.exit).toHaveBeenLastCalledWith(143); + added("SIGINT")[0]("SIGINT"); + expect(process.exit).toHaveBeenLastCalledWith(130); + expect(running.close).toHaveBeenCalledTimes(1); + await close(); + }); + + it("registers the lock cleanup for the process's exit (#5595)", async () => { + const running = await run(["--transport=streamable-http"]); + expect(process.listeners("exit")).toContain(releaseHeldLocks); + await running.close(); + }); + + // A real signal, sent to a real server process that is serving Streamable + // HTTP and holds the lock mid-write. Windows has no SIGTERM to deliver: + // process.kill() there ends the process outright, so no handler can run. + it.skipIf(process.platform === "win32")( + "removes a lock held mid-write when SIGTERM stops the HTTP server (#5595)", + async () => { + const lockPath = `${graph.filePath}.lock`; + const distIndex = pathToFileURL( + path.join( + path.dirname(fileURLToPath(import.meta.url)), + "..", + "dist", + "index.js", + ), + ).href; + const script = ` + const { run, withFileLock } = await import(${JSON.stringify(distIndex)}); + await run(["--transport", "streamable-http"]); + await withFileLock(${JSON.stringify(lockPath)}, () => { + console.log("held"); + return new Promise(() => {}); + }); + `; + const child = spawn( + process.execPath, + ["--input-type=module", "-e", script], + { stdio: ["ignore", "pipe", "ignore"], env: process.env }, + ); + const exited = new Promise((resolve) => + child.on("exit", (code) => resolve(code)), + ); + await new Promise((resolve, reject) => { + child.stdout.on("data", (data: Buffer) => { + if (data.toString().includes("held")) resolve(); + }); + child.on("exit", () => reject(new Error("exited before holding"))); + }); + expect(existsSync(lockPath)).toBe(true); + + child.kill("SIGTERM"); + + expect(await exited).toBe(0); + expect(existsSync(lockPath)).toBe(false); + }, + ); + + it("reports a shutdown that fails and exits non-zero", async () => { + const running = await run(["--transport=streamable-http"]); + const close = running.close; + const failure = new Error("stuck"); + running.close = vi.fn().mockRejectedValue(failure); + added("SIGTERM")[0]("SIGTERM"); + await vi.waitFor(() => expect(process.exit).toHaveBeenCalledWith(1)); + expect(console.error).toHaveBeenCalledWith("Error shutting down:", failure); + await close(); + }); +}); diff --git a/src/memory/__tests__/write-limits.test.ts b/src/memory/__tests__/write-limits.test.ts new file mode 100644 index 0000000000..4e81d934a8 --- /dev/null +++ b/src/memory/__tests__/write-limits.test.ts @@ -0,0 +1,392 @@ +// Tests for the opt-in write limits (#5525): MEMORY_MAX_ENTITIES, +// MEMORY_MAX_RELATIONS and MEMORY_MAX_FILE_BYTES. graphLimitsFromEnv() is +// tested directly for its parsing; the limits themselves are driven through an +// SDK Client over an in-memory transport, asserting on the tool result and on +// the graph file, which a refused call must leave byte for byte unchanged. +// The last blocks show the limits reach the Streamable HTTP endpoint, and +// that main() reads them from the environment. +import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; +import { promises as fs } from "fs"; +import path from "path"; +import { + Client, + InMemoryTransport, + StreamableHTTPClientTransport, +} from "@modelcontextprotocol/client"; +import type { CallToolResult } from "@modelcontextprotocol/server"; +import { GRAPH_LIMIT_ENV, graphLimitsFromEnv, main } from "../index.js"; +import type { GraphLimits } from "../index.js"; +import { startHttpServer } from "../http.js"; +import { + call, + connect, + makeTempGraph, + readFileText, + textOf, +} from "./helpers.js"; + +const entity = (name: string, observations: string[] = []) => ({ + name, + entityType: "person", + observations, +}); + +describe("graphLimitsFromEnv", () => { + it("leaves every limit off when nothing is set", () => { + expect(graphLimitsFromEnv({})).toEqual({}); + }); + + it("refuses an empty or blank variable rather than treating it as unset", () => { + expect(() => graphLimitsFromEnv({ MEMORY_MAX_ENTITIES: "" })).toThrow( + 'MEMORY_MAX_ENTITIES must be a positive whole number, got ""', + ); + expect(() => graphLimitsFromEnv({ MEMORY_MAX_RELATIONS: " " })).toThrow( + 'MEMORY_MAX_RELATIONS must be a positive whole number, got " "', + ); + }); + + it("reads each limit from its variable, trimming whitespace", () => { + expect( + graphLimitsFromEnv({ + MEMORY_MAX_ENTITIES: "100", + MEMORY_MAX_RELATIONS: " 200 ", + MEMORY_MAX_FILE_BYTES: "1048576", + }), + ).toEqual({ maxEntities: 100, maxRelations: 200, maxFileBytes: 1048576 }); + }); + + it.each([ + "0", + "-1", + "1.5", + "1e3", + "abc", + "10 MB", + "0x10", + "99999999999999999999", + ])("refuses %j, naming the variable", (value) => { + expect(() => graphLimitsFromEnv({ MEMORY_MAX_FILE_BYTES: value })).toThrow( + `MEMORY_MAX_FILE_BYTES must be a positive whole number, got "${value}"`, + ); + }); + + it("names every variable in GRAPH_LIMIT_ENV", () => { + expect(Object.values(GRAPH_LIMIT_ENV)).toEqual([ + "MEMORY_MAX_ENTITIES", + "MEMORY_MAX_RELATIONS", + "MEMORY_MAX_FILE_BYTES", + ]); + }); +}); + +describe("write limits", () => { + let filePath: string; + let cleanup: () => Promise; + const open: { close: () => Promise }[] = []; + + beforeEach(async () => { + ({ filePath, cleanup } = await makeTempGraph()); + }); + + afterEach(async () => { + for (const conn of open.splice(0)) { + await conn.close(); + } + await cleanup(); + }); + + async function clientWith(limits: GraphLimits): Promise { + const conn = await connect(filePath, limits); + open.push(conn); + return conn.client; + } + + // A refused call: an error result naming the variable, and no write. + async function expectRefused( + result: Promise, + variable: string, + before: string, + ): Promise { + const refused = await result; + expect(refused.isError).toBe(true); + expect(textOf(refused)).toMatch(/^Refused: /); + expect(textOf(refused)).toContain(`set by ${variable}`); + expect(textOf(refused)).toContain("Nothing was saved"); + expect(await readFileText(filePath)).toBe(before); + } + + it("changes nothing when no limit is set", async () => { + const client = await clientWith({}); + const result = await call(client, "create_entities", { + entities: [entity("A"), entity("B"), entity("C")], + }); + expect(result.isError).toBeUndefined(); + }); + + describe("MEMORY_MAX_ENTITIES", () => { + it("allows creating up to the limit and refuses the call that passes it", async () => { + const client = await clientWith({ maxEntities: 2 }); + const ok = await call(client, "create_entities", { + entities: [entity("A"), entity("B")], + }); + expect(ok.isError).toBeUndefined(); + const before = await readFileText(filePath); + + await expectRefused( + call(client, "create_entities", { entities: [entity("C")] }), + "MEMORY_MAX_ENTITIES", + before, + ); + }); + + it("refuses the whole call, not just the entities past the limit", async () => { + const client = await clientWith({ maxEntities: 2 }); + await call(client, "create_entities", { entities: [entity("A")] }); + const before = await readFileText(filePath); + + await expectRefused( + call(client, "create_entities", { + entities: [entity("B"), entity("C")], + }), + "MEMORY_MAX_ENTITIES", + before, + ); + }); + + it("still answers a call that adds nothing once the graph is full", async () => { + const client = await clientWith({ maxEntities: 1 }); + await call(client, "create_entities", { entities: [entity("A")] }); + + const result = await call(client, "create_entities", { + entities: [entity("A")], + }); + expect(result.isError).toBeUndefined(); + expect(result.structuredContent).toEqual({ + entities: [], + skipped: ["A"], + }); + }); + + it("lets a graph already over a lowered limit shrink, and refuses its growth", async () => { + const unlimited = await clientWith({}); + await call(unlimited, "create_entities", { + entities: [entity("A"), entity("B"), entity("C")], + }); + + const client = await clientWith({ maxEntities: 1 }); + const before = await readFileText(filePath); + await expectRefused( + call(client, "create_entities", { entities: [entity("D")] }), + "MEMORY_MAX_ENTITIES", + before, + ); + + // Growth on another dimension is not refused by this one. + const observed = await call(client, "add_observations", { + observations: [{ entityName: "A", contents: ["likes tea"] }], + }); + expect(observed.isError).toBeUndefined(); + + const deleted = await call(client, "delete_entities", { + entityNames: ["B"], + }); + expect(deleted.isError).toBeUndefined(); + expect(await readFileText(filePath)).not.toContain('"name":"B"'); + }); + }); + + describe("MEMORY_MAX_RELATIONS", () => { + it("allows relations up to the limit and refuses the one that passes it", async () => { + const client = await clientWith({ maxRelations: 1 }); + await call(client, "create_entities", { + entities: [entity("A"), entity("B")], + }); + const ok = await call(client, "create_relations", { + relations: [{ from: "A", to: "B", relationType: "knows" }], + }); + expect(ok.isError).toBeUndefined(); + const before = await readFileText(filePath); + + await expectRefused( + call(client, "create_relations", { + relations: [{ from: "B", to: "A", relationType: "knows" }], + }), + "MEMORY_MAX_RELATIONS", + before, + ); + + // A repeat of a stored relation adds nothing, so it is still answered. + const repeat = await call(client, "create_relations", { + relations: [{ from: "A", to: "B", relationType: "knows" }], + }); + expect(repeat.isError).toBeUndefined(); + expect(repeat.structuredContent).toEqual({ relations: [] }); + }); + }); + + describe("MEMORY_MAX_FILE_BYTES", () => { + it("refuses add_observations that would grow the file past the limit", async () => { + const unlimited = await clientWith({}); + await call(unlimited, "create_entities", { entities: [entity("A")] }); + const before = await readFileText(filePath); + const size = Buffer.byteLength(before, "utf-8"); + + // Room for a short observation, not a long one. + const client = await clientWith({ maxFileBytes: size + 20 }); + const ok = await call(client, "add_observations", { + observations: [{ entityName: "A", contents: ["short"] }], + }); + expect(ok.isError).toBeUndefined(); + const afterShort = await readFileText(filePath); + + await expectRefused( + call(client, "add_observations", { + observations: [{ entityName: "A", contents: ["x".repeat(100)] }], + }), + "MEMORY_MAX_FILE_BYTES", + afterShort, + ); + }); + + it("counts bytes, not characters", async () => { + const unlimited = await clientWith({}); + await call(unlimited, "create_entities", { entities: [entity("A")] }); + const size = Buffer.byteLength(await readFileText(filePath), "utf-8"); + + // Ten emoji add 42 bytes to the file (each is 4 bytes in UTF-8, plus + // the quotes) but only 22 UTF-16 code units, so a budget of 30 fits + // them only if the cap counted string length rather than bytes. + const client = await clientWith({ maxFileBytes: size + 30 }); + await expectRefused( + call(client, "add_observations", { + observations: [{ entityName: "A", contents: ["😀".repeat(10)] }], + }), + "MEMORY_MAX_FILE_BYTES", + await readFileText(filePath), + ); + }); + + it("answers a call that adds nothing even when re-saving grows the file", async () => { + // A record with no final newline: the save writes it back with one, a + // byte larger than the limit, though nothing was added. + const record = + '{"type":"entity","name":"A","entityType":"person","observations":["x"]}'; + await fs.writeFile(filePath, record); + const client = await clientWith({ + maxFileBytes: Buffer.byteLength(record, "utf-8"), + }); + + const entities = await call(client, "create_entities", { + entities: [entity("A")], + }); + expect(entities.isError).toBeUndefined(); + const observations = await call(client, "add_observations", { + observations: [{ entityName: "A", contents: ["x"] }], + }); + expect(observations.isError).toBeUndefined(); + }); + + it("refuses the first write to a new file that would already be too large", async () => { + const client = await clientWith({ maxFileBytes: 10 }); + const refused = await call(client, "create_entities", { + entities: [entity("A")], + }); + expect(refused.isError).toBe(true); + expect(textOf(refused)).toContain("set by MEMORY_MAX_FILE_BYTES"); + await expect(readFileText(filePath)).rejects.toMatchObject({ + code: "ENOENT", + }); + }); + }); +}); + +describe("write limits over Streamable HTTP", () => { + it("holds the endpoint's write tools to the limits it was given", async () => { + vi.spyOn(console, "error").mockImplementation(() => {}); + const { filePath, cleanup } = await makeTempGraph(); + const running = await startHttpServer( + filePath, + { host: "127.0.0.1", port: 0 }, + { maxEntities: 1 }, + ); + const client = new Client({ name: "http-test", version: "0.0.0" }); + try { + await client.connect( + new StreamableHTTPClientTransport(new URL(running.url)), + ); + const ok = await call(client, "create_entities", { + entities: [entity("A")], + }); + expect(ok.isError).toBeUndefined(); + const refused = await call(client, "create_entities", { + entities: [entity("B")], + }); + expect(refused.isError).toBe(true); + expect(textOf(refused)).toContain("set by MEMORY_MAX_ENTITIES"); + } finally { + await client.close(); + await running.close(); + await cleanup(); + vi.restoreAllMocks(); + } + }); +}); + +describe("main reads the limits from the environment", () => { + const saved: Record = {}; + const names = ["MEMORY_FILE_PATH", ...Object.values(GRAPH_LIMIT_ENV)]; + let dir: string; + let cleanup: () => Promise; + + beforeEach(async () => { + for (const name of names) { + saved[name] = process.env[name]; + delete process.env[name]; + } + ({ dir, cleanup } = await makeTempGraph()); + process.env.MEMORY_FILE_PATH = path.join(dir, "memory.jsonl"); + vi.spyOn(console, "error").mockImplementation(() => {}); + }); + + afterEach(async () => { + for (const name of names) { + if (saved[name] === undefined) { + delete process.env[name]; + } else { + process.env[name] = saved[name]; + } + } + vi.restoreAllMocks(); + await cleanup(); + }); + + it("enforces MEMORY_MAX_ENTITIES on the server it starts", async () => { + process.env.MEMORY_MAX_ENTITIES = "1"; + const [clientTransport, serverTransport] = + InMemoryTransport.createLinkedPair(); + const client = new Client({ name: "memory-test-client", version: "0.0.0" }); + const server = await main(serverTransport); + await client.connect(clientTransport); + try { + const ok = await call(client, "create_entities", { + entities: [entity("A")], + }); + expect(ok.isError).toBeUndefined(); + const refused = await call(client, "create_entities", { + entities: [entity("B")], + }); + expect(refused.isError).toBe(true); + expect(textOf(refused)).toContain("set by MEMORY_MAX_ENTITIES"); + } finally { + await client.close(); + await server.close(); + } + }); + + it("refuses to start on an invalid limit", async () => { + process.env.MEMORY_MAX_RELATIONS = "lots"; + await expect(main(InMemoryTransport.createLinkedPair()[1])).rejects.toThrow( + 'MEMORY_MAX_RELATIONS must be a positive whole number, got "lots"', + ); + }); +}); diff --git a/src/memory/http.ts b/src/memory/http.ts new file mode 100644 index 0000000000..7d4846d2ae --- /dev/null +++ b/src/memory/http.ts @@ -0,0 +1,132 @@ +// Serves the memory server over Streamable HTTP (#576), the alternative to +// stdio that `--transport streamable-http` selects. +// +// One `/mcp` endpoint answers both protocol eras through the SDK's +// `createMcpHandler`: a 2026-07-28 request is served by a fresh server built +// for it, and a 2025-era request by the SDK's stateless fallback (also a fresh +// server per request, with no session, so GET and DELETE are answered 405). +// The graph lives in its file, so a fresh server per request loses nothing; +// the file lock orders concurrent mutations as it does between processes. +// A 2026-07-28 client hears of graph changes on its subscriptions/listen +// stream: each server publishes them on the handler's bus rather than on its +// own request. A 2025-era client has no session, so resources/subscribe +// cannot outlive its request and HTTP sends it no updates. +// +// The listener binds loopback unless `HOST` widens it, and a browser page may +// reach it only from a localhost Origin, the same posture as the everything +// server's HTTP transports (#5371). `startHttpServer()` resolves once the port +// is bound and rejects when it cannot be, so a launcher sees the failure. + +import { createServer as createNodeServer, type Server } from "node:http"; +import type { AddressInfo } from "node:net"; +import { + createMcpHandler, + type McpHttpHandler, +} from "@modelcontextprotocol/server"; +import { + localhostOriginValidation, + toNodeHandler, +} from "@modelcontextprotocol/node"; +import { createServer, RESOURCE_URI } from "./index.js"; +import type { GraphLimits } from "./index.js"; + +/** The interface bound when `HOST` is unset: loopback only. */ +export const DEFAULT_HOST = "127.0.0.1"; +/** The port bound when `PORT` is unset. */ +export const DEFAULT_PORT = 3001; +/** The one path the endpoint answers on. */ +export const MCP_PATH = "/mcp"; + +/** Where to listen: `HOST` and `PORT` from the environment, else the defaults. */ +export function httpEndpoint(env: NodeJS.ProcessEnv = process.env): { + host: string; + port: number; +} { + const host = env.HOST || DEFAULT_HOST; + if (!env.PORT) return { host, port: DEFAULT_PORT }; + const port = Number(env.PORT); + if (!Number.isInteger(port) || port < 0 || port > 65535) { + throw new Error( + `Invalid PORT ${JSON.stringify(env.PORT)}: expected a whole number from 0 to 65535`, + ); + } + return { host, port }; +} + +/** The URL of the endpoint bound at `address`:`port`, an IPv6 literal in brackets. */ +export function endpointUrl(address: string, port: number): string { + const host = address.includes(":") ? `[${address}]` : address; + return `http://${host}:${port}${MCP_PATH}`; +} + +/** A running HTTP endpoint: the bound address, and how to stop it. */ +export interface RunningHttpServer { + httpServer: Server; + handler: McpHttpHandler; + /** The URL clients connect to, with the port actually bound. */ + url: string; + /** End in-flight MCP exchanges, then stop listening and drop open sockets. */ + close: () => Promise; +} + +/** + * Bind the endpoint on `host`:`port` (port 0 picks a free one) and serve the + * memory server over the graph at `memoryFilePath` on it, holding its write + * tools to `limits`. Rejects when the port cannot be bound. + */ +export async function startHttpServer( + memoryFilePath: string, + { host, port }: { host: string; port: number }, + limits: GraphLimits = {}, +): Promise { + const onerror = (error: Error) => + console.error("Error serving MCP request:", error); + const handler: McpHttpHandler = createMcpHandler( + ({ era }) => + createServer( + memoryFilePath, + era, + () => handler.notify.resourceUpdated(RESOURCE_URI), + limits, + ), + { onerror }, + ); + const serve = toNodeHandler(handler, { onerror }); + const allowOrigin = localhostOriginValidation(); + + const httpServer = createNodeServer((req, res) => { + // The path, without parsing the target: a malformed one (`//[`) would + // make URL parsing throw here, outside any handler, and end the process. + const path = String(req.url).split("?")[0]; + if (path !== MCP_PATH) { + res.writeHead(404, { "content-type": "text/plain" }).end("Not Found"); + return; + } + if (!allowOrigin(req, res)) return; + // Not awaited: the listener is synchronous. The adapter never rejects; it + // reports a failure through `onerror` and answers it with a 500 itself. + void serve(req, res); + }); + + await new Promise((resolve, reject) => { + httpServer.once("error", reject); + httpServer.listen({ host, port }, () => { + httpServer.off("error", reject); + resolve(); + }); + }); + + const bound = httpServer.address() as AddressInfo; + return { + httpServer, + handler, + url: endpointUrl(bound.address, bound.port), + close: async () => { + await handler.close(); + await new Promise((resolve) => { + httpServer.close(() => resolve()); + httpServer.closeAllConnections(); + }); + }, + }; +} diff --git a/src/memory/index.ts b/src/memory/index.ts index e57bf12ed3..c98d2173ca 100644 --- a/src/memory/index.ts +++ b/src/memory/index.ts @@ -6,8 +6,10 @@ // tests can run it in-process; main() serves it on stdio through the SDK's // serveStdio entry, which answers 2026-07-28 clients (server/discover, change // notifications on subscriptions/listen) and 2025-era clients (initialize, -// resources/subscribe) from the same factory (#4852). main() runs only when -// this file is the process entry point, so importing it starts nothing. +// resources/subscribe) from the same factory (#4852). run() reads --transport +// and starts stdio (the default) or Streamable HTTP (http.ts, #576). It runs +// only when this file is the process entry point, so importing it starts +// nothing. import { serveStdio, type StdioServerHandle, @@ -15,7 +17,7 @@ import { import { McpServer } from "@modelcontextprotocol/server"; import type { Transport } from "@modelcontextprotocol/server"; import { z } from "zod"; -import { promises as fs, realpathSync } from "fs"; +import { promises as fs, readFileSync, realpathSync, unlinkSync } from "fs"; import type { FileHandle } from "fs/promises"; import path from "path"; import os from "os"; @@ -171,6 +173,60 @@ export function skippedEntitiesNotice(skipped: string[]): string { ); } +// Opt-in ceilings on how large the write tools may grow the graph (#5525). +// Every mutation reads the whole graph file and writes it back under the +// cross-process lock, so its cost, and how long it holds the lock, grow +// linearly with the file. These let an operator bound that growth. Each is +// unset by default, which leaves the store unbounded, as it always was. +export interface GraphLimits { + // Most entities the graph may hold. + maxEntities?: number; + // Most relations the graph may hold. + maxRelations?: number; + // Most bytes the saved graph file may hold. + maxFileBytes?: number; +} + +// The environment variable that sets each limit. +export const GRAPH_LIMIT_ENV: Readonly> = { + maxEntities: "MEMORY_MAX_ENTITIES", + maxRelations: "MEMORY_MAX_RELATIONS", + maxFileBytes: "MEMORY_MAX_FILE_BYTES", +}; + +// Read the limits from the environment. Only an unset variable leaves its +// limit off; any other value that is not a positive whole number, an empty +// one included, stops startup, since a limit silently ignored would leave the +// store unbounded while the operator believes it capped. +export function graphLimitsFromEnv( + env: NodeJS.ProcessEnv = process.env, +): GraphLimits { + const limits: GraphLimits = {}; + for (const key of Object.keys(GRAPH_LIMIT_ENV) as (keyof GraphLimits)[]) { + const name = GRAPH_LIMIT_ENV[key]; + if (env[name] === undefined) { + continue; + } + const raw = env[name].trim(); + const value = Number(raw); + if (!/^\d+$/.test(raw) || !Number.isSafeInteger(value) || value < 1) { + throw new Error( + `${name} must be a positive whole number, got "${env[name]}". ` + + "Unset it to leave that limit off.", + ); + } + limits[key] = value; + } + return limits; +} + +// How large a graph is, on each dimension GraphLimits caps. +interface GraphSize { + entities: number; + relations: number; + bytes: number; +} + // Timings for the cross-process lock around each mutation. Exposed so tests // can shorten them; the server always uses the defaults. export interface FileLockOptions { @@ -219,20 +275,44 @@ function isLockOwnerDead(contents: string): boolean { } } -// Whether the lock at lockPath is abandoned. Its owner and its mtime are read -// through one open handle, so both describe the same lock file even if it is +// What a waiter learns from one look at a lock file: whether it is abandoned, +// and which file it looked at. The device and inode numbers identify the file +// itself rather than its path, so a later check can tell that file from one +// that has replaced it at the same path. They are read as bigints because a +// Windows file id does not fit in a double. +interface LockJudgement { + stale: boolean; + dev: bigint; + ino: bigint; +} + +// Judge the lock file open at handle. Its owner and its mtime are read +// through that one handle, so both describe the same lock file even if it is // replaced meanwhile. +async function judgeLock( + handle: FileHandle, + staleMs: number, +): Promise { + const [contents, stats] = await Promise.all([ + handle.readFile("utf-8"), + handle.stat({ bigint: true }), + ]); + return { + stale: + isLockOwnerDead(contents) || Date.now() - Number(stats.mtimeMs) > staleMs, + dev: stats.dev, + ino: stats.ino, + }; +} + +// Whether the lock at lockPath is abandoned. async function isLockStale( lockPath: string, staleMs: number, ): Promise { const handle = await fs.open(lockPath, "r"); try { - const [contents, stats] = await Promise.all([ - handle.readFile("utf-8"), - handle.stat(), - ]); - return isLockOwnerDead(contents) || Date.now() - stats.mtimeMs > staleMs; + return (await judgeLock(handle, staleMs)).stale; } finally { await handle.close(); } @@ -243,6 +323,25 @@ async function isLockStale( // re-checks the lock under that guard: two waiters can never both judge the // same abandoned lock stale and one then remove the lock the other has just // taken in its place. +// +// The guard orders breakers only. The lock's own holder can still release it, +// and a breaker that stalls past staleMs loses its guard to another, so the +// file at lockPath can be replaced by a successor's live lock after the +// re-check has judged it stale. Removing by path would then delete that live +// lock and let a third writer in beside its holder (#5560). So the lock is +// never deleted where it stands. It is renamed aside to a name nobody else +// uses, which is atomic and takes whichever file is at lockPath at that +// instant, and what was taken is then compared with the file that was judged: +// the judged file is deleted, and anything else is a live lock and is renamed +// straight back. The handle the judgement was read through stays open until +// then, so the judged file's inode number cannot be reused by a successor's +// file and the comparison cannot be fooled. +// +// What remains is the moment a live lock spends aside before it is put back: +// a writer that creates the lock in exactly that moment is overwritten by the +// restored one and runs beside its holder. Reaching it takes a replacement +// between the judgement and the rename, then a create between the two +// renames; a lock file cannot close that without the kernel's help. async function breakStaleLock( lockPath: string, staleMs: number, @@ -265,17 +364,111 @@ async function breakStaleLock( } try { await breaker.close(); - if (!(await isLockStale(lockPath, staleMs))) { - return false; + const judged = await fs.open(lockPath, "r"); + try { + const { stale, dev, ino } = await judgeLock(judged, staleMs); + if (!stale) { + return false; + } + const asidePath = `${lockPath}.${randomBytes(8).toString("hex")}.stale`; + await fs.rename(lockPath, asidePath); + const taken = await fs.stat(asidePath, { bigint: true }); + if (taken.dev !== dev || taken.ino !== ino) { + // Not the lock that was judged: a successor's live one. Put it back. + await fs.rename(asidePath, lockPath); + return false; + } + console.error(`Breaking stale memory file lock ${lockPath}`); + await fs.unlink(asidePath); + return true; + } finally { + await judged.close(); } - console.error(`Breaking stale memory file lock ${lockPath}`); - await fs.unlink(lockPath); - return true; } finally { await fs.unlink(breakerPath).catch(ignoreError); } } +// The lock files this process holds right now, each mapped to the token it +// writes into it and whether that write has finished. withFileLock releases its lock in a `finally`, which never +// runs when a signal ends the process, so the exit hook releaseHeldLocks() +// removes them instead (#5485). Without it, a lock left by a stopped server +// stalls the next writer until it goes stale, which takes the full staleMs +// when that writer is on another host (another container) and cannot see +// that this process has gone. +interface HeldLock { + token: string; + written: boolean; +} +const heldLocks = new Map(); + +// The lock paths this process holds right now, for tests. +export function heldLockPaths(): string[] { + return [...heldLocks.keys()]; +} + +// Synchronously remove every lock this process still holds, as the process +// exits: an `exit` listener cannot wait on a promise. As in withFileLock's own +// release, a lock is removed only while it still holds this process's token, +// so a lock broken as stale and re-taken by another process stays in place. +// A lock is tracked from the moment its exclusive create returns, before its +// token is written. Until that write finishes, a file holding only the start +// of the token (or none of it) is ours too: the exit interrupted the write. +// Nothing else can have replaced it by then, since a lock that new, with a +// live owner, is never judged stale. Once the token is written only an exact +// match is ours, so another writer's replacement, empty while its own token +// is being written, is left alone. +export function releaseHeldLocks(): void { + for (const [lockPath, { token, written }] of heldLocks) { + try { + const contents = readFileSync(lockPath, "utf-8"); + if (written ? contents === token : token.startsWith(contents)) { + unlinkSync(lockPath); + } + } catch { + // Already gone, or unreadable: there is nothing of ours to remove. + } + } + heldLocks.clear(); +} + +// The exit codes a shell reports for a process its signal ended: 128 + the +// signal's number. +const SIGNAL_EXIT_CODES = { SIGINT: 130, SIGTERM: 143 } as const; + +let exitLockCleanupInstalled = false; +let lockCleanupInstalled = false; + +// Release held locks when the process exits normally or through +// process.exit(), by the `exit` event. Installed once, however the server is +// started. It covers a signal only when something turns that signal into a +// process.exit(): installLockCleanup() does for stdio, and run() does for +// Streamable HTTP, whose signals first close the listener (#5595). +export function installExitLockCleanup(): void { + if (exitLockCleanupInstalled) { + return; + } + exitLockCleanupInstalled = true; + process.on("exit", releaseHeldLocks); +} + +// Release held locks however the server process ends (#5485): on a normal +// exit or process.exit() through the `exit` event, and on SIGINT or SIGTERM, +// whose default action would end the process without emitting `exit`. A +// signal handler replaces that default, so it exits itself, with the status +// the default would have given. Installed once, by main(): only the server +// process should take over its signals, not a test that imports this module. +export function installLockCleanup(): void { + if (lockCleanupInstalled) { + return; + } + lockCleanupInstalled = true; + installExitLockCleanup(); + for (const [signal, code] of Object.entries(SIGNAL_EXIT_CODES)) { + process.on(signal, () => process.exit(code)); + } +} + // Run operation while holding an exclusive lock file at lockPath, so that // mutations from separate server processes sharing one graph file take turns // and each one loads the graph the previous one saved (#4797). The lock is a @@ -305,14 +498,21 @@ export async function withFileLock( } } if (handle) { + // Track the lock before anything else is awaited: a signal is handled + // only between tasks, never between the open's completion and this + // line, so from here on the exit hook can remove it (#5485). + const held: HeldLock = { token, written: false }; + heldLocks.set(lockPath, held); try { await handle.writeFile(token); + held.written = true; await handle.close(); } catch (error) { // The lock was created but not written: remove it rather than leave // every other writer waiting for it to go stale. await handle.close().catch(ignoreError); await fs.unlink(lockPath).catch(ignoreError); + heldLocks.delete(lockPath); throw error; } break; @@ -381,6 +581,13 @@ export async function withFileLock( if (current === token) { await fs.unlink(lockPath).catch(ignoreError); } + // Stop tracking the lock only once the release is done, so an exit during + // it still removes the lock. A lock this same process broke as stale and + // re-took in another withFileLock call carries that call's token, and + // stays tracked for it. + if (heldLocks.get(lockPath)?.token === token) { + heldLocks.delete(lockPath); + } } } @@ -389,6 +596,7 @@ export class KnowledgeGraphManager { constructor( private memoryFilePath: string, private lockOptions: FileLockOptions = {}, + private limits: GraphLimits = {}, ) {} // Serializes all read-modify-write graph mutations behind a single queue. @@ -439,9 +647,12 @@ export class KnowledgeGraphManager { // them back to saveGraph so they are written out unchanged. Otherwise the // next unrelated write would silently delete them from disk, together with // every valid observation of an entity that has one bad field. + // size is the graph as loaded, for the write tools' limit check (see + // checkLimits). private async loadGraphWithUnreadable(): Promise<{ graph: KnowledgeGraph; unreadable: string[]; + size: GraphSize; }> { try { const data = await fs.readFile(this.memoryFilePath, "utf-8"); @@ -499,14 +710,23 @@ export class KnowledgeGraphManager { } } - return { graph, unreadable }; + const size = { + entities: graph.entities.length, + relations: graph.relations.length, + bytes: Buffer.byteLength(data, "utf-8"), + }; + return { graph, unreadable, size }; } catch (error) { if ( error instanceof Error && "code" in error && error.code === "ENOENT" ) { - return { graph: { entities: [], relations: [] }, unreadable: [] }; + return { + graph: { entities: [], relations: [] }, + unreadable: [], + size: { entities: 0, relations: 0, bytes: 0 }, + }; } throw error; } @@ -529,9 +749,50 @@ export class KnowledgeGraphManager { } } + // Refuse a write that would leave the graph over a limit and larger than it + // was (`before`), on any one dimension. Comparing against `before` keeps a + // graph already over a lowered limit usable: a call that adds nothing still + // succeeds, and the delete tools, which never pass `before`, can always + // shrink it. The refusal is thrown before anything is written, so the call + // changes nothing. + private checkLimits( + graph: KnowledgeGraph, + content: string, + before: GraphSize, + ): void { + const after: GraphSize = { + entities: graph.entities.length, + relations: graph.relations.length, + bytes: Buffer.byteLength(content, "utf-8"), + }; + const dimensions: [keyof GraphSize, keyof GraphLimits, string][] = [ + ["entities", "maxEntities", "entities"], + ["relations", "maxRelations", "relations"], + ["bytes", "maxFileBytes", "bytes in the memory file"], + ]; + for (const [dimension, key, unit] of dimensions) { + const limit = this.limits[key]; + if ( + limit !== undefined && + after[dimension] > limit && + after[dimension] > before[dimension] + ) { + throw new Error( + `Refused: this change would bring the knowledge graph to ${after[dimension]} ${unit}, ` + + `over the limit of ${limit} set by ${GRAPH_LIMIT_ENV[key]}. Nothing was saved. ` + + "Delete entities, relations or observations that are no longer needed to make room, " + + `or ask the operator to raise ${GRAPH_LIMIT_ENV[key]}.`, + ); + } + } + } + + // before is the graph's size as loaded; the write tools that add to the + // graph pass it, so the save is refused if it breaks a limit (checkLimits). private async saveGraph( graph: KnowledgeGraph, unreadable: string[], + before?: GraphSize, ): Promise { // The modelled fields come first and always hold the current values; a // record's extras (see extraFields) follow unchanged. A record created by @@ -557,6 +818,10 @@ export class KnowledgeGraphManager { ), ...unreadable, ]; + const content = lines.join("\n") + "\n"; + if (before) { + this.checkLimits(graph, content, before); + } // Write to a temporary file in the same directory, then rename it over // the target. fs.writeFile would truncate the memory file before writing, @@ -601,7 +866,7 @@ export class KnowledgeGraphManager { // umask removed. await fs.writeFile( tempFilePath, - lines.join("\n") + "\n", + content, mode === undefined ? undefined : { mode }, ); if (mode !== undefined) { @@ -617,7 +882,7 @@ export class KnowledgeGraphManager { async createEntities(entities: Entity[]): Promise { return this.withLock(async () => { - const { graph, unreadable } = await this.loadGraphWithUnreadable(); + const { graph, unreadable, size } = await this.loadGraphWithUnreadable(); const newEntities = entities.filter( (e, index) => !graph.entities.some( @@ -627,14 +892,20 @@ export class KnowledgeGraphManager { !entities.slice(0, index).some((earlier) => earlier.name === e.name), ); graph.entities.push(...newEntities); - await this.saveGraph(graph, unreadable); + // Only a call that adds something is held to the limits: re-saving can + // grow an existing file that was not written in this exact form. + await this.saveGraph( + graph, + unreadable, + newEntities.length > 0 ? size : undefined, + ); return newEntities; }); } async createRelations(relations: Relation[]): Promise { return this.withLock(async () => { - const { graph, unreadable } = await this.loadGraphWithUnreadable(); + const { graph, unreadable, size } = await this.loadGraphWithUnreadable(); const entityNames = new Set(graph.entities.map((e) => e.name)); relations.forEach((r) => { @@ -659,7 +930,12 @@ export class KnowledgeGraphManager { .some((earlier) => isSameRelation(earlier, r)), ); graph.relations.push(...newRelations); - await this.saveGraph(graph, unreadable); + // Held to the limits only when it adds something (see createEntities). + await this.saveGraph( + graph, + unreadable, + newRelations.length > 0 ? size : undefined, + ); return newRelations; }); } @@ -668,7 +944,7 @@ export class KnowledgeGraphManager { observations: { entityName: string; contents: string[] }[], ): Promise<{ entityName: string; addedObservations: string[] }[]> { return this.withLock(async () => { - const { graph, unreadable } = await this.loadGraphWithUnreadable(); + const { graph, unreadable, size } = await this.loadGraphWithUnreadable(); const results = observations.map((o) => { const entity = graph.entities.find((e) => e.name === o.entityName); if (!entity) { @@ -682,7 +958,9 @@ export class KnowledgeGraphManager { entity.observations.push(...newObservations); return { entityName: o.entityName, addedObservations: newObservations }; }); - await this.saveGraph(graph, unreadable); + // Held to the limits only when it adds something (see createEntities). + const added = results.some((r) => r.addedObservations.length > 0); + await this.saveGraph(graph, unreadable, added ? size : undefined); return results; }); } @@ -900,7 +1178,7 @@ const RelationSchema = z.object({ relationType: z.string().describe("The type of the relation"), }); -const RESOURCE_URI = "memory://knowledge-graph"; +export const RESOURCE_URI = "memory://knowledge-graph"; export const SEARCH_QUERY_MAX_LENGTH = 2048; @@ -957,12 +1235,23 @@ const ReadEntitySchema = EntitySchema.extend({ // result on stdio; tests connect it to an in-memory transport, so each call // returns an independent server with its own subscriber set. `era` is the // protocol era the instance will serve, which decides how graph changes are -// announced (see notifyGraphUpdated). +// announced (see notifyGraphUpdated). `publishGraphUpdated`, when given, +// announces every change instead of the instance itself, whatever era wrote +// it: over HTTP each request gets a fresh server that holds no listen stream +// and no subscriber, so http.ts hands in the handler's subscription bus, which +// every open 2026-07-28 stream listens on. `limits` caps how large the write +// tools may grow the graph; main() and run() read it from the environment. export function createServer( memoryFilePath: string, era: "legacy" | "modern" = "legacy", + publishGraphUpdated?: () => void, + limits: GraphLimits = {}, ): McpServer { - const knowledgeGraphManager = new KnowledgeGraphManager(memoryFilePath); + const knowledgeGraphManager = new KnowledgeGraphManager( + memoryFilePath, + {}, + limits, + ); const server = new McpServer({ name: "memory-server", @@ -980,7 +1269,9 @@ export function createServer( // the notification only to a listen stream that named the URI, so it is // always handed over. function notifyGraphUpdated() { - if (era === "modern" || resourceSubscribers.has(RESOURCE_URI)) { + if (publishGraphUpdated) { + publishGraphUpdated(); + } else if (era === "modern" || resourceSubscribers.has(RESOURCE_URI)) { // Fire-and-forget: the tool result must not wait on (or fail because of) // the notification, so a delivery failure is logged rather than thrown. server.server @@ -1431,20 +1722,25 @@ export function registerKnowledgeGraphSubscriptions( // including one that stops the transport from starting, is reported on stderr. export async function main(transport?: Transport): Promise { const memoryFilePath = await ensureMemoryFilePath(); + const limits = graphLimitsFromEnv(); const locationWarning = memoryFileLocationWarning(memoryFilePath); if (locationWarning) { console.error(locationWarning); } - const handle = serveStdio(({ era }) => createServer(memoryFilePath, era), { - transport, - // serveStdio reports a transport that fails, including one that cannot - // start, here rather than by rejecting, so record the failure in the - // exit status for whatever supervises the process. - onerror: (error) => { - console.error("Transport error:", error); - process.exitCode = 1; + installLockCleanup(); + const handle = serveStdio( + ({ era }) => createServer(memoryFilePath, era, undefined, limits), + { + transport, + // serveStdio reports a transport that fails, including one that cannot + // start, here rather than by rejecting, so record the failure in the + // exit status for whatever supervises the process. + onerror: (error) => { + console.error("Transport error:", error); + process.exitCode = 1; + }, }, - }); + ); console.error("Knowledge Graph MCP Server running on stdio"); return handle; } @@ -1466,9 +1762,87 @@ export function isMainModule( } } +/** The transports `--transport` can name. */ +export const TRANSPORTS = ["stdio", "streamable-http"] as const; +export type TransportName = (typeof TRANSPORTS)[number]; + +/** + * The transport the command line asks for: `--transport ` or + * `--transport=`, else stdio. Throws on a missing or unknown name. + * Other arguments are ignored, as they always have been. + */ +export function parseTransport(args: string[]): TransportName { + let value: string | undefined; + for (let index = 0; index < args.length; index++) { + const arg = args[index]; + if (arg === "--transport") { + value = args[++index]; + if (value === undefined) { + throw new Error("--transport needs a value: stdio or streamable-http"); + } + } else if (arg.startsWith("--transport=")) { + value = arg.slice("--transport=".length); + } + } + if (value === undefined) return "stdio"; + if (!(TRANSPORTS as readonly string[]).includes(value)) { + throw new Error( + `Unknown transport ${JSON.stringify(value)}: expected stdio or streamable-http`, + ); + } + return value as TransportName; +} + +// Start the server on the transport args names, and hand back how to stop +// it. Streamable HTTP listens on HOST:PORT (loopback:3001 by default) and also +// stops, exiting the process, on SIGINT or SIGTERM. Closing the listener does +// not wait for a tool call that is mid-write, so the exit that follows still +// goes through the lock cleanup (#5595); a second signal does not wait for +// the close either, and exits with the status the signal's default would give. +export async function run( + args: string[] = process.argv.slice(2), +): Promise<{ close: () => Promise }> { + if (parseTransport(args) === "stdio") { + return main(); + } + const memoryFilePath = await ensureMemoryFilePath(); + const limits = graphLimitsFromEnv(); + const locationWarning = memoryFileLocationWarning(memoryFilePath); + if (locationWarning) { + console.error(locationWarning); + } + const { httpEndpoint, startHttpServer } = await import("./http.js"); + const running = await startHttpServer(memoryFilePath, httpEndpoint(), limits); + console.error( + `Knowledge Graph MCP Server running on Streamable HTTP at ${running.url}`, + ); + installExitLockCleanup(); + let stopping = false; + const stop = (signal: keyof typeof SIGNAL_EXIT_CODES) => { + if (stopping) { + process.exit(SIGNAL_EXIT_CODES[signal]); + } else { + stopping = true; + running.close().then( + () => process.exit(0), + (error: unknown) => { + console.error("Error shutting down:", error); + process.exit(1); + }, + ); + } + }; + process.on("SIGINT", () => stop("SIGINT")); + process.on("SIGTERM", () => stop("SIGTERM")); + return running; +} + if (isMainModule()) { - main().catch((error) => { - console.error("Fatal error in main():", error); + run().catch((error: unknown) => { + console.error( + "Fatal error running server:", + error instanceof Error ? error.message : error, + ); process.exit(1); }); } diff --git a/src/memory/package.json b/src/memory/package.json index 3ae2cab2f3..01ae5dea35 100644 --- a/src/memory/package.json +++ b/src/memory/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/server-memory", - "version": "2.1.1", + "version": "2.2.1", "description": "MCP server for enabling memory for Claude through a knowledge graph", "license": "SEE LICENSE IN LICENSE", "mcpName": "io.github.modelcontextprotocol/server-memory", @@ -34,6 +34,7 @@ "validate": "npm run format:check && npm run lint && npm run typecheck && npm run build && npm run test" }, "dependencies": { + "@modelcontextprotocol/node": "^2.1.1", "@modelcontextprotocol/server": "^2.3.1", "zod": "^4.2.0" }, diff --git a/src/sequentialthinking/CHANGELOG.md b/src/sequentialthinking/CHANGELOG.md index 9700d8625e..2ca7cabe93 100644 --- a/src/sequentialthinking/CHANGELOG.md +++ b/src/sequentialthinking/CHANGELOG.md @@ -1,5 +1,15 @@ # @modelcontextprotocol/server-sequential-thinking +## 2.2.0 + +### Minor Changes + +- [#5536](https://github.com/modelcontextprotocol/servers/pull/5536) [`311c0fd`](https://github.com/modelcontextprotocol/servers/commit/311c0fdc953f38da08153fd2e8d134d03c8e168b) [@cliffhall](https://github.com/cliffhall) - Serve Streamable HTTP as well as stdio ([#576](https://github.com/modelcontextprotocol/servers/issues/576)). `--transport streamable-http` serves the server on one `/mcp` endpoint, for 2026-07-28 and 2025-era clients alike, at `HOST`:`PORT` (`127.0.0.1:3001` by default); stdio stays the default. Over HTTP the filesystem server requires its allowed directories on the command line, since it cannot ask a client for its Roots, and the sequential-thinking history belongs to the server process rather than to one connection. + +### Patch Changes + +- [#5535](https://github.com/modelcontextprotocol/servers/pull/5535) [`a5c60fa`](https://github.com/modelcontextprotocol/servers/commit/a5c60fa8cb442de81b99ccc4bcac8cd79e8c044f) [@cliffhall](https://github.com/cliffhall) - Count the thought box's header rows toward its 1000-row cap, so a long `branchId` can no longer draw past it on stderr: line breaks in a `branchId` are shown as `\r` and `\n`, and a header too long for the cap is cut with a row saying how many characters it left out ([#5526](https://github.com/modelcontextprotocol/servers/issues/5526)). + ## 2.1.1 ### Patch Changes diff --git a/src/sequentialthinking/README.md b/src/sequentialthinking/README.md index 81ae0ae26a..c0e7539ec3 100644 --- a/src/sequentialthinking/README.md +++ b/src/sequentialthinking/README.md @@ -134,7 +134,7 @@ On Windows, use `cmd /c` to launch `npx`: To disable logging of thought information set env var: `DISABLE_THOUGHT_LOGGING` to `true`. -Each thought is logged to stderr as a box, one row per line of the thought. The box is at most 100 characters wide, with longer lines (and a long branch ID in the header) wrapped, and draws at most 1000 rows of thought text; past that it ends with a row saying how many lines it left out. Only the log is shortened: the server keeps the whole thought in its history, and the tool result is unchanged. +Each thought is logged to stderr as a box, one row per line of the thought. The box is at most 100 characters wide, with longer lines (and a long branch ID in the header) wrapped, and draws at most 1000 rows of text, header and thought together; past that it ends with a row saying how many lines it left out. A line break in a branch ID is shown in the header as `\r` or `\n`, and a header too long for those rows (a very long branch ID) is cut, with a row saying how many characters it left out. Only the log is shortened: the server keeps the whole thought in its history, and the tool result is unchanged. To bound memory use, the server retains at most `MAX_THOUGHT_HISTORY` thoughts per connection (a positive integer; default `1000`). Past the cap the oldest thought is dropped, from its branch too, so `thoughtHistoryLength` in the result stops at the cap and a branch whose thoughts have all been dropped is no longer listed in `branches`. @@ -218,6 +218,33 @@ Run the following: codex mcp add sequential-thinking npx -y @modelcontextprotocol/server-sequential-thinking ``` +## Streamable HTTP + +The server talks over stdio by default. With `--transport streamable-http` it +runs on its own as an HTTP service instead, serving one MCP endpoint, `/mcp`, +to any number of clients of either protocol era: + +```sh +npx -y @modelcontextprotocol/server-sequential-thinking --transport streamable-http +``` + +It listens on `127.0.0.1:3001` unless `HOST` and `PORT` say otherwise (for +example `PORT=8080`); `HOST=0.0.0.0` exposes it to every machine that can reach +this one, so set it deliberately. A request from a browser page on any +origin but localhost is refused with `403`, and the endpoint sends no CORS +headers, so it serves clients that are not browser pages. Point a client at the URL, such as +`http://127.0.0.1:3001/mcp`, instead of giving it a command: + +```json +{ + "mcpServers": { + "sequentialthinking": { "type": "http", "url": "http://127.0.0.1:3001/mcp" } + } +} +``` + +Over HTTP each request is served by a fresh server, and a 2025-era client gets no session (GET and DELETE on `/mcp` answer `405`), so the server cannot send it requests or notifications between its own requests. So the thought history and branches, which over stdio belong to one connection, **belong to the server process over HTTP and are shared by every client it serves**: run one process per client when histories must stay apart. + ## Building Docker: diff --git a/src/sequentialthinking/__tests__/http.test.ts b/src/sequentialthinking/__tests__/http.test.ts new file mode 100644 index 0000000000..9148e687d8 --- /dev/null +++ b/src/sequentialthinking/__tests__/http.test.ts @@ -0,0 +1,268 @@ +// The Streamable HTTP transport (#576): `http.ts` bound on a free loopback +// port and driven by the SDK Client over real HTTP in both protocol eras, plus +// `run()`'s transport selection and `httpEndpoint()`'s reading of HOST and +// PORT. Over HTTP every request gets a fresh server, so the shared thought +// history is asserted across calls and across clients. + +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { connect as connectTcp } from "node:net"; +import { + Client, + StreamableHTTPClientTransport, +} from "@modelcontextprotocol/client"; +import { + DEFAULT_HOST, + DEFAULT_PORT, + endpointUrl, + httpEndpoint, + startHttpServer, + type RunningHttpServer, +} from "../http.js"; +import { parseTransport, run } from "../index.js"; +import { TOOL_NAME, parseOk, thought, type WireResult } from "./helpers.js"; + +const ERAS = [ + ["2026-07-28", { mode: { pin: "2026-07-28" } }, "modern"], + ["2025-11-25", { mode: "legacy" }, "legacy"], +] as const; + +async function connect( + url: string, + versionNegotiation: (typeof ERAS)[number][1], +): Promise { + const client = new Client( + { name: "http-test", version: "0.0.0" }, + { versionNegotiation }, + ); + await client.connect(new StreamableHTTPClientTransport(new URL(url))); + return client; +} + +describe("Streamable HTTP", () => { + let running: RunningHttpServer | undefined; + + beforeEach(() => { + vi.spyOn(console, "error").mockImplementation(() => {}); + process.env.DISABLE_THOUGHT_LOGGING = "true"; + }); + + afterEach(async () => { + await running?.close(); + running = undefined; + delete process.env.DISABLE_THOUGHT_LOGGING; + vi.restoreAllMocks(); + }); + + it.each(ERAS)( + "serves a %s client and keeps one history across its requests", + async (_, negotiation, era) => { + running = await startHttpServer({ host: "127.0.0.1", port: 0 }); + const client = await connect(running.url, negotiation); + try { + expect(client.getProtocolEra()).toBe(era); + const { tools } = await client.listTools(); + expect(tools.map((t) => t.name)).toEqual([TOOL_NAME]); + for (const n of [1, 2]) { + const result = (await client.callTool({ + name: TOOL_NAME, + arguments: thought({ thoughtNumber: n }), + })) as WireResult; + expect(parseOk(result).thoughtHistoryLength).toBe(n); + } + } finally { + await client.close(); + } + }, + ); + + it("shares the history between clients of the same process", async () => { + running = await startHttpServer({ host: "127.0.0.1", port: 0 }); + const first = await connect(running.url, ERAS[0][1]); + const second = await connect(running.url, ERAS[1][1]); + try { + await first.callTool({ name: TOOL_NAME, arguments: thought() }); + const result = (await second.callTool({ + name: TOOL_NAME, + arguments: thought(), + })) as WireResult; + expect(parseOk(result).thoughtHistoryLength).toBe(2); + } finally { + await first.close(); + await second.close(); + } + }); + + it("answers a malformed request target 404 and keeps serving", async () => { + running = await startHttpServer({ host: "127.0.0.1", port: 0 }); + const url = new URL(running.url); + const reply = await new Promise((resolve, reject) => { + const socket = connectTcp(Number(url.port), url.hostname, () => + socket.write("GET //[ HTTP/1.1\r\nHost: localhost\r\n\r\n"), + ); + socket.setEncoding("utf8"); + socket.once("data", (chunk: string) => { + socket.destroy(); + resolve(chunk); + }); + socket.once("error", reject); + }); + expect(reply).toMatch(/^HTTP\/1\.1 404/); + expect((await fetch(new URL("/other", url))).status).toBe(404); + }); + + it("answers 404 off the MCP path and 403 to a foreign Origin", async () => { + running = await startHttpServer({ host: "127.0.0.1", port: 0 }); + const base = new URL(running.url); + expect((await fetch(new URL("/other", base))).status).toBe(404); + const foreign = await fetch(base, { + method: "POST", + headers: { + origin: "https://evil.example", + "content-type": "application/json", + }, + body: "{}", + }); + expect(foreign.status).toBe(403); + }); + + it("reports a request the SDK refuses through onerror", async () => { + running = await startHttpServer({ host: "127.0.0.1", port: 0 }); + // A 2026-07-28 header on a request with no 2026-07-28 envelope. + const response = await fetch(running.url, { + method: "POST", + headers: { + "content-type": "application/json", + accept: "application/json, text/event-stream", + "mcp-protocol-version": "2026-07-28", + }, + body: JSON.stringify({ + jsonrpc: "2.0", + id: 1, + method: "tools/list", + params: {}, + }), + }); + expect(response.status).toBe(400); + expect(console.error).toHaveBeenCalledWith( + "Error serving MCP request:", + expect.any(Error), + ); + }); + + it("rejects when the port is already bound", async () => { + running = await startHttpServer({ host: "127.0.0.1", port: 0 }); + const port = Number(new URL(running.url).port); + await expect(startHttpServer({ host: "127.0.0.1", port })).rejects.toThrow( + /EADDRINUSE/, + ); + }); +}); + +describe("endpointUrl", () => { + it("brackets an IPv6 literal", () => { + expect(endpointUrl("127.0.0.1", 3001)).toBe("http://127.0.0.1:3001/mcp"); + expect(endpointUrl("::1", 3001)).toBe("http://[::1]:3001/mcp"); + }); +}); + +describe("httpEndpoint", () => { + it("defaults to loopback on the default port", () => { + expect(httpEndpoint({})).toEqual({ + host: DEFAULT_HOST, + port: DEFAULT_PORT, + }); + }); + + it("reads HOST and PORT", () => { + expect(httpEndpoint({ HOST: "0.0.0.0", PORT: "8080" })).toEqual({ + host: "0.0.0.0", + port: 8080, + }); + }); + + it.each(["abc", "-1", "65536", "1.5"])("refuses PORT=%s", (PORT) => { + expect(() => httpEndpoint({ PORT })).toThrow(/Invalid PORT/); + }); +}); + +describe("parseTransport", () => { + it.each([ + [[], "stdio"], + [["--transport", "stdio"], "stdio"], + [["--transport", "streamable-http"], "streamable-http"], + [["--transport=streamable-http"], "streamable-http"], + ] as const)("reads %j as %s", (args, expected) => { + expect(parseTransport([...args])).toBe(expected); + }); + + it("throws on a missing or unknown transport", () => { + expect(() => parseTransport(["--transport"])).toThrow(/needs a value/); + expect(() => parseTransport(["--transport", "sse"])).toThrow( + /Unknown transport "sse"/, + ); + }); +}); + +describe("run", () => { + const saved = { HOST: process.env.HOST, PORT: process.env.PORT }; + const signals = ["SIGINT", "SIGTERM"] as const; + let before: Record<(typeof signals)[number], unknown[]>; + + /** The signal listeners `run()` added since the test began. */ + function added(signal: (typeof signals)[number]) { + return process + .listeners(signal) + .filter((listener) => !before[signal].includes(listener)); + } + + beforeEach(() => { + vi.spyOn(console, "error").mockImplementation(() => {}); + vi.spyOn(process, "exit").mockImplementation((() => undefined) as never); + before = { + SIGINT: process.listeners("SIGINT"), + SIGTERM: process.listeners("SIGTERM"), + }; + process.env.HOST = "127.0.0.1"; + process.env.PORT = "0"; + }); + + afterEach(() => { + for (const signal of signals) { + for (const listener of added(signal)) process.off(signal, listener); + } + for (const [key, value] of Object.entries(saved)) { + if (value === undefined) delete process.env[key]; + else process.env[key] = value; + } + vi.restoreAllMocks(); + }); + + it("starts Streamable HTTP on HOST:PORT and stops it on SIGINT", async () => { + await run(["--transport", "streamable-http"]); + expect(added("SIGINT")).toHaveLength(1); + expect(added("SIGTERM")).toHaveLength(1); + const announced = vi + .mocked(console.error) + .mock.calls.flat() + .map(String) + .find((line) => line.includes("running on Streamable HTTP")); + const url = announced!.match(/http:\/\/\S+/)![0]; + // A 2025-era session operation, which the stateless endpoint refuses. + expect((await fetch(url)).status).toBe(405); + + added("SIGINT")[0]("SIGINT"); + await vi.waitFor(() => expect(process.exit).toHaveBeenCalledWith(0)); + await expect(fetch(url)).rejects.toThrow(); + }); + + it("reports a shutdown that fails and exits non-zero", async () => { + const running = await run(["--transport=streamable-http"]); + const close = running.close; + const failure = new Error("stuck"); + running.close = vi.fn().mockRejectedValue(failure); + added("SIGTERM")[0]("SIGTERM"); + await vi.waitFor(() => expect(process.exit).toHaveBeenCalledWith(1)); + expect(console.error).toHaveBeenCalledWith("Error shutting down:", failure); + await close(); + }); +}); diff --git a/src/sequentialthinking/__tests__/thought-logging.test.ts b/src/sequentialthinking/__tests__/thought-logging.test.ts index 6b9345e295..dda69ba097 100644 --- a/src/sequentialthinking/__tests__/thought-logging.test.ts +++ b/src/sequentialthinking/__tests__/thought-logging.test.ts @@ -2,7 +2,7 @@ // "true" (any case), each accepted thought is drawn as a box on stderr, with // a header that differs for plain thoughts, revisions and branches, and one // row per line of the thought, wrapped at MAX_BOX_TEXT_WIDTH and cut off -// after MAX_BOX_ROWS. Thoughts +// once header and thought fill MAX_BOX_ROWS rows. Thoughts // are driven through the in-process client and stderr is captured by spying // on console.error, which also keeps the boxes off the test output. chalk's // colour level depends on the terminal the tests run in, so it is pinned to 0 @@ -232,15 +232,18 @@ ${rows.join("\n")} }); // #5433: past MAX_BOX_ROWS the box stops drawing and says how many lines - // it left out; the call itself is unaffected. + // it left out; the call itself is unaffected. The header's one row counts + // toward the cap (#5526), so the thought gets the rest. it("draws a thought with very many lines", async () => { const lines = Array.from({ length: 200_000 }, (_, i) => `${i % 10}`); const result = await conn!.think(thought({ thought: lines.join("\n") })); expect(result.isError).toBeFalsy(); const out = logged()[0].split("\n"); - expect(out).toHaveLength(MAX_BOX_ROWS + 1 + 5); + // A leading blank, the borders and separator, MAX_BOX_ROWS rows of + // header and thought, and the summary row. + expect(out).toHaveLength(MAX_BOX_ROWS + 5); expect(out.at(-2)).toContain( - `… ${200_000 - MAX_BOX_ROWS} more lines not shown`, + `… ${200_000 - (MAX_BOX_ROWS - 1)} more lines not shown`, ); // The summary is wider than every one-character line and the header, // so it sets the box's width; it must not stick out of it. @@ -284,28 +287,33 @@ ${row("short")} const result = await conn!.think(thought({ thought: text })); expect(result.isError).toBeFalsy(); const out = logged()[0]; - // 200 wrapped rows for the long line, short lines up to the row cap, - // then the summary row; each row is W + 6 characters and a newline. - const shortShown = MAX_BOX_ROWS - n / W; - expect(out.split("\n")).toHaveLength(MAX_BOX_ROWS + 1 + 5); + // The header row, 200 wrapped rows for the long line, short lines up to + // the row cap, then the summary row; each row is W + 6 characters and a + // newline. + const shortShown = MAX_BOX_ROWS - 1 - n / W; + expect(out.split("\n")).toHaveLength(MAX_BOX_ROWS + 5); expect(out).toContain(`… ${n - 1 - shortShown} more lines not shown`); expect(out.length).toBeLessThan((MAX_BOX_ROWS + 10) * (W + 7)); }); it("counts a line the row cap cuts off as not shown", async () => { - const text = `${"s\n".repeat(MAX_BOX_ROWS - 1)}${"L".repeat(2 * W)}`; + // The header row and these short lines leave one row for the long one. + const text = `${"s\n".repeat(MAX_BOX_ROWS - 2)}${"L".repeat(2 * W)}`; await conn!.think(thought({ thought: text })); const rows = logged()[0].split("\n"); - expect(rows).toHaveLength(MAX_BOX_ROWS + 1 + 5); + expect(rows).toHaveLength(MAX_BOX_ROWS + 5); expect(rows.at(-3)).toBe(row("L".repeat(W))); expect(rows.at(-2)).toBe(row("… 1 more line not shown")); }); it("draws a thought that exactly fills the cap with no summary row", async () => { - const text = Array.from({ length: MAX_BOX_ROWS }, () => "s").join("\n"); + // With the header's one row, these lines fill the cap exactly. + const text = Array.from({ length: MAX_BOX_ROWS - 1 }, () => "s").join( + "\n", + ); await conn!.think(thought({ thought: text })); const rows = logged()[0].split("\n"); - expect(rows).toHaveLength(MAX_BOX_ROWS + 5); + expect(rows).toHaveLength(MAX_BOX_ROWS + 4); expect(logged()[0]).not.toContain("not shown"); }); @@ -338,6 +346,81 @@ ${row("short")} expect(out.length).toBeLessThan((lines + 10) * (W + 7)); }); + // #5526: a long branchId's header rows count toward MAX_BOX_ROWS, so they + // cannot add rows past the cap the thought's rows are held to. + it("counts a wrapped header's rows toward the row cap", async () => { + const branchId = "b".repeat(2 * W); + const header = `🌿 Branch 1/3 (from thought 1, ID: ${branchId})`; + const headerRows = Math.ceil(header.length / W); + expect(headerRows).toBeGreaterThan(1); + await conn!.think( + thought({ + thought: Array.from({ length: MAX_BOX_ROWS }, () => "s").join("\n"), + branchFromThought: 1, + branchId, + }), + ); + const rows = logged()[0].split("\n"); + expect(rows).toHaveLength(MAX_BOX_ROWS + 5); + expect(rows.at(-2)).toBe(row(`… ${headerRows} more lines not shown`)); + }); + + // #5526: a line ending in a branchId would start a line of output the + // row cap never counted; the header shows it escaped instead. + it("escapes line endings in a branchId so the header stays on its rows", async () => { + const branchId = "x\r\ny\rz\n".repeat(500); + const escaped = "x\\r\\ny\\rz\\n".repeat(500); + const header = `🌿 Branch 1/3 (from thought 1, ID: ${escaped})`; + await conn!.think( + thought({ thought: "t", branchFromThought: 1, branchId }), + ); + const out = logged()[0]; + expect(out).not.toContain("\r"); + const rows = out.split("\n"); + const headerRows = Math.ceil(header.length / W); + // A leading blank, the borders and separator, the header rows and the + // thought's one row. + expect(rows).toHaveLength(headerRows + 5); + expect( + rows + .slice(2, 2 + headerRows) + .map((r) => r.slice(2, 2 + W).trimEnd()) + .join(""), + ).toBe(header); + }); + + // #5526: a header too long for every row is cut, so a huge branchId logs + // no more than the cap; its last row says how much was left out. + it("cuts a header longer than the row cap", async () => { + const branchId = "b".repeat(MAX_BOX_ROWS * W); + const header = `🌿 Branch 1/3 (from thought 1, ID: ${branchId})`; + const result = await conn!.think( + thought({ thought: "t", branchFromThought: 1, branchId }), + ); + expect(result.isError).toBeFalsy(); + const out = logged()[0]; + const rows = out.split("\n"); + // A leading blank, the top border, MAX_BOX_ROWS header rows, the + // separator, the thought's summary row and the bottom border. + expect(rows).toHaveLength(MAX_BOX_ROWS + 5); + const shown = (MAX_BOX_ROWS - 1) * W; + expect( + rows + .slice(2, MAX_BOX_ROWS + 1) + .map((r) => r.slice(2, 2 + W)) + .join(""), + ).toBe(header.slice(0, shown)); + expect(rows[MAX_BOX_ROWS + 1]).toBe( + row(`… ${header.length - shown} more characters not shown`), + ); + expect(rows[MAX_BOX_ROWS + 2]).toBe(`├${border}┤`); + expect(rows.at(-2)).toBe(row("… 1 more line not shown")); + expect(new Set(rows.slice(1).map((r) => r.length))).toEqual( + new Set([W + 6]), + ); + expect(out.length).toBeLessThan((MAX_BOX_ROWS + 10) * (W + 7)); + }); + it("never splits an emoji across rows", async () => { // The emoji's two UTF-16 halves would straddle the cut at W. const text = `${"a".repeat(W - 1)}😀tail`; diff --git a/src/sequentialthinking/http.ts b/src/sequentialthinking/http.ts new file mode 100644 index 0000000000..81c81f782f --- /dev/null +++ b/src/sequentialthinking/http.ts @@ -0,0 +1,122 @@ +// Serves the sequential-thinking server over Streamable HTTP (#576), the +// alternative to stdio that `--transport streamable-http` selects. +// +// One `/mcp` endpoint answers both protocol eras through the SDK's +// `createMcpHandler`: a 2026-07-28 request is served by a fresh server built +// for it, and a 2025-era request by the SDK's stateless fallback (also a fresh +// server per request, with no session, so GET and DELETE are answered 405). +// Because no server outlives its request, the thought history is held by one +// `SequentialThinkingServer` shared by every request this process serves: +// over HTTP the history belongs to the process, not to a connection. +// +// The listener binds loopback unless `HOST` widens it, and a browser page may +// reach it only from a localhost Origin, the same posture as the everything +// server's HTTP transports (#5371). `startHttpServer()` resolves once the port +// is bound and rejects when it cannot be, so a launcher sees the failure. + +import { createServer as createNodeServer, type Server } from "node:http"; +import type { AddressInfo } from "node:net"; +import { + createMcpHandler, + type McpHttpHandler, +} from "@modelcontextprotocol/server"; +import { + localhostOriginValidation, + toNodeHandler, +} from "@modelcontextprotocol/node"; +import { createServer } from "./index.js"; +import { SequentialThinkingServer } from "./lib.js"; + +/** The interface bound when `HOST` is unset: loopback only. */ +export const DEFAULT_HOST = "127.0.0.1"; +/** The port bound when `PORT` is unset. */ +export const DEFAULT_PORT = 3001; +/** The one path the endpoint answers on. */ +export const MCP_PATH = "/mcp"; + +/** Where to listen: `HOST` and `PORT` from the environment, else the defaults. */ +export function httpEndpoint(env: NodeJS.ProcessEnv = process.env): { + host: string; + port: number; +} { + const host = env.HOST || DEFAULT_HOST; + if (!env.PORT) return { host, port: DEFAULT_PORT }; + const port = Number(env.PORT); + if (!Number.isInteger(port) || port < 0 || port > 65535) { + throw new Error( + `Invalid PORT ${JSON.stringify(env.PORT)}: expected a whole number from 0 to 65535`, + ); + } + return { host, port }; +} + +/** The URL of the endpoint bound at `address`:`port`, an IPv6 literal in brackets. */ +export function endpointUrl(address: string, port: number): string { + const host = address.includes(":") ? `[${address}]` : address; + return `http://${host}:${port}${MCP_PATH}`; +} + +/** A running HTTP endpoint: the bound address, and how to stop it. */ +export interface RunningHttpServer { + httpServer: Server; + handler: McpHttpHandler; + /** The URL clients connect to, with the port actually bound. */ + url: string; + /** End in-flight MCP exchanges, then stop listening and drop open sockets. */ + close: () => Promise; +} + +/** + * Bind the endpoint on `host`:`port` (port 0 picks a free one) and serve the + * sequential-thinking server on it. Rejects when the port cannot be bound. + */ +export async function startHttpServer({ + host, + port, +}: { + host: string; + port: number; +}): Promise { + const thinking = new SequentialThinkingServer(); + const onerror = (error: Error) => + console.error("Error serving MCP request:", error); + const handler = createMcpHandler(() => createServer(thinking), { onerror }); + const serve = toNodeHandler(handler, { onerror }); + const allowOrigin = localhostOriginValidation(); + + const httpServer = createNodeServer((req, res) => { + // The path, without parsing the target: a malformed one (`//[`) would + // make URL parsing throw here, outside any handler, and end the process. + const path = String(req.url).split("?")[0]; + if (path !== MCP_PATH) { + res.writeHead(404, { "content-type": "text/plain" }).end("Not Found"); + return; + } + if (!allowOrigin(req, res)) return; + // Not awaited: the listener is synchronous. The adapter never rejects; it + // reports a failure through `onerror` and answers it with a 500 itself. + void serve(req, res); + }); + + await new Promise((resolve, reject) => { + httpServer.once("error", reject); + httpServer.listen({ host, port }, () => { + httpServer.off("error", reject); + resolve(); + }); + }); + + const bound = httpServer.address() as AddressInfo; + return { + httpServer, + handler, + url: endpointUrl(bound.address, bound.port), + close: async () => { + await handler.close(); + await new Promise((resolve) => { + httpServer.close(() => resolve()); + httpServer.closeAllConnections(); + }); + }, + }; +} diff --git a/src/sequentialthinking/index.ts b/src/sequentialthinking/index.ts index be0aaa2eb2..f8cd5ab2df 100644 --- a/src/sequentialthinking/index.ts +++ b/src/sequentialthinking/index.ts @@ -5,9 +5,10 @@ // SDK Client over an in-memory transport (#4854); `main()` serves it through // the SDK's `serveStdio` entry, which answers both 2026-07-28 clients // (`server/discover`, no handshake) and 2025-era clients (`initialize`) from -// the same factory (#4852); and stdio is only attached when this file is run -// as the binary, so importing it from a test never touches the runner's -// stdin/stdout. +// the same factory (#4852); `run()` reads `--transport` and starts stdio (the +// default) or Streamable HTTP (`http.ts`, #576); and a transport is only +// attached when this file is run as the binary, so importing it from a test +// never touches the runner's stdin/stdout. import { realpathSync } from "node:fs"; import { fileURLToPath } from "node:url"; @@ -37,19 +38,21 @@ const coercedBoolean = z }); /** - * Build the sequential-thinking server with its one tool registered. Each call - * returns an independent server with its own thought history and branches. - * `serveStdio` calls it once per connection, so the history lives exactly as - * long as the client's connection, on either protocol era. + * Build the sequential-thinking server with its one tool registered, recording + * thoughts in `thinkingServer`. By default each call gets a history and + * branches of its own: `serveStdio` calls it once per connection, so the + * history lives exactly as long as the client's connection, on either + * protocol era. Over HTTP every request gets a fresh server, so `http.ts` + * passes one history shared by all of them. */ -export function createServer(): McpServer { +export function createServer( + thinkingServer: SequentialThinkingServer = new SequentialThinkingServer(), +): McpServer { const server = new McpServer({ name: "sequential-thinking-server", version: SERVER_VERSION, }); - const thinkingServer = new SequentialThinkingServer(); - server.registerTool( "sequentialthinking", { @@ -189,8 +192,75 @@ export function isEntryPoint( } } +/** The transports `--transport` can name. */ +export const TRANSPORTS = ["stdio", "streamable-http"] as const; +export type TransportName = (typeof TRANSPORTS)[number]; + +/** + * The transport the command line asks for: `--transport ` or + * `--transport=`, else stdio. Throws on a missing or unknown name. + * Other arguments are ignored, as they always have been. + */ +export function parseTransport(args: string[]): TransportName { + let value: string | undefined; + for (let index = 0; index < args.length; index++) { + const arg = args[index]; + if (arg === "--transport") { + value = args[++index]; + if (value === undefined) { + throw new Error("--transport needs a value: stdio or streamable-http"); + } + } else if (arg.startsWith("--transport=")) { + value = arg.slice("--transport=".length); + } + } + if (value === undefined) return "stdio"; + if (!(TRANSPORTS as readonly string[]).includes(value)) { + throw new Error( + `Unknown transport ${JSON.stringify(value)}: expected stdio or streamable-http`, + ); + } + return value as TransportName; +} + +/** + * Start the server on the transport `args` names, and hand back how to stop + * it. Streamable HTTP listens on `HOST`:`PORT` (loopback:3001 by default) and + * also stops, exiting the process, on SIGINT or SIGTERM. + */ +export async function run( + args: string[] = process.argv.slice(2), +): Promise<{ close: () => Promise }> { + if (parseTransport(args) === "stdio") { + return main(); + } + const { httpEndpoint, startHttpServer } = await import("./http.js"); + const running = await startHttpServer(httpEndpoint()); + console.error( + `Sequential Thinking MCP Server running on Streamable HTTP at ${running.url}`, + ); + const stop = () => { + running.close().then( + () => process.exit(0), + (error: unknown) => { + console.error("Error shutting down:", error); + process.exit(1); + }, + ); + }; + process.once("SIGINT", stop); + process.once("SIGTERM", stop); + return running; +} + /* v8 ignore start -- runs only when this file is the process entry point (the spawned bin), which stdio-smoke.test.ts exercises; v8 cannot see into that child */ if (isEntryPoint(import.meta.url, process.argv[1])) { - main(); + run().catch((error: unknown) => { + console.error( + "Fatal error running server:", + error instanceof Error ? error.message : error, + ); + process.exit(1); + }); } /* v8 ignore stop */ diff --git a/src/sequentialthinking/lib.ts b/src/sequentialthinking/lib.ts index b9299910bc..cc13c50840 100644 --- a/src/sequentialthinking/lib.ts +++ b/src/sequentialthinking/lib.ts @@ -22,12 +22,15 @@ export interface ThoughtData { export const MAX_BOX_TEXT_WIDTH = 100; /** - * The most rows of thought text a box draws (#5433). Each row is padded to - * the box's width, so a thought of many short lines would still log about a - * hundred times its own size; past this many rows the box ends with one row - * saying how many lines it left out. Header rows (a long branchId) are not - * counted. Only stderr is cut: the thought kept in thoughtHistory is whole, - * and the tool result, which carries no thought text, is unchanged. + * The most rows of text a box draws, header and thought together (#5433, + * #5526). Each row is padded to the box's width, so a thought of many short + * lines would still log about a hundred times its own size; past this many + * rows the box ends with one row saying how many lines it left out. The + * header's rows count too, so a long branchId, which wraps onto rows of its + * own, cannot draw past the cap: a header too long for every row is cut, its + * last row saying how many characters it left out. Only stderr is cut: the + * thought kept in thoughtHistory is whole, and the tool result, which carries + * no thought text, is unchanged. */ export const MAX_BOX_ROWS = 1000; @@ -130,9 +133,14 @@ export class SequentialThinkingServer { } else if (branchFromThought) { label = "🌿 Branch"; colour = chalk.green; + // #5526: a line ending in the branchId is shown as its escape, \r or + // \n, so the header stays on rows the box draws and MAX_BOX_ROWS counts. context = branchId !== undefined - ? ` (from thought ${branchFromThought}, ID: ${branchId})` + ? ` (from thought ${branchFromThought}, ID: ${branchId.replace( + /[\r\n]/g, + (eol) => (eol === "\r" ? "\\r" : "\\n"), + )})` : ` (from thought ${branchFromThought})`; } else { label = "💭 Thought"; @@ -158,15 +166,32 @@ export class SequentialThinkingServer { ); // A header longer than the cap (a long branchId) wraps like a thought // line; only its first row, which starts with the label, is coloured. - const headerTexts = wrapRow(visibleHeader, wrapWidth); - // Rows are drawn up to MAX_BOX_ROWS; the lines left over are counted, not - // drawn, so a huge thought costs no more than the cap. + // #5526: its rows count toward MAX_BOX_ROWS. Only one character more than + // the cap's rows can hold is wrapped, so a huge branchId costs no more + // than the cap, and more than MAX_BOX_ROWS rows means the header does not + // fit. It then keeps MAX_BOX_ROWS - 1 rows and a last one saying how many + // characters it left out: always more than one row's worth. Such a header + // is longer than the box is wide, so wrapWidth is MAX_BOX_TEXT_WIDTH and + // that row fits it. + const headerTexts = wrapRow( + visibleHeader.slice(0, MAX_BOX_ROWS * wrapWidth + 1), + wrapWidth, + ); + if (headerTexts.length > MAX_BOX_ROWS) { + headerTexts.length = MAX_BOX_ROWS - 1; + const shown = headerTexts.reduce((n, text) => n + text.length, 0); + headerTexts.push( + `… ${visibleHeader.length - shown} more characters not shown`, + ); + } + // Thought rows fill what the header left of MAX_BOX_ROWS; the lines left + // over are counted, not drawn, so a huge thought costs no more than the cap. const texts: string[] = []; // Lines drawn in full; a line cut off by the cap counts as hidden. let whole = 0; for (const line of lines) { const wrapped = wrapRow(line, wrapWidth); - const room = MAX_BOX_ROWS - texts.length; + const room = MAX_BOX_ROWS - headerTexts.length - texts.length; texts.push(...wrapped.slice(0, room)); if (wrapped.length > room) break; whole++; diff --git a/src/sequentialthinking/package.json b/src/sequentialthinking/package.json index 18b019f929..8a650518e5 100644 --- a/src/sequentialthinking/package.json +++ b/src/sequentialthinking/package.json @@ -1,6 +1,6 @@ { "name": "@modelcontextprotocol/server-sequential-thinking", - "version": "2.1.1", + "version": "2.2.0", "description": "MCP server for sequential thinking and problem solving", "license": "SEE LICENSE IN LICENSE", "mcpName": "io.github.modelcontextprotocol/server-sequential-thinking", @@ -34,6 +34,7 @@ "validate": "npm run format:check && npm run lint && npm run typecheck && npm run build && npm run test" }, "dependencies": { + "@modelcontextprotocol/node": "^2.1.1", "@modelcontextprotocol/server": "^2.3.1", "chalk": "^5.3.0", "zod": "^4.2.0" diff --git a/src/time/README.md b/src/time/README.md index 3c75a7687d..877551eff9 100644 --- a/src/time/README.md +++ b/src/time/README.md @@ -232,6 +232,31 @@ Example: The Docker image cannot see the host's timezone, so it reads the `LOCAL_TIMEZONE` environment variable when the container starts, and uses `UTC` when it is unset or empty. Pass it with `-e`: `"-e", "LOCAL_TIMEZONE"` forwards the client's own value, as in the Docker configuration above, and `"-e", "LOCAL_TIMEZONE=America/New_York"` sets one. A `--local-timezone` given after the image name takes precedence. +## Streamable HTTP + +The server talks over stdio by default. With `--transport streamable-http` it +runs on its own as an HTTP service instead, serving one MCP endpoint, `/mcp`, +to any number of clients of either protocol era: + +```sh +uvx mcp-server-time --transport streamable-http +``` + +It listens on `127.0.0.1:3001` unless `HOST` and `PORT` say otherwise (for +example `PORT=8080`); `HOST=0.0.0.0` exposes it to every machine that can reach +this one, so set it deliberately. Point a client at the URL, such as +`http://127.0.0.1:3001/mcp`, instead of giving it a command: + +```json +{ + "mcpServers": { + "time": { "type": "http", "url": "http://127.0.0.1:3001/mcp" } + } +} +``` + +Every other option works as it does over stdio. A browser page from any origin but localhost is refused with `403`, whatever `HOST` is, to guard against DNS rebinding; on loopback the SDK also checks each request's `Host` header. + ## Example Interactions 1. Get current time: diff --git a/src/time/pyproject.toml b/src/time/pyproject.toml index 9d28ca13ff..f25287ba0a 100644 --- a/src/time/pyproject.toml +++ b/src/time/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mcp-server-time" -version = "2026.11.11" +version = "2026.11.18" description = "A Model Context Protocol server providing tools for time queries and timezone conversions for LLMs" readme = "README.md" requires-python = ">=3.10" diff --git a/src/time/src/mcp_server_time/__init__.py b/src/time/src/mcp_server_time/__init__.py index cce7ccc9ad..70d6ff6551 100644 --- a/src/time/src/mcp_server_time/__init__.py +++ b/src/time/src/mcp_server_time/__init__.py @@ -1,4 +1,5 @@ from .server import serve +from .transport import TRANSPORTS, http_endpoint def main(): @@ -10,9 +11,22 @@ def main(): description="give a model the ability to handle time queries and timezone conversions" ) parser.add_argument("--local-timezone", type=str, help="Override local timezone") + parser.add_argument( + "--transport", + choices=TRANSPORTS, + default="stdio", + help="How clients reach the server (default: stdio). streamable-http " + "listens on $HOST:$PORT, 127.0.0.1:3001 by default", + ) args = parser.parse_args() - asyncio.run(serve(args.local_timezone)) + if args.transport == "streamable-http": + # A bad HOST or PORT stops the server here, as a usage error. + try: + http_endpoint() + except ValueError as e: + parser.error(str(e)) + asyncio.run(serve(args.local_timezone, args.transport)) if __name__ == "__main__": diff --git a/src/time/src/mcp_server_time/server.py b/src/time/src/mcp_server_time/server.py index 7e5bc22d64..a7c1271483 100644 --- a/src/time/src/mcp_server_time/server.py +++ b/src/time/src/mcp_server_time/server.py @@ -30,6 +30,8 @@ from pydantic import BaseModel, Field from tzlocal import get_localzone_name # ← returns "Europe/Paris", etc. +from .transport import run + # The version this server reports in serverInfo, read from the installed # distribution's metadata (pyproject.toml) so it cannot drift from the # published version (#360). Without it the SDK reports its own `mcp` version. @@ -385,7 +387,7 @@ def get_time_ago( return server -async def serve(local_timezone: str | None = None) -> None: +async def serve(local_timezone: str | None = None, transport: str = "stdio") -> None: if local_timezone: # Fail before the transport opens, with one line naming the bad value # rather than a traceback. zoneinfo raises a different type per kind of @@ -399,9 +401,4 @@ async def serve(local_timezone: str | None = None) -> None: "not a known IANA timezone name" ) server = create_server(str(get_local_tz(local_timezone))) - # Both eras (#4853): the SDK's dual-era loop lets the client's first - # request decide. `initialize` gets the 2025-11-25 handshake; - # `server/discover` or a request carrying a 2026-07-28 envelope gets the - # modern, sessionless era, with its required result fields (resultType, - # ttlMs, cacheScope) filled in by the SDK. - await server.run_stdio_async() + await run(server, transport) diff --git a/src/time/src/mcp_server_time/transport.py b/src/time/src/mcp_server_time/transport.py new file mode 100644 index 0000000000..a1d7064e43 --- /dev/null +++ b/src/time/src/mcp_server_time/transport.py @@ -0,0 +1,89 @@ +"""How the time server is reached: stdio (the default) or Streamable HTTP (#576). + +`--transport streamable-http` serves the same server on one `/mcp` endpoint +through the SDK's Streamable HTTP app, which answers 2026-07-28 and 2025-era +clients alike. It listens on `HOST`:`PORT` from the environment, loopback:3001 +by default: the same variables, defaults and loopback-first posture as the +TypeScript servers. + +A browser page may reach it only from a localhost Origin, whatever `HOST` is, +as with the TypeScript servers' `localhostOriginValidation`. The SDK's own +DNS-rebinding protection checks Origin only when it binds loopback, and its +Host check cannot name the addresses of an interface `HOST` widens to, so the +Origin check is this module's middleware; on loopback the SDK's Host and +Origin checks still run behind it. +""" + +import os +from collections.abc import Mapping +from urllib.parse import urlsplit + +import uvicorn +from mcp.server.mcpserver import MCPServer +from starlette.datastructures import Headers +from starlette.responses import PlainTextResponse +from starlette.types import ASGIApp, Receive, Scope, Send + +TRANSPORTS = ("stdio", "streamable-http") +DEFAULT_HOST = "127.0.0.1" +DEFAULT_PORT = 3001 + + +def http_endpoint(env: Mapping[str, str] = os.environ) -> tuple[str, int]: + """The host and port to listen on: `HOST` and `PORT`, else the defaults.""" + host = env.get("HOST") or DEFAULT_HOST + raw = env.get("PORT") + if not raw: + return host, DEFAULT_PORT + if not raw.isascii() or not raw.isdigit() or int(raw) > 65535: + raise ValueError( + f"Invalid PORT {raw!r}: expected a whole number from 0 to 65535" + ) + return host, int(raw) + + +LOCALHOST_NAMES = ("localhost", "127.0.0.1", "::1") + + +def origin_allowed(origin: str | None) -> bool: + """Whether a request with this Origin may proceed: none (a non-browser + client), or one whose host is localhost, 127.0.0.1 or [::1].""" + if origin is None: + return True + try: + hostname = urlsplit(origin).hostname + except ValueError: + return False + return hostname in LOCALHOST_NAMES + + +class LocalhostOriginMiddleware: + """Answer an HTTP request from any other Origin with 403 before `app` sees it.""" + + def __init__(self, app: ASGIApp) -> None: + self.app = app + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + if scope["type"] == "http" and not origin_allowed( + Headers(scope=scope).get("origin") + ): + response = PlainTextResponse("Invalid Origin header", status_code=403) + await response(scope, receive, send) + return + await self.app(scope, receive, send) + + +async def run(server: MCPServer, transport: str) -> None: + """Serve `server` on `transport` until it is stopped.""" + if transport == "streamable-http": + host, port = http_endpoint() + app = LocalhostOriginMiddleware(server.streamable_http_app(host=host)) + config = uvicorn.Config(app, host=host, port=port) + await uvicorn.Server(config).serve() + else: + # Both eras (#4853): the SDK's dual-era loop lets the client's first + # request decide. `initialize` gets the 2025-11-25 handshake; + # `server/discover` or a request carrying a 2026-07-28 envelope gets + # the modern, sessionless era, with its required result fields + # (resultType, ttlMs, cacheScope) filled in by the SDK. + await server.run_stdio_async() diff --git a/src/time/tests/test_entrypoints.py b/src/time/tests/test_entrypoints.py index abf7d7799a..a16157c7a7 100644 --- a/src/time/tests/test_entrypoints.py +++ b/src/time/tests/test_entrypoints.py @@ -41,7 +41,7 @@ def test_main_passes_local_timezone_to_serve( patch.object(sys, "argv", ["mcp-server-time", *argv]), ): mcp_server_time.main() - serve.assert_awaited_once_with(expected_local_timezone) + serve.assert_awaited_once_with(expected_local_timezone, "stdio") def test_main_help_describes_the_server(capsys: pytest.CaptureFixture[str]) -> None: @@ -93,7 +93,7 @@ def test_init_module_run_as_main_calls_main() -> None: patch.object(sys, "argv", ["mcp-server-time", "--local-timezone", "UTC"]), ): runpy.run_module("mcp_server_time.__init__", run_name="__main__") - serve.assert_awaited_once_with("UTC") + serve.assert_awaited_once_with("UTC", "stdio") @pytest.fixture diff --git a/src/time/tests/test_http.py b/src/time/tests/test_http.py new file mode 100644 index 0000000000..b23866dcac --- /dev/null +++ b/src/time/tests/test_http.py @@ -0,0 +1,186 @@ +# The Streamable HTTP transport (#576): `serve(transport="streamable-http")` +# run in-process on a free loopback port and driven by the SDK `Client` over +# real HTTP in both protocol eras, plus `main()`'s `--transport` flag and +# `http_endpoint()`'s reading of HOST and PORT. + +import socket +import sys +from collections.abc import AsyncIterator +from contextlib import asynccontextmanager +from typing import Any +from unittest.mock import AsyncMock, patch + +import anyio +import pytest +from mcp import Client +from mcp.types import CallToolResult, TextContent + +import mcp_server_time +from mcp_server_time.server import serve +from mcp_server_time.transport import ( + DEFAULT_HOST, + DEFAULT_PORT, + LocalhostOriginMiddleware, + http_endpoint, + origin_allowed, +) + +ERAS = [ + pytest.param("2026-07-28", "2026-07-28", id="2026-07-28"), + pytest.param("legacy", "2025-11-25", id="2025-11-25"), +] + + +def free_port() -> int: + """A loopback port nothing is listening on right now.""" + with socket.socket() as sock: + sock.bind(("127.0.0.1", 0)) + return sock.getsockname()[1] + + +@asynccontextmanager +async def http_server(monkeypatch: pytest.MonkeyPatch) -> AsyncIterator[str]: + """Run `serve()` over Streamable HTTP and yield its URL once it answers.""" + port = free_port() + monkeypatch.setenv("HOST", "127.0.0.1") + monkeypatch.setenv("PORT", str(port)) + async with anyio.create_task_group() as tg: + tg.start_soon(serve, "UTC", "streamable-http") + with anyio.fail_after(10): + while True: + try: + await (await anyio.connect_tcp("127.0.0.1", port)).aclose() + break + except OSError: + await anyio.sleep(0.05) + yield f"http://127.0.0.1:{port}/mcp" + tg.cancel_scope.cancel() + + +@pytest.mark.parametrize(("mode", "negotiated"), ERAS) +async def test_serves_each_era_over_streamable_http( + monkeypatch: pytest.MonkeyPatch, mode: str, negotiated: str +) -> None: + async with http_server(monkeypatch) as url, Client(url, mode=mode) as client: + assert client.session.protocol_version == negotiated + result = await client.call_tool( + "convert_time", + { + "source_timezone": "UTC", + "time": "12:00", + "target_timezone": "Asia/Tokyo", + }, + ) + assert isinstance(result, CallToolResult) + assert not result.is_error + block = result.content[0] + assert isinstance(block, TextContent) + assert "Asia/Tokyo" in block.text + + +def test_http_endpoint_defaults_to_loopback() -> None: + assert http_endpoint({}) == (DEFAULT_HOST, DEFAULT_PORT) + + +def test_http_endpoint_reads_host_and_port() -> None: + assert http_endpoint({"HOST": "0.0.0.0", "PORT": "8080"}) == ("0.0.0.0", 8080) + + +@pytest.mark.parametrize("port", ["abc", "-1", "65536", "1.5", "٣"]) +def test_http_endpoint_refuses_a_bad_port(port: str) -> None: + with pytest.raises(ValueError, match="Invalid PORT"): + http_endpoint({"PORT": port}) + + +@pytest.mark.parametrize( + "argv,transport", + [ + ([], "stdio"), + (["--transport", "stdio"], "stdio"), + (["--transport", "streamable-http"], "streamable-http"), + ], +) +def test_main_passes_the_transport_to_serve( + monkeypatch: pytest.MonkeyPatch, argv: list[str], transport: str +) -> None: + monkeypatch.delenv("PORT", raising=False) + serve_mock = AsyncMock() + with ( + patch.object(mcp_server_time, "serve", serve_mock), + patch.object(sys, "argv", ["mcp-server-time", *argv]), + ): + mcp_server_time.main() + serve_mock.assert_awaited_once_with(None, transport) + + +@pytest.mark.parametrize( + "argv", [["--transport", "sse"], ["--transport", "streamable-http"]] +) +def test_main_refuses_an_unknown_transport_or_a_bad_port( + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture[str], + argv: list[str], +) -> None: + monkeypatch.setenv("PORT", "not-a-port") + serve_mock = AsyncMock() + with ( + patch.object(mcp_server_time, "serve", serve_mock), + patch.object(sys, "argv", ["mcp-server-time", *argv]), + pytest.raises(SystemExit) as exit_info, + ): + mcp_server_time.main() + assert exit_info.value.code == 2 + serve_mock.assert_not_awaited() + assert "error:" in capsys.readouterr().err + + +@pytest.mark.parametrize( + "origin,allowed", + [ + (None, True), + ("http://localhost:6274", True), + ("http://127.0.0.1", True), + ("http://[::1]:3000", True), + ("https://evil.example", False), + ("http://localhost.evil.example", False), + ("http://[::1", False), + ("null", False), + ], +) +def test_origin_allowed(origin: str | None, allowed: bool) -> None: + assert origin_allowed(origin) is allowed + + +async def test_middleware_refuses_a_foreign_origin_whatever_the_host() -> None: + """The check does not depend on the bind address, so it holds under HOST=0.0.0.0.""" + reached: list[str] = [] + + async def app(scope: Any, receive: Any, send: Any) -> None: + reached.append(scope["type"]) + + sent: list[Any] = [] + + async def send(message: Any) -> None: + sent.append(message) + + async def receive() -> Any: + return {"type": "http.request", "body": b"", "more_body": False} + + middleware = LocalhostOriginMiddleware(app) + foreign = { + "type": "http", + "method": "POST", + "path": "/mcp", + "headers": [ + (b"host", b"192.168.1.20:3001"), + (b"origin", b"https://evil.example"), + ], + } + await middleware(foreign, receive, send) + assert reached == [] + assert sent[0]["status"] == 403 + + local = {**foreign, "headers": [(b"origin", b"http://localhost:6274")]} + await middleware(local, receive, send) + await middleware({"type": "lifespan"}, receive, send) + assert reached == ["http", "lifespan"] diff --git a/src/time/uv.lock b/src/time/uv.lock index 1b60e2d802..4c4fc2bfd2 100644 --- a/src/time/uv.lock +++ b/src/time/uv.lock @@ -709,7 +709,7 @@ wheels = [ [[package]] name = "mcp-server-time" -version = "2026.11.11" +version = "2026.11.18" source = { editable = "." } dependencies = [ { name = "mcp" },