"""
Proxy Server for Claude Desktop (Free Version).
This proxy runs via STDIO and forwards requests to the HTTP MCP server.
Claude Desktop connects to this proxy, which handles authentication automatically.
Usage:
1. Start the HTTP server first: python server.py --http
2. Configure Claude Desktop to use this proxy
"""
import os
from dotenv import load_dotenv
from fastmcp import FastMCP, Client
from fastmcp.client.auth import BearerAuth
# Load environment variables
load_dotenv()
# Configuration
MCP_SERVER_URL = os.getenv("MCP_SERVER_URL", "http://localhost:8000/mcp")
MCP_AUTH_TOKEN = os.getenv("MCP_AUTH_TOKEN")
# Create authenticated client to connect to HTTP server
if MCP_AUTH_TOKEN:
client = Client(
MCP_SERVER_URL,
auth=BearerAuth(token=MCP_AUTH_TOKEN)
)
else:
client = Client(MCP_SERVER_URL)
# Create proxy server (runs via STDIO for Claude Desktop)
# Named 'mcp' so FastMCP CLI can auto-detect it
mcp = FastMCP.as_proxy(client, name="Efforti Name Resolver")
if __name__ == "__main__":
# Run via STDIO - this is what Claude Desktop expects
mcp.run()