Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

This PR fixes the two failing conformance tests identified in CI run #21354654074.

Investigation Results

The original problem statement incorrectly attributed CI failures to the ErrorHandling tool. Investigation revealed:

  • The tools-call-error conformance test passes with the original implementation
  • The actual failures were in elicitation-sep1330-enums (5 failures) and dns-rebinding-protection (1 failure)
  • The MCP server infrastructure properly handles exceptions thrown from tools (in McpServerImpl.cs lines 566-579)

Changes

1. Fixed elicitation-sep1330-enums Test (5 failures → 0 failures)

Updated ElicitationSep1330Enums tool to implement all 5 enum schema variants required by SEP-1330 specification:

  1. Untitled single-select: { type: "string", enum: [...] }
  2. Titled single-select: { type: "string", oneOf: [{ const, title }, ...] }
  3. Legacy titled (deprecated, for backward compatibility): { type: "string", enum: [...], enumNames: [...] }
  4. Untitled multi-select: { type: "array", items: { type: "string", enum: [...] } }
  5. Titled multi-select: { type: "array", items: { anyOf: [{ const, title }, ...] } }

2. Fixed dns-rebinding-protection Test (1 failure → 0 failures)

Added DNS rebinding protection middleware to prevent DNS rebinding attacks:

  • Validates Host header against allowed hosts (exact match for localhost, 127.0.0.1)
  • Returns HTTP 421 (Misdirected Request) for invalid Host headers
  • Configured for conformance testing environment

3. Housekeeping

  • Added node_modules, package.json, package-lock.json to .gitignore
  • Removed accidentally committed node_modules from repository

Testing

  • ✅ Build succeeds with 0 warnings and 0 errors
  • ✅ Both failing conformance tests are now fixed
  • ✅ Code review feedback addressed (tightened DNS protection validation)

The changes are minimal and focused on fixing the specific conformance test requirements.

Original prompt

The failing job indicates that the test tool method ErrorHandling in tests/ModelContextProtocol.ConformanceServer/Tools/ConformanceTools.cs throws an unhandled exception, which is causing the job to fail. The function currently is:

public static string ErrorHandling()
{
    throw new Exception("This tool intentionally returns an error for testing");
}

To resolve the CI failure for conformance, update this method to return a string response instead of throwing an exception. Ideally, refactor it as:

public static string ErrorHandling()
{
    return "Error handling test passed (no exception thrown)";
}

This should allow the job to pass, unless the test specifically expects an error to be thrown (in which case test expectations need updating). Make the above change in tests/ModelContextProtocol.ConformanceServer/Tools/ConformanceTools.cs.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 26, 2026 12:12
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ErrorHandling method to return string instead of throwing exception Fix ConformanceServer ErrorHandling tool to return response instead of throwing Jan 26, 2026
Copilot AI requested a review from eiriktsarpalis January 26, 2026 12:19
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot AI changed the title Fix ConformanceServer ErrorHandling tool to return response instead of throwing Revert: ErrorHandling tool changes - original behavior was correct Jan 26, 2026
Copilot AI and others added 4 commits January 26, 2026 14:07
Implement all 5 enum variants required by SEP-1330:
- Untitled single-select (simple enum)
- Titled single-select (oneOf with const+title)
- Legacy titled (enum + enumNames, with pragma)
- Untitled multi-select (array with items.enum)
- Titled multi-select (array with items.anyOf)

This addresses the elicitation-sep1330-enums conformance test failures.

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Implement Host header validation middleware to prevent DNS rebinding attacks:
- Validates Host header against allowed hosts (localhost, 127.0.0.1)
- Returns 421 Misdirected Request for invalid hosts
- Configured for conformance testing environment

This addresses the dns-rebinding-protection conformance test.

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
- Tighten DNS rebinding protection to only exact matches for localhost and 127.0.0.1
- Improve pragma comment to explain SEP-1330 backward compatibility requirement

Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Copilot AI changed the title Revert: ErrorHandling tool changes - original behavior was correct Fix conformance test failures: SEP-1330 enums and DNS rebinding protection Jan 26, 2026
@eiriktsarpalis eiriktsarpalis deleted the copilot/fix-error-handling-method branch January 26, 2026 14:34
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.

2 participants