Skip to content

Client example - simple streamable #167

Closed
Closed

Description

@devcrocod
No description provided.

Activity

  1. added theissue type on Jul 18, 2025
  2. loganknecht commented on Sep 26, 2025

    @loganknecht

    Hello,

    Previously I'ved used the Python SDK to work with an MCP client to great success.

    However, I'm at a bit of a loss here. I see that there is a way to use the kotlin sdk in order to do MCP client interactions. But I cannot seem to figure out how to do so.

    I know you have these two files

    But I cannot for the life of me figure out what to do with this?

    At best my current effort looks like this

    package com.example.myapplication
    
    import android.os.Bundle
    import androidx.appcompat.app.AppCompatActivity
    import androidx.lifecycle.lifecycleScope
    
    //Third-Party?
    import io.ktor.client.HttpClient
    import io.ktor.client.engine.cio.CIO
    import io.modelcontextprotocol.kotlin.sdk.client.StreamableHttpClientTransport
    import kotlinx.coroutines.launch
    
    class MainActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
    
            // -----------------------------------------------------------------------
            // MCP Client
            // -----------------------------------------------------------------------
            val client = HttpClient(CIO)
    
            val transport = StreamableHttpClientTransport(client,
                                                          "http://server_url/mcp");
    
            lifecycleScope.launch {
                transport.start()
                client.close()
            }
        }
    }

    But I'm not sure really how to work with this?

    How are we supposed to use the kotlin sdk to interact with an MCP Server?

    I'm more than happy to help with crafting an example for the community, but I'm not really an android developer. Any guidance would be greatly appreciated 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions