-
Notifications
You must be signed in to change notification settings - Fork 187
Add MCP conformance test coverage #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f964123
Add MCP conformance test coverage
skarpovdev 59b6400
fixup! Add MCP conformance test coverage
skarpovdev 65b244f
fixup! Add MCP conformance test coverage
skarpovdev c8a4a86
fixup! Add MCP conformance test coverage
skarpovdev f927aa4
fixup! Add MCP conformance test coverage
skarpovdev e9f7f9f
cr
skarpovdev c4340f9
cr
skarpovdev bfd7b9a
cr
skarpovdev 03243a5
cr
skarpovdev 8c9e9e1
cr
skarpovdev 76d8ced
Update .github/workflows/build.yml
skarpovdev 498ce26
Add support for multiple transports in conformance tests and move to …
skarpovdev df6f844
cr
skarpovdev b911d1c
cr
skarpovdev 7ab4b98
cr
skarpovdev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,3 +56,6 @@ dist | |
| ### SWE agents ### | ||
| .claude/ | ||
| .junie/ | ||
|
|
||
| ### Conformance test results ### | ||
| kotlin-sdk-test/results/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...st/src/jvmTest/kotlin/io/modelcontextprotocol/kotlin/sdk/conformance/ConformanceClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| package io.modelcontextprotocol.kotlin.sdk.conformance | ||
|
|
||
| import io.github.oshai.kotlinlogging.KotlinLogging | ||
| import io.ktor.client.HttpClient | ||
| import io.ktor.client.engine.cio.CIO | ||
| import io.ktor.client.plugins.sse.SSE | ||
| import io.modelcontextprotocol.kotlin.sdk.client.Client | ||
| import io.modelcontextprotocol.kotlin.sdk.client.StreamableHttpClientTransport | ||
| import io.modelcontextprotocol.kotlin.sdk.shared.Transport | ||
| import io.modelcontextprotocol.kotlin.sdk.types.CallToolRequest | ||
| import io.modelcontextprotocol.kotlin.sdk.types.CallToolRequestParams | ||
| import io.modelcontextprotocol.kotlin.sdk.types.Implementation | ||
| import kotlinx.coroutines.runBlocking | ||
| import kotlinx.serialization.json.JsonPrimitive | ||
| import kotlinx.serialization.json.buildJsonObject | ||
|
|
||
| private val logger = KotlinLogging.logger {} | ||
|
|
||
| fun main(args: Array<String>) { | ||
| require(args.isNotEmpty()) { | ||
| "Server URL must be provided as an argument" | ||
| } | ||
|
|
||
| val serverUrl = args.last() | ||
| logger.info { "Connecting to test server at: $serverUrl" } | ||
|
|
||
| val httpClient = HttpClient(CIO) { | ||
| install(SSE) | ||
| } | ||
| val transport: Transport = StreamableHttpClientTransport(httpClient, serverUrl) | ||
|
|
||
| val client = Client( | ||
| clientInfo = Implementation( | ||
| name = "kotlin-conformance-client", | ||
| version = "1.0.0", | ||
| ), | ||
| ) | ||
|
|
||
| var exitCode = 0 | ||
|
|
||
| runBlocking { | ||
| try { | ||
| client.connect(transport) | ||
| logger.info { "✅ Connected to server successfully" } | ||
|
|
||
| try { | ||
| val tools = client.listTools() | ||
| logger.info { "Available tools: ${tools.tools.map { it.name }}" } | ||
|
|
||
| if (tools.tools.isNotEmpty()) { | ||
| val toolName = tools.tools.first().name | ||
| logger.info { "Calling tool: $toolName" } | ||
|
|
||
| val result = client.callTool( | ||
| CallToolRequest( | ||
| params = CallToolRequestParams( | ||
| name = toolName, | ||
| arguments = buildJsonObject { | ||
| put("input", JsonPrimitive("test")) | ||
| }, | ||
| ), | ||
| ), | ||
| ) | ||
| logger.info { "Tool result: ${result.content}" } | ||
| } | ||
| } catch (e: Exception) { | ||
| logger.debug(e) { "Error during tool operations (may be expected for some scenarios)" } | ||
| } | ||
|
|
||
| logger.info { "✅ Client operations completed successfully" } | ||
| } catch (e: Exception) { | ||
| logger.error(e) { "❌ Client failed" } | ||
| exitCode = 1 | ||
| } finally { | ||
| try { | ||
| transport.close() | ||
| } catch (e: Exception) { | ||
| logger.warn(e) { "Error closing transport" } | ||
| } | ||
| httpClient.close() | ||
| } | ||
| } | ||
|
|
||
| kotlin.system.exitProcess(exitCode) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.