relay

An agent for server-side relay infrastructure that connects clients to MCP servers running on Android phones. It routes encrypted connections, wakes devices, joins the two network connections, and manages certificates.

In plain words
What is it for?
Use it to develop or maintain the relay server, device wake endpoint, TCP connection handling, per-device routing, and Cloudflare-based ACME certificate orchestration.
Why use it?
It lets clients reach a sleeping phone without the relay reading or storing the connection's private data; TLS remains encrypted end to end.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/monkopedia/rouse-context/relay
Clone the repo
git clone --depth 1 https://github.com/Monkopedia/rouse-context

Made for: Claude Code.

Per session 23 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 579 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00023 $0.00579
Opus 5 $0.00012 $0.00290
Sonnet 5 $0.00005 $0.00116
Haiku 4.5 $0.00002 $0.00058

Measured 2d ago against content hash cd4ff000746f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

relay scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/relay.md · 57 lines

How it starts

The opening of the file, as written. The whole thing — 57 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Relay Server Agent

You work on the relay server component of Rouse Context. This is server-side infrastructure code, NOT Android code.

What the Relay Does

The relay is a publicly reachable server that bridges MCP clients to on-device MCP servers running on Android phones. It:

  1. Receives TLS connections from MCP clients on per-device subdomains (e.g. abc123.rousecontext.com)
  2. Routes based on SNI hostname — pure TLS passthrough, NEVER terminates TLS, NEVER reads payloads
  3. Fires a high-priority FCM push to wake the target device
  4. Holds the client TCP connection open while the device wakes and connects back
  5. Splices the two TCP connections (client ↔ device) for the duration of the session
  6. Tears down cleanly on disconnect or idle timeout

It also provides:

  • /wake/:deviceId — HTTP endpoint for optional pre-warming before TLS connection
  • ACME cert orchestration — receives CSRs from devices, performs DNS-01 challenges via Cloudflare API, returns signed certs

Security Invariants

  • The relay MUST NEVER terminate TLS. It sees ciphertext only.
  • The relay MUST NEVER store, log, or inspect payload data.
  • Device private keys NEVER leave the device. The relay only handles CSRs and signed certs.
  • These are structural guarantees, not policy promises. The code must make violation impossible.

Key Engineering Challenges

  • TCP splice implementation handling half-open connections gracefully (one side closes, the other hasn't yet)
  • FCM delivery reliability — the relay must handle the case where the device doesn't connect back within a timeout
  • Connection lifecycle: client connects → FCM sent → device connects back → splice established → idle timeout → teardown
  • High availability — multiple relay instances with shared state for device routing

Language & Toolchain

Rust. The relay runs on a small VPS (512MB-1GB RAM), so the low memory footprint of a Rust binary matters. The relay is architecturally isolated from the Android codebase — no shared code.

Read the full file on GitHub · 57 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 57 lines · 23 tokens per session scan A cd4ff000746f

Subscribe to this mod's changes

relay is an agent published in the GitHub repository Monkopedia/rouse-context (3 stars, last pushed 2d ago), licensed Apache-2.0. It adds 23 tokens to every session and 579 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

mobile-developer

Cross-platform mobile development specialist for React Native and Flutter. Use PROACTIVELY for mobile applications, native integrations, offline sync, push notifications, and cross-platform optimization.

maxrave-dev/SimpMusic · 38 tokens

cloud-architect

Multi-cloud architecture, cost optimization, serverless vs containers, disaster recovery, and infrastructure design specialist. Use for high-level architecture decisions, cloud migration planning, or cost optimization. Trigger phrases: cloud, AWS, GCP, Azure, serverless, containers, Kubernetes, infrastructure, cost…

travisjneuman/.claude · 69 tokens

dependency-browser

Extracts a Maven dependency's JAR (or sources JAR) into the project build dir so you can browse its classes and source. Use when you need to explore the API or internals of a library. Pass coordinates as group:artifact:version or group:artifact:version:sources. Omit version to have it looked up from…

jonapoul/aktual · 83 tokens

mobile-architect

Mobile architecture expert. Specializes in MVI, Clean Architecture, modularization, and dependency design. Use for architecture decisions, feature planning, and code organization.

ahmed3elshaer/everything-claude-code-mobile · 32 tokens

kmp-architect

KMP architecture expert. Designs shared module structures, expect/actual patterns, navigation, and DI for Kotlin Multiplatform projects.

ahmed3elshaer/everything-claude-code-mobile · 31 tokens

mobile-compactor

Analyzes mobile development sessions and performs strategic context compaction to optimize token usage while preserving critical information.

ahmed3elshaer/everything-claude-code-mobile · 0 tokens