Skip to content

feat(mcp): add categories input to the analyze tool - #149

Merged
oekazuma merged 1 commit into
mainfrom
advisor/020-mcp-categories-input
Jul 8, 2026
Merged

oekazuma merged 1 commit into
mainfrom
advisor/020-mcp-categories-input

Conversation

@oekazuma

@oekazuma oekazuma commented Jul 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

Implements plan plans/020-mcp-categories-input.md — the follow-up promised in plan 018's maintenance notes: the MCP analyze tool now accepts a categories input, mirroring the CLI's --category flag (#147).

Agents connected via MCP could previously only narrow a scan by enumerating individual rule ids in rules; now categories: ["seo"] restricts analysis to whole categories (case-insensitive, validated against the five known categories, intersected with any rules/ignore selection). analyzeProject already accepted the option, so this is schema + pass-through.

Changes

  • packages/mcp/src/tools/analyze.ts: categories added to the zod input schema (same lowercase-preprocess pattern as the existing weights input) and threaded into analyzeProject
  • 4 new tests in packages/mcp/test/analyze-tool.test.ts: SEO-only filtering, unfiltered baseline, case-insensitive normalization via a real client-server pair, and unknown-category rejection
  • Docs: categories row added to the analyze-input table in the MCP guide (en/ja)
  • Changeset: minor for @svelte-vitals/mcp

Verification

  • 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

    • Added a new optional category filter for analysis, letting you limit results to specific rule categories.
    • Category names are matched without case sensitivity.
  • Documentation

    • Updated the MCP guide in English and Japanese to describe the new category filter.
  • Bug Fixes

    • Improved validation so unsupported categories are rejected with a clear input error.

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.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55db7ee9-b82a-4912-81b5-dec6d125ab08

📥 Commits

Reviewing files that changed from the base of the PR and between 8b6cf6b and edc54c2.

📒 Files selected for processing (5)
  • .changeset/mcp-analyze-categories.md
  • docs/src/content/docs/guides/mcp.md
  • docs/src/content/docs/ja/guides/mcp.md
  • packages/mcp/src/tools/analyze.ts
  • packages/mcp/test/analyze-tool.test.ts

📝 Walkthrough

Walkthrough

This PR adds an optional categories input to the MCP analyze tool, enabling case-insensitive filtering of analysis results by rule category (seo, performance, correctness, security, architecture). The schema validates input, handleAnalyze forwards it to analyzeProject, and documentation/tests are updated accordingly.

Changes

MCP analyze categories filter

Layer / File(s) Summary
Schema and handler support for categories
packages/mcp/src/tools/analyze.ts
Adds a categories field to analyzeInputSchema with case-insensitive preprocessing and enum validation, and forwards args.categories to analyzeProject in handleAnalyze.
Tests for category filtering and validation
packages/mcp/test/analyze-tool.test.ts
Adds unit tests verifying category-scoped and unfiltered results, plus integration tests using a linked client-server pair confirming case-insensitivity and rejection of unknown categories with an "Input validation error".
Changeset and documentation updates
.changeset/mcp-analyze-categories.md, docs/src/content/docs/guides/mcp.md, docs/src/content/docs/ja/guides/mcp.md
Adds a minor changeset entry and documents the new categories input parameter in the English and Japanese MCP guides.

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
Loading

Possibly related PRs

  • oekazuma/svelte-vitals#28: Builds on the same handleAnalyze/analyze implementation extended by this PR's categories input.
  • oekazuma/svelte-vitals#70: Introduces the security category and rules that this PR's categories filter validates against.
  • oekazuma/svelte-vitals#129: Also modifies packages/mcp/src/tools/analyze.ts input schema/handler argument forwarding, at the same API layer.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding a categories input to the MCP analyze tool.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@oekazuma

oekazuma commented Jul 8, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma
oekazuma merged commit f474ebf into main Jul 8, 2026
7 checks passed
@oekazuma
oekazuma deleted the advisor/020-mcp-categories-input branch July 8, 2026 15:19
oekazuma added a commit that referenced this pull request Jul 10, 2026
… parallel session

021 (dev dashboard whole-project, PR #152) and 022 (MCP categories input,
PR #149; renumbered from 020 to resolve the collision with the parallel
session's 020-reusable-github-action plan). Index rows updated with merge
outcomes including the #150 conflict resolution.
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