Skip to content

Conversation

@skarpovdev
Copy link
Contributor

@skarpovdev skarpovdev commented Nov 28, 2025

Motivation and Context

  1. The currently failing checks are commented out in ConformanceTest, see the TODOs.
  2. I added detailed logging for Gradle task, Server, and Client to allow easier output reading when viewing tests results outside of IDE.
  3. As a future improvement, instead of hard-coding scenarios, we can get them with npx @modelcontextprotocol/conformance list and run all of them.
  4. The conformance framework writes its result into kotlin-sdk-test/results directory and contains JSONs like the one below:
[
  {
    "id": "mcp-client-initialization",
    "name": "MCPClientInitialization",
    "description": "Validates that MCP client properly initializes with server",
    "status": "SUCCESS",
    "timestamp": "2025-11-28T14:38:36.718Z",
    "specReferences": [
      {
        "id": "MCP-Lifecycle",
        "url": "https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle"
      }
    ],
    "details": {
      "protocolVersionSent": "2025-06-18",
      "expectedSpecVersion": "2025-06-18",
      "versionMatch": true,
      "clientName": "kotlin-conformance-client",
      "clientVersion": "1.0.0"
    }
  },
  {
    "id": "server-info",
    "name": "ServerInfo",
    "description": "Test server info returned to client",
    "status": "INFO",
    "timestamp": "2025-11-28T14:38:36.718Z",
    "specReferences": [
      {
        "id": "MCP-Lifecycle",
        "url": "https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle"
      }
    ],
    "details": {
      "serverName": "test-server",
      "serverVersion": "1.0.0"
    }
  }
]

As another future improvement, we can do somethig with these JSON files, like putting them into a job summary on GitHub.

  1. The client test also generated stderr.txt file in kotlin-sdk-test/results/initialize-....... which contains errors because it tries to call a tool. I haven't investigated if it's just the way I wrote the client or related to StreamableHttpClientTransport.
  2. The server is the simplified version of the existing server for Kotlin<--->Typescript tests. If conformance tests extend significantly, we can either combine the server implementations or ditch the integration tests.

How Has This Been Tested?

Breaking Changes

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 Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Copilot AI review requested due to automatic review settings November 28, 2025 15:13
Copilot finished reviewing on behalf of skarpovdev November 28, 2025 15:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive MCP (Model Context Protocol) conformance test coverage to the Kotlin SDK. The implementation includes a test server, test client, and a test harness that integrates with the official @modelcontextprotocol/conformance testing framework from npm.

Key Changes

  • Created a conformance test framework with dynamic JUnit tests for both server and client scenarios
  • Implemented an HTTP-based MCP test server using Ktor with SSE support for streaming
  • Added a conformance test client that validates MCP protocol compliance
  • Integrated conformance testing into the CI/CD pipeline with artifact collection

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/conformance/ConformanceTest.kt Test harness that launches the conformance server and runs both server and client test scenarios using the official conformance tool
kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/conformance/ConformanceServer.kt HTTP-based MCP server implementation with session management, SSE streaming, and test resources (tools, prompts, resources)
kotlin-sdk-test/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/conformance/ConformanceClient.kt MCP client implementation that connects to test servers and validates tool calling functionality
kotlin-sdk-test/build.gradle.kts Adds custom Gradle task for running conformance tests with detailed logging and test classpath configuration
.gitignore Excludes conformance test results directory from version control
.github/workflows/build.yml Integrates conformance tests into CI pipeline with Node.js setup and artifact upload for test results

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

kpavlov
kpavlov previously approved these changes Dec 1, 2025
Copy link
Contributor

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

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

@skarpovdev, Thank you! It's cool to have these tests running!

I see ConformanceTest is running as a part of :kotlin-sdk-test:jvmTest. Did you consider creating a different module/source root and/or excluding ConformanceTest from the everyday jvmRun task?

Would it also make sense to create different ConformanceClient/Server for other protocols?

I'm okay with it being done in a follow-up PR

@kpavlov kpavlov requested a review from devcrocod December 1, 2025 10:09
@kpavlov kpavlov added the tests label Dec 1, 2025
Co-authored-by: Konstantin Pavlov <1517853+kpavlov@users.noreply.github.com>
@skarpovdev
Copy link
Contributor Author

skarpovdev commented Dec 1, 2025

I see ConformanceTest is running as a part of :kotlin-sdk-test:jvmTest. Did you consider creating a different module/source root and/or excluding ConformanceTest from the everyday jvmRun task?

Good point, I'll exclude them from other tests move them to a separate module.

Would it also make sense to create different ConformanceClient/Server for other protocols?

Will do in this PR while I'm in the context.

@skarpovdev
Copy link
Contributor Author

Looking at conformance/src/scenarios/server/client-helper.ts the conformance framework doesn't support anything else const transport = new StreamableHTTPClientTransport(new URL(serverUrl));.
It doesn't support testing Stdio since it requires --url parameter and at the same time doesn't have --command option for server testing, so to test Stdio we would probably have to wrap it in another transport layer.
I left WebSocket one hoping it may work in near future, but Stdio seems unlikely to be covered by conformance framework.

Copy link
Contributor

@kpavlov kpavlov left a comment

Choose a reason for hiding this comment

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

LGTM

@kpavlov kpavlov merged commit f04ccfd into modelcontextprotocol:main Dec 1, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants