feat(tests): add unit tests for MCP tool registration and validation#133
Conversation
- Introduced a new test file `server.test.ts` to validate MCP tool registration. - Added tests to ensure at least one tool is registered, uniqueness of tool names, and compliance with naming and description constraints. - Updated the description of the `currents-list-affected-tests` tool for clarity.
📝 WalkthroughWalkthroughThis PR adds a Vitest suite that captures and validates all tools registered by importing ChangesMCP Tool Conventions and Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
- Added a new constant for the Cursor IDE prefix and a test to ensure the combined length of the tool name and prefix does not exceed 60 characters. - Updated the tool registration name for clarity and consistency.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
mcp-server/src/server.ts (1)
143-150:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAvoid silently renaming a public MCP tool.
Changing the registered name here is a breaking API change for any client still calling
currents-get-affected-test-executions-by-action; those calls will start failing with "tool not found" after upgrade. Please either preserve backward compatibility or treat this as an explicit breaking change with the corresponding versioning/migration note.🤖 Prompt for 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. In `@mcp-server/src/server.ts` around lines 143 - 150, The tool registration changed the public tool name and will break existing clients; revert to the original registered name "currents-get-affected-test-executions-by-action" when calling server.registerTool (or register both names) so existing consumers keep working; update the registration call near server.registerTool and ensure inputSchema and handler still reference getAffectedTestExecutionsByActionTool.schema and getAffectedTestExecutionsByActionTool.handler, or if you intentionally want a breaking change, add explicit migration/versioning notes and bump the public API version accordingly.
🤖 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.
Outside diff comments:
In `@mcp-server/src/server.ts`:
- Around line 143-150: The tool registration changed the public tool name and
will break existing clients; revert to the original registered name
"currents-get-affected-test-executions-by-action" when calling
server.registerTool (or register both names) so existing consumers keep working;
update the registration call near server.registerTool and ensure inputSchema and
handler still reference getAffectedTestExecutionsByActionTool.schema and
getAffectedTestExecutionsByActionTool.handler, or if you intentionally want a
breaking change, add explicit migration/versioning notes and bump the public API
version accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7f02ebb2-8633-491e-8ab5-ee8840a541a0
📒 Files selected for processing (2)
mcp-server/src/server.test.tsmcp-server/src/server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- mcp-server/src/server.test.ts
Summary
mcp-server/src/server.test.ts— a unit test suite that validates all registered MCP tools against SEP-986 naming conventions and description best practices (name length, allowed characters, uniqueness, description formatting).currents-list-affected-teststool description that violated the "no trailing non-period character" convention.Changes
Tests (
mcp-server/src/server.test.ts)Mocks
McpServerto capture everyregisterToolcall at import time, then runs data-driven checks on each tool:[a-zA-Z0-9_\-./]+, non-empty, uniqueServer (
mcp-server/src/server.ts)Removes inner parentheses from the
currents-list-affected-testsdescription so it passes the "ends with a period" check.Review hints
Made with Cursor
Summary by CodeRabbit
Tests
Documentation
Chores