Skip to content

fix(mcp): harden the input of the MCP tools, release 0.13.0 [*] - #26

Merged
schmunk42 merged 8 commits into
masterfrom
feature/flowable-mcp-input
Nov 26, 2026
Merged

schmunk42 merged 8 commits into
masterfrom
feature/flowable-mcp-input

Conversation

@schmunk42

Copy link
Copy Markdown
Member

Part A of #18: the MCP tools are hardened at their input. Several of the rules sit where all transports meet, so HTTP, the console commands and the external worker are affected too. The CHANGELOG entry 0.13.0 lists every observable change.

What changes

  • Configuration selection (FlowableClientLocator): an explicit apiConfiguration must be the first 8 characters or the full UUID, lowercase, of an active configuration of type flowable. The format is checked before any lookup, the comparison happens in PHP (no LIKE), and malformed, unknown, inactive, other type and an ambiguous prefix all answer the same generic 400. The {uuid} form of the input schemas carries the same pattern.
  • Ids in engine paths (FlowableClient): every id must match ^[A-Za-z0-9][A-Za-z0-9:._-]*$ and is rejected before any engine request. Deployment resource names are exempt, only . and .. segments are rejected there.
  • Uploads: one file name rule for the single uploads and flowable_deploy_bundle, the file name is escaped in Content-Disposition, inline content is limited to 1 MiB per file, a bundle to 20 files and 4 MiB in total, and flowable_dmn_deploy takes only .dmn (.bar and .zip stay with the HTTP upload).
  • Read tools: the six read tools and flowable_dmn_deploy validate their MCP arguments against the schema they publish, fail-closed without a buildable schema. HTTP reads are unchanged.
  • Tool visibility: a tool whose input schema cannot be built is removed from the metadata (neither listed nor callable) and logged; McpToolInputSchemaFactory acts only on the bundle's resources and rejects .. in the input path.

The first commit is a refactor without behaviour change: the apiConfiguration schema block lives once in src/Schema/api-configuration.json instead of 20 copies, and all three loading paths (MCP inputSchema, input validation, OpenAPI and form-schema fallback) go through InputSchemaLoader. InputSchemaSnapshotTest compares every delivered schema byte for byte with a snapshot of 0.12.1.

Breaking for consumers

  • FlowableClientLocator::__construct() no longer takes a UuidResolver.
  • Selectors of 9 to 35 characters, uppercase selectors and inactive configurations are rejected.
  • A process definition whose BPMN key starts with _ or contains non-ASCII letters (id e.g. _key:1:5) can no longer be addressed by id; job ids the external worker gets from the engine fall under the rule as well. The rule is not verified against a live engine.
  • MCP read tools reject unknown keys, strings for numbers and itemsPerPage above 200.

Notes

  • dmstr/api-platform-utils-bundle stays in composer.json, although the locator no longer uses it; dependencies are not changed in this PR.
  • Every regression test was run against the code before its fix and fails there.
  • Left for the rest of MCP tools: security hardening and cleanup after review #18: the description of the shared apiConfiguration definition still says "full or partial UUID"; the console upload commands call the client directly and do not apply the file name rule (the header escaping applies).

Part of #18

🤖 Generated with Claude Code

schmunk42 and others added 8 commits November 26, 2026 09:11
…input schemas through one loader [*]

The apiConfiguration block was copied into 20 input schema files and two
PHP-built form schemas and had drifted. It now lives once in
src/Schema/api-configuration.json. InputSchemaLoader resolves the
references for the MCP inputSchema, the input validator and the new
InputSchemaFileResolver (OpenAPI requestBody, form-schema fallback), so
no $ref or $defs reaches a client.

No behaviour change: InputSchemaSnapshotTest compares every delivery
path byte for byte with fixtures captured from 0.12.1.

Part of #18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… the multipart file name [*]

Every id that becomes a segment of an engine path must match
^[A-Za-z0-9][A-Za-z0-9:._-]*$ and is rejected with a 400 before any
request is sent, for every caller (HTTP, MCP, CLI, worker). A deployment
resource name comes from engine data and may contain "/" or spaces, so
only "." and ".." segments are rejected there.

Quotes, CR and LF in an uploaded file name are escaped in the
Content-Disposition header of the multipart body.

Part of #18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…selector [*]

An explicit apiConfiguration selector must be the first 8 characters or
the full UUID, lowercase. The format is checked before any lookup and
the selector is compared in PHP with the ids of the active "flowable"
configurations, so no wildcard reaches the database. Malformed, unknown,
inactive, other type and an ambiguous prefix all end in the same generic
400 that names no other configuration. This applies to HTTP, MCP, the
--api-configuration option of the console commands and the external
worker. The {uuid} branch of the input schemas carries the same pattern.

BREAKING CHANGE: FlowableClientLocator::__construct() no longer takes a
UuidResolver; partial UUIDs of 9 to 35 characters, uppercase selectors
and inactive configurations are rejected.

Part of #18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-input [*]

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…-input [*]

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…pe and size [*]

The six read tools and flowable_dmn_deploy validate their MCP arguments
against the input schema they publish; a tool without a buildable schema
is rejected instead of running unvalidated. HTTP reads are unchanged.

Uploads share one file name rule (no path, no "..", no leading ".", no
quotes or control characters, at most 255 characters) over every
transport. Inline content is limited to 1 MiB per file after decoding,
flowable_deploy_bundle to 20 files and 4 MiB in total.
flowable_dmn_deploy takes only .dmn; .bar and .zip stay with the HTTP
upload. An apiConfiguration value that is neither a string nor
{uuid: string} is rejected instead of selecting implicitly.

Part of #18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… schema factory [*]

A tool whose input file is missing, holds invalid JSON or whose path
contains ".." is removed from the resource metadata, so it is neither
listed nor callable, with every combination of the switches. The error
is logged on the flowable channel. McpToolInputSchemaFactory acts only
on the bundle's resources and rejects ".." in the input path. The opis
validation of request bodies and MCP tool arguments is one function.

Part of #18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…imits and tool validation [*]

Part of #18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@schmunk42
schmunk42 merged commit 87f201a into master Nov 26, 2026
2 checks passed
@schmunk42
schmunk42 deleted the feature/flowable-mcp-input branch November 26, 2026 09:50
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.

1 participant