loremfile 0.3.1__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {loremfile-0.3.1 → loremfile-0.3.3}/PKG-INFO +10 -5
- {loremfile-0.3.1 → loremfile-0.3.3}/README.md +9 -4
- {loremfile-0.3.1 → loremfile-0.3.3}/pyproject.toml +1 -1
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile.egg-info/PKG-INFO +10 -5
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/__init__.py +1 -1
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/mcp.py +39 -10
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/tools.json +56 -12
- {loremfile-0.3.1 → loremfile-0.3.3}/tests/test_mcp.py +108 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/setup.cfg +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile.egg-info/SOURCES.txt +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile.egg-info/dependency_links.txt +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile.egg-info/entry_points.txt +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile.egg-info/top_level.txt +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/__main__.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/api.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/cli.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/src/loremfile_client/pytest_plugin.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/tests/test_commands.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/tests/test_only_loremfile_dev.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/tests/test_packaging.py +0 -0
- {loremfile-0.3.1 → loremfile-0.3.3}/tests/test_pytest_plugin.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: loremfile
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Download CC0 sample files from loremfile.dev and verify every byte
|
|
5
5
|
Author: the loremfile.dev contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -94,12 +94,17 @@ and they are the npm package's `npx loremfile mcp` tools, definition for definit
|
|
|
94
94
|
|
|
95
95
|
| Tool | Arguments | Returns |
|
|
96
96
|
|---|---|---|
|
|
97
|
-
| `list_fixtures` | `format`, `tag`, `max_bytes`, `limit`, `offset` | One page of
|
|
98
|
-
| `describe_fixture` | `path` (required) | One fixture's
|
|
97
|
+
| `list_fixtures` | `format`, `tag`, `max_bytes`, `limit`, `offset` | One page of fixtures in ascending path order, each with `path`, `url`, `format`, `mime`, `bytes`, `sha256`, `license`, `tags` and `description`, plus `total` and `next_offset`. `format` and `tag` accept a string or a list matched as any of. `limit` defaults to 50, at most 250. |
|
|
98
|
+
| `describe_fixture` | `path` (required) | One fixture's metadata, including the fields in a list row plus `size_class`, measured `props` and the catalog version that introduced it (`added_in`). |
|
|
99
99
|
| `verify_file` | `path` (required), `file` (required) | Whether the local `file` is the published `path`: `status` is `ok`, `changed` or `missing`, with both hashes and sizes. The file is read to hash it and goes nowhere. |
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
Omit `format` to discover the catalog keys in the results. The filter accepts `jpg`/`jpeg`,
|
|
102
|
+
`tif`/`tiff`, `htm`/`html` and `yml`/`yaml` interchangeably. `size_class` describes how the
|
|
103
|
+
byte count relates to the nominal size. `free` means the filename makes no size claim.
|
|
104
|
+
|
|
105
|
+
Fixtures are CC0 1.0 Universal (`CC0-1.0`). The bytes at each published fixture URL never
|
|
106
|
+
change. The manifest is read once per server process from loremfile.dev, under the same
|
|
107
|
+
rules as the commands above.
|
|
103
108
|
|
|
104
109
|
## What it will not do
|
|
105
110
|
|
|
@@ -74,12 +74,17 @@ and they are the npm package's `npx loremfile mcp` tools, definition for definit
|
|
|
74
74
|
|
|
75
75
|
| Tool | Arguments | Returns |
|
|
76
76
|
|---|---|---|
|
|
77
|
-
| `list_fixtures` | `format`, `tag`, `max_bytes`, `limit`, `offset` | One page of
|
|
78
|
-
| `describe_fixture` | `path` (required) | One fixture's
|
|
77
|
+
| `list_fixtures` | `format`, `tag`, `max_bytes`, `limit`, `offset` | One page of fixtures in ascending path order, each with `path`, `url`, `format`, `mime`, `bytes`, `sha256`, `license`, `tags` and `description`, plus `total` and `next_offset`. `format` and `tag` accept a string or a list matched as any of. `limit` defaults to 50, at most 250. |
|
|
78
|
+
| `describe_fixture` | `path` (required) | One fixture's metadata, including the fields in a list row plus `size_class`, measured `props` and the catalog version that introduced it (`added_in`). |
|
|
79
79
|
| `verify_file` | `path` (required), `file` (required) | Whether the local `file` is the published `path`: `status` is `ok`, `changed` or `missing`, with both hashes and sizes. The file is read to hash it and goes nowhere. |
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
Omit `format` to discover the catalog keys in the results. The filter accepts `jpg`/`jpeg`,
|
|
82
|
+
`tif`/`tiff`, `htm`/`html` and `yml`/`yaml` interchangeably. `size_class` describes how the
|
|
83
|
+
byte count relates to the nominal size. `free` means the filename makes no size claim.
|
|
84
|
+
|
|
85
|
+
Fixtures are CC0 1.0 Universal (`CC0-1.0`). The bytes at each published fixture URL never
|
|
86
|
+
change. The manifest is read once per server process from loremfile.dev, under the same
|
|
87
|
+
rules as the commands above.
|
|
83
88
|
|
|
84
89
|
## What it will not do
|
|
85
90
|
|
|
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "loremfile"
|
|
14
|
-
version = "0.3.
|
|
14
|
+
version = "0.3.3"
|
|
15
15
|
description = "Download CC0 sample files from loremfile.dev and verify every byte"
|
|
16
16
|
readme = "README.md"
|
|
17
17
|
# A range, and a policy: the floor is the oldest CPython still receiving security fixes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: loremfile
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Download CC0 sample files from loremfile.dev and verify every byte
|
|
5
5
|
Author: the loremfile.dev contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -94,12 +94,17 @@ and they are the npm package's `npx loremfile mcp` tools, definition for definit
|
|
|
94
94
|
|
|
95
95
|
| Tool | Arguments | Returns |
|
|
96
96
|
|---|---|---|
|
|
97
|
-
| `list_fixtures` | `format`, `tag`, `max_bytes`, `limit`, `offset` | One page of
|
|
98
|
-
| `describe_fixture` | `path` (required) | One fixture's
|
|
97
|
+
| `list_fixtures` | `format`, `tag`, `max_bytes`, `limit`, `offset` | One page of fixtures in ascending path order, each with `path`, `url`, `format`, `mime`, `bytes`, `sha256`, `license`, `tags` and `description`, plus `total` and `next_offset`. `format` and `tag` accept a string or a list matched as any of. `limit` defaults to 50, at most 250. |
|
|
98
|
+
| `describe_fixture` | `path` (required) | One fixture's metadata, including the fields in a list row plus `size_class`, measured `props` and the catalog version that introduced it (`added_in`). |
|
|
99
99
|
| `verify_file` | `path` (required), `file` (required) | Whether the local `file` is the published `path`: `status` is `ok`, `changed` or `missing`, with both hashes and sizes. The file is read to hash it and goes nowhere. |
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
Omit `format` to discover the catalog keys in the results. The filter accepts `jpg`/`jpeg`,
|
|
102
|
+
`tif`/`tiff`, `htm`/`html` and `yml`/`yaml` interchangeably. `size_class` describes how the
|
|
103
|
+
byte count relates to the nominal size. `free` means the filename makes no size claim.
|
|
104
|
+
|
|
105
|
+
Fixtures are CC0 1.0 Universal (`CC0-1.0`). The bytes at each published fixture URL never
|
|
106
|
+
change. The manifest is read once per server process from loremfile.dev, under the same
|
|
107
|
+
rules as the commands above.
|
|
103
108
|
|
|
104
109
|
## What it will not do
|
|
105
110
|
|
|
@@ -43,11 +43,26 @@ UNSUPPORTED_VERSION = -32022
|
|
|
43
43
|
|
|
44
44
|
SERVER_INFO = {"name": "loremfile", "version": __version__}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
46
|
+
FIXTURE_INSTRUCTIONS = (
|
|
47
|
+
"These tools return metadata for the test files published at loremfile.dev: URLs, sizes, "
|
|
48
|
+
"SHA-256 hashes and measured properties, never file contents. "
|
|
49
|
+
"Licence: https://loremfile.dev/legal/license."
|
|
50
50
|
)
|
|
51
|
+
STDIO_INSTRUCTIONS = "verify_file compares a local file with the published hash."
|
|
52
|
+
INSTRUCTIONS = f"{FIXTURE_INSTRUCTIONS} {STDIO_INSTRUCTIONS}"
|
|
53
|
+
|
|
54
|
+
FIXTURE_LICENSE = "CC0-1.0"
|
|
55
|
+
# The same extension pairs as site search. Keep the catalogue key in the result.
|
|
56
|
+
FORMAT_SYNONYMS = {
|
|
57
|
+
"jpg": "jpeg",
|
|
58
|
+
"jpeg": "jpg",
|
|
59
|
+
"tif": "tiff",
|
|
60
|
+
"tiff": "tif",
|
|
61
|
+
"htm": "html",
|
|
62
|
+
"html": "htm",
|
|
63
|
+
"yml": "yaml",
|
|
64
|
+
"yaml": "yml",
|
|
65
|
+
}
|
|
51
66
|
|
|
52
67
|
#: The tool surface, shared byte for byte with the npm client (tools.json in both trees),
|
|
53
68
|
#: and documented in client/README.md. Read-only tools, URLs and metadata only.
|
|
@@ -139,7 +154,9 @@ def _by_path(document: dict[str, Any], path: str) -> dict[str, Any]:
|
|
|
139
154
|
|
|
140
155
|
def list_fixtures(document: dict[str, Any], args: Any) -> dict[str, Any]: # noqa: ANN401
|
|
141
156
|
args = _only(args, ["format", "tag", "max_bytes", "limit", "offset"])
|
|
142
|
-
|
|
157
|
+
requested_formats = _strings(args.get("format", MISSING), "format")
|
|
158
|
+
formats = set(requested_formats)
|
|
159
|
+
formats.update(FORMAT_SYNONYMS.get(key, key) for key in requested_formats)
|
|
143
160
|
tags = _strings(args.get("tag", MISSING), "tag")
|
|
144
161
|
max_bytes = _integer(
|
|
145
162
|
args.get("max_bytes", MISSING), "max_bytes", low=0, high=None, fallback=None
|
|
@@ -148,9 +165,8 @@ def list_fixtures(document: dict[str, Any], args: Any) -> dict[str, Any]: # noq
|
|
|
148
165
|
args.get("limit", MISSING), "limit", low=1, high=MAX_LIMIT, fallback=DEFAULT_LIMIT
|
|
149
166
|
)
|
|
150
167
|
offset = _integer(args.get("offset", MISSING), "offset", low=0, high=None, fallback=0)
|
|
151
|
-
#
|
|
152
|
-
#
|
|
153
|
-
# verify_file still take one by path.
|
|
168
|
+
# Any of the formats, any of the tags, and the size ceiling. The sample.{format} aliases
|
|
169
|
+
# repeat another file's bytes and stay out; describe_fixture and verify_file take them by path.
|
|
154
170
|
matches = sorted(
|
|
155
171
|
(
|
|
156
172
|
e
|
|
@@ -177,6 +193,8 @@ def list_fixtures(document: dict[str, Any], args: Any) -> dict[str, Any]: # noq
|
|
|
177
193
|
"format": e["format"],
|
|
178
194
|
"mime": e["mime"],
|
|
179
195
|
"bytes": e["bytes"],
|
|
196
|
+
"sha256": e["sha256"],
|
|
197
|
+
"license": FIXTURE_LICENSE,
|
|
180
198
|
"tags": e.get("tags") or [],
|
|
181
199
|
"description": e.get("description") or "",
|
|
182
200
|
}
|
|
@@ -187,7 +205,17 @@ def list_fixtures(document: dict[str, Any], args: Any) -> dict[str, Any]: # noq
|
|
|
187
205
|
|
|
188
206
|
def describe_fixture(document: dict[str, Any], args: Any) -> dict[str, Any]: # noqa: ANN401
|
|
189
207
|
args = _only(args, ["path"])
|
|
190
|
-
|
|
208
|
+
path = args.get("path", MISSING)
|
|
209
|
+
if path is MISSING:
|
|
210
|
+
raise ToolError("path is required")
|
|
211
|
+
if not isinstance(path, str):
|
|
212
|
+
raise ToolError(f"path must be a string, not {_serialise(path)}")
|
|
213
|
+
if not path.strip():
|
|
214
|
+
raise ToolError(f"path must be a non-empty string, not {_serialise(path)}")
|
|
215
|
+
entry = _by_path(document, path)
|
|
216
|
+
props = entry.get("props")
|
|
217
|
+
if props is not None:
|
|
218
|
+
props = {key: value for key, value in props.items() if key != "format"}
|
|
191
219
|
return {
|
|
192
220
|
"catalog_version": str(document.get("catalog_version", "")),
|
|
193
221
|
"path": entry["path"],
|
|
@@ -196,10 +224,11 @@ def describe_fixture(document: dict[str, Any], args: Any) -> dict[str, Any]: #
|
|
|
196
224
|
"mime": entry["mime"],
|
|
197
225
|
"bytes": entry["bytes"],
|
|
198
226
|
"sha256": entry["sha256"],
|
|
227
|
+
"license": FIXTURE_LICENSE,
|
|
199
228
|
"size_class": entry.get("size_class"),
|
|
200
229
|
"tags": entry.get("tags") or [],
|
|
201
230
|
"description": entry.get("description") or "",
|
|
202
|
-
"props":
|
|
231
|
+
"props": props,
|
|
203
232
|
"added_in": entry.get("added_in"),
|
|
204
233
|
}
|
|
205
234
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{
|
|
3
3
|
"name": "list_fixtures",
|
|
4
4
|
"title": "List loremfile.dev fixtures",
|
|
5
|
-
"description": "One page of
|
|
5
|
+
"description": "One page of published CC0 sample files in ascending path order, filtered by format, tag and maximum byte count. Reads fixture metadata over the network. Each row includes the URL, SHA-256 and a description. `total` counts every match. Use `next_offset` for the next page. It is null on the last page.",
|
|
6
6
|
"inputSchema": {
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
|
-
"description": "Formats to include, any of, e.g. [\"pdf\", \"png\"]."
|
|
21
|
+
"description": "Formats to include, any of, e.g. [\"pdf\", \"png\"]. Extension synonyms are jpg/jpeg, tif/tiff, htm/html and yml/yaml. Omit format to list all formats, with the catalogue key in each row's format field."
|
|
22
22
|
},
|
|
23
23
|
"tag": {
|
|
24
24
|
"anyOf": [
|
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"type": "string"
|
|
92
92
|
},
|
|
93
93
|
"format": {
|
|
94
|
-
"type": "string"
|
|
94
|
+
"type": "string",
|
|
95
|
+
"description": "Catalogue format key, e.g. jpg."
|
|
95
96
|
},
|
|
96
97
|
"mime": {
|
|
97
98
|
"type": "string"
|
|
@@ -99,6 +100,15 @@
|
|
|
99
100
|
"bytes": {
|
|
100
101
|
"type": "integer"
|
|
101
102
|
},
|
|
103
|
+
"sha256": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"description": "Published SHA-256 of the fixture bytes, as 64 lowercase hexadecimal characters."
|
|
106
|
+
},
|
|
107
|
+
"license": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"const": "CC0-1.0",
|
|
110
|
+
"description": "CC0 1.0 Universal public domain dedication."
|
|
111
|
+
},
|
|
102
112
|
"tags": {
|
|
103
113
|
"type": "array",
|
|
104
114
|
"items": {
|
|
@@ -115,6 +125,8 @@
|
|
|
115
125
|
"format",
|
|
116
126
|
"mime",
|
|
117
127
|
"bytes",
|
|
128
|
+
"sha256",
|
|
129
|
+
"license",
|
|
118
130
|
"tags",
|
|
119
131
|
"description"
|
|
120
132
|
]
|
|
@@ -135,13 +147,13 @@
|
|
|
135
147
|
"readOnlyHint": true,
|
|
136
148
|
"destructiveHint": false,
|
|
137
149
|
"idempotentHint": true,
|
|
138
|
-
"openWorldHint":
|
|
150
|
+
"openWorldHint": true
|
|
139
151
|
}
|
|
140
152
|
},
|
|
141
153
|
{
|
|
142
154
|
"name": "describe_fixture",
|
|
143
155
|
"title": "Describe one loremfile.dev fixture",
|
|
144
|
-
"description": "
|
|
156
|
+
"description": "Published metadata for one CC0 fixture, including its URL, MIME type, byte count, SHA-256, tags, description and measured properties. Reads fixture metadata over the network. Fetch the URL for the file.",
|
|
145
157
|
"inputSchema": {
|
|
146
158
|
"type": "object",
|
|
147
159
|
"properties": {
|
|
@@ -168,7 +180,8 @@
|
|
|
168
180
|
"type": "string"
|
|
169
181
|
},
|
|
170
182
|
"format": {
|
|
171
|
-
"type": "string"
|
|
183
|
+
"type": "string",
|
|
184
|
+
"description": "Catalogue format key, e.g. jpg. Use it to filter list_fixtures."
|
|
172
185
|
},
|
|
173
186
|
"mime": {
|
|
174
187
|
"type": "string"
|
|
@@ -179,11 +192,17 @@
|
|
|
179
192
|
"sha256": {
|
|
180
193
|
"type": "string"
|
|
181
194
|
},
|
|
195
|
+
"license": {
|
|
196
|
+
"type": "string",
|
|
197
|
+
"const": "CC0-1.0",
|
|
198
|
+
"description": "CC0 1.0 Universal public domain dedication."
|
|
199
|
+
},
|
|
182
200
|
"size_class": {
|
|
183
201
|
"type": [
|
|
184
202
|
"string",
|
|
185
203
|
"null"
|
|
186
|
-
]
|
|
204
|
+
],
|
|
205
|
+
"description": "How the byte count relates to the nominal size. exact means equal, boundary means exactly one byte above or below, approx means within 5%, and free means the filename makes no size claim. Null if unrecorded."
|
|
187
206
|
},
|
|
188
207
|
"tags": {
|
|
189
208
|
"type": "array",
|
|
@@ -198,13 +217,37 @@
|
|
|
198
217
|
"type": [
|
|
199
218
|
"object",
|
|
200
219
|
"null"
|
|
201
|
-
]
|
|
220
|
+
],
|
|
221
|
+
"description": "Properties measured from the fixture bytes. Keys depend on the format and may be absent. Null if no properties are recorded. See https://loremfile.dev/docs/manifest for format-specific keys.",
|
|
222
|
+
"properties": {
|
|
223
|
+
"pages": {
|
|
224
|
+
"type": "integer",
|
|
225
|
+
"description": "Page count for a PDF, or number of page records in a HAR log."
|
|
226
|
+
},
|
|
227
|
+
"width": {
|
|
228
|
+
"type": ["number", "string", "null"],
|
|
229
|
+
"description": "Measured width in pixels for raster images and media, including embedded artwork where reported. SVG may record its width attribute or null."
|
|
230
|
+
},
|
|
231
|
+
"height": {
|
|
232
|
+
"type": ["number", "string", "null"],
|
|
233
|
+
"description": "Measured height in pixels for raster images and media, including embedded artwork where reported. SVG may record its height attribute or null."
|
|
234
|
+
},
|
|
235
|
+
"duration_ms": {
|
|
236
|
+
"type": "integer",
|
|
237
|
+
"description": "Measured audio or video duration in milliseconds."
|
|
238
|
+
},
|
|
239
|
+
"rows": {
|
|
240
|
+
"type": "integer",
|
|
241
|
+
"description": "Measured row count. The format determines which rows are included."
|
|
242
|
+
}
|
|
243
|
+
}
|
|
202
244
|
},
|
|
203
245
|
"added_in": {
|
|
204
246
|
"type": [
|
|
205
247
|
"string",
|
|
206
248
|
"null"
|
|
207
|
-
]
|
|
249
|
+
],
|
|
250
|
+
"description": "Catalogue version that first published the fixture. Null if unrecorded."
|
|
208
251
|
}
|
|
209
252
|
},
|
|
210
253
|
"required": [
|
|
@@ -215,6 +258,7 @@
|
|
|
215
258
|
"mime",
|
|
216
259
|
"bytes",
|
|
217
260
|
"sha256",
|
|
261
|
+
"license",
|
|
218
262
|
"size_class",
|
|
219
263
|
"tags",
|
|
220
264
|
"description",
|
|
@@ -226,13 +270,13 @@
|
|
|
226
270
|
"readOnlyHint": true,
|
|
227
271
|
"destructiveHint": false,
|
|
228
272
|
"idempotentHint": true,
|
|
229
|
-
"openWorldHint":
|
|
273
|
+
"openWorldHint": true
|
|
230
274
|
}
|
|
231
275
|
},
|
|
232
276
|
{
|
|
233
277
|
"name": "verify_file",
|
|
234
278
|
"title": "Verify a local copy of a loremfile.dev fixture",
|
|
235
|
-
"description": "Hash a file on this machine and compare it with the published SHA-256 and size of a fixture. `status` is ok, changed or missing. The file is read only to hash it.",
|
|
279
|
+
"description": "Hash a file on this machine and compare it with the published SHA-256 and size of a fixture. Reads the published manifest over the network. `status` is ok, changed or missing. The file is read only to hash it.",
|
|
236
280
|
"inputSchema": {
|
|
237
281
|
"type": "object",
|
|
238
282
|
"properties": {
|
|
@@ -301,7 +345,7 @@
|
|
|
301
345
|
"readOnlyHint": true,
|
|
302
346
|
"destructiveHint": false,
|
|
303
347
|
"idempotentHint": true,
|
|
304
|
-
"openWorldHint":
|
|
348
|
+
"openWorldHint": true
|
|
305
349
|
}
|
|
306
350
|
}
|
|
307
351
|
]
|
|
@@ -10,7 +10,9 @@ import os
|
|
|
10
10
|
import re
|
|
11
11
|
import subprocess
|
|
12
12
|
import sys
|
|
13
|
+
import urllib.error
|
|
13
14
|
from collections.abc import Iterator
|
|
15
|
+
from hashlib import sha256
|
|
14
16
|
from pathlib import Path
|
|
15
17
|
from typing import Any
|
|
16
18
|
|
|
@@ -144,6 +146,8 @@ def test_a_2026_07_28_client_discovers_the_server_and_lists_the_documented_tools
|
|
|
144
146
|
assert discovered["supportedVersions"] == [mcp.MODERN, mcp.LEGACY]
|
|
145
147
|
assert discovered["capabilities"] == {"tools": {}}
|
|
146
148
|
assert discovered["_meta"][f"{mcp.META}serverInfo"]["name"] == "loremfile"
|
|
149
|
+
assert "https://loremfile.dev/legal/license" in discovered["instructions"]
|
|
150
|
+
assert "verify_file compares" in discovered["instructions"]
|
|
147
151
|
listed = child.modern("tools/list")["result"]
|
|
148
152
|
assert (listed["resultType"], listed["cacheScope"]) == ("complete", "public")
|
|
149
153
|
assert surface(listed["tools"]) == documented()
|
|
@@ -176,6 +180,67 @@ def test_the_paging_bounds_the_schema_advertises_are_the_ones_enforced() -> None
|
|
|
176
180
|
assert (limit["default"], limit["maximum"]) == (mcp.DEFAULT_LIMIT, mcp.MAX_LIMIT)
|
|
177
181
|
|
|
178
182
|
|
|
183
|
+
def assert_manifest_annotations(
|
|
184
|
+
tools: list[dict[str, Any]], monkeypatch: pytest.MonkeyPatch
|
|
185
|
+
) -> None:
|
|
186
|
+
"""Follow the default api.manifest loader to its transport without sending a request.
|
|
187
|
+
|
|
188
|
+
Deliberately strict: every tool ``tools/list`` advertises must attempt the manifest
|
|
189
|
+
fetch. A tool that genuinely needs no network fails here, and that is the point.
|
|
190
|
+
Declaring one closed-world is then a decision taken on purpose, in this guard, and
|
|
191
|
+
not a default.
|
|
192
|
+
"""
|
|
193
|
+
requests = []
|
|
194
|
+
|
|
195
|
+
def block(request, **_kwargs):
|
|
196
|
+
requests.append(request.full_url)
|
|
197
|
+
raise urllib.error.URLError("manifest network probe")
|
|
198
|
+
|
|
199
|
+
with monkeypatch.context() as patch:
|
|
200
|
+
patch.delenv(api.OVERRIDE, raising=False)
|
|
201
|
+
patch.setattr(api.urllib.request, "urlopen", block)
|
|
202
|
+
for tool in tools:
|
|
203
|
+
requests.clear()
|
|
204
|
+
# A fresh server defeats the cache. Dispatch loads before validating args.
|
|
205
|
+
reply = mcp.Server().handle(
|
|
206
|
+
{
|
|
207
|
+
"jsonrpc": "2.0",
|
|
208
|
+
"id": 1,
|
|
209
|
+
"method": "tools/call",
|
|
210
|
+
"params": {"name": tool["name"], "arguments": {}, "_meta": META},
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
assert requests == [f"{api.BASE_URL}manifest.json"], tool["name"]
|
|
214
|
+
assert reply["result"]["isError"] is True, tool["name"]
|
|
215
|
+
assert "manifest network probe" in reply["result"]["content"][0]["text"]
|
|
216
|
+
assert tool["annotations"]["openWorldHint"] is True, (
|
|
217
|
+
f"{tool['name']}: manifest network access requires openWorldHint: true"
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def test_manifest_fetching_tool_handlers_declare_an_open_world(
|
|
222
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
223
|
+
) -> None:
|
|
224
|
+
"""An annotation is a published claim about behaviour, and a scanner will check it."""
|
|
225
|
+
reply = mcp.Server().handle(
|
|
226
|
+
{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {"_meta": META}}
|
|
227
|
+
)
|
|
228
|
+
tools = reply["result"]["tools"]
|
|
229
|
+
assert any(tool["name"] == "verify_file" for tool in tools), (
|
|
230
|
+
"control: discovery finds verify_file"
|
|
231
|
+
)
|
|
232
|
+
assert_manifest_annotations(tools, monkeypatch)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def test_the_manifest_annotation_guard_rejects_each_closed_world_declaration(
|
|
236
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
237
|
+
) -> None:
|
|
238
|
+
for tool in mcp.TOOLS:
|
|
239
|
+
closed = {**tool, "annotations": {**tool["annotations"], "openWorldHint": False}}
|
|
240
|
+
with pytest.raises(AssertionError, match="manifest network access requires openWorldHint"):
|
|
241
|
+
assert_manifest_annotations([closed], monkeypatch)
|
|
242
|
+
|
|
243
|
+
|
|
179
244
|
# --- versions and malformed requests: each guard, watched firing ------------------------
|
|
180
245
|
|
|
181
246
|
|
|
@@ -226,6 +291,9 @@ def test_list_fixtures_pages_and_says_where_it_is(child: Client, server: str) ->
|
|
|
226
291
|
assert (every["limit"], every["next_offset"]) == (mcp.DEFAULT_LIMIT, None)
|
|
227
292
|
assert [f["path"] for f in every["fixtures"]] == sorted(BODIES)
|
|
228
293
|
assert every["fixtures"][0]["url"] == f"{server}{sorted(BODIES)[0]}"
|
|
294
|
+
for row in every["fixtures"]:
|
|
295
|
+
assert row["sha256"] == sha256(BODIES[row["path"]]).hexdigest()
|
|
296
|
+
assert row["license"] == "CC0-1.0"
|
|
229
297
|
first = child.call("list_fixtures", {"limit": 3})["structuredContent"]
|
|
230
298
|
assert (first["count"], first["next_offset"], first["total"]) == (3, 3, 4)
|
|
231
299
|
last = child.call("list_fixtures", {"limit": 3, "offset": 3})["structuredContent"]
|
|
@@ -254,6 +322,27 @@ def test_list_fixtures_filters_as_loremfile_list_does(child: Client) -> None:
|
|
|
254
322
|
assert paths({"limit": 2.0}) == ["pdf/other.pdf", "pdf/small.pdf"], "50.0 is 50, as in JS"
|
|
255
323
|
|
|
256
324
|
|
|
325
|
+
def test_format_synonyms_and_describe_use_the_catalog_key() -> None:
|
|
326
|
+
path = "jpg/example.jpg"
|
|
327
|
+
entry = {
|
|
328
|
+
"path": path,
|
|
329
|
+
"format": "jpg",
|
|
330
|
+
"mime": "image/jpeg",
|
|
331
|
+
"bytes": 100,
|
|
332
|
+
"sha256": "0" * 64,
|
|
333
|
+
"props": {"format": "jpeg", "width": 1, "height": 1},
|
|
334
|
+
}
|
|
335
|
+
catalog = {"fixtures": [entry]}
|
|
336
|
+
page = mcp.list_fixtures(catalog, {"format": ["jpeg", "jpg"]})
|
|
337
|
+
assert page["total"] == 1
|
|
338
|
+
assert page == mcp.list_fixtures(catalog, {"format": "jpeg"})
|
|
339
|
+
assert page["fixtures"][0]["format"] == "jpg"
|
|
340
|
+
described = mcp.describe_fixture(catalog, {"path": path})
|
|
341
|
+
assert described["format"] == "jpg"
|
|
342
|
+
assert described["props"] == {"width": 1, "height": 1}
|
|
343
|
+
assert entry["props"]["format"] == "jpeg"
|
|
344
|
+
|
|
345
|
+
|
|
257
346
|
@pytest.mark.parametrize(
|
|
258
347
|
"arguments",
|
|
259
348
|
[
|
|
@@ -285,12 +374,31 @@ def test_describe_fixture_returns_the_entry_and_names_a_path_it_does_not_know(
|
|
|
285
374
|
assert entry["url"] == f"{server}pdf/small.pdf"
|
|
286
375
|
assert entry["catalog_version"] == "9.9.9"
|
|
287
376
|
assert re.fullmatch(r"[0-9a-f]{64}", entry["sha256"])
|
|
377
|
+
assert entry["license"] == "CC0-1.0"
|
|
288
378
|
for path in ("pdf/nope.pdf", "pdf/withdrawn.pdf"):
|
|
289
379
|
missing = child.call("describe_fixture", {"path": path})
|
|
290
380
|
assert missing["isError"] is True
|
|
291
381
|
assert path in missing["content"][0]["text"]
|
|
292
382
|
|
|
293
383
|
|
|
384
|
+
@pytest.mark.parametrize(
|
|
385
|
+
("arguments", "message"),
|
|
386
|
+
[
|
|
387
|
+
({}, "path is required"),
|
|
388
|
+
({"path": ""}, 'path must be a non-empty string, not ""'),
|
|
389
|
+
({"path": " "}, 'path must be a non-empty string, not " "'),
|
|
390
|
+
({"path": 123}, "path must be a string, not 123"),
|
|
391
|
+
({"path": None}, "path must be a string, not null"),
|
|
392
|
+
],
|
|
393
|
+
)
|
|
394
|
+
def test_describe_fixture_explains_invalid_paths(
|
|
395
|
+
child: Client, arguments: dict[str, Any], message: str
|
|
396
|
+
) -> None:
|
|
397
|
+
response = child.call("describe_fixture", arguments)
|
|
398
|
+
assert response["isError"] is True
|
|
399
|
+
assert response["content"][0]["text"] == message
|
|
400
|
+
|
|
401
|
+
|
|
294
402
|
def test_verify_file_reports_ok_changed_and_missing(child: Client, tmp_path: Path) -> None:
|
|
295
403
|
good = tmp_path / "small.pdf"
|
|
296
404
|
good.write_bytes(BODIES["pdf/small.pdf"])
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|