You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
There is no MCPHTTPServerTransport to 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)
What's the purpose of NetworkTransport actor? should the following code work?
/// // Create a TCP connection to a server
letconnection=NWConnection(
host:NWEndpoint.Host("192.168.1.034"),
port:NWEndpoint.Port(23232),
using:.tcp
)
// Initialize the transport with the connection
lettransport=NetworkTransport(connection: connection)tryawait server.start(transport: transport)await server.waitUntilCompleted()
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?/// // Create a TCP connection to a server let connection = NWConnection( host: NWEndpoint.Host("192.168.1.034"), port: NWEndpoint.Port(23232), using: .tcp ) // Initialize the transport with the connection let transport = NetworkTransport(connection: connection) try await server.start(transport: transport) await server.waitUntilCompleted()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.