Skip to content

test: extend coding standards enforcement and fix handler error paths#411

Closed
cursor[bot] wants to merge 4 commits into
mainfrom
cursor/mcp-server-coding-standards-b108
Closed

test: extend coding standards enforcement and fix handler error paths#411
cursor[bot] wants to merge 4 commits into
mainfrom
cursor/mcp-server-coding-standards-b108

Conversation

@cursor

@cursor cursor Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Extends the automated coding-standards guardrails introduced in #406 and fixes two handler error-handling gaps.

Changes

New test suites (pnpm standards:check)

  • handler-contract.test.ts — API handlers must import/use toMcpError + errorResult; outer catch blocks throw toMcpError for infrastructure failures; harness_list pagination defaults (page=0, size=20, max=100); no process.stdout.write in src/.
  • toolset-extractors.test.ts — Blocks new inline responseExtractor functions outside a grandfathered allowlist; caps inline extractor count at 14 until promoted to extractors.ts.

Registry contract

  • registry-contract.test.tscreate/update/delete operations must not use risk: "read" (execute actions with risk: "read" remain allowed — they are intentional read-only queries via harness_execute).

Handler fixes

  • harness_describe — Outer try/catch with isUserError → graceful JSON; unexpected failures → toMcpError.
  • harness_schema — Catch block now distinguishes user-fixable errors (errorResult) from infrastructure failures (toMcpError).

Verification

pnpm standards:check  # 28 tests pass
pnpm build
pnpm test             # 2145 tests pass

Standards coverage

The suite now enforces the registry-driven architecture rules from docs/coding-standards.md:

Rule Enforced by
11 fixed MCP tools, no new handlers architecture.test.ts
Toolset purity (no client/SDK imports) architecture.test.ts
No console.log / stdout writes architecture.test.ts, handler-contract.test.ts
Singleton HarnessClient, no raw fetch architecture.test.ts
Zod v4, .describe() on inputs architecture.test.ts, registry-metadata.test.ts
Registry registration sync architecture.test.ts, registry-contract.test.ts
listFilterFields only with list registry-metadata.test.ts
Write confirmation via elicitation registry-metadata.test.ts
operationPolicy on every endpoint registry-contract.test.ts
No risk: read on CRUD ops registry-contract.test.ts
Shared extractors (no new inline) toolset-extractors.test.ts
Handler error handling pattern handler-contract.test.ts
Open in Web View Automation 

thisrohangupta and others added 4 commits June 23, 2026 00:42
Update version across package.json, both manifest files, and the
release-metadata test that keeps them in sync.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

AI-Session-Id: 1b46c8db-abe4-4e9f-a38b-750362ead8ac
AI-Tool: claude-code
AI-Model: unknown
Expand automated architecture guardrails to cover:
- Global fetch() limited to documented exceptions (HarnessClient, log-resolver CDN blobs, audit webhooks)
- HarnessClient instantiation only in src/index.ts
- Zod v4 import convention in tool handlers and config
- Explicit openWorldHint annotations on all tool handlers
- No deprecated server.tool() usage
- Runtime registry contract checks (scope, identifierFields, operationPolicy)

Document fetch() exceptions in docs/coding-standards.md.

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
…Fields

Add registry-metadata.test.ts to guard listFilterFields/list operation
alignment, write-handler elicitation wiring, and Zod .describe() on tool
inputs. Move get-only params from listFilterFields to get.paramsSchema on
15 resources so harness_list no longer advertises non-list filters.

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Add handler-contract and toolset-extractors test suites to enforce
error-handling patterns, stdout safety, pagination defaults, inline
extractor ceiling, and create/update/delete risk classification.

Fix harness_describe and harness_schema to follow the documented
errorResult/toMcpError convention for infrastructure failures.

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ thisrohangupta
❌ cursoragent
You have signed the CLA already but the status is still pending? Let us recheck it.

@thisrohangupta

Copy link
Copy Markdown
Collaborator

Closing as stale: merge conflicts with main and work superseded by merged PRs (#447, #446, #449, #469, #440, #398, etc.) or duplicate agent-generated attempts. Reopen from a fresh branch if still needed.

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.

3 participants