Sometimes I run two agents simultaneously for different tasks. these tasks are often executed in different Slicer sessions also running concurrently (e.g., stable vs a preview version, or different code branches being tested simultaneously).
Yes, I do that often. I start the two servers on different ports in different instances or Slicer (look at the port it reports at startup or specify the port manually). You can tell the Claude which port to use via the .mcp.json (restart the window in vscode) or just tell Claude to use that port and it figures out to use curl to do it.
Do you think it is possible to check whether there is an mcp server already running and if so, bump up to the port number programmatically for the new slicer session? Or do you always manually adjust inside the slicer?
@pieper Sometimes it increments the port just fine and sometimes I get this. I can’t tell whats triggering the error.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<string>", line 146, in loadSlicerRCFile
File "<string>", line 14, in <module>
File "<string>", line 543, in startMcpServer
File "/home/maga/Downloads/Slicer/bin/../lib/Slicer-5.12/qt-scripted-modules/WebServer.py", line 656, in start
self.server = SlicerHTTPServer(requestHandlers=self.requestHandlers,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/maga/Downloads/Slicer/bin/../lib/Slicer-5.12/qt-scripted-modules/WebServer.py", line 307, in __init__
HTTPServer.__init__(self, server_address, SlicerHTTPServer.DummyRequestHandler)
File "/home/maga/Downloads/Slicer/lib/Python/lib/python3.12/socketserver.py", line 457, in __init__
self.server_bind()
File "/home/maga/Downloads/Slicer/lib/Python/lib/python3.12/http/server.py", line 136, in server_bind
socketserver.TCPServer.server_bind(self)
File "/home/maga/Downloads/Slicer/lib/Python/lib/python3.12/socketserver.py", line 478, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use
I always ask Claude to start its own Slicer with the server interface open at any port it prefers. It can then iterate on its own, rebuild and restart Slicer as needed, etc.