Skip to content

Add observe serve HTTP endpoint for VPS info - #18

Merged
pol-cova merged 2 commits into
mainfrom
cursor/observe-serve-endpoint-2a71
Jul 24, 2026
Merged

pol-cova merged 2 commits into
mainfrom
cursor/observe-serve-endpoint-2a71

Conversation

@pol-cova

@pol-cova pol-cova commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds observe serve, a read-only HTTP server that exposes the same JSON snapshot as observe snapshot. This lets any frontend fetch live VPS metrics with a simple fetch() call.

Changes

  • New observe serve subcommand with flags:
    • --port (default 8080) — override the listen port
    • --auto-port (default true) — if the requested port is busy, try the next available port
    • --bind (default 127.0.0.1)
    • --token (optional bearer auth)
    • --path (default /info)
    • --cors (default *)
  • New internal/server package with CORS, OPTIONS preflight, and token auth
  • Tests for JSON response, CORS headers, auth, method validation, and port fallback
  • README section with usage and HTML fetch example

Usage

# Local only; auto-picks 8081 if 8080 is busy
observe serve

# Override port with auto fallback
observe serve --port 8080

# Require exact port (fail if busy)
observe serve --port 9000 --auto-port=false

# Public with auth
observe serve --bind 0.0.0.0 --port 8080 --token "your-secret"
fetch("http://your-vps:8080/info", {
  headers: { Authorization: "Bearer your-secret" }
}).then(r => r.json())

Security

  • Binds to 127.0.0.1 by default
  • Warns when binding to 0.0.0.0 without a token
  • Read-only GET endpoint only

Test plan

  • go test ./...
  • go vet ./...
  • go build
Open in Web Open in Cursor 

cursoragent and others added 2 commits July 19, 2026 11:49
Expose the existing snapshot JSON over a read-only GET endpoint with
CORS support so any frontend can fetch machine metrics. Includes optional
bearer token auth, safe localhost default binding, and tests.

Co-authored-by: Paul Contreras <pol-cova@users.noreply.github.com>
Allow overriding the listen port with --port while defaulting to
automatically trying the next free port when 8080 (or the chosen port)
is already in use. Use --auto-port=false to require an exact port.

Co-authored-by: Paul Contreras <pol-cova@users.noreply.github.com>
@pol-cova
pol-cova marked this pull request as ready for review July 19, 2026 11:51
@pol-cova
pol-cova merged commit bf42fc3 into main Jul 24, 2026
1 check passed
@pol-cova
pol-cova deleted the cursor/observe-serve-endpoint-2a71 branch July 24, 2026 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants