@vantageos/mcp-doctor 0.19.0 → 0.21.0
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.
- package/CHANGELOG.md +29 -0
- package/README.md +65 -103
- package/dist/chunk-OLW7SIJF.js +1093 -0
- package/dist/doctor.d.ts +120 -83
- package/dist/doctor.js +4387 -701
- package/dist/kit/source/index.d.ts +125 -0
- package/dist/kit/source/index.js +56 -0
- package/dist/scan-Cn2EjRVE.d.ts +84 -0
- package/package.json +9 -3
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { T as Tree } from '../../scan-Cn2EjRVE.js';
|
|
3
|
+
|
|
4
|
+
type SrcFile = Tree["files"][number];
|
|
5
|
+
interface Parsed {
|
|
6
|
+
rel: string;
|
|
7
|
+
sf: ts.SourceFile;
|
|
8
|
+
}
|
|
9
|
+
declare function sourceOf(f: SrcFile): string;
|
|
10
|
+
declare function parseFile(f: SrcFile): Parsed;
|
|
11
|
+
declare function lineOf(n: ts.Node): number;
|
|
12
|
+
/** Strip `await`, parentheses, `!` non-null, `as`/`satisfies` casts. */
|
|
13
|
+
declare function unwrap(e: ts.Expression): ts.Expression;
|
|
14
|
+
/** A property read: `x.prop`, or `x["prop"]` (a string-literal element access
|
|
15
|
+
* is the same read, spelled differently). A computed key is not a read of a
|
|
16
|
+
* known property and gives undefined. */
|
|
17
|
+
declare function propRead(e: ts.Node): {
|
|
18
|
+
obj: ts.Expression;
|
|
19
|
+
name: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
/** The initializer of the NEAREST `const <id> = <init>` visible from `id`, or
|
|
22
|
+
* undefined (a parameter or a `let` in between shadows it, so does a
|
|
23
|
+
* destructure). Exactly one level: the caller never follows an alias of an
|
|
24
|
+
* alias. */
|
|
25
|
+
declare function constInit(id: ts.Identifier): ts.Expression | undefined;
|
|
26
|
+
/** `e` as a property read, one const alias deep: `x.p`, `x["p"]`, or an
|
|
27
|
+
* identifier declared `const a = x.p` / `const a = x["p"]` (read as `x.p`). */
|
|
28
|
+
declare function propReadResolved(e: ts.Expression): {
|
|
29
|
+
obj: ts.Expression;
|
|
30
|
+
name: string;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/** Visit every descendant of `n` (pre-order), NOT descending into nested
|
|
33
|
+
* function bodies when `ownOnly` is set. */
|
|
34
|
+
declare function walk(n: ts.Node, visit: (x: ts.Node) => void, ownOnly?: boolean): void;
|
|
35
|
+
/** `a.b.c` as text, or undefined when the expression is not a dotted chain. */
|
|
36
|
+
declare function dotted(e: ts.Expression): string | undefined;
|
|
37
|
+
/** The callee's last name: `ctx.db.patch` -> `patch`, `helper` -> `helper`. */
|
|
38
|
+
declare function calleeName(c: ts.CallExpression): string | undefined;
|
|
39
|
+
type Builder = "mutation" | "action" | "query" | "internalMutation" | "internalAction" | "internalQuery";
|
|
40
|
+
interface Registration {
|
|
41
|
+
name: string;
|
|
42
|
+
builder: Builder;
|
|
43
|
+
rel: string;
|
|
44
|
+
line: number;
|
|
45
|
+
/** the handler function (`handler: async (ctx, args) => {…}`). */
|
|
46
|
+
handler: ts.FunctionLikeDeclaration;
|
|
47
|
+
/** arg name -> referenced table, for `v.id("T")` / `v.optional(v.id("T"))`. */
|
|
48
|
+
argIdTable: Map<string, string>;
|
|
49
|
+
}
|
|
50
|
+
declare function idTableOf(text: string): string | undefined;
|
|
51
|
+
/** The ONE table a validator's text references through `v.id("T")` — through
|
|
52
|
+
* `v.optional`, `v.array`, or a nested `v.object` — or undefined when it names
|
|
53
|
+
* none or several. */
|
|
54
|
+
declare function singleIdTable(text: string): string | undefined;
|
|
55
|
+
/** Every `export const NAME = <builder>({ … handler … })` of a file. */
|
|
56
|
+
declare function registrations(p: Parsed): Registration[];
|
|
57
|
+
interface FnDef {
|
|
58
|
+
name: string;
|
|
59
|
+
rel: string;
|
|
60
|
+
line: number;
|
|
61
|
+
fn: ts.FunctionLikeDeclaration;
|
|
62
|
+
}
|
|
63
|
+
/** Every top-level `function f` / `const f = (…) => …` across the parsed files. */
|
|
64
|
+
declare function indexFunctions(ps: Parsed[]): Map<string, FnDef[]>;
|
|
65
|
+
/** Names of the plain-identifier functions a body calls. */
|
|
66
|
+
declare function calledNames(fn: ts.Node): Set<string>;
|
|
67
|
+
/** A per-function boolean property closed over the call graph: `own(fn)` holds,
|
|
68
|
+
* or the function calls (by name) another function for which it holds. */
|
|
69
|
+
declare function closeOverCalls(idx: Map<string, FnDef[]>, own: (d: FnDef) => boolean): Set<string>;
|
|
70
|
+
/** The tenant columns, as standard 2825122 §4 R-52 lists them:
|
|
71
|
+
* `orgId`/`tenantId`/`workspaceId`/`orgSlug` (vantage-peers stamps its agents
|
|
72
|
+
* under `orgSlug: client_org_mapping.clerkOrgSlug`). A `namespace` is NOT in this
|
|
73
|
+
* set: the standard counts it only when it is "checked against the caller's
|
|
74
|
+
* allowed prefixes", which is a property of the code around the table, not of
|
|
75
|
+
* the schema. `readSchema` records it apart (`SchemaTable.namespace`) and R-52
|
|
76
|
+
* decides it per table (cross-tenant-write.ts `namespaceDecisions`). */
|
|
77
|
+
declare const TENANT_COLUMNS: ReadonlySet<string>;
|
|
78
|
+
/** The column that is a tenant column only where it is prefix-checked. */
|
|
79
|
+
declare const NAMESPACE_COLUMN = "namespace";
|
|
80
|
+
type TenantKind = "required" | "optional" | "none";
|
|
81
|
+
interface SchemaTable {
|
|
82
|
+
name: string;
|
|
83
|
+
/** from the TENANT_COLUMNS alone. */
|
|
84
|
+
tenant: TenantKind;
|
|
85
|
+
/** whether a `namespace` column exists and is optional — a tenant column
|
|
86
|
+
* only where the code checks it against the caller's allowed prefixes. */
|
|
87
|
+
namespace: TenantKind;
|
|
88
|
+
fields: string[];
|
|
89
|
+
/** field -> the table its `v.id("T")` references. */
|
|
90
|
+
idRef: Map<string, string>;
|
|
91
|
+
}
|
|
92
|
+
/** Read every `name: defineTable({...})` of a schema file. */
|
|
93
|
+
declare function readSchema(p: Parsed): Map<string, SchemaTable>;
|
|
94
|
+
|
|
95
|
+
type SrcLine = SrcFile["lines"][number];
|
|
96
|
+
interface Site {
|
|
97
|
+
rel: string;
|
|
98
|
+
n: number;
|
|
99
|
+
note: string;
|
|
100
|
+
}
|
|
101
|
+
interface Scan {
|
|
102
|
+
conform: Site[];
|
|
103
|
+
violate: Site[];
|
|
104
|
+
cnj: Site[];
|
|
105
|
+
}
|
|
106
|
+
declare function emptyScan(): Scan;
|
|
107
|
+
/** basename of a `rel` path, lower-cased. */
|
|
108
|
+
declare function base(rel: string): string;
|
|
109
|
+
/** a source file we should judge — never a test or generated file. */
|
|
110
|
+
declare function isJudgeable(f: SrcFile): boolean;
|
|
111
|
+
|
|
112
|
+
declare const R4_SOURCE_ID = "R-4 source: a list read does not filter in memory, on a caller argument, rows its index range does not bound";
|
|
113
|
+
interface R4Scan extends Scan {
|
|
114
|
+
/** read paths found in the units judged. */
|
|
115
|
+
reads: number;
|
|
116
|
+
}
|
|
117
|
+
declare function scanR4FilterPaths(files: SrcFile[]): R4Scan;
|
|
118
|
+
|
|
119
|
+
declare function declaredNames(fn: ts.Node): Set<string>;
|
|
120
|
+
/** Does `node` read a caller-dependent value (an identifier in `tainted`) from
|
|
121
|
+
* outside itself? Declarations inside `node` shadow the outer names. */
|
|
122
|
+
declare function readsTainted(node: ts.Node, tainted: ReadonlySet<string>): boolean;
|
|
123
|
+
|
|
124
|
+
export { NAMESPACE_COLUMN, R4_SOURCE_ID, TENANT_COLUMNS, Tree, base, calledNames, calleeName, closeOverCalls, constInit, declaredNames, dotted, emptyScan, idTableOf, indexFunctions, isJudgeable, lineOf, parseFile, propRead, propReadResolved, readSchema, readsTainted, registrations, scanR4FilterPaths, singleIdTable, sourceOf, unwrap, walk };
|
|
125
|
+
export type { Builder, FnDef, Parsed, R4Scan, Registration, Scan, SchemaTable, Site, SrcFile, SrcLine, TenantKind };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NAMESPACE_COLUMN,
|
|
3
|
+
R4_SOURCE_ID,
|
|
4
|
+
TENANT_COLUMNS,
|
|
5
|
+
base,
|
|
6
|
+
calledNames,
|
|
7
|
+
calleeName,
|
|
8
|
+
closeOverCalls,
|
|
9
|
+
constInit,
|
|
10
|
+
declaredNames,
|
|
11
|
+
dotted,
|
|
12
|
+
emptyScan,
|
|
13
|
+
idTableOf,
|
|
14
|
+
indexFunctions,
|
|
15
|
+
isJudgeable,
|
|
16
|
+
lineOf,
|
|
17
|
+
parseFile,
|
|
18
|
+
propRead,
|
|
19
|
+
propReadResolved,
|
|
20
|
+
readSchema,
|
|
21
|
+
readsTainted,
|
|
22
|
+
registrations,
|
|
23
|
+
scanR4FilterPaths,
|
|
24
|
+
singleIdTable,
|
|
25
|
+
sourceOf,
|
|
26
|
+
unwrap,
|
|
27
|
+
walk
|
|
28
|
+
} from "../../chunk-OLW7SIJF.js";
|
|
29
|
+
export {
|
|
30
|
+
NAMESPACE_COLUMN,
|
|
31
|
+
R4_SOURCE_ID,
|
|
32
|
+
TENANT_COLUMNS,
|
|
33
|
+
base,
|
|
34
|
+
calledNames,
|
|
35
|
+
calleeName,
|
|
36
|
+
closeOverCalls,
|
|
37
|
+
constInit,
|
|
38
|
+
declaredNames,
|
|
39
|
+
dotted,
|
|
40
|
+
emptyScan,
|
|
41
|
+
idTableOf,
|
|
42
|
+
indexFunctions,
|
|
43
|
+
isJudgeable,
|
|
44
|
+
lineOf,
|
|
45
|
+
parseFile,
|
|
46
|
+
propRead,
|
|
47
|
+
propReadResolved,
|
|
48
|
+
readSchema,
|
|
49
|
+
readsTainted,
|
|
50
|
+
registrations,
|
|
51
|
+
scanR4FilterPaths,
|
|
52
|
+
singleIdTable,
|
|
53
|
+
sourceOf,
|
|
54
|
+
unwrap,
|
|
55
|
+
walk
|
|
56
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
interface SourceLine {
|
|
2
|
+
n: number;
|
|
3
|
+
raw: string;
|
|
4
|
+
/** true when the line is a comment-only line (JSDoc star, slash-slash, block open/close). */
|
|
5
|
+
comment: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface SourceFile {
|
|
8
|
+
path: string;
|
|
9
|
+
rel: string;
|
|
10
|
+
lines: SourceLine[];
|
|
11
|
+
}
|
|
12
|
+
/** A directory a walk declined to descend into, recorded AS the walk skipped it. */
|
|
13
|
+
interface SkippedDir {
|
|
14
|
+
/** Path relative to the walk root, `/`-separated. */
|
|
15
|
+
path: string;
|
|
16
|
+
/** Why the canonical list excludes this directory name. */
|
|
17
|
+
reason: string;
|
|
18
|
+
/**
|
|
19
|
+
* Set only by a walk that probed the skipped directory for its own candidate
|
|
20
|
+
* inputs (C-26: a deploy-config file). Names the first candidate found there,
|
|
21
|
+
* relative to the walk root. Unset means "not probed", never "nothing there".
|
|
22
|
+
*/
|
|
23
|
+
candidate?: string;
|
|
24
|
+
}
|
|
25
|
+
interface Tree {
|
|
26
|
+
root: string;
|
|
27
|
+
files: SourceFile[];
|
|
28
|
+
/**
|
|
29
|
+
* `unreadable` is set (with the parse error) when the file exists but is not a
|
|
30
|
+
* JSON object; `json` is then `{}` and MUST NOT be read as the file's content.
|
|
31
|
+
* Detectors that read this file go through `guardUnreadablePackageJson`.
|
|
32
|
+
*/
|
|
33
|
+
packageJson: {
|
|
34
|
+
path: string;
|
|
35
|
+
json: Record<string, unknown>;
|
|
36
|
+
unreadable?: string;
|
|
37
|
+
} | null;
|
|
38
|
+
/**
|
|
39
|
+
* Directories skipped on THIS run, recorded by the walks as they skip them
|
|
40
|
+
* (deduplicated by path). Mutable on purpose: a detector that walks the tree
|
|
41
|
+
* itself records into it through `recordSkip`. Never derived from the
|
|
42
|
+
* configured list: the report states what was walked past, not what could be.
|
|
43
|
+
*/
|
|
44
|
+
skippedDirs: SkippedDir[];
|
|
45
|
+
/**
|
|
46
|
+
* The backend source root (a `convex/` directory) a detector may read the
|
|
47
|
+
* backend's door list from. Set by the caller (`--backend=<dir>`); when unset a
|
|
48
|
+
* detector that needs it looks for the nearest `convex/` above `root` and says
|
|
49
|
+
* so when it finds none. Unset means "not supplied", never "no backend".
|
|
50
|
+
*/
|
|
51
|
+
backendRoot?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Product-looking source the scan did NOT read (`.js` `.mjs` `.cjs` `.jsx` `.mts` `.cts`, relative paths;
|
|
54
|
+
* declarations, tests and config files excluded). A rule that says `absent` on the strength of the files
|
|
55
|
+
* it read must not say it while this list is non-empty: it says could-not-judge and names them.
|
|
56
|
+
*/
|
|
57
|
+
unscannedSource?: string[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The target names nothing the doctor can read, so there is no subject to judge. Thrown by
|
|
61
|
+
* `loadTree` before any detector runs; the CLI turns it into exit 2 ("could not judge"), never 1:
|
|
62
|
+
* a verdict of "violation" about a tree that was never read is a finding manufactured from nothing.
|
|
63
|
+
*
|
|
64
|
+
* The forms a target can take come from `fs.statSync` and `fs.readdirSync`, and every one of them
|
|
65
|
+
* that yields no readable file ends here, named:
|
|
66
|
+
* - stat fails (does not exist, permission, a path through a file, a loop);
|
|
67
|
+
* - a directory that cannot be listed;
|
|
68
|
+
* - a directory with no entries;
|
|
69
|
+
* - a directory whose walk reaches no readable file (only empty, skipped, unreadable or
|
|
70
|
+
* non-regular entries — a FIFO, socket or device is never read: reading one can block);
|
|
71
|
+
* - a regular file that is not `.ts` / `.tsx` (the only single files the scan reads);
|
|
72
|
+
* - a `.ts` / `.tsx` file that cannot be read;
|
|
73
|
+
* - anything that is neither a directory nor a regular file.
|
|
74
|
+
* A directory holding at least one file IS a subject: the detectors judge it, and a missing README
|
|
75
|
+
* or lockfile there is a real violation.
|
|
76
|
+
*/
|
|
77
|
+
declare class SubjectUnreadableError extends Error {
|
|
78
|
+
readonly target: string;
|
|
79
|
+
readonly form: string;
|
|
80
|
+
constructor(target: string, form: string);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { SubjectUnreadableError as a };
|
|
84
|
+
export type { SkippedDir as S, Tree as T };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vantageos/mcp-doctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Static MCP conformance checker: audits an MCP server source tree against the MCP 2026-07-28 standard and emits a conformance-diff table (file:line | present | absent | non-conforming | verdict).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/doctor.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"types": "./dist/doctor.d.ts",
|
|
11
11
|
"import": "./dist/doctor.js"
|
|
12
12
|
},
|
|
13
|
+
"./source": {
|
|
14
|
+
"types": "./dist/kit/source/index.d.ts",
|
|
15
|
+
"import": "./dist/kit/source/index.js"
|
|
16
|
+
},
|
|
13
17
|
"./package.json": "./package.json"
|
|
14
18
|
},
|
|
15
19
|
"bin": {
|
|
@@ -49,6 +53,8 @@
|
|
|
49
53
|
"test": "node scripts/changelog-assemble.mjs --check && vitest run",
|
|
50
54
|
"changelog:check": "node scripts/changelog-assemble.mjs --check",
|
|
51
55
|
"test:watch": "vitest",
|
|
56
|
+
"test:probes": "bash scripts/run-foreign-probes.sh",
|
|
57
|
+
"test:full": "npm test && npm run test:probes",
|
|
52
58
|
"test:d10-foreign-bite": "bash scripts/d10-foreign-bite-probe.sh",
|
|
53
59
|
"test:v050-foreign-bite": "bash scripts/v050-foreign-bite-probe.sh",
|
|
54
60
|
"test:v070-foreign-bite": "bash scripts/v070-foreign-bite-probe.sh",
|
|
@@ -77,12 +83,12 @@
|
|
|
77
83
|
"@types/node": "^26.1.2",
|
|
78
84
|
"tsup": "^9.0.0",
|
|
79
85
|
"tsx": "^4.23.15",
|
|
80
|
-
"typescript": "^5.7.2",
|
|
81
86
|
"vite": "^8.3.5",
|
|
82
87
|
"vitest": "^5.0.5"
|
|
83
88
|
},
|
|
84
89
|
"dependencies": {
|
|
85
|
-
"standardwebhooks": "1.1.1"
|
|
90
|
+
"standardwebhooks": "1.1.1",
|
|
91
|
+
"typescript": "^5.7.2"
|
|
86
92
|
},
|
|
87
93
|
"allowScripts": {
|
|
88
94
|
"esbuild@0.28.2": true,
|