validate inbound input with Ajv - #769
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
envis no longer required on tools that authenticate: resolveAuth also accepts explicit credentials, MPKIT_* env vars, or the default .pos entry.