whisper-money/tests/Feature/Mcp
Víctor Falcón bd1ad633f8
feat(mcp): filter search_transactions by label (#724)
## What

Adds label filtering to the `search_transactions` MCP tool. It's the one
filter the web transactions view has that the MCP surface was missing.

- New optional `label_ids` array param. Returns transactions carrying
**any** of the given labels (OR-semantics), matching the web app's label
filter (`Transaction::scopeApplyFilters`).
- Combines with the other filters (account, category, date, amount) with
AND, consistent with how the tool already treats them — so `category_id`
+ `label_ids` means "in that category **and** carrying one of these
labels".
- Each returned transaction now also exposes its `labels` (`id`,
`name`), so the agent can see why a row matched, consistent with what
the write tools already return.

## Validation & consistency

- `label_ids` are validated against the space via `labelsInSpace`,
promoted from `WriteTool` to the shared `McpTool` base so read and write
tools use one implementation. An unknown or stale label id now returns
the same actionable *"call list_labels"* error the rest of the MCP
surface gives, instead of a silent empty result.
- The tool `#[Description]` now mentions `label`, so agents discover the
capability without inspecting each param.

## Tests

- `search_transactions` filters by label id (matching row in, unlabelled
row out).
- A foreign/unknown label id is rejected with an error.
- Full MCP read + write suites stay green (26 tests) — confirms moving
`labelsInSpace` to the base didn't regress the write tools.

Pint, Larastan and the affected Pest suites pass locally.
2026-07-22 15:13:03 +02:00
..
McpEndpointAuthTest.php feat(mcp): read-only MCP server for Pro accounts (#689) 2026-07-17 16:54:15 +02:00
McpOAuthTest.php fix(oauth): stop reporting client-facing OAuthServerException to Sentry (#723) 2026-07-22 12:40:24 +00:00
McpToolsTest.php feat(mcp): filter search_transactions by label (#724) 2026-07-22 15:13:03 +02:00
McpWriteToolsTest.php feat(mcp): add write tools (Phase 2) (#690) 2026-07-17 15:25:03 +00:00