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
feat: zero-config auto-port assignment via FNV-1a hash
Each user gets a deterministic port based on their OS username
(FNV-1a hash with ROR by name length, 12-bit range 31337-35432).
Multi-user setups now work without any manual VECTOR_MEMORY_PORT
configuration. The env var remains as an escape hatch for the rare
hash collision case.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
-**index.js** — Thin STDIO MCP proxy. One per copilot instance. Checks if the HTTP server is running, launches it if not, then ferries tool calls over HTTP.
18
-
-**vector-memory-server.js** — Singleton HTTP server on `localhost:31337`. Owns the embedding model (one copy in memory), SQLite vector DB, and background indexing.
18
+
-**vector-memory-server.js** — Singleton HTTP server. Owns the embedding model (one copy in memory), SQLite vector DB, and background indexing. Port is auto-assigned per user via a deterministic hash of the username.
19
19
-**embed-worker.js** — Worker thread that loads the ONNX model and handles embedding inference off the main thread.
20
20
-**lib.js** — Pure logic extracted for testability: filtering, dedup, post-processing, process detection.
21
21
@@ -67,10 +67,10 @@ Add to `~/.copilot/mcp-config.json`:
67
67
68
68
| Variable | Default | Description |
69
69
|---|---|---|
70
-
|`VECTOR_MEMORY_PORT`|`31337`| HTTP port for the singleton server. Change this to run independent instances per user. |
70
+
|`VECTOR_MEMORY_PORT`|*(auto)*| HTTP port for the singleton server. By default, a deterministic port is computed from your OS username (FNV-1a hash, range 31337–35432). Only set this if two users happen to collide. |
71
71
|`VECTOR_MEMORY_IDLE_TIMEOUT`|`5`| Minutes of inactivity before the server shuts down. `0` or negative = never shut down. |
72
72
73
-
Set these in the `env` block of `mcp-config.json`:
73
+
Set these in the `env` block of `mcp-config.json` (only if needed):
74
74
75
75
```json
76
76
{
@@ -79,19 +79,24 @@ Set these in the `env` block of `mcp-config.json`:
Each user automatically gets a deterministic port based on their OS username (FNV-1a hash with rotation, range 31337–35432). This means multi-user setups work **zero-config** — no manual port assignment needed.
92
+
93
+
In the rare case of a hash collision (two usernames mapping to the same port), the server detects the conflict at startup and tells the affected user to set `VECTOR_MEMORY_PORT` manually.
94
+
90
95
#### Multi-user setup
91
96
92
-
On a shared machine, each user needs their own port to keep session history isolated (the vector index lives in each user's `~/.copilot/`). Point both configs at the same codebase:
97
+
On a shared machine, each user's server runs on their auto-assigned port. Just point both configs at the same codebase — no `env` block needed:
93
98
94
-
**User A** (`~/.copilot/mcp-config.json`) — uses default port 31337:
99
+
**User A** (`~/.copilot/mcp-config.json`):
95
100
```json
96
101
{
97
102
"mcpServers": {
@@ -103,16 +108,13 @@ On a shared machine, each user needs their own port to keep session history isol
103
108
}
104
109
```
105
110
106
-
**User B** (`~/.copilot/mcp-config.json`) — uses port 31338:
111
+
**User B** (`~/.copilot/mcp-config.json`) — same config, different port automatically:
**Error:**`Port 31337 is owned by user "X" (expected "Y")`
193
+
**Error:**`Port 31796 is owned by user "X" (expected "Y")`
192
194
193
-
Two users on the same machine are pointing at the same port. Each user needs a unique port. Edit `~/.copilot/mcp-config.json` and add a `VECTOR_MEMORY_PORT` env var:
195
+
Two usernames hashed to the same port (rare — FNV-1a produces very few collisions). One user needs to set a manual override. Edit `~/.copilot/mcp-config.json` and add a `VECTOR_MEMORY_PORT` env var:
194
196
195
197
```json
196
198
{
@@ -210,9 +212,9 @@ See [Multi-user setup](#multi-user-setup) for full details.
210
212
211
213
### Port occupied by another service
212
214
213
-
**Error:**`Vector memory server failed to start — port 31337 may be in use by another service`
215
+
**Error:**`Vector memory server failed to start — port XXXXX may be in use by another service`
214
216
215
-
Something else is listening on the default port. Pick a different port using the same`VECTOR_MEMORY_PORT` env var as above.
217
+
Something else is listening on your auto-assigned port. Pick a different port using the `VECTOR_MEMORY_PORT` env var as above.
0 commit comments