Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions agents/agents-mcp-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ kotlin {
commonMain {
dependencies {
api(libs.mcp.server)
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.sse)

api(project(":agents:agents-tools"))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
import kotlin.test.assertIsNot
import kotlin.test.assertNotEquals
import kotlin.test.assertNotNull
Expand Down Expand Up @@ -68,19 +67,20 @@ class KoogToolAsMcpToolTest {
@OptIn(InternalAgentToolsApi::class)
@Test
fun testKoogToolAsMcpToolWithInvalidArguments() = testMcpTool(RandomNumberTool()) { mcpTool, origin ->
assertFailsWith<IllegalStateException> {
val args = buildJsonObject { put("seed", "forty-two") }
run {
Comment thread
tiginamaria marked this conversation as resolved.
val errorArgs = buildJsonObject { put("seed", "forty-two") }

withContext(Dispatchers.Default.limitedParallelism(1)) {
val errorResult = withContext(Dispatchers.Default.limitedParallelism(1)) {
withTimeout(20.seconds) {
mcpTool.execute(args)
mcpTool.execute(errorArgs)
}
}

assertTrue(errorResult?.isError ?: false)
}

// check that the server is still working
run {
// check that the server is still working

val args = buildJsonObject { put("seed", "42") }

val result = withContext(Dispatchers.Default.limitedParallelism(1)) {
Expand All @@ -102,17 +102,19 @@ class KoogToolAsMcpToolTest {
val tool = ThrowingExceptionTool()

testMcpTool(tool) { mcpTool, origin ->
tool.throwing = true
run {
tool.throwing = true

assertFailsWith<IllegalStateException> {
val args = EmptyJsonObject

withContext(Dispatchers.Default.limitedParallelism(1)) {
val errorResult = withContext(Dispatchers.Default.limitedParallelism(1)) {
withTimeout(20.seconds) {
mcpTool.execute(args)
}
}

assertTrue(errorResult?.isError ?: false)

val last = origin.last
assertNotNull(last)
assertTrue(last.isFailure)
Expand Down Expand Up @@ -158,7 +160,7 @@ class KoogToolAsMcpToolTest {
val toolRegistry = withContext(Dispatchers.Default.limitedParallelism(1)) {
withTimeout(20.seconds) {
McpToolRegistryProvider.fromTransport(
transport = McpToolRegistryProvider.defaultSseTransport("http://localhost:$port/sse")
transport = McpToolRegistryProvider.defaultSseTransport("http://localhost:$port")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class McpToolTest {
val toolRegistry = withContext(Dispatchers.Default.limitedParallelism(1)) {
withTimeout(1.minutes) {
McpToolRegistryProvider.fromTransport(
transport = McpToolRegistryProvider.defaultSseTransport("http://localhost:$testPort/sse"),
transport = McpToolRegistryProvider.defaultSseTransport("http://localhost:$testPort"),
name = "test-client",
version = "0.1.0"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun main() {
// Create the ToolRegistry with tools from the MCP server
println("Connecting to Playwright MCP server...")
val toolRegistry = McpToolRegistryProvider.fromTransport(
transport = McpToolRegistryProvider.defaultSseTransport("http://localhost:8931")
transport = McpToolRegistryProvider.defaultSseTransport("http://localhost:8931/sse")
)
println("Successfully connected to Playwright MCP server")

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ktlint = "14.0.1"
ktor3 = "3.2.2"
lettuce = "6.5.5.RELEASE"
logback = "1.5.13"
mcp = "0.7.2"
mcp = "0.7.7"
mockito = "5.19.0"
mockk = "1.13.8"
mokksy = "0.5.1"
Expand Down
Loading