portmap
Deterministic local service topology for AI agents. Run the CLI — do not guess ports.
When to use
- Before writing
fetch('http://localhost:…')or curl commands - When
.envhas*_URLpointing at localhost - When multiple services (frontend + API) exist in one repo or workspace
- After an agent session that may have hardcoded wrong ports
Workflow
Scan the project:
npx portmap scan .Or static-only (no OS listeners):
npx portmap declare .Read the output:
services[]— declared vs actual portsreferences[]— env keys → localhost URLsedges[]— how frontend connects to backendfindings[]— fix these before debugging
Fix in order:
- PRT-04 — env URL points to port with no listener
- PRT-01 — declared service not running
- PRT-03 — port collision in config
- PRT-05 — listener on unexpected port (Vite port bump)
Write artifact for future sessions:
portmap scan . --writeCommits
.portmap.jsonso agents read stable topology.
MCP tools (if configured)
| Tool | Use when |
|---|---|
portmap_scan |
Full report JSON |
portmap_graph |
Slim services + edges + references |
portmap_resolve_url |
"What is the correct URL for VITE_API_URL?" |
portmap_findings |
List actionable PRT-* issues |
Multi-repo workspace
portmap workspace ~/code/my-monorepo
Resolves cross-project env refs (PRT-07) when API lives in a sibling folder.
Rules
- Never assume port 3000 — read
references[] - Never re-implement port discovery with an LLM
- portmap is read-only — it does not start/stop/kill processes
- Pair with harness-score and unhappypath