feat(mcp): add categories input to the analyze tool - #149
Conversation
Mirrors the CLI's --category flag: restrict analysis to rules in the given categories, intersecting with rules/ignore selection. Category values are accepted case-insensitively, matching the weights input's existing convention.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds an optional ChangesMCP analyze categories filter
Estimated code review effort: 2 (Simple) | ~12 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant handleAnalyze
participant analyzeProject
Client->>Server: callTool("analyze", { categories: ["SEO"] })
Server->>handleAnalyze: validate & lowercase categories
alt valid category
handleAnalyze->>analyzeProject: analyzeProject(categories)
analyzeProject-->>handleAnalyze: filtered issues
handleAnalyze-->>Server: McpToolResult
Server-->>Client: structured results
else unknown category
handleAnalyze-->>Server: Input validation error
Server-->>Client: isError, "Input validation error"
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Implements plan
plans/020-mcp-categories-input.md— the follow-up promised in plan 018's maintenance notes: the MCPanalyzetool now accepts acategoriesinput, mirroring the CLI's--categoryflag (#147).Agents connected via MCP could previously only narrow a scan by enumerating individual rule ids in
rules; nowcategories: ["seo"]restricts analysis to whole categories (case-insensitive, validated against the five known categories, intersected with anyrules/ignoreselection).analyzeProjectalready accepted the option, so this is schema + pass-through.Changes
packages/mcp/src/tools/analyze.ts:categoriesadded to the zod input schema (same lowercase-preprocess pattern as the existingweightsinput) and threaded intoanalyzeProjectpackages/mcp/test/analyze-tool.test.ts: SEO-only filtering, unfiltered baseline, case-insensitive normalization via a real client-server pair, and unknown-category rejectioncategoriesrow added to the analyze-input table in the MCP guide (en/ja)@svelte-vitals/mcpVerification
pnpm typecheck,pnpm test(workspace: core 377 / cli 437 / vite 84 / mcp 17),pnpm lint— all green🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Bug Fixes