Kotlin Multiplatform SDK for the Mastodon API.
- Group:
org.litote.mastodon.ktor.sdk - License: Apache 2.0
- Ktor and kotlinx.serialization dependencies — fully KMP compatible
- Granularity at the operation level: each API operation is a separate dependency/Gradle module
- alpha stage SDK for operation composition (e.g. upload an image and post a media status)
- alpha stage Gradle plugin for usage with Gradle projects
- alpha stage CLI tools for command-line usage
- alpha stage MCP server to expose Mastodon tools to AI assistants (Claude Desktop, Claude Code, etc.)
Each API operation has its own module in the client directory. Add only what you need:
// POST /api/v1/statuses
implementation("org.litote.mastodon.ktor.sdk:statuses-api-v1-statuses-post-client:<version>")
// POST /api/v2/media
implementation("org.litote.mastodon.ktor.sdk:media-api-v2-media-post-client:<version>")Configure a ClientConfiguration with your server and access token:
val config = ClientConfiguration(
baseUrl = "https://mastodon.example.com/",
httpClientConfig = {
install(ContentNegotiation) { json(Json { ignoreUnknownKeys = true }) }
defaultRequest {
header("Authorization", "Bearer $accessToken")
}
}
)
val client = StatusesApiV1StatusesPostClient(config)
val response = client.createStatus(TextStatus(status = "Hello Mastodon!"))- All operations available in client directory
- These clients are generated with OpenAPI Ktor Client Generator
For operation composition (e.g. upload an image and post a media status).
See sdk/README.md for usage.
For projects that build with Gradle, the gradle-plugin module provides sendText and sendMedia tasks that call the SDK directly — no shell invocation needed.
See gradle-plugin/README.md for setup and usage.
Expose Mastodon tools to any MCP client (Claude Desktop, Claude Code, etc.) via a STDIO transport.
See mcp-server/README.md for setup and usage.
Command-line tools to post statuses to Mastodon.
See cli/README.md for usage.