Remote MCP

Remote MCP (HTTP) enables MCP tools to run over HTTP by using FastAPI and Mangum with the entrypoints/lambda_handler.py entry point. The deployment supports multiple authentication modes, configured via the AUTH_MODE environment variable at process startup. This guide describes the supported authentication modes, deployment configuration, local HTTP setup, validation procedures, and client integrations for Cursor, VS Code, GitHub Copilot, and Claude Code.

The article also provides guidance on configuring secure communication, validating token-exchange workflows, and deploying the Remote MCP service in both local and cloud environments.

Prerequisites

Before configuring Remote MCP (HTTP), ensure that the following prerequisites are available:

  • Python and Poetry are installed.

  • FastAPI, Mangum, and project dependencies are installed.

  • Access to the OvalEdge environment is available.

  • Valid OvalEdge user token and secret are available for remote_credentials authentication.

  • HTTPS or a TLS termination proxy is configured for protected routes.

  • AWS SAM and Lambda permissions are available for cloud deployment.

  • Environment variables are configured in the .env file or exported through the shell.

  • The repository is cloned locally.

Authentication Modes

The Remote MCP deployment supports multiple authentication modes.

Authentication Mode
Client Credentials
OAuth or Discovery Routes
Description

remote_credentials

X-OvalEdge-Token and X-OvalEdge-Secret

Minimal /.well-known/* stubs (no browser OAuth)

Recommended authentication mode for production deployments. The server caches OvalEdge JWT tokens based on credential keys.

The following routes are shared across all authentication modes:

  • POST/mcp

  • GET/health

  • GET/

All environment variables are documented in the .env.example file below.

Remote Credentials Authentication

The remote_credentials authentication mode uses request headers to validate credentials.

Authentication Workflow

The middleware performs the following actions:

  1. Reads the X-OvalEdge-Token and X-OvalEdge-Secret headers.

  2. Exchanges the credentials with OvalEdge.

  3. Caches JWT tokens by using a digest of the token and secret.

  4. Sets current_oe_jwt and current_oe_credential_cache_key for the request.

HTTPS Enforcement

Protected routes require HTTPS communication.

The application validates HTTPS by using one of the following methods:

  • request.url.scheme == "https"

  • X-Forwarded-Proto: https

If the request uses plain HTTP without the required header, the application returns the following response:

Cache Handling

If OvalEdge APIs return a downstream 401 response:

  1. The application removes the cached credential entry.

  2. The MCP client retries the request with the same headers.

  3. The application performs a new credential exchange.

Configuration Parameter

The cache limit is controlled by the following parameter:

Implementation Files

The remote_credentials implementation uses the following files:

  • server/auth/middleware.py

  • server/auth/credentials_cache.py

  • server/auth/token_exchange.py

  • server/auth/context.py

  • server/client.py

  • server/constants.py

Application Entry Point and Deployment

The application entry point is:

The application behavior changes according to the configured authentication mode:

  • remote mode loads the OAuth routers.

  • remote_credentials mode loads server/auth/remote_credentials_discovery.py.

MCP HTTP Stateless Configuration

The MCP_HTTP_STATELESS parameter controls HTTP behavior.

Parameter Value
Description

true

Recommended for AWS Lambda deployments.

false

Enables GET/mcp registration for SSE fallback support. Required for Cursor and similar HTTP MCP clients.

If MCP_HTTP_STATELESS=false is not configured for supported clients, the application may return an incorrect Content-Type response during GET requests.

AWS Lambda and SAM Deployment

The SAM template file is located at:

Supported Parameters

The template supports the following parameters:

  • AuthMode

  • OAuthIssuer

  • OAuthAudience

  • McpHttpStateless

Deployment Procedure

Perform the following steps to deploy the application:

  1. Navigate to the repository root directory.

  2. Configure the OVALEDGE_BASE_URL environment variable.

  3. Run the deployment script.

To display deployment help information, run the following command:

For detailed deployment instructions, refer to:

Local HTTP Configuration

Follow these steps to configure the application locally using uvicorn.

Configure Environment Variables

  • Configure the following environment variables:

Start the HTTP Application

  • Navigate to the repository directory and start the application.

Local Validation and Testing

Protected routes require HTTPS communication or the X-Forwarded-Proto: https header.

Plain http://127.0.0.1 requests without the required header return the following response:

Configure OvalEdge Credentials

  • Export the required credentials before validation.

Validate Token Exchange

  • Run the validation script.

Validate Health Endpoint

  • Run the following command:

  • Expected result:

    • HTTP 200 response

Validate MCP Initialization

  • Run the following command:

  • Expected Results:

    • Successful authentication returns a valid MCP HTTP response.

    • HTTP 401 indicates invalid credentials or rejected authentication.

Automated Testing

  • Run the following automated tests:

Optional HTTPS Configuration

Configure HTTPS locally by using one of the following methods:

  • Configure a reverse proxy such as Caddy or NGINX.

  • Run uvicorn with SSL certificates.

Example:

Cursor HTTP MCP Configuration

  • Cursor resolves ${env:VAR} values from the process environment instead of the repository .env file.

  • Configure the following parameter on the server:

  • Example mcp.json Configuration

  • Each user must use a unique token and secret combination. The server maintains a separate JWT cache entry for each credential pair.

  • The MCP endpoint supports both of the following formats:

    • http://127.0.0.1:8000/mcp

    • http://127.0.0.1:8000/mcp/

  • The application normalizes slashless/mcp requests to prevent redirect-related issues.

VS Code and GitHub Copilot Configuration

VS Code and GitHub Copilot use a top-level servers object with type: "http" entries.

Configuration Locations

Use one of the following configuration methods:

  • Workspace configuration: .vscode/mcp.json

  • User configuration: Command Palette → MCP: Open User Configuration

  • Guided configuration: Command Palette → MCP: Add Server

Server Requirement

  • Configure the following parameter on the server:

  • Example:

Claude Code HTTP MCP Configuration

Claude Code requires HTTP transport registration through the claude mcp command.

Install Claude Code CLI

  • Use one of the following installation methods.

    • macOS, Linux, or WSL

    • Windows PowerShell

    • Alternative Installation Methods

Complete CLI Authentication

  • Run the following command and complete the authentication flow:

Configure MCP HTTP Stateless Mode

  • Configure the following parameter:

Register the Remote MCP Server

  • Run the following command from the required workspace directory:

Replace the placeholder values with valid OvalEdge credentials.

Use Claude Code

  • Open Claude Code and run the required sessions or commands.

Remove the Remote MCP Configuration

  • Run the following command:

Validation Script Execution

  • Run the following validation commands from the repository root directory.

OAuth Validation

  • Configure the OAuth environment variables from .env.example before running OAuth validation.

  • The --all option validates the following components:

    • Settings validation

    • OIDC discovery

    • OvalEdge token exchange

    • MCP validation

    • Optional credential validation

  • Refer to the validation script documentation for additional parameters such as:

    • --discovery

    • --ovaledge

    • --mcp

Security Guidelines

Remote Credentials Authentication

The remote_credentials mode sends long-lived OvalEdge credentials through request headers.

Follow these security guidelines:

  • Terminate TLS at the edge by using API Gateway or ALB.

  • Do not log credential header values.

  • Use HTTPS for all production deployments.

OAuth 2.x Remote MCP

Treat IdP tokens as sensitive credentials during transmission.

Configure the following parameters carefully after the OAuth implementation becomes stable:

  • OAUTH_AUDIENCE

  • Issuer discovery settings

Remote MCP Directory Layout

The following files are relevant to Remote MCP deployment and authentication.

File Path
Description

entrypoints/lambda_handler.py

HTTP application and Mangum handler

server/auth/middleware.py

Authentication mode handling

server/auth/metadata.py

OAuth metadata handling

server/auth/registration.py

OAuth registration handling

server/auth/remote_credentials_discovery.py

Remote credentials discovery handling

infra/template.yaml

Sample deployment template


Copyright © 2026, OvalEdge LLC, Peachtree Corners, GA, USA.

Last updated

Was this helpful?