Build secure MCP-compliant servers to integrate Large Language Models with your data and tools using familiar http4k patterns
MCP 2025-11-25 + Draft protocols with OAuth & Resource Metadata, passing MCP conformance tests. Full support for Tools, Prompts, Resources, Tasks, Sampling, Elicitation, and more.
Pure functions, no side effects. Test Tools, Resources, and MCP Apps fully in-memory - no network, no ports, no flaky CI.
http4k’s powerful Lens system for type-safe tool definitions and capability bindings with compile-time safety.
Server-rendered UI components with the MCP Apps protocol. Dashboards, forms, and visualizations directly in MCP clients. Fully testable.
OpenTelemetry MCP Semantic Conventions support. Plug into Jaeger, Honeycomb, Datadog - with zero custom instrumentation.
Payment-gated MCP tools and resources with x402 and Machine Payments Protocol (MPP). Protocol-level and tool-level payment filters for automated machine-to-machine commerce.
HTTP Streaming, SSE, WebSocket, JSON-RPC, and Standard IO transports. Stateful or stateless protocols for desktop and web clients.
Build your own AI agents with pure Kotlin MCP protocol clients. Plug any A2A agent straight into Claude Desktop, Cursor, or any MCP client via the provided bridge.
Define typesafe MCP tools and capabilities with simple, testable functions.
fun liveWeatherTool(): ToolCapability {
val city = Tool.Arg.string().required("city")
val report = Tool.Output.auto(WeatherReport(100, "Sunny")).toLens()
return Tool(
"weather",
"Checks the weather for a particular city.", city, output = report
) bind { request: ToolRequest ->
val forecast = WeatherReport(100, "Sunny in ${city(request)}")
ToolResponse.Ok().with(report of forecast)
}
}
data class WeatherReport(val temperature: Int, val outlook: String)Compose capabilities into a lightweight server, with security built in.
fun main() {
val mcpServer = mcp(
ServerMetaData(McpEntity.of("weather"), Version.of("1.0.0")),
OAuthMcpSecurity(authServer, mcpResource) { it == "my_oauth_token" },
liveWeatherTool(),
loadFromFileSystem(),
searchWebsite()
)
mcpServer.asServer(JettyLoom(3002)).start()
}Connect your MCP Server or MCP App to Claude Desktop as a standard MCP connector.

Call your MCP server from other agents with the pure Kotlin MCP Client.
fun main() {
val mcpClient = HttpStreamingMcpClient(
Uri.of("http://localhost:3002/mcp"),
McpEntity.of("http4k mcp client"), Version.of("1.0.0"),
)
mcpClient.start()
mcpClient.tools().call(
ToolName.of("weather"),
ToolRequest(mapOf("city" to "london"))
)
}
Ready to build? Start experimenting with MCP Servers and Apps at the http4k toolbox
http4k MCP (Model Context Protocol) is available under the http4k Commercial License. Free for qualifying small businesses (under $1M ARR), non-commercial, non-profit, and research use. Checkout is handled securely by Stripe.
All http4k Pro modules are also automatically included with the Enterprise Edition. Need bulk seats, team licensing, or custom terms? Get in touch.
