fix: start the MCP loopback listener
This commit is contained in:
1 parent
e7f9e3478d
commit
794471d75c
3 files changed
+14
-2
No files matched your search
@@ -14,7 +14,8 @@ final class MCPServerController {
|
||||
switch self {
|
||||
case .stopped: String(localized: "Off")
|
||||
case .starting: String(localized: "Starting…")
|
||||
case .ready(let port): String(localized: "Listening on localhost:\(port)")
|
||||
case .ready(let port):
|
||||
String(localized: "Listening on localhost:\(String(port))")
|
||||
case .failed(let reason): reason
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ actor LoopbackHTTPServer {
|
||||
parameters.requiredLocalEndpoint = .hostPort(
|
||||
host: NWEndpoint.Host(address), port: endpointPort
|
||||
)
|
||||
let listener = try NWListener(using: parameters, on: endpointPort)
|
||||
let listener = try NWListener(using: parameters)
|
||||
listener.newConnectionLimit = Self.maximumConnections
|
||||
listener.newConnectionHandler = { [weak self] connection in
|
||||
Task { await self?.accept(connection) }
|
||||
|
||||
@@ -5,10 +5,21 @@ import Testing
|
||||
|
||||
@Suite
|
||||
struct LoopbackHTTPServerTests {
|
||||
@Test
|
||||
func constructsLoopbackListenersWithoutDuplicatingThePortArgument() async throws {
|
||||
let server = LoopbackHTTPServer()
|
||||
|
||||
try await server.start(port: 57_391, token: "test-token") { _ in
|
||||
.text(200, "OK")
|
||||
}
|
||||
await server.stop()
|
||||
}
|
||||
|
||||
@Test
|
||||
func mcpServerIsOffByDefault() {
|
||||
#expect(SettingsKey.defaultMCPServerEnabled == false)
|
||||
#expect(SettingsKey.defaultMCPServerPort == 7_391)
|
||||
#expect(MCPServerController.Status.ready(port: 7_391).label == "Listening on localhost:7391")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user