modelcontextprotocol / modelcontextprotocol/experimental-ext-interceptors

Add HTTP example for transparent-proxy (TypeScript SDK)

Open
#19 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
23
Forks
14
Avg merge
1d 17h
Merged PRs (30d)
1

Description

Summary

Add a Streamable HTTP variant of the TypeScript transparent-proxy example (typescript/sdk/examples/transparent-proxy), so users can connect to an interceptor gateway over HTTP instead of stdio only.
Raised in PR #13 review (transparent-proxy/src/index.ts): “nit: Think it would be stronger to have HTTP examples.”
Deferred from the initial TypeScript SDK PR; scoped as a separate examples-only PR (no changes to mcp-ext-interceptors library API).

Background

  • Current transparent-proxy matches C# TransparentProxySample: stdio toward the host, stdio clients to backend + interceptor host.
  • C# does not ship an HTTP transparent-proxy sample either. HTTP appears in the optional ConfigDrivenGatewaySample for outbound Streamable HTTP client connections; hosting the gateway over HTTP is documented in the C# README but not a runnable sample.
  • The interceptor SDK is transport-agnostic: McpInterceptorGateway, configureServer(), and registerNotificationForwarding() stay the same; only transports and process orchestration change.

Proposed scope (pick one tier for the first PR)

Tier 1 — HTTP proxy, stdio peers (recommended first PR)
  • New example (e.g. examples/transparent-proxy-http/ or example:transparent-proxy:http).
  • Inbound: StreamableHTTPServerTransport + HTTP server (/mcp POST/GET/DELETE, session management, SSE for notifications) via @modelcontextprotocol/sdk v1 (server/streamableHttp.js, optionally server/express.js).
  • Outbound: keep today’s stdio spawn for interceptor-server + @modelcontextprotocol/server-everything (minimal diff from current sample).
  • README: ports, how to connect a Streamable HTTP client to http://127.0.0.1:<port>/mcp.
Tier 2 — Outbound HTTP only (C# ConfigDriven parity)
  • HTTP-serving variants of interceptor-server (and optionally a stub backend).
  • Proxy surface can remain stdio or add HTTP from Tier 1.
  • Sample JSON config for endpoints (sample-only, not library API).
Tier 3 — Full three-server HTTP demo
  • HTTP proxy + HTTP backend + HTTP interceptor host (production-like, most orchestration/CI cost).
    Suggest Tier 1 for the first follow-up PR; Tier 2/3 as later issues if needed.

Implementation notes

  • Reference MCP SDK Streamable HTTP patterns (v1.29+ has StreamableHTTPServerTransport, StreamableHTTPClientTransport; v2 repo examples/server/src/simpleStreamableHttp.ts is a good session/routing reference).
  • Stateful session map is the main complexity vs stdio (initialize → store transport by Mcp-Session-Id → reuse on POST, GET for SSE). Required for registerNotificationForwarding to be meaningful over HTTP.
  • Example-only deps: likely express if using createMcpExpressApp() — not added to published package.
  • CI: consider marking HTTP example as manual or a single integration test with dynamic ports (harder than stdio spawn).

Acceptance criteria

  • Runnable HTTP transparent-proxy example documented in typescript/sdk/README.md
  • npm run example:… script (or documented multi-step run)
  • Demonstrates McpInterceptorGateway with Streamable HTTP server transport
  • Short comment in example linking to C# parity (TransparentProxySample = stdio; this extends the story)
  • No changes required to src/ interceptor library unless a gap is found during wiring

Non-goals (this issue)

  • OAuth / auth on the HTTP endpoint (unless trivial from SDK helpers)
  • Publishing HTTP examples as part of the npm package
  • C# sample changes (can file separately if we want cross-language parity)

Related

  • PR #13 review thread on typescript/sdk/examples/transparent-proxy/src/index.ts
  • C#: samples/TransparentProxySample (stdio), samples/ConfigDrivenGatewaySample (outbound HTTP)
  • Design doc: typescript/sdk/docs/design-and-implementation.md §11 (examples)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with typescript/sdk/examples/transparent-proxy/src/index.ts and the existing transparent-proxy README, then read typescript/sdk/docs/design-and-implementation.md §11 and the referenced Streamable HTTP examples. Choose and document the first tier, add the runnable HTTP example and npm command, and verify the README and acceptance criteria demonstrate Streamable HTTP server transport without changing src/ unless wiring exposes a gap.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.