Yardmaster
Allows opt-in creation and management of public HTTPS ngrok tunnels for registered ports, exposing local services at public URLs with optional HTTP Basic Auth, IP allow/deny restrictions, region selection, and paid custom reserved domains.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Yardmaster register a port for myapp and expose it with a public tunnel"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Yardmaster
Automatic port allocation with opt-in ngrok tunnel management for AI agents via MCP protocol.
Table of Contents
Related MCP server: wharfy
Features
Automatic Port Allocation: Assigns ports from configurable range (default: 3000-9000)
ngrok Tunnel Creation: Opt-in public HTTPS tunnels (
tunnel: true/--tunnel)MCP Protocol Support: Four tools for AI agent integration
CLI Interface: Manual port management via command line
Terminal UI (TUI): Interactive interface built with Go and bubbletea
Persistent Registry: JSON-based storage at
~/.yardmaster/registry.jsonSecurity Features: HTTP Basic Auth and IP restrictions
Custom Domains: Support for paid ngrok reserved domains
Thread Safe: File locking prevents concurrent access corruption
Prerequisites
Node.js 18 or later
ngrok account (free tier available, only needed for public tunnels)
Go 1.21 or later (optional, only for TUI)
Installation
git clone https://github.com/croakingtoad/yardmaster.git
cd yardmaster
npm install
npm run build
npm link # Optional: makes 'yardmaster' command globally availableIf you need a public tunnel, set your ngrok auth token:
export NGROK_AUTH_TOKEN="your_token_here"Get your token from: https://dashboard.ngrok.com/get-started/your-authtoken
Verify installation:
yardmaster statusQuick Start
Register and use a port:
yardmaster register myapp --tunnel
# Output: Port 3000 registered for 'myapp'
# ngrok URL: https://abc123.ngrok.app
# Your app is now accessible at https://abc123.ngrok.appWithout --tunnel, yardmaster register myapp reserves a local port only and does not require an ngrok token.
Release when done:
yardmaster release myappView all registrations:
yardmaster listConfiguration
Environment Variables
# Required only when using --tunnel or tunnel: true
export NGROK_AUTH_TOKEN="your_token_here"
# Optional - Security
export NGROK_BASIC_AUTH="username:password"
export NGROK_IP_ALLOW="1.2.3.4/32,10.0.0.0/8"
export NGROK_IP_DENY="192.168.1.0/24"
# Optional - Custom domain (requires paid ngrok account)
export NGROK_DOMAIN="your-subdomain.ngrok.dev"
# Optional - Port range
export PORT_RANGE_START=4000
export PORT_RANGE_END=5000User Config File
Create ~/.yardmaster/config.json:
{
"port_range": {
"start": 3000,
"end": 9000
},
"ngrok": {
"auth_token": "your_token_here",
"region": "us"
}
}Available ngrok regions: us, eu, ap, au, sa, jp, in
Environment variables override config file settings.
Usage
CLI Commands
# Register a local port (auto-assign from range; no tunnel by default)
yardmaster register <app_name>
# Register a port and expose it publicly through ngrok
yardmaster register <app_name> --tunnel
# Register a specific local port
yardmaster register <app_name> <port>
# List all active ports
yardmaster list
# Release a port
yardmaster release <app_name>
# Show configuration and status
yardmaster status
yardmaster configMCP Server
For AI agents like Claude, add to your MCP config (e.g., claude_desktop_config.json):
{
"mcpServers": {
"yardmaster": {
"command": "node",
"args": ["/absolute/path/to/yardmaster/dist/index.js"],
"env": {
"NGROK_AUTH_TOKEN": "your_token_here"
}
}
}
}Requirements:
Use absolute paths, not relative
Include an auth token in
envor set it globally only when calls usetunnel: true
Available MCP Tools
register_port
Input:
app_name(required),desired_port(optional),tunnel(optional, defaultfalse)Output:
{ port, ngrok_url, success, message }Registers port; only creates an ngrok tunnel when
tunnel: trueis passed
release_port
Input:
app_name(required)Output:
{ port, success, message }Closes tunnel (if any) and releases port
query_ports
Input:
filter(optional)Output:
{ total, registrations[] }Lists active port registrations
get_available_port
Input:
range_start(optional),range_end(optional)Output:
{ port, success, message }Returns next available port in range
Terminal UI (TUI)
Build and run the interactive terminal interface:
cd tui
go build -ldflags="-s -w" -o yardmaster-tui
./yardmaster-tuiFeatures:
Event-driven updates (no polling)
Pagination (20 ports per page)
Security status display
Vim-style navigation (j/k/h/l)
Thread-safe file locking
Keyboard Shortcuts:
↑/↓orj/k- Navigate←/→orh/l- Change pageEnter- View detailsEsc- Go backr- Refreshq- Quit
See tui/README.md for complete documentation.
Training AI Agents
To ensure AI agents use Yardmaster instead of hardcoded ports, add instructions to your project or global configuration.
Global Configuration (Recommended)
Add this to ~/.claude/CLAUDE.md to enable Yardmaster coordination for all projects:
## 🚂 Yardmaster Port Management - CRITICAL RULES
**BEFORE starting ANY server, API, or service, you MUST use Yardmaster for port allocation.**
### Mandatory Workflow
1. **Check** if yardmaster MCP is available (it should be)
2. **Query** existing ports: `mcp.callTool('yardmaster', 'query_ports')`
3. **Register** a port BEFORE starting server: `mcp.callTool('yardmaster', 'register_port', {app_name: 'project-name-component', tunnel: true})`
4. **Use** the returned port number in your server config
5. **Share** the returned ngrok URL with user (public access)
6. **Release** when done: `mcp.callTool('yardmaster', 'release_port', {app_name: 'project-name-component'})`
### Forbidden Actions
❌ **NEVER** hardcode ports (3000, 8080, 5173, 5000, 8000, etc.)
❌ **NEVER** start a server without registering with yardmaster first
❌ **NEVER** use `PORT=3000` or similar hardcoded environment variables
❌ **NEVER** skip yardmaster even if "just testing" or "quick prototype"
### Why This Matters
- Prevents port conflicts across projects
- Provides public URLs via ngrok when `tunnel: true` is requested
- Enables port coordination across multiple agents
- Tracks what's running where
- Automatic cleanup and port recycling
### Examples
#### Starting a Vite dev server:
\`\`\`javascript
// 1. Register port first
const result = await mcp.callTool('yardmaster', 'register_port', {
app_name: 'myproject-frontend',
tunnel: true
});
// Returns: { port: 3024, ngrok_url: "https://abc123.ngrok.app" }
// 2. Configure vite with assigned port
// vite.config.ts:
export default defineConfig({
server: { port: 3024 } // Use result.port
})
// 3. Tell user the public URL
console.log("Frontend running at:", result.ngrok_url);
\`\`\`
#### Starting a Node/Express API:
\`\`\`javascript
const result = await mcp.callTool('yardmaster', 'register_port', {
app_name: 'myproject-api',
tunnel: true
});
app.listen(result.port, () => {
console.log(\`API: \${result.ngrok_url}\`);
});
\`\`\`
#### Starting multiple services:
\`\`\`javascript
// Register each service with descriptive names
const frontend = await mcp.callTool('yardmaster', 'register_port', {app_name: 'myapp-web'});
const api = await mcp.callTool('yardmaster', 'register_port', {app_name: 'myapp-api'});
const db = await mcp.callTool('yardmaster', 'register_port', {app_name: 'myapp-postgres'});
// Use assigned ports for each service
// frontend.port, api.port, db.port
\`\`\`
### Naming Convention
Use descriptive app names: `{project}-{component}`
- ✅ `ecommerce-frontend`, `ecommerce-api`, `ecommerce-admin`
- ✅ `blog-web`, `blog-cms`, `blog-search`
- ❌ `app`, `test`, `server` (too generic)
### Error Handling
\`\`\`javascript
const result = await mcp.callTool('yardmaster', 'register_port', {
app_name: 'myapp-web'
});
if (!result.success) {
// Handle port unavailable - try a different name or check what's using ports
const ports = await mcp.callTool('yardmaster', 'query_ports');
console.log("Existing ports:", ports);
}
\`\`\`
### Cleanup
Always release ports when done:
\`\`\`bash
# At end of session or when stopping server
await mcp.callTool('yardmaster', 'release_port', {app_name: 'myapp-web'});
\`\`\`
**This is not optional. Always use Yardmaster for port management.**Project-Level Configuration
For project-specific instructions, create /path/to/your/project/CLAUDE.md:
## Port Management
This project uses Yardmaster for port coordination.
**Services:**
- Frontend: Register as `projectname-web`
- API: Register as `projectname-api`
- Database: Register as `projectname-db`
See global CLAUDE.md for full Yardmaster workflow.Example Workflow
Starting a React development server:
// 1. Register port
const result = await mcp.callTool('yardmaster', 'register_port', {
app_name: 'frontend',
tunnel: true
});
// Returns: { port: 3000, ngrok_url: "https://abc123.ngrok.app" }
// 2. Configure Vite with assigned port
// vite.config.ts:
export default defineConfig({
server: { port: 3000 } // Use result.port
})
// 3. Start server and share ngrok URL
npm run dev
// Tell user: "App running at https://abc123.ngrok.app"Handling Port Conflicts
If desired port is unavailable:
// Attempt specific port
const result = await mcp.callTool('yardmaster', 'register_port', {
app_name: 'frontend',
desired_port: 3000
});
if (!result.success) {
// Auto-assign instead
const fallback = await mcp.callTool('yardmaster', 'register_port', {
app_name: 'frontend'
});
// Use fallback.port
}Architecture
┌─────────────────────────┐
│ AI Agent (Claude) │
└───────────┬─────────────┘
│ MCP Protocol
┌───────────▼─────────────┐
│ Yardmaster MCP Server │
│ - register_port │
│ - release_port │
│ - query_ports │
│ - get_available_port │
└───────────┬─────────────┘
│
┌────────┴────────┐
│ │
┌──▼──────┐ ┌──────▼──────┐
│Registry │ │NgrokManager │
│(JSON) │ │(SDK) │
└─────────┘ └──────┬──────┘
│
┌──────▼──────┐
│ ngrok Cloud │
│ Public URLs │
└─────────────┘Components:
PortRegistry: Manages port allocations with JSON persistence and file locking
NgrokManager: Wraps @ngrok/ngrok SDK for tunnel lifecycle
MCP Server: Exposes tools for AI agent integration
CLI: Command-line interface for manual operations
TUI: Interactive terminal interface (Go/bubbletea)
Security
Authentication
HTTP Basic Auth protects tunnel endpoints:
export NGROK_BASIC_AUTH="username:password"
export NGROK_AUTH_TOKEN="your_token_here"
yardmaster register secure-app --tunnelAll tunnels created after setting NGROK_BASIC_AUTH require username/password authentication.
IP Restrictions
Limit tunnel access by IP address using CIDR notation:
# Allow only specific IPs
export NGROK_IP_ALLOW="1.2.3.4/32,10.0.0.0/8"
# Deny specific IP ranges
export NGROK_IP_DENY="192.168.1.0/24"
export NGROK_AUTH_TOKEN="your_token_here"
yardmaster register restricted-app --tunnelNote: IP restrictions require a paid ngrok account. Free accounts receive error ERR_NGROK_9017.
Security Metadata
Security settings are stored in registry for each port:
{
"security": {
"basic_auth": true,
"ip_restrictions": false,
"custom_domain": true
}
}The TUI displays actual security status per port.
Important Security Notes
Never commit
NGROK_AUTH_TOKENto version controlUse environment variables or user config files (
~/.yardmaster/config.json)User config files are stored in home directory, outside repository
Public ngrok tunnels without authentication are accessible by anyone
Always use authentication or IP restrictions for production services
Troubleshooting
"Failed to initialize ngrok"
Cause: A public tunnel was requested but the auth token is not set or is invalid
Solution:
Verify token:
echo $NGROK_AUTH_TOKENValidate at https://dashboard.ngrok.com/get-started/your-authtoken
Check for typos (tokens are 48+ characters)
Set in
~/.yardmaster/config.jsonas alternative
"No available ports in range"
Cause: All ports in range (3000-9000 by default) are occupied
Solution:
List active:
yardmaster listRelease unused:
yardmaster release <app_name>Expand range: Set
PORT_RANGE_STARTandPORT_RANGE_ENDCheck system processes:
lsof -i :3000-9000
"Port already in use"
Cause: Port is registered to another application
Solution:
Check registration:
yardmaster listRelease existing:
yardmaster release <app_name>Use auto-assignment (omit port number)
MCP Server Not Responding
Cause: Path error, missing token, or server crash
Solution:
Use absolute path in MCP config (not relative)
If using
tunnel: true, verifyNGROK_AUTH_TOKENinenvor the global environmentTest manually:
node /absolute/path/to/yardmaster/dist/index.jsCheck MCP logs (location varies by client)
Restart AI client
Invalid Input Errors
NGROK_BASIC_AUTH format:
Must be
username:password(colon-separated)Example:
NGROK_BASIC_AUTH="admin:secure123"Both username and password required
NGROK_IP_ALLOW/DENY format:
CIDR notation:
IP/prefixSingle IP:
1.2.3.4/32Multiple:
1.2.3.4/32,10.0.0.0/8(comma-separated)IPv6 supported:
2001:db8::/32Prefix range: 0-32 (IPv4), 0-128 (IPv6)
Development
Setup
npm install
npm run buildScripts
npm run build- Compile TypeScriptnpm run dev- Watch modenpm test- Run test suitenpm run lint- ESLintnpm run type-check- TypeScript validation
Testing
TypeScript Tests cover CLI behavior, configuration, registry operations, validation, and error handling.
Go Tests cover TUI registry parsing, JSON error handling, and port filtering.
Test layout
TypeScript tests are deliberately co-located with the source they exercise as
src/*.test.ts. Test doubles may live alongside that source when they let a
test drive the real implementation. The TypeScript build preserves this layout
under dist/, and the test script runs the emitted test modules. Moving every
test into a separate test directory would not change behaviour and would break
the established build-and-test layout.
Supported testability APIs
The following exports are supported APIs for exercising real server and ngrok
code in tests. They do not change the production path: start() still loads
the real configuration, connects the real stdio transport, and NgrokManager
uses the real @ngrok/ngrok SDK by default.
YardmasterServeris exported so tests can construct the actual MCP server.YardmasterServer.initialize(config)is public so tests can initialize that actual server with controlled configuration.YardmasterServer.connect(transport)is public so tests can connect it to a controlled transport instead of the production stdio transport.NgrokSdkis exported andnew NgrokManager(config, sdk)accepts it as an optional second argument so tests can driveNgrokManagerwith an SDK seam; omitting it uses the real ngrok SDK.
These seams exist to keep tests on the shipped implementation rather than on copies of its logic.
Run tests:
# TypeScript
npm test
# Go
cd tui && go test ./...Build TUI
cd tui
go build -ldflags="-s -w" -o yardmaster-tuiThe -ldflags="-s -w" flags strip debug symbols, reducing binary size by 30%.
Project Structure
yardmaster/
├── src/ # TypeScript source
│ ├── registry.ts # Port allocation
│ ├── ngrok-manager.ts # Tunnel management
│ ├── validation.ts # Input validation
│ └── index.ts # MCP server
├── tui/ # Go TUI application
│ ├── internal/
│ │ ├── models/ # State management
│ │ ├── registry/ # Registry parser
│ │ └── ui/ # View renderers
│ └── main.go
├── config/ # Default configuration
└── dist/ # Compiled JavaScriptRoadmap
Completed Features
Custom ngrok domains and subdomains
Authentication (Basic Auth, IP restrictions)
Terminal UI with bubbletea
File locking for concurrency safety
Event-driven file watching (fsnotify)
Input validation with error messages
Test suite
Pagination for large port lists
Planned Features
Web Dashboard (browser-based UI)
Multi-Machine Aggregation (shared registry across machines)
Analytics (port usage metrics and history)
Docker Integration (auto-discover containerized apps)
Webhooks (notifications on port events)
Database Backend (SQLite/Postgres instead of JSON)
Team Features (multi-user/organization support)
Performance
Registry capacity: Tested with 1000+ ports
Pagination: 20 ports per page in TUI
File watching: Event-driven updates (zero polling overhead)
Binary size: 3.3MB (TUI), stripped
Startup time: <100ms for CLI operations
Concurrency: Thread-safe with file locking (Node.js and Go)
License
MIT
Contributing
Issues and pull requests are welcome. Please include tests for new features.
For bug reports, include:
Operating system and version
Node.js version
Error messages (if any)
Steps to reproduce
Repository: https://github.com/croakingtoad/yardmaster
Built by LOCOMOTIVE
Available Tools
5 toolsannotate_portA
Yardmaster port registry: update hostname or exposure notes on an existing active registration without releasing its port. Pass null to clear the notes.
Inputs: notes (required), app_name (required).
get_available_portB
Yardmaster port registry: get the next available/free port in the configured range. Use when asked to find an open port for a new dev server. Useful for checking port availability before registration.
Inputs: range_end, range_start.
query_portsA
Yardmaster port registry: list all registered ports with their applications, ngrok URLs, and notes. Notes carry hostname/exposure detail, so read them when determining how an app is reachable. Use when asked what ports are in use, what is running where, or to look up the port registry. Optionally filter by app name or port number.
Inputs: filter.
register_portA
Yardmaster port registry: register a port for an application. Use when asked to register, claim, or reserve a port for a dev server or app. If port is not specified, one will be auto-assigned from the configured range. Does NOT create a public tunnel unless tunnel=true is passed.
Inputs: app_name (required), notes, tunnel, desired_port.
release_portA
Yardmaster port registry: release a registered port and stop its ngrok tunnel if one exists. Use when asked to release, free, or unregister a port. Frees the port for other applications.
Inputs: app_name (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool maps to a distinct action on the port registry: query (read), get_available_port (discover free), register_port (create), annotate_port (update metadata), release_port (delete). The only potential overlap—checking availability—is explicitly clarified in get_available_port's description versus query_ports. An agent can select the right tool without confusion.
All five tools follow a consistent snake_case verb_noun pattern (annotate_port, release_port, query_ports, register_port, get_available_port). Verb choice varies slightly (query vs get), but the convention is predictable and readable throughout.
Five tools is a tight, well-scoped set that exactly covers the port-registry lifecycle: discover, claim, annotate, list, and release. No tool feels redundant or missing at this scale.
Full create/read/update/delete coverage plus a free-port discovery helper, so the core lifecycle has no dead ends. Minor gaps exist: annotate_port only updates hostname/exposure notes, with no way to change an application name or toggle tunnel settings after registration beyond release and re-register.
Maintenance
Related MCP Connectors
Connect AI agents to discover services and coordinate real-world tasks.
The cloud for agents. Tools for AI agents to register, build, and deploy other agents. Zero human required.
Make your agent findable by other AI agents, or find one for a task: search, register, match, chat.
Gives AI agents a public IPv6 identity, hostname, port forwarding, web fetch, team mesh. Free tier.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to discover, configure, and manage local development servers. Provides tools for app registration, port allocation, lifecycle control, and log access without manual config editing.MIT
- AlicenseNot gradedqualityCmaintenanceMCP server for managing local dev ports on macOS. It enables AI agents to inspect listening ports, identify owning processes and parent chains, kill processes safely, wait for ports, and report LAN exposure.7 npm1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to deterministically discover which localhost ports and env URLs are actually running, resolving declared configs, OS listeners, and service connections into a machine-readable .portmap.json with actionable findings.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to coordinate ports and dev servers on a shared Linux machine, reserve ports, start and stop worktree servers, inspect listening services, Tailscale devices and dev worktrees, and clean up safely without collisions.15 npmMIT