Skip to content

feat(tests): add unit tests for MCP tool registration and validation#133

Merged
agoldis merged 2 commits into
mainfrom
fix/sanity-tests
May 18, 2026
Merged

feat(tests): add unit tests for MCP tool registration and validation#133
agoldis merged 2 commits into
mainfrom
fix/sanity-tests

Conversation

@agoldis

@agoldis agoldis commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds 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).
  • Fixes a parenthesized substring in the currents-list-affected-tests tool description that violated the "no trailing non-period character" convention.

Changes

Tests (mcp-server/src/server.test.ts)

Mocks McpServer to capture every registerTool call at import time, then runs data-driven checks on each tool:

  • Name: ≤ 64 chars, matches [a-zA-Z0-9_\-./]+, non-empty, unique
  • Description: non-empty, ≤ 1024 chars, no leading/trailing whitespace, starts with a capital letter, ends with a period

Server (mcp-server/src/server.ts)

Removes inner parentheses from the currents-list-affected-tests description so it passes the "ends with a period" check.

Review hints

  • The test file is self-contained — start there.
  • The server change is a one-character cosmetic fix; confirm the description still reads naturally.

Made with Cursor

Summary by CodeRabbit

  • Tests

    • Added an automated test suite that validates all registered tools follow best-practice rules: at least one tool present, unique and properly formatted names within length limits, and descriptions meeting length/formatting/capitalization/ punctuation constraints.
  • Documentation

    • Clarified a tool description to improve readability about the preview endpoint.
  • Chores

    • Renamed a registered tool to a shorter, standardized identifier.

Review Change Stack

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

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds a Vitest suite that captures and validates all tools registered by importing mcp-server/src/server.js and makes two small metadata edits in mcp-server/src/server.ts (one description reformat and one tool name change).

Changes

MCP Tool Conventions and Validation

Layer / File(s) Summary
Tool best practices validation tests
mcp-server/src/server.test.ts
Vitest suite mocks MCP server registration and stdio, imports ./server.js at module load to capture registered tool {name, description} pairs, then asserts: at least one tool registered; tool names are unique, non-empty, match allowed characters, and are ≤64 chars (with a Cursor combined-name constraint ≤60); tool descriptions are non-empty, ≤1024 chars, have no surrounding whitespace, start with a capital letter, and end with a period.
Tool metadata edits
mcp-server/src/server.ts
Reformats the currents-list-affected-tests tool description so the "Preview endpoint" note is a standalone sentence, and renames one registered tool from currents-get-affected-test-executions-by-action to currents-get-affected-executions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 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 summarizes the primary change: adding unit tests for MCP tool registration and validation, which is the main focus of the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sanity-tests

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Avoid 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

📥 Commits

Reviewing files that changed from the base of the PR and between 42c11a7 and cfb14e1.

📒 Files selected for processing (2)
  • mcp-server/src/server.test.ts
  • mcp-server/src/server.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • mcp-server/src/server.test.ts

@agoldis agoldis merged commit fc0b650 into main May 18, 2026
5 checks passed
@agoldis agoldis deleted the fix/sanity-tests branch May 18, 2026 19:25
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