Skip to content

test(sequentialthinking): bring index.ts from 0% to full coverage (per #4474 server-by-server plan) - #4691

Open
Parker-Fawcett wants to merge 3 commits into
modelcontextprotocol:mainfrom
Parker-Fawcett:test/sequentialthinking-index-coverage
Open

test(sequentialthinking): bring index.ts from 0% to full coverage (per #4474 server-by-server plan)#4691
Parker-Fawcett wants to merge 3 commits into
modelcontextprotocol:mainfrom
Parker-Fawcett:test/sequentialthinking-index-coverage

Conversation

@Parker-Fawcett

Copy link
Copy Markdown

Description

Adds src/sequentialthinking/__tests__/index.test.ts (198 lines, 13 tests) covering the previously untested index.ts — the tool-registration layer. Second PR in the #4474 server-by-server series (filesystem landed as #4690; memory is next).

No production code changes. lib.ts is mocked here so the handler's branch logic is driven deterministically; it keeps its own dedicated suite at 96.7%.

Server Details

  • Server: sequentialthinking
  • Changes to: none (tests only)

Motivation and Context

#4474 requires ≥90% per-file coverage on all four dimensions. The audit in #4690 showed this server's index.ts at 0% (~134 lines: registration, schema coercion, handler, startup).

What's covered

  • Registration wiring: single sequentialthinking tool, read-only annotation set, detailed description, all five outputSchema keys.
  • Safe boolean coercion (coercedBoolean): boolean passthrough, "true"/"TRUE"/"false"/"False" strings, and rejection of non-boolean non-string values through the real zod schema captured from the registration config.
  • Coerced numeric fields: string inputs ("3", "5") parse to numbers for required counters.
  • Full parameter surface: all nine documented input parameters present.
  • Handler: success path parses the JSON text into structuredContent and passes content through untouched; isError results are returned without parsing.
  • Startup: fatal connect-failure path reports and exits via a fault injected into the transport handshake on a fresh module evaluation.

How Has This Been Tested?

Breaking Changes

None — test-only change.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follows MCP security best practices
  • I have updated the server's README accordingly (N/A)
  • I have tested this with an LLM client (N/A — no runtime behavior change)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options (N/A)

Additional context

One implementation note for reviewers: mocking a sibling module from a test inside __tests__/ requires the mock path relative to the test file (vi.mock('../lib.js')), not relative to the importing module — worth knowing if more per-server index suites follow this template.

Next in the series per #4474: memory (81.8% overall, closest to its gate).

Parker Fawcett and others added 3 commits August 23, 2026 09:56
… writing literal filenames

On POSIX, a path like C:\Users\me\notes\file.md is not absolute, so validatePath() sent it down the relative-path branch and path.resolve() placed it inside the allowed root as a single entry literally named 'C:\Users\me\notes\file.md' (or created a C:/ directory tree). Callers saw success and only discovered the mistake when inspecting disk - reported in modelcontextprotocol#4686.

validatePath() now rejects drive-letter forms (^[A-Za-z]:(?:[\\/]|$)) up front when process.platform is not win32, with an explicit access-denied error. The check is one-directional and platform-guarded so Windows behavior is untouched and POSIX paths are never rewritten (no modelcontextprotocol#3628 regression).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…, and roots flows

index.ts was the only 0%-coverage file in server-filesystem: the entire MCP tool-registration layer (14 tools), every handler body, the argv-driven startup path, and the roots-protocol integration were untested. Per modelcontextprotocol#4474's per-server coverage plan, this adds a vitest suite that captures registerTool calls through a mocked McpServer so the real wiring (names, schemas, annotations) plus handler behavior are exercised without changing production code or exporting test-only helpers.

Coverage of src/filesystem/index.ts: lines 0% -> 98.54%, statements 0% -> 98.51%, functions 0% -> 100%, branches 0% -> 94.28%. Server overall rises from 46% to 90.39%. Suite grows 158 -> 206 tests, all passing.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Adds src/sequentialthinking/__tests__/index.test.ts covering the tool-registration layer that previously had no tests: the sequentialthinking tool wiring (annotations, description, outputSchema keys), the safe boolean-coercion preprocess across boolean/string/case-variant/passthrough inputs, z.coerce.number behavior on required fields, the handler's structured-content parsing and error passthrough paths, and the fatal startup failure path via a transport-connect fault injected on a fresh module evaluation.

Coverage of src/sequentialthinking/index.ts: lines 0% -> 100%, statements -> 100%, functions -> 100%, branches -> 90%. Server overall rises from 54.7% to 98.11%. Suite grows 14 -> 27 tests.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
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