Add MCP tool validation tests and README sync automation#134
Conversation
…alidation tests - Introduced a script to automatically sync the tools table in README.md with registered tools in server.ts. - Added a pre-commit hook to trigger the README update when server.ts changes. - Enhanced unit tests to ensure all registered tools are accurately reflected in README.md, checking for missing or stale entries. - Updated package.json to include new scripts for README synchronization.
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a Node.js tool that regenerates the README "Tools" table from ChangesREADME Tools Sync System
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@mcp-server/scripts/hooks/pre-commit`:
- Around line 1-7: The pre-commit hook currently runs node
mcp-server/scripts/sync-readme-tools.mjs but doesn't stop the commit if that
command fails; modify the hook (mcp-server/scripts/hooks/pre-commit) to
fail-fast by exiting non-zero when node mcp-server/scripts/sync-readme-tools.mjs
returns a non-zero status (for example, check the command's exit code or enable
immediate exit), so that git add README.md and the commit are only reached if
sync-readme-tools.mjs succeeds.
In `@mcp-server/scripts/sync-readme-tools.mjs`:
- Around line 88-105: The code assumes the table anchor "| Tool" exists and may
slice the README incorrectly if tableStart === -1; add an explicit guard after
computing tableStart (and before using tableEnd/tableEndMarker) that checks if
tableStart === -1 and aborts with a clear error (use process.exit(1) or respect
checkOnly) and a descriptive message; update the branches that log/out on stale
state (using checkOnly) to handle this case and avoid constructing
updated/readmePath writes when the anchor is missing (references: tableStart,
tableEndMarker, tableEnd, oldTable, checkOnly, updated, readmePath).
In `@mcp-server/src/server.test.ts`:
- Around line 56-57: The README regex only captures `([\w-]+)` after the
`currents-` prefix in the readme.matchAll(...) call, but valid tool names may
include `.` and `/`; update the regex used in the readme.matchAll(...)
invocation (the pattern currently shown as `\| `(currents-[\w-]+)` `) to allow
dots and slashes (e.g. `[\w./-]+`) so the captured group returned to the
.map((m) => m[1]) includes names with `.` and `/`.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a6956479-0a43-44e3-9730-7fe68ebcfda2
📒 Files selected for processing (5)
README.mdmcp-server/package.jsonmcp-server/scripts/hooks/pre-commitmcp-server/scripts/sync-readme-tools.mjsmcp-server/src/server.test.ts
- Introduced package.json to define development dependencies for the project, including `oxfmt` and `oxlint`. - Added package-lock.json to lock the versions of dependencies, ensuring consistent installations across environments. - Updated sync-readme-tools.mjs to enhance error handling for missing tools table in README.md.
- Deleted the root-level package.json and package-lock.json files as they are no longer needed. - Updated mcp-server's package.json and package-lock.json to reflect new dependencies and version updates, including `audit` and updates to `@release-it/conventional-changelog` and `release-it`.
- Added 'set -e' to the pre-commit hook script to ensure it exits immediately if a command fails, enhancing error handling during the commit process.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@mcp-server/package.json`:
- Line 34: The prepare script in package.json runs git config core.hooksPath
unconditionally and fails when not in a git worktree; change the "prepare"
script to first check for git and that the current repo is a worktree (e.g.,
test for git binary and that git rev-parse --is-inside-work-tree succeeds)
before running git config core.hooksPath mcp-server/scripts/hooks so installs in
CI/artifacts/non-git contexts do not exit with code 128; update the package.json
"prepare" entry accordingly to perform the guard and only run the hook setup
when those checks pass.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 355103a4-d09e-4177-a309-17f21cf2ae8a
⛔ Files ignored due to path filters (1)
mcp-server/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (1)
mcp-server/package.json
Summary
server.test.ts) that validate all registered MCP tools against SEP-986 naming constraints, description quality rules, and Cursor IDE combined-name length limitssync-readme-tools.mjsscript that regenerates the README tools table fromserver.tssource, with a--checkmode for CIcurrents-get-affected-test-executions-by-action→currents-get-affected-executionsChanges by layer
Tests (
server.test.ts): new test suite that mocks the MCP SDK, captures allregisterToolcalls, and validates:extension-currents:prefix lengthTooling (
scripts/sync-readme-tools.mjs): parsesserver.tswith a regex to extract tool names/descriptions, builds a markdown table, and splices it intoREADME.md. Supports--checkfor CI gating.Server (
server.ts): renamed one tool and removed parentheses from one description to pass validation.Docs (
README.md): regenerated tools table reflecting the current tool set (adds 3 affected-tests tools, removes stale entries, alphabetizes by group).Review hints
server.test.ts— it defines all the validation rulessync-readme-tools.mjsfor the regex that parsesserver.tsserver.tsandREADME.mdchanges are mechanical fixes driven by the new testsMade with Cursor
Summary by CodeRabbit
New Features
Documentation
Chores
Tests