# Concurrent slicer mcp session

**URL:** <https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612>\
**Category:** Support\
**Created:** [July 13, 2026, 11:49pm UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612 "2026-07-13T23:49:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [July 13, 2026, 11:49pm UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/1 "2026-07-13T23:49:36Z")

</div>

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).

The issue is my slicerrc.py calls the [slicer-skill/slicer-mcp-server.py at main · pieper/slicer-skill · GitHub](https://github.com/pieper/slicer-skill/blob/main/slicer-mcp-server.py) to auto start the mcp session. If I start two slicer sessions concurrently these mcp servers collide.

Did anyone have a robust solution on how to handle concurrency?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 14, 2026, 7:51am UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/2 "2026-07-14T07:51:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [July 14, 2026, 4:05pm UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/3 "2026-07-14T16:05:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 15, 2026, 4:38am UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/4 "2026-07-15T04:38:26Z")

</div>

This happens automatically already.

The first Slicer instance uses port 2026:

```auto
  MCP server: http://localhost:2026/mcp
  Log file: /var/folders/yk/qm79wxyd1x38xpn3n046gykh0000gn/T/slicer-mcp-44515.log

  Configure your MCP client with:
    {"mcpServers": {"slicer": {"url": "http://localhost:2026/mcp"}}}

  To stop: mcpLogic.stop()

```

The second uses 2027:

```auto

  MCP server: http://localhost:2027/mcp
  Log file: /var/folders/yk/qm79wxyd1x38xpn3n046gykh0000gn/T/slicer-mcp-44711.log

  Configure your MCP client with:
    {"mcpServers": {"slicer": {"url": "http://localhost:2027/mcp"}}}

  To stop: mcpLogic.stop()

```

It should be enough to paste the second blob into Claude and tell it it should be using this port info.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [July 15, 2026, 5:18am UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/5 "2026-07-15T05:18:12Z")

</div>

Great I didn’t notice that it automatically incremented the ports.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/3622_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [July 24, 2026, 4:49am UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/6 "2026-07-24T04:49:31Z")

</div>

@pieper Sometimes it increments the port just fine and sometimes I get this. I can’t tell whats triggering the error.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 24, 2026, 6:33pm UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/7 "2026-07-24T18:33:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 24, 2026, 7:15pm UTC](https://discourse.slicer.org/t/concurrent-slicer-mcp-session/47612/8 "2026-07-24T19:15:36Z")

</div>

Having Claude start it’s own slicer with the server enabled is a great idea. I’ll add that suggestion to the skill.md file.
