Repository navigation
Open
Labels
enhancementNew feature or request
Description
I'm trying to build a very simple MCP Server base on HTTP SSE protocol (not STDIO).
This feature is implemented or not ? The MCP doesn't seem to be connected.
import Foundation
import Logging
// Configure Logger
LoggingSystem.bootstrap { label in
var handler = StreamLogHandler.standardOutput(label: label)
handler.logLevel = .trace
return handler
}
// Create logger
let logger = Logger(label: "com.example.mcp")
let server = Server(
name: "Swift Version Server",
version: "1.0.0",
capabilities: .init(tools: .init(listChanged: false))
)
let transport = HTTPClientTransport(
endpoint: URL(string: "http://localhost:8080")!,
logger:logger
)
try await server.start(transport: transport)
let tool = Tool(name: "swift_version",
description: "Returns the current Swift version",
inputSchema: .object([
"type": .string("object")
]))
await server.withMethodHandler(ListTools.self) { params in
ListTools.Result(tools: [tool])
}
await server.withMethodHandler(CallTool.self) { params in
guard params.name == tool.name else {
throw MCPError.invalidParams("Wrong tool name: \(params.name)")
}
return CallTool.Result(content: [.text(swiftVersion() ?? "No version")])
}
func swiftVersion() -> String? {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
process.arguments = ["swift", "--version"]
let outputPipe = Pipe()
process.standardOutput = outputPipe
do {
try process.run()
process.waitUntilExit()
let data = outputPipe.fileHandleForReading.readDataToEndOfFile()
return String(data: data, encoding: .utf8)
} catch {
return "Error running swift-version: \(error)"
}
}
await server.waitUntilCompleted()
Reacted by muvaffak and Aleksey Pleshkov
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
sebsto commentedon Oct 8, 2025
Hello Clement,
There is no
MCPHTTPServerTransportto implement a server in this library.You need to create your own HTTP endpoint, using Vapor or Hummingbird, your own custom transport for it and bind the pieces together.
@stallent has a reasonably working implementation in his fork's branch.
Look at the thread here
#110
Based on his work, I created a minimal HTTP server with Hummingbird. I use it for request / responses. I haven't try streamable events yet. You can look at the code, but it's a heavy work in progress.
https://github.com/sebsto/agentkit (the README is not updated, look at the Example directory instead)
realmtai commentedon Nov 15, 2025
What's the purpose of
NetworkTransportactor? should the following code work?DePasqualeOrg commentedon Jan 4, 2026
I've implemented this functionality in my PR #175. I'd love to hear your feedback if you're able to test it.