dependencyproof-mcp 0.1.1__py3-none-any.whl
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.
- dependencyproof/__init__.py +3 -0
- dependencyproof/__main__.py +46 -0
- dependencyproof/core.py +713 -0
- dependencyproof/server.py +35 -0
- dependencyproof_mcp-0.1.1.dist-info/METADATA +215 -0
- dependencyproof_mcp-0.1.1.dist-info/RECORD +10 -0
- dependencyproof_mcp-0.1.1.dist-info/WHEEL +5 -0
- dependencyproof_mcp-0.1.1.dist-info/entry_points.txt +3 -0
- dependencyproof_mcp-0.1.1.dist-info/licenses/LICENSE +21 -0
- dependencyproof_mcp-0.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Read a single structured review request from stdin; no implicit file access."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import sys
|
|
6
|
+
from .core import review, InputError, strict_json, MAX_BYTES
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main():
|
|
10
|
+
parser = argparse.ArgumentParser(
|
|
11
|
+
description="DependencyProof: verify explicit offline dependency evidence from JSON stdin."
|
|
12
|
+
)
|
|
13
|
+
parser.add_argument(
|
|
14
|
+
"--fail-on-contradiction",
|
|
15
|
+
action="store_true",
|
|
16
|
+
help="Exit 1 when supplied claims or observations contradict evidence.",
|
|
17
|
+
)
|
|
18
|
+
args = parser.parse_args()
|
|
19
|
+
try:
|
|
20
|
+
raw = sys.stdin.buffer.read(MAX_BYTES + 1)
|
|
21
|
+
if len(raw) > MAX_BYTES:
|
|
22
|
+
raise InputError("CLI request exceeds 256 KiB")
|
|
23
|
+
request = strict_json(raw.decode("utf-8"))
|
|
24
|
+
if (
|
|
25
|
+
not isinstance(request, dict)
|
|
26
|
+
or not {"manifest", "format"} <= request.keys()
|
|
27
|
+
or set(request)
|
|
28
|
+
- {"manifest", "format", "imports", "metadata", "claims", "local_modules"}
|
|
29
|
+
):
|
|
30
|
+
raise InputError("Invalid review request keys")
|
|
31
|
+
result = review(**request)
|
|
32
|
+
print(json.dumps(result, indent=2, ensure_ascii=True))
|
|
33
|
+
return int(
|
|
34
|
+
args.fail_on_contradiction
|
|
35
|
+
and any(
|
|
36
|
+
f["status"] == "contradicted"
|
|
37
|
+
for f in result["claims"] + result["findings"]
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
except (InputError, UnicodeError) as e:
|
|
41
|
+
print(json.dumps({"error": str(e)}, ensure_ascii=True), file=sys.stderr)
|
|
42
|
+
return 2
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
raise SystemExit(main())
|
dependencyproof/core.py
ADDED
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
"""Review explicitly supplied manifest, source and package metadata only."""
|
|
2
|
+
|
|
3
|
+
import ast
|
|
4
|
+
import json
|
|
5
|
+
import re
|
|
6
|
+
import sys
|
|
7
|
+
import tomllib
|
|
8
|
+
from collections import defaultdict
|
|
9
|
+
from typing import Any
|
|
10
|
+
from packaging.requirements import Requirement, InvalidRequirement
|
|
11
|
+
from packaging.utils import canonicalize_name
|
|
12
|
+
from packaging.version import Version, InvalidVersion
|
|
13
|
+
|
|
14
|
+
MAX_BYTES = 256 * 1024
|
|
15
|
+
MAX_ITEMS = 300
|
|
16
|
+
MAX_FINDINGS = 300
|
|
17
|
+
JS_PACKAGE = re.compile(r"^(?:@[a-zA-Z0-9._~-]+/)?[a-zA-Z0-9._~-]+$")
|
|
18
|
+
PY_NAME = re.compile(r"^[a-zA-Z0-9](?:[a-zA-Z0-9._-]*[a-zA-Z0-9])?$")
|
|
19
|
+
JS_EXACT = re.compile(r"^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)$")
|
|
20
|
+
JS_IMPORT = re.compile(
|
|
21
|
+
r"""^\s*(?:import\s+(?:[^'";]+?\s+from\s+)?|export\s+[^'";]+?\s+from\s+)(?P<q>['"])(?P<module>[^'"]+)(?P=q)\s*;?\s*$"""
|
|
22
|
+
)
|
|
23
|
+
JS_REQUIRE = re.compile(
|
|
24
|
+
r"""^\s*(?:const|let|var)\s+[\w$]+\s*=\s*require\(\s*(?P<q>['"])(?P<module>[^'"]+)(?P=q)\s*\)\s*;?\s*$"""
|
|
25
|
+
)
|
|
26
|
+
NODE_BUILTINS = frozenset(
|
|
27
|
+
"assert async_hooks buffer child_process cluster console constants crypto dgram diagnostics_channel dns domain events fs http http2 https module net os path perf_hooks process punycode querystring readline repl stream string_decoder sys timers tls trace_events tty url util v8 vm wasi worker_threads zlib".split()
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class InputError(ValueError):
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def bounded(text: str, name: str) -> str:
|
|
36
|
+
if not isinstance(text, str) or len(text) > MAX_BYTES:
|
|
37
|
+
raise InputError(f"{name} must be UTF-8 text within {MAX_BYTES} bytes")
|
|
38
|
+
try:
|
|
39
|
+
size = len(text.encode("utf-8"))
|
|
40
|
+
except UnicodeError as exc:
|
|
41
|
+
raise InputError(f"{name} is not valid UTF-8") from exc
|
|
42
|
+
if size > MAX_BYTES or text.count("\n") > 10000:
|
|
43
|
+
raise InputError(f"{name} exceeds supported bounds")
|
|
44
|
+
return text
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def limited_list(value, name):
|
|
48
|
+
if not isinstance(value, list) or len(value) > MAX_ITEMS:
|
|
49
|
+
raise InputError(f"{name} must be a list with at most {MAX_ITEMS} entries")
|
|
50
|
+
return value
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def strict_json(text):
|
|
54
|
+
def object_hook(pairs):
|
|
55
|
+
result = {}
|
|
56
|
+
for k, v in pairs:
|
|
57
|
+
if k in result:
|
|
58
|
+
raise InputError("Duplicate JSON object key")
|
|
59
|
+
result[k] = v
|
|
60
|
+
return result
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
return json.loads(
|
|
64
|
+
bounded(text, "JSON"),
|
|
65
|
+
object_pairs_hook=object_hook,
|
|
66
|
+
parse_constant=lambda _: (_ for _ in ()).throw(
|
|
67
|
+
InputError("Nonfinite JSON number")
|
|
68
|
+
),
|
|
69
|
+
)
|
|
70
|
+
except InputError:
|
|
71
|
+
raise
|
|
72
|
+
except (ValueError, RecursionError) as e:
|
|
73
|
+
raise InputError("Invalid JSON manifest") from e
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def normalize(name, ecosystem):
|
|
77
|
+
if not isinstance(name, str) or len(name) > 214:
|
|
78
|
+
raise InputError("Invalid package name")
|
|
79
|
+
if ecosystem == "python" and PY_NAME.fullmatch(name):
|
|
80
|
+
return canonicalize_name(name)
|
|
81
|
+
if ecosystem == "npm" and JS_PACKAGE.fullmatch(name):
|
|
82
|
+
return name
|
|
83
|
+
raise InputError(f"Invalid {ecosystem} package name")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def observation(
|
|
87
|
+
code, status, message, action, *, name=None, location=None, detail=None
|
|
88
|
+
):
|
|
89
|
+
return {
|
|
90
|
+
"code": code,
|
|
91
|
+
"status": status,
|
|
92
|
+
"name": name,
|
|
93
|
+
"location": location,
|
|
94
|
+
"message": message,
|
|
95
|
+
"action": action,
|
|
96
|
+
"detail": detail,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def parse_npm(text):
|
|
101
|
+
raw = strict_json(text)
|
|
102
|
+
if not isinstance(raw, dict):
|
|
103
|
+
raise InputError("package.json must be an object")
|
|
104
|
+
declarations = []
|
|
105
|
+
for section in (
|
|
106
|
+
"dependencies",
|
|
107
|
+
"devDependencies",
|
|
108
|
+
"peerDependencies",
|
|
109
|
+
"optionalDependencies",
|
|
110
|
+
):
|
|
111
|
+
table = raw.get(section, {})
|
|
112
|
+
if not isinstance(table, dict):
|
|
113
|
+
raise InputError(f"{section} must be an object")
|
|
114
|
+
for name, constraint in table.items():
|
|
115
|
+
name = normalize(name, "npm")
|
|
116
|
+
if not isinstance(constraint, str) or not 1 <= len(constraint) <= 500:
|
|
117
|
+
raise InputError(f"Invalid dependency spec for {name}")
|
|
118
|
+
declarations.append(
|
|
119
|
+
dict(
|
|
120
|
+
name=name,
|
|
121
|
+
constraint=constraint,
|
|
122
|
+
section=section,
|
|
123
|
+
location=f"package.json:{section}.{name}",
|
|
124
|
+
conditional=False,
|
|
125
|
+
extras=[],
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
if len(declarations) > MAX_ITEMS:
|
|
129
|
+
raise InputError("Too many dependencies")
|
|
130
|
+
scripts = raw.get("scripts", {})
|
|
131
|
+
if not isinstance(scripts, dict) or any(
|
|
132
|
+
not isinstance(v, str) for v in scripts.values()
|
|
133
|
+
):
|
|
134
|
+
raise InputError("scripts must map names to strings")
|
|
135
|
+
return declarations, raw, []
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _requirement(spec, section, location):
|
|
139
|
+
try:
|
|
140
|
+
req = Requirement(spec)
|
|
141
|
+
except InvalidRequirement:
|
|
142
|
+
return None, observation(
|
|
143
|
+
"UNSUPPORTED_REQUIREMENT",
|
|
144
|
+
"unknown",
|
|
145
|
+
"Requirement could not be interpreted as PEP 508.",
|
|
146
|
+
"Supply a standard PEP 508 requirement or confirm the installer-specific syntax.",
|
|
147
|
+
location=location,
|
|
148
|
+
)
|
|
149
|
+
# Never follow direct URLs or evaluate markers; they are metadata only.
|
|
150
|
+
return (
|
|
151
|
+
dict(
|
|
152
|
+
name=normalize(req.name, "python"),
|
|
153
|
+
constraint=str(req.specifier),
|
|
154
|
+
section=section,
|
|
155
|
+
location=location,
|
|
156
|
+
conditional=bool(req.marker),
|
|
157
|
+
extras=sorted(req.extras),
|
|
158
|
+
direct_reference=bool(req.url),
|
|
159
|
+
),
|
|
160
|
+
None,
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def parse_requirements(text):
|
|
165
|
+
declarations = []
|
|
166
|
+
findings = []
|
|
167
|
+
for line_no, line in enumerate(bounded(text, "requirements").splitlines(), 1):
|
|
168
|
+
line = line.strip()
|
|
169
|
+
if not line or line.startswith("#"):
|
|
170
|
+
continue
|
|
171
|
+
line = re.split(r"\s+#", line, maxsplit=1)[0]
|
|
172
|
+
# Do not follow includes, credentials, URLs or installer flags.
|
|
173
|
+
if line.startswith("-") or line.endswith("\\") or " --" in line:
|
|
174
|
+
findings.append(
|
|
175
|
+
observation(
|
|
176
|
+
"INSTALLER_DIRECTIVE",
|
|
177
|
+
"unknown",
|
|
178
|
+
"Installer-specific directive is not followed.",
|
|
179
|
+
"Supply resolved requirement text without flags, includes or continuations.",
|
|
180
|
+
location=f"requirements:{line_no}",
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
continue
|
|
184
|
+
item, issue = _requirement(line, "requirements", f"requirements:{line_no}")
|
|
185
|
+
if item:
|
|
186
|
+
declarations.append(item)
|
|
187
|
+
else:
|
|
188
|
+
findings.append(issue)
|
|
189
|
+
if len(declarations) > MAX_ITEMS or len(findings) > MAX_ITEMS:
|
|
190
|
+
raise InputError("Too many requirement records")
|
|
191
|
+
return declarations, {}, findings
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def parse_pyproject(text):
|
|
195
|
+
try:
|
|
196
|
+
raw = tomllib.loads(bounded(text, "pyproject"))
|
|
197
|
+
except (tomllib.TOMLDecodeError, RecursionError) as e:
|
|
198
|
+
raise InputError("Invalid pyproject TOML") from e
|
|
199
|
+
project = raw.get("project", {})
|
|
200
|
+
if not isinstance(project, dict):
|
|
201
|
+
raise InputError("[project] must be a table")
|
|
202
|
+
sections = [("project.dependencies", project.get("dependencies", []))]
|
|
203
|
+
optional = project.get("optional-dependencies", {})
|
|
204
|
+
if not isinstance(optional, dict):
|
|
205
|
+
raise InputError("optional-dependencies must be a table")
|
|
206
|
+
sections += [(f"project.optional-dependencies.{k}", v) for k, v in optional.items()]
|
|
207
|
+
declarations = []
|
|
208
|
+
findings = []
|
|
209
|
+
for section, items in sections:
|
|
210
|
+
if not isinstance(items, list) or any(not isinstance(x, str) for x in items):
|
|
211
|
+
raise InputError(f"{section} must contain requirement strings")
|
|
212
|
+
for index, spec in enumerate(items, 1):
|
|
213
|
+
item, issue = _requirement(spec, section, f"pyproject:{section}[{index}]")
|
|
214
|
+
if item:
|
|
215
|
+
declarations.append(item)
|
|
216
|
+
else:
|
|
217
|
+
findings.append(issue)
|
|
218
|
+
dynamic = project.get("dynamic", [])
|
|
219
|
+
tools = raw.get("tool", {})
|
|
220
|
+
if not isinstance(dynamic, list) or not isinstance(tools, dict):
|
|
221
|
+
raise InputError("Invalid project.dynamic or tool table")
|
|
222
|
+
if (
|
|
223
|
+
"dependencies" in dynamic
|
|
224
|
+
or "optional-dependencies" in dynamic
|
|
225
|
+
or "poetry" in tools
|
|
226
|
+
or "dependency-groups" in raw
|
|
227
|
+
):
|
|
228
|
+
findings.append(
|
|
229
|
+
observation(
|
|
230
|
+
"UNRESOLVED_PYPROJECT",
|
|
231
|
+
"unknown",
|
|
232
|
+
"Additional or dynamic dependency declarations may exist.",
|
|
233
|
+
"Supply resolved PEP 508 dependency text for those declarations separately.",
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
if len(declarations) > MAX_ITEMS or len(findings) > MAX_ITEMS:
|
|
237
|
+
raise InputError("Too many project requirements")
|
|
238
|
+
return declarations, raw, findings
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def package_from_spec(spec):
|
|
242
|
+
if spec.startswith(("./", "../", "/", "#", "file:")):
|
|
243
|
+
return None, "local"
|
|
244
|
+
if spec.startswith("node:"):
|
|
245
|
+
part = spec[5:].split("/")[0]
|
|
246
|
+
return (
|
|
247
|
+
(None, "builtin")
|
|
248
|
+
if part in NODE_BUILTINS or spec in ("node:test", "node:sqlite")
|
|
249
|
+
else (None, "unknown")
|
|
250
|
+
)
|
|
251
|
+
if ":" in spec:
|
|
252
|
+
return None, "unknown"
|
|
253
|
+
parts = spec.split("/")
|
|
254
|
+
if parts[0] in NODE_BUILTINS:
|
|
255
|
+
return None, "builtin"
|
|
256
|
+
name = "/".join(parts[:2]) if spec.startswith("@") else parts[0]
|
|
257
|
+
if not JS_PACKAGE.fullmatch(name):
|
|
258
|
+
return None, "unknown"
|
|
259
|
+
return name, "package"
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def parse_imports(source, ecosystem):
|
|
263
|
+
source = bounded(source, "imports")
|
|
264
|
+
result = []
|
|
265
|
+
findings = []
|
|
266
|
+
if ecosystem == "python":
|
|
267
|
+
try:
|
|
268
|
+
tree = ast.parse(source)
|
|
269
|
+
except (SyntaxError, RecursionError) as e:
|
|
270
|
+
return [], [
|
|
271
|
+
observation(
|
|
272
|
+
"IMPORT_SOURCE_SYNTAX",
|
|
273
|
+
"unknown",
|
|
274
|
+
"Supplied Python text could not be parsed.",
|
|
275
|
+
"Supply valid complete source or syntactically complete import statements.",
|
|
276
|
+
location=f"imports:{getattr(e,'lineno',None) or '?'}",
|
|
277
|
+
)
|
|
278
|
+
]
|
|
279
|
+
for node in ast.walk(tree):
|
|
280
|
+
if isinstance(node, ast.Import):
|
|
281
|
+
result.extend(
|
|
282
|
+
(alias.name.split(".")[0], "absolute", node.lineno)
|
|
283
|
+
for alias in node.names
|
|
284
|
+
)
|
|
285
|
+
elif isinstance(node, ast.ImportFrom):
|
|
286
|
+
if node.level:
|
|
287
|
+
result.append((node.module or ".", "local", node.lineno))
|
|
288
|
+
elif node.module:
|
|
289
|
+
result.append((node.module.split(".")[0], "absolute", node.lineno))
|
|
290
|
+
else:
|
|
291
|
+
for number, line in enumerate(source.splitlines(), 1):
|
|
292
|
+
if not line.strip() or line.strip().startswith("//"):
|
|
293
|
+
continue
|
|
294
|
+
match = JS_IMPORT.fullmatch(line) or JS_REQUIRE.fullmatch(line)
|
|
295
|
+
if not match:
|
|
296
|
+
findings.append(
|
|
297
|
+
observation(
|
|
298
|
+
"UNPARSED_IMPORT_STATEMENT",
|
|
299
|
+
"unknown",
|
|
300
|
+
"Statement is outside the supported static import syntax.",
|
|
301
|
+
"Supply a standalone ES import/export-from or simple require assignment.",
|
|
302
|
+
location=f"imports:{number}",
|
|
303
|
+
)
|
|
304
|
+
)
|
|
305
|
+
continue
|
|
306
|
+
spec = match.group("module")
|
|
307
|
+
name, kind = package_from_spec(spec)
|
|
308
|
+
result.append((name or spec, kind, number))
|
|
309
|
+
if len(result) > MAX_ITEMS or len(findings) > MAX_ITEMS:
|
|
310
|
+
raise InputError("Too many import records")
|
|
311
|
+
return sorted(result, key=lambda item: item[2]), findings
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def parse_metadata(rows, ecosystem):
|
|
315
|
+
result = {}
|
|
316
|
+
for row in limited_list(rows, "metadata"):
|
|
317
|
+
if not isinstance(row, dict) or set(row) - {
|
|
318
|
+
"name",
|
|
319
|
+
"versions",
|
|
320
|
+
"import_names",
|
|
321
|
+
"provenance",
|
|
322
|
+
}:
|
|
323
|
+
raise InputError("Invalid metadata record")
|
|
324
|
+
name = normalize(row.get("name"), ecosystem)
|
|
325
|
+
if name in result:
|
|
326
|
+
raise InputError("Repeated metadata package")
|
|
327
|
+
versions = limited_list(row.get("versions", []), "versions")
|
|
328
|
+
imports = limited_list(row.get("import_names", []), "import_names")
|
|
329
|
+
if any(not isinstance(v, str) or not 1 <= len(v) <= 128 for v in versions):
|
|
330
|
+
raise InputError("Invalid version metadata")
|
|
331
|
+
if any(
|
|
332
|
+
not isinstance(v, str) or not v.isidentifier() or len(v) > 128
|
|
333
|
+
for v in imports
|
|
334
|
+
):
|
|
335
|
+
raise InputError("Invalid Python import mapping")
|
|
336
|
+
provenance = row.get("provenance", "caller-supplied")
|
|
337
|
+
if not isinstance(provenance, str) or len(provenance) > 200:
|
|
338
|
+
raise InputError("Invalid provenance label")
|
|
339
|
+
result[name] = {
|
|
340
|
+
"versions": list(dict.fromkeys(versions)),
|
|
341
|
+
"import_names": list(dict.fromkeys(imports)),
|
|
342
|
+
"provenance": provenance,
|
|
343
|
+
}
|
|
344
|
+
return result
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def satisfies(declaration, version, ecosystem):
|
|
348
|
+
if ecosystem == "npm":
|
|
349
|
+
spec = declaration["constraint"]
|
|
350
|
+
if JS_EXACT.fullmatch(spec) and JS_EXACT.fullmatch(version):
|
|
351
|
+
return version == spec
|
|
352
|
+
return None
|
|
353
|
+
if declaration.get("direct_reference") or declaration["conditional"]:
|
|
354
|
+
return None
|
|
355
|
+
try:
|
|
356
|
+
return Requirement(
|
|
357
|
+
declaration["name"] + declaration["constraint"]
|
|
358
|
+
).specifier.contains(Version(version), prereleases=None)
|
|
359
|
+
except (InvalidRequirement, InvalidVersion):
|
|
360
|
+
return None
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def _equal_config(left, right):
|
|
364
|
+
stack = [(left, right)]
|
|
365
|
+
while stack:
|
|
366
|
+
a, b = stack.pop()
|
|
367
|
+
if type(a) is not type(b):
|
|
368
|
+
return False
|
|
369
|
+
if isinstance(a, list):
|
|
370
|
+
if len(a) != len(b):
|
|
371
|
+
return False
|
|
372
|
+
stack.extend(zip(a, b))
|
|
373
|
+
elif isinstance(a, dict):
|
|
374
|
+
if a.keys() != b.keys():
|
|
375
|
+
return False
|
|
376
|
+
stack.extend((a[k], b[k]) for k in a)
|
|
377
|
+
elif a != b:
|
|
378
|
+
return False
|
|
379
|
+
return True
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def _resolve_config(raw, path):
|
|
383
|
+
value = raw
|
|
384
|
+
for part in path:
|
|
385
|
+
if not isinstance(value, dict) or part not in value:
|
|
386
|
+
return False, None
|
|
387
|
+
value = value[part]
|
|
388
|
+
return True, value
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def review(
|
|
392
|
+
manifest: str,
|
|
393
|
+
format: str,
|
|
394
|
+
imports: str = "",
|
|
395
|
+
metadata: list[dict] | None = None,
|
|
396
|
+
claims: list[dict] | None = None,
|
|
397
|
+
local_modules: list[str] | None = None,
|
|
398
|
+
) -> dict[str, Any]:
|
|
399
|
+
try:
|
|
400
|
+
if (
|
|
401
|
+
len(
|
|
402
|
+
json.dumps(
|
|
403
|
+
[metadata, claims, local_modules],
|
|
404
|
+
ensure_ascii=True,
|
|
405
|
+
allow_nan=False,
|
|
406
|
+
)
|
|
407
|
+
)
|
|
408
|
+
> MAX_BYTES * 4
|
|
409
|
+
):
|
|
410
|
+
raise InputError("Auxiliary evidence exceeds supported bounds")
|
|
411
|
+
except (TypeError, ValueError, RecursionError) as e:
|
|
412
|
+
raise InputError("Invalid or overlarge auxiliary evidence") from e
|
|
413
|
+
if not isinstance(format, str) or format not in {
|
|
414
|
+
"package.json",
|
|
415
|
+
"requirements.txt",
|
|
416
|
+
"pyproject.toml",
|
|
417
|
+
}:
|
|
418
|
+
raise InputError("Invalid manifest format")
|
|
419
|
+
ecosystem = "npm" if format == "package.json" else "python"
|
|
420
|
+
declarations, raw, findings = {
|
|
421
|
+
"package.json": parse_npm,
|
|
422
|
+
"requirements.txt": parse_requirements,
|
|
423
|
+
"pyproject.toml": parse_pyproject,
|
|
424
|
+
}[format](manifest)
|
|
425
|
+
incomplete = any(f["status"] == "unknown" for f in findings)
|
|
426
|
+
observed = defaultdict(list)
|
|
427
|
+
for item in declarations:
|
|
428
|
+
observed[item["name"]].append(item)
|
|
429
|
+
catalog = parse_metadata([] if metadata is None else metadata, ecosystem)
|
|
430
|
+
local = set()
|
|
431
|
+
for value in limited_list(
|
|
432
|
+
[] if local_modules is None else local_modules, "local_modules"
|
|
433
|
+
):
|
|
434
|
+
if not isinstance(value, str) or len(value) > 214:
|
|
435
|
+
raise InputError("Invalid local module label")
|
|
436
|
+
local.add(value)
|
|
437
|
+
mappings = defaultdict(set)
|
|
438
|
+
for name, meta in catalog.items():
|
|
439
|
+
for imp in meta["import_names"]:
|
|
440
|
+
mappings[imp].add(name)
|
|
441
|
+
import_rows, import_issues = parse_imports(imports, ecosystem)
|
|
442
|
+
findings.extend(import_issues)
|
|
443
|
+
imports_result = []
|
|
444
|
+
for spec, kind, line in import_rows:
|
|
445
|
+
location = f"imports:{line}"
|
|
446
|
+
resolved = []
|
|
447
|
+
if kind == "local" or spec in local:
|
|
448
|
+
status = "local"
|
|
449
|
+
elif (
|
|
450
|
+
kind == "builtin"
|
|
451
|
+
or ecosystem == "python"
|
|
452
|
+
and spec in sys.stdlib_module_names
|
|
453
|
+
):
|
|
454
|
+
status = "stdlib_or_builtin"
|
|
455
|
+
elif ecosystem == "npm" and kind == "package":
|
|
456
|
+
resolved = [spec]
|
|
457
|
+
status = (
|
|
458
|
+
"declared"
|
|
459
|
+
if spec in observed
|
|
460
|
+
else (
|
|
461
|
+
"unknown_manifest_incomplete"
|
|
462
|
+
if incomplete
|
|
463
|
+
else "missing_declaration"
|
|
464
|
+
)
|
|
465
|
+
)
|
|
466
|
+
elif ecosystem == "python" and kind == "absolute":
|
|
467
|
+
resolved = sorted(mappings.get(spec, []))
|
|
468
|
+
if len(resolved) == 1:
|
|
469
|
+
status = (
|
|
470
|
+
"declared"
|
|
471
|
+
if resolved[0] in observed
|
|
472
|
+
else (
|
|
473
|
+
"unknown_manifest_incomplete"
|
|
474
|
+
if incomplete
|
|
475
|
+
else "missing_declaration"
|
|
476
|
+
)
|
|
477
|
+
)
|
|
478
|
+
elif len(resolved) > 1:
|
|
479
|
+
status = "unknown_ambiguous_mapping"
|
|
480
|
+
else:
|
|
481
|
+
status = "unknown_import_mapping"
|
|
482
|
+
else:
|
|
483
|
+
status = "unknown_import_kind"
|
|
484
|
+
imports_result.append(
|
|
485
|
+
dict(import_name=spec, status=status, packages=resolved, location=location)
|
|
486
|
+
)
|
|
487
|
+
if status == "missing_declaration":
|
|
488
|
+
findings.append(
|
|
489
|
+
observation(
|
|
490
|
+
"MISSING_DECLARATION",
|
|
491
|
+
"contradicted",
|
|
492
|
+
"Observed import maps to a package not declared in the supplied manifest.",
|
|
493
|
+
"Confirm whether it is intentionally external, transitive or optional; declare it only after verifying the package.",
|
|
494
|
+
name=resolved[0],
|
|
495
|
+
location=location,
|
|
496
|
+
)
|
|
497
|
+
)
|
|
498
|
+
elif status.startswith("unknown"):
|
|
499
|
+
findings.append(
|
|
500
|
+
observation(
|
|
501
|
+
"UNRESOLVED_IMPORT",
|
|
502
|
+
"unknown",
|
|
503
|
+
"Import could not be resolved against the supplied evidence.",
|
|
504
|
+
"Provide explicit import-to-distribution mapping or local-module information; do not guess a package name.",
|
|
505
|
+
name=spec,
|
|
506
|
+
location=location,
|
|
507
|
+
)
|
|
508
|
+
)
|
|
509
|
+
# Detect definite mismatch of exact unconditional specs, never infer intersection of arbitrary ranges.
|
|
510
|
+
for name, group in observed.items():
|
|
511
|
+
if ecosystem == "npm":
|
|
512
|
+
exact = {
|
|
513
|
+
x["constraint"] for x in group if JS_EXACT.fullmatch(x["constraint"])
|
|
514
|
+
}
|
|
515
|
+
else:
|
|
516
|
+
exact = set()
|
|
517
|
+
for x in group:
|
|
518
|
+
if (
|
|
519
|
+
x["conditional"]
|
|
520
|
+
or x.get("direct_reference")
|
|
521
|
+
or x["section"].startswith("project.optional-dependencies.")
|
|
522
|
+
):
|
|
523
|
+
continue
|
|
524
|
+
try:
|
|
525
|
+
req = Requirement(name + x["constraint"])
|
|
526
|
+
if len(req.specifier) == 1:
|
|
527
|
+
sp = next(iter(req.specifier))
|
|
528
|
+
if (
|
|
529
|
+
sp.operator == "=="
|
|
530
|
+
and "*" not in sp.version
|
|
531
|
+
and Version(sp.version).local is None
|
|
532
|
+
):
|
|
533
|
+
exact.add(Version(sp.version))
|
|
534
|
+
except (InvalidRequirement, InvalidVersion):
|
|
535
|
+
pass
|
|
536
|
+
if len(exact) > 1:
|
|
537
|
+
findings.append(
|
|
538
|
+
observation(
|
|
539
|
+
"CONFLICTING_EXACT_DECLARATIONS",
|
|
540
|
+
"contradicted" if ecosystem == "python" else "warning",
|
|
541
|
+
"Multiple different exact versions are declared; check whether their contexts can coexist.",
|
|
542
|
+
"Reconcile the declaration contexts and verify the intended dependency version.",
|
|
543
|
+
name=name,
|
|
544
|
+
detail={
|
|
545
|
+
"declarations": [
|
|
546
|
+
{"section": x["section"], "constraint": x["constraint"]}
|
|
547
|
+
for x in group
|
|
548
|
+
]
|
|
549
|
+
},
|
|
550
|
+
)
|
|
551
|
+
)
|
|
552
|
+
claims_result = []
|
|
553
|
+
for idx, claim in enumerate(
|
|
554
|
+
limited_list([] if claims is None else claims, "claims"), 1
|
|
555
|
+
):
|
|
556
|
+
if not isinstance(claim, dict):
|
|
557
|
+
raise InputError("Claim must be an object")
|
|
558
|
+
kind = claim.get("kind")
|
|
559
|
+
loc = f"claims:{idx}"
|
|
560
|
+
if kind == "dependency":
|
|
561
|
+
if set(claim) - {"kind", "name", "section", "constraint", "version"}:
|
|
562
|
+
raise InputError("Unexpected dependency claim field")
|
|
563
|
+
name = normalize(claim.get("name"), ecosystem)
|
|
564
|
+
section = claim.get("section")
|
|
565
|
+
constraint = claim.get("constraint")
|
|
566
|
+
version = claim.get("version")
|
|
567
|
+
if any(
|
|
568
|
+
x is not None and (not isinstance(x, str) or len(x) > 500)
|
|
569
|
+
for x in [section, constraint, version]
|
|
570
|
+
):
|
|
571
|
+
raise InputError("Invalid dependency claim values")
|
|
572
|
+
group = [
|
|
573
|
+
x
|
|
574
|
+
for x in observed.get(name, [])
|
|
575
|
+
if section is None or section == x["section"]
|
|
576
|
+
]
|
|
577
|
+
if not group:
|
|
578
|
+
status = "unknown" if incomplete else "contradicted"
|
|
579
|
+
code = "DECLARATION_NOT_FOUND"
|
|
580
|
+
message = (
|
|
581
|
+
"Claimed declaration is absent from the supplied manifest scope."
|
|
582
|
+
)
|
|
583
|
+
elif constraint is not None and not any(
|
|
584
|
+
x["constraint"] == constraint for x in group
|
|
585
|
+
):
|
|
586
|
+
status = "contradicted"
|
|
587
|
+
code = "DECLARATION_TEXT_MISMATCH"
|
|
588
|
+
message = "Claimed constraint text does not match declaration."
|
|
589
|
+
else:
|
|
590
|
+
status = "supported"
|
|
591
|
+
code = "DECLARATION_FOUND"
|
|
592
|
+
message = "Declaration is present in supplied text."
|
|
593
|
+
item = observation(
|
|
594
|
+
code,
|
|
595
|
+
status,
|
|
596
|
+
message,
|
|
597
|
+
"Use the manifest declaration as evidence; verify dependency behavior separately.",
|
|
598
|
+
name=name,
|
|
599
|
+
location=loc,
|
|
600
|
+
)
|
|
601
|
+
if version is not None:
|
|
602
|
+
meta = catalog.get(name)
|
|
603
|
+
checks = [satisfies(x, version, ecosystem) for x in group]
|
|
604
|
+
mandatory_mismatch = ecosystem == "python" and any(
|
|
605
|
+
result is False
|
|
606
|
+
and (
|
|
607
|
+
section is not None
|
|
608
|
+
or not x["section"].startswith("project.optional-dependencies.")
|
|
609
|
+
)
|
|
610
|
+
for x, result in zip(group, checks)
|
|
611
|
+
)
|
|
612
|
+
item["detail"] = {
|
|
613
|
+
"declaration_status": status,
|
|
614
|
+
"requested_version": version,
|
|
615
|
+
"metadata_status": (
|
|
616
|
+
"listed"
|
|
617
|
+
if meta and version in meta["versions"]
|
|
618
|
+
else "unknown_not_listed"
|
|
619
|
+
),
|
|
620
|
+
"constraint_status": (
|
|
621
|
+
"contradicted"
|
|
622
|
+
if mandatory_mismatch
|
|
623
|
+
or checks
|
|
624
|
+
and all(x is False for x in checks)
|
|
625
|
+
else (
|
|
626
|
+
"supported"
|
|
627
|
+
if checks and all(x is True for x in checks)
|
|
628
|
+
else "unknown"
|
|
629
|
+
)
|
|
630
|
+
),
|
|
631
|
+
"provenance": meta["provenance"] if meta else None,
|
|
632
|
+
}
|
|
633
|
+
detail = item["detail"]
|
|
634
|
+
if (
|
|
635
|
+
status == "contradicted"
|
|
636
|
+
or detail["constraint_status"] == "contradicted"
|
|
637
|
+
):
|
|
638
|
+
item.update(
|
|
639
|
+
status="contradicted",
|
|
640
|
+
message="Declaration or version constraint contradicts the supplied claim.",
|
|
641
|
+
)
|
|
642
|
+
elif (
|
|
643
|
+
status != "supported"
|
|
644
|
+
or detail["constraint_status"] != "supported"
|
|
645
|
+
or detail["metadata_status"] != "listed"
|
|
646
|
+
):
|
|
647
|
+
item.update(
|
|
648
|
+
status="unknown",
|
|
649
|
+
message="Version cannot be fully verified from supplied declaration and metadata.",
|
|
650
|
+
)
|
|
651
|
+
else:
|
|
652
|
+
item.update(
|
|
653
|
+
message="Version is listed in supplied metadata and matches the declaration constraint."
|
|
654
|
+
)
|
|
655
|
+
claims_result.append(item)
|
|
656
|
+
elif kind == "config":
|
|
657
|
+
if set(claim) - {"kind", "path", "expected"}:
|
|
658
|
+
raise InputError("Unexpected config claim field")
|
|
659
|
+
path = claim.get("path")
|
|
660
|
+
if (
|
|
661
|
+
not isinstance(path, list)
|
|
662
|
+
or not 1 <= len(path) <= 10
|
|
663
|
+
or any(not isinstance(x, str) or len(x) > 200 for x in path)
|
|
664
|
+
):
|
|
665
|
+
raise InputError("Config path must be a short array of object keys")
|
|
666
|
+
if format == "requirements.txt":
|
|
667
|
+
status = "unknown"
|
|
668
|
+
message = "Requirements text has no config object."
|
|
669
|
+
else:
|
|
670
|
+
exists, actual = _resolve_config(raw, path)
|
|
671
|
+
if not exists:
|
|
672
|
+
status = "contradicted"
|
|
673
|
+
message = "Config key is absent from supplied document."
|
|
674
|
+
elif "expected" in claim and not _equal_config(
|
|
675
|
+
actual, claim["expected"]
|
|
676
|
+
):
|
|
677
|
+
status = "contradicted"
|
|
678
|
+
message = "Config value differs from supplied expectation."
|
|
679
|
+
else:
|
|
680
|
+
status = "supported"
|
|
681
|
+
message = (
|
|
682
|
+
"Config key or expected value exists in supplied document."
|
|
683
|
+
)
|
|
684
|
+
claims_result.append(
|
|
685
|
+
observation(
|
|
686
|
+
"CONFIG_CLAIM",
|
|
687
|
+
status,
|
|
688
|
+
message,
|
|
689
|
+
"Check relevant official documentation separately for semantic validity.",
|
|
690
|
+
location=loc,
|
|
691
|
+
detail={"path": path},
|
|
692
|
+
)
|
|
693
|
+
)
|
|
694
|
+
else:
|
|
695
|
+
raise InputError("Unsupported claim kind")
|
|
696
|
+
return dict(
|
|
697
|
+
ecosystem=ecosystem,
|
|
698
|
+
manifest_format=format,
|
|
699
|
+
declarations=declarations,
|
|
700
|
+
imports=imports_result,
|
|
701
|
+
claims=claims_result,
|
|
702
|
+
findings=findings[:MAX_FINDINGS],
|
|
703
|
+
omitted_findings=max(0, len(findings) - MAX_FINDINGS),
|
|
704
|
+
limitations=[
|
|
705
|
+
"Only supplied text and caller metadata were reviewed; no registry or installed environment checked.",
|
|
706
|
+
"A listed metadata version is evidence only about the supplied list, not actual availability.",
|
|
707
|
+
"Python distribution mapping requires explicit caller metadata; stdlib classification uses this runtime's module list.",
|
|
708
|
+
"JavaScript import extraction supports simple standalone static statements; ranges other than plain exact stable numeric versions are unknown.",
|
|
709
|
+
"Python markers, direct references, optional group selection and arbitrary range intersections are not resolved.",
|
|
710
|
+
"Node builtin classification uses a fixed name list, not a target-version runtime check.",
|
|
711
|
+
"Configuration claims validate presence/value only, not whether a framework supports a config or API.",
|
|
712
|
+
],
|
|
713
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Official local stdio MCP server."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal
|
|
4
|
+
from mcp.server.fastmcp import FastMCP
|
|
5
|
+
from mcp.types import ToolAnnotations
|
|
6
|
+
from .core import review
|
|
7
|
+
|
|
8
|
+
mcp = FastMCP(
|
|
9
|
+
"dependencyproof-mcp",
|
|
10
|
+
instructions="Check only supplied dependency declarations, import text and caller evidence. Do not infer registry availability or validate APIs. No file, network or command operations.",
|
|
11
|
+
)
|
|
12
|
+
READ_ONLY = ToolAnnotations(
|
|
13
|
+
readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=False
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@mcp.tool(annotations=READ_ONLY, structured_output=True)
|
|
18
|
+
def verify_dependencies(
|
|
19
|
+
manifest: str,
|
|
20
|
+
format: Literal["package.json", "requirements.txt", "pyproject.toml"],
|
|
21
|
+
imports: str = "",
|
|
22
|
+
metadata: list[dict[str, Any]] | None = None,
|
|
23
|
+
claims: list[dict[str, Any]] | None = None,
|
|
24
|
+
local_modules: list[str] | None = None,
|
|
25
|
+
) -> dict[str, Any]:
|
|
26
|
+
"""Compare explicit declarations and import statements against supplied metadata and claims; unresolved evidence remains unknown."""
|
|
27
|
+
return review(manifest, format, imports, metadata, claims, local_modules)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def main():
|
|
31
|
+
mcp.run(transport="stdio")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if __name__ == "__main__":
|
|
35
|
+
main()
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dependencyproof-mcp
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Offline verification of explicit dependency, import and configuration claims.
|
|
5
|
+
Author: Ahmed Saeed
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/ahmedsaeed1-eng/dependencyproof-mcp
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: mcp==1.29.0
|
|
12
|
+
Requires-Dist: packaging<27,>=24
|
|
13
|
+
Provides-Extra: test
|
|
14
|
+
Requires-Dist: hypothesis<7,>=6; extra == "test"
|
|
15
|
+
Requires-Dist: ruff==0.17.6; extra == "test"
|
|
16
|
+
Requires-Dist: black==26.10.1; extra == "test"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# DependencyProof MCP
|
|
20
|
+
|
|
21
|
+
<!-- mcp-name: io.github.ahmedsaeed1-eng/dependencyproof-mcp -->
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
**Do not install a package or trust a configuration just because an assistant suggested it. Verify the evidence first.**
|
|
26
|
+
|
|
27
|
+
[](pyproject.toml)
|
|
28
|
+
[](tests/)
|
|
29
|
+
[](https://github.com/ahmedsaeed1-eng/dependencyproof-mcp/actions/workflows/ci.yml)
|
|
30
|
+
[](https://github.com/ahmedsaeed1-eng/dependencyproof-mcp/stargazers)
|
|
31
|
+
|
|
32
|
+
[](pyproject.toml)
|
|
33
|
+
[](https://modelcontextprotocol.io/)
|
|
34
|
+
[](#evidence-boundary)
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
|
|
37
|
+
DependencyProof is a local evidence checker for coding agents and human reviewers. It compares explicit dependency declarations, imports, version observations and configuration claims. It is not a registry client. A missing record in a caller-provided version list never proves that a version does not exist.
|
|
38
|
+
|
|
39
|
+
The focus is motivated by developer feedback on generated code and dependency/configuration errors in the [2026 Stack Overflow Developer Survey — technology disruption data](https://survey.stackoverflow.co/2026/technology/data/disruption). This independent project does not claim to solve every hallucination or verify live package/API availability.
|
|
40
|
+
|
|
41
|
+
## Evidence ledger
|
|
42
|
+
|
|
43
|
+
| Verdict | Meaning |
|
|
44
|
+
|:--|:--|
|
|
45
|
+
| **supported** | The claim matches the explicit supplied declaration or observed metadata. This is not live verification. |
|
|
46
|
+
| **contradicted** | The supplied evidence has a definite declaration/value mismatch, or a supported version predicate fails. |
|
|
47
|
+
| **unknown** | Evidence or parser coverage is insufficient; do not invent an answer. |
|
|
48
|
+
| **warning** | Review a possible conflict; deployment or dependency context may affect it. |
|
|
49
|
+
|
|
50
|
+
The example npm review uses invented package names and illustrative metadata, not real registry records.
|
|
51
|
+
|
|
52
|
+
| Claim | Supplied evidence | Result |
|
|
53
|
+
|:--|:--|:--|
|
|
54
|
+
| example-ui at 1.2.0 | exact declaration and listed version | supported |
|
|
55
|
+
| example-ui at 1.3.0 | declared 1.2.0, metadata lists 1.3.0 | contradicted |
|
|
56
|
+
| example-router at 3.1.0 | declared ^3.0.0; no npm range parser | unknown |
|
|
57
|
+
| scripts.build exists | absent from supplied package.json | contradicted |
|
|
58
|
+
|
|
59
|
+
See [npm example input](examples/npm-request.json) and [Python example input](examples/python-request.json).
|
|
60
|
+
|
|
61
|
+
## Install and connect
|
|
62
|
+
|
|
63
|
+
Python 3.11 or newer is required for the standard-library TOML parser.
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
git clone https://github.com/ahmedsaeed1-eng/dependencyproof-mcp.git
|
|
67
|
+
cd dependencyproof-mcp
|
|
68
|
+
python -m pip install .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Installation uses the package manager; the MCP server itself never installs anything, invokes external commands or accesses a network.
|
|
72
|
+
|
|
73
|
+
### Codex
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
codex mcp add dependencyproof -- dependencyproof-mcp
|
|
77
|
+
codex mcp list
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If the entry point is not on PATH, use the absolute path of the Python interpreter in the environment containing this project:
|
|
81
|
+
|
|
82
|
+
```toml
|
|
83
|
+
[mcp_servers.dependencyproof]
|
|
84
|
+
command = "/absolute/path/to/python"
|
|
85
|
+
args = ["-m", "dependencyproof.server"]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Claude Desktop
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"dependencyproof": {
|
|
94
|
+
"command": "/absolute/path/to/python",
|
|
95
|
+
"args": ["-m", "dependencyproof.server"]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
These are configuration examples; check the host's current MCP settings. The included protocol test uses the official MCP client, not a live Codex or Claude host.
|
|
102
|
+
|
|
103
|
+
### Standalone CLI
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
dependencyproof < examples/npm-request.json
|
|
107
|
+
dependencyproof --fail-on-contradiction < examples/python-request.json
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
From the checkout with dependencies installed, use `python -m dependencyproof` as an alternative. The CLI accepts explicit request JSON on stdin and returns a JSON report on stdout. Exit codes: 0 (report produced), 1 (contradicted evidence, when the flag is enabled), 2 (invalid request). Unknowns are not counted as verified.
|
|
111
|
+
|
|
112
|
+
## MCP tool: verify_dependencies
|
|
113
|
+
|
|
114
|
+
| Argument | Purpose |
|
|
115
|
+
|:--|:--|
|
|
116
|
+
| format | package.json, requirements.txt, or pyproject.toml |
|
|
117
|
+
| manifest | Complete manifest text in the chosen format |
|
|
118
|
+
| imports | Python source/import statements or simple standalone JavaScript static statements; optional |
|
|
119
|
+
| metadata | Caller-provided package information; optional |
|
|
120
|
+
| claims | Explicit assertions to compare against supplied data; optional |
|
|
121
|
+
| local_modules | Explicit local/workspace module names that should not be treated as external dependencies; optional |
|
|
122
|
+
|
|
123
|
+
### Claim and metadata examples
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"format":"requirements.txt",
|
|
128
|
+
"manifest":"Pillow==10.4.0",
|
|
129
|
+
"imports":"import PIL",
|
|
130
|
+
"metadata":[
|
|
131
|
+
{
|
|
132
|
+
"name":"Pillow",
|
|
133
|
+
"versions":["10.4.0"],
|
|
134
|
+
"import_names":["PIL"],
|
|
135
|
+
"provenance":"caller-supplied metadata"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"claims":[
|
|
139
|
+
{"kind":"dependency","name":"Pillow","version":"10.4.0"}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The manifest declares a distribution named Pillow, whereas the import is PIL. Python imports are not assumed to share their distribution names. Only a supplied mapping can connect the two; otherwise the import is unresolved. Names are classified against the Python runtime's standard-library names or explicitly supplied local module labels.
|
|
145
|
+
|
|
146
|
+
A dependency claim may add:
|
|
147
|
+
|
|
148
|
+
- `section`: exact manifest section or declaration group name.
|
|
149
|
+
- `constraint`: expected declaration string. Python specifiers are represented using PyPA's parsed specifier string; npm constraints remain verbatim. This check is string equality, not mathematical range equivalence.
|
|
150
|
+
- `version`: requested version. Status is supported only when that exact version appears in caller metadata and the supported constraint check passes. Contradiction comes from the manifest predicate, never absence from nonexhaustive metadata. Multiple mandatory Python constraints are checked conjunctively. Conditional requirements and direct references remain unresolved.
|
|
151
|
+
|
|
152
|
+
A config claim uses a path of object/table keys and optionally an expected JSON value:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{"kind":"config","path":["scripts","test"],"expected":"node --test"}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
This checks key/value presence in the supplied manifest. It cannot determine whether a particular framework actually recognizes or supports that key.
|
|
159
|
+
|
|
160
|
+
### Coverage by ecosystem
|
|
161
|
+
|
|
162
|
+
| Check | npm | Python |
|
|
163
|
+
|:--|:--|:--|
|
|
164
|
+
| Declared dependencies | dependencies, devDependencies, peerDependencies, optionalDependencies | PEP 508 requirements and PEP 621 project dependencies/optional groups |
|
|
165
|
+
| Imports | standalone static import, export-from, simple require assignment | built-in AST, including relative imports |
|
|
166
|
+
| Versions | plain stable exact numeric versions only | PEP 440 parsed predicates using packaging |
|
|
167
|
+
| Conflicts | warning for multiple distinct exact declarations | contradiction for distinct unconditional nonoptional exact pins |
|
|
168
|
+
| Config values | package.json | pyproject.toml |
|
|
169
|
+
|
|
170
|
+
Not supported: JavaScript multiline/dynamic import syntax, project resolution aliases unless supplied, npm version range intersection, workspace resolution, resolved lockfiles, Python installer flags/includes, dynamic dependency declarations, optional group selection, registry existence, dependency graph or API symbol compatibility.
|
|
171
|
+
|
|
172
|
+
The report gives declaration records, per-import status, claim detail, provenance labels, observations with source locations and recommended next actions. Manifest locations identify logical JSON/TOML keys, while requirements/import locations include line numbers; no source file is opened.
|
|
173
|
+
|
|
174
|
+
## Agent workflow
|
|
175
|
+
|
|
176
|
+
Paste this into project-specific instructions to encourage evidence-based changes:
|
|
177
|
+
|
|
178
|
+
```text
|
|
179
|
+
Before adding or changing a dependency or configuration:
|
|
180
|
+
1. Provide the relevant manifest text and proposed import/claim to DependencyProof.
|
|
181
|
+
2. For Python imports, provide a verified import-to-distribution mapping.
|
|
182
|
+
3. For version claims, provide trusted metadata separately and identify its provenance.
|
|
183
|
+
4. Investigate contradicted and unknown results. Do not invent a package,
|
|
184
|
+
version, or API example to resolve them.
|
|
185
|
+
5. If necessary, consult official documentation through the normal authorized
|
|
186
|
+
workflow and run the project's existing tests. DependencyProof itself never
|
|
187
|
+
installs dependencies, modifies files, or executes tests.
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Evidence boundary
|
|
191
|
+
|
|
192
|
+
- Inputs are explicit text. No implicit repository traversal, filesystem reads, registry access, telemetry, credentials, mutation or external command execution.
|
|
193
|
+
- Text limit: 256 KiB and 10,000 LF characters per source; 300 records per list; up to 300 findings. Auxiliary evidence is limited by a 1 MiB serialized size check. The CLI request itself is limited to 256 KiB.
|
|
194
|
+
- Caller metadata is not independently verified. Presence is not proof that a package exists in a registry or that a declared dependency is installed.
|
|
195
|
+
- A declaration can be conditional, optional or supplied in distinct contexts; a missing declaration in supplied text is not proof that software cannot run.
|
|
196
|
+
- PEP 508 markers are not evaluated, and direct references are not followed. Python standard-library classification uses the running Python version's module names, not an arbitrary target runtime. Node builtin classification uses a fixed name list and does not verify target-version availability.
|
|
197
|
+
- No security or vulnerability assessment. Do not supply credential-bearing URLs or confidential manifest values.
|
|
198
|
+
|
|
199
|
+
## Reproduce the tests
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
python -m pip install ".[test]"
|
|
203
|
+
ruff check dependencyproof tests
|
|
204
|
+
black --check dependencyproof tests
|
|
205
|
+
python -m unittest discover -s tests -v
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Local tests cover malformed/duplicate JSON, PEP 440 version evidence, name normalization, ambiguous Python mapping, missing declarations, incomplete installer configurations, nested config value mismatch, exact npm versions, unknown ranges and prereleases, CLI behavior, and a real official MCP stdio client session. 19 local tests (including 75 generated property examples), Ruff and Black passed on Linux/Python 3.12. CI is configured for Python 3.11/3.12 on Linux, macOS and Windows, but passing results on those hosts must be established by the workflow itself.
|
|
209
|
+
|
|
210
|
+
MIT license. See [LICENSE](LICENSE) and [THIRD_PARTY.md](THIRD_PARTY.md).
|
|
211
|
+
|
|
212
|
+
### Distribution
|
|
213
|
+
|
|
214
|
+
A release workflow is prepared for future PyPI Trusted Publishing and requires explicit dispatch with publishing enabled plus configured publisher authorization. The package is not yet published; use the source installation above.
|
|
215
|
+
The included MCP server metadata prepares its registry entry, not a claim that it is already listed.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dependencyproof/__init__.py,sha256=eZ3tnZJMc-i9zSDidw4LuYgEaLkqVJUp5NUDS3fh3Ik,86
|
|
2
|
+
dependencyproof/__main__.py,sha256=IepJIqOp7CSp7Kczyxr_k6rnt21x1QOgb2AIyK85Hyo,1565
|
|
3
|
+
dependencyproof/core.py,sha256=zo7X4ESRwnZx8CCFFO3okCFEvtCZ3_ZBq589X2yWWBA,27954
|
|
4
|
+
dependencyproof/server.py,sha256=hd9H5ffJN8EfEyPbwQLm-AtLychBAHeO3wFRyRxFdKA,1192
|
|
5
|
+
dependencyproof_mcp-0.1.1.dist-info/licenses/LICENSE,sha256=NCfqM6lB-F3EsSWS0OfHwYqjFprLg30tHDud5MDIY-I,1068
|
|
6
|
+
dependencyproof_mcp-0.1.1.dist-info/METADATA,sha256=Gx4ytnC1981h8ZRZm9bOfLE0u-boj2-7nFyEhyBqNwQ,11729
|
|
7
|
+
dependencyproof_mcp-0.1.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
8
|
+
dependencyproof_mcp-0.1.1.dist-info/entry_points.txt,sha256=HHLtt1sdbdpAgvgEV-1lBW32yiuz4JBipNs6gOtRByg,116
|
|
9
|
+
dependencyproof_mcp-0.1.1.dist-info/top_level.txt,sha256=1NFRdjhxDsgP95pTTQxHfsPrM2-uwXma_IyAN1yCjHg,16
|
|
10
|
+
dependencyproof_mcp-0.1.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ahmed Saeed
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dependencyproof
|