package cc.unitmesh.xiuper.fs.mcp import cc.unitmesh.xiuper.fs.* import io.modelcontextprotocol.kotlin.sdk.client.Client /** * Android implementation of MCP Backend. * Uses the MCP SDK which supports Android. */ actual interface McpBackend : FsBackend { actual val isAvailable: Boolean val mcpClient: Client } /** * Android MCP backend implementation. * Provides its own implementation since we can't reference JvmMcpBackend directly. */ class AndroidMcpBackend( override val mcpClient: Client ) : McpBackend { override val isAvailable: Boolean = true override suspend fun stat(path: FsPath): FsStat { return when { path.value == "/" || path.value == "/resources" || path.value == "/tools" -> FsStat(path, isDirectory = true) else -> throw FsException(FsErrorCode.ENOENT, "Path not found: ${path.value}") } } override suspend fun list(path: FsPath): List { return when (path.value) { "/" -> listOf( FsEntry.Directory("resources"), FsEntry.Directory("tools") ) else -> emptyList() } } override suspend fun read(path: FsPath, options: ReadOptions): ReadResult { throw FsException(FsErrorCode.ENOTSUP, "MCP read not implemented for Android yet") } override suspend fun write(path: FsPath, content: ByteArray, options: WriteOptions): WriteResult { throw FsException(FsErrorCode.ENOTSUP, "MCP write not implemented for Android yet") } override suspend fun delete(path: FsPath) { throw FsException(FsErrorCode.EACCES, "Delete not supported for MCP resources") } override suspend fun mkdir(path: FsPath) { throw FsException(FsErrorCode.EACCES, "Create directory not supported for MCP resources") } } /** * Create an Android MCP backend. */ actual suspend fun createMcpBackend(serverConfig: McpServerConfig): McpBackend? { return try { // TODO: Implement actual MCP client creation for Android null // Placeholder for now } catch (e: Exception) { null } }