Skip to main content
Glama
remote-mcp-server

remote-mcp-server

by CasterShell
README.md
# remote-mcp-server

A production-ready Remote **Model Context Protocol (MCP)** server over Streamable HTTP with a built-in **OAuth 2.1 Authorization Server**, strict Zod output schemas, SSRF-hardened fetching, gzipped file uploads, and on-host Whisper speech-to-text.

## Highlights

- **Modern MCP Protocol:** Implements MCP `2026-07-28` Streamable HTTP with stateless `2025-11-25` compatibility via `@modelcontextprotocol/server`.
- **Built-in OAuth 2.1 Authorization Server (`src/oauth.js`):**
  - RFC 9728 Protected Resource Metadata (`/.well-known/oauth-protected-resource`) with `resource_documentation`
  - OAuth Authorization Server Metadata (`/.well-known/oauth-authorization-server`)
  - **Client ID Metadata Documents (CIMD)** & **Dynamic Client Registration (DCR)**
  - Mandatory **PKCE S256**, `resource` parameter audience binding, `iss` response validation, and owner-passphrase consent gating
  - Rotating opaque refresh tokens (stored hashed) and HMAC-signed short-lived access tokens
- **Schema-First Tools (`src/mcp.js`):**
  - `memo_write` — stores structured notes with compact JSON output matching declared `outputSchema`
  - `memo_search` — searches stored notes within a strict 1,024-byte response budget
  - `upload` — accepts raw or `gzip`-compressed payloads (handling multi-MB files cleanly over serverless request limits) and returns verified byte-length download URLs
  - `transcribe` — runs quantized `onnx-community/whisper-base.en` via `@huggingface/transformers`, splitting long audio at silence pauses to prevent skipped speech segments
- **SSRF Defense (`src/safefetch.js`):** Validates schemes (`http`/`https`), ports (`80`/`443`), DNS resolution, and blocks loopback/private/link-local IPv4 and IPv6 ranges (`ipaddr.js`) before following fetches.
- **Pluggable Storage (`src/store.js`):** Local filesystem backend (`STORE_DIR`) for local dev & CI, or `@vercel/blob` for serverless deployment.

## Quick Start

```bash
npm install
npm test
```

Run locally:

```bash
cp .env.example .env
node scripts/local.mjs
```

CLI memo client (uses OAuth 2.1 DCR + PKCE):

```bash
MCP_SERVER_URL=http://127.0.0.1:3000 node scripts/memo.mjs --help
```

## Architecture

See [ARCHITECTURE.md](ARCHITECTURE.md) for the OAuth 2.1 + MCP request flow, storage abstraction, and security boundaries.

## License

MIT