Skip to content

validate inbound input with Ajv - #769

Merged
rafal-k merged 6 commits into
masterfrom
add-ajv-input-validation
Sep 2, 2026
Merged

validate inbound input with Ajv#769
rafal-k merged 6 commits into
masterfrom
add-ajv-input-validation

Conversation

@rafal-k

@rafal-k rafal-k commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Adds schema validation on the MCP transports (stdio + HTTP), the tools config, and the GUI server routes, as evidence of input validation for the SOC2 audit. Ajv because the MCP tool schemas are already JSON Schema and are advertised to clients verbatim, so there is no second definition to drift.

env is no longer required on tools that authenticate: resolveAuth also accepts explicit credentials, MPKIT_* env vars, or the default .pos entry.

rafal-k and others added 5 commits September 1, 2026 22:21
Adds schema validation on the MCP transports (stdio + HTTP), the tools
config, and the GUI server routes, as evidence of input validation for
the SOC2 audit. Ajv because the MCP tool schemas are already JSON Schema
and are advertised to clients verbatim, so there is no second definition
to drift.

`env` is no longer required on tools that authenticate: resolveAuth also
accepts explicit credentials, MPKIT_* env vars, or the default .pos entry.
The log cursor schema was derived from logStream.js rather than from the
client that calls the route, so gui/next's `?lastId=null` first poll got a
400 and the admin Logs page rendered empty. Fixed in the client, with a
shim for GUI builds already installed.

Also: the auth invariant is now derived from the tool registry rather than
a hand-written list, which it had silently stopped guarding; the tools
config rejects entries naming a tool that does not exist, and reports
through the logger instead of a stack trace; and validate() no longer
reports an unknown mode or a boolean schema as a compile failure.
logs-fetch returned its paging cursor as a string while the schema it
accepts declares an integer, so handing the returned cursor back — the
documented paging flow — failed with -32602.

The unknown-tool guard used `name in registry`, which walks the prototype
chain, so a config keyed `toString` or `constructor` passed as a known
tool and was then silently ignored.

Also: report a config error without an OS notification, and document the
first-.pos-entry fallback on the mutating tools whose descriptions the
bundled config overrides.
@rafal-k
rafal-k requested a review from fklosowski September 2, 2026 14:22

@fklosowski fklosowski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok.

@rafal-k
rafal-k merged commit 72f35b6 into master Sep 2, 2026
9 checks passed
@rafal-k
rafal-k deleted the add-ajv-input-validation branch September 2, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants