Skip to content

About

OAuth to x402 bridge MCP server. Lets OAuth only MCP clients such as Manus call Sally AI, with the x402 crypto payment signing handled server side.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Sally OAuth Bridge

OAuth-to-x402 bridge MCP server that enables Manus to call Sally AI

What This Does

This server acts as a bridge between:

  • Manus (OAuth-based MCP client)
  • Sally AI (x402 blockchain payment-based health assistant)

It solves the authentication incompatibility by:

  1. Providing OAuth endpoints that Manus expects
  2. Handling x402 payment signing internally
  3. Exposing Sally's chat functionality as an MCP tool

Features

✅ OAuth-compatible MCP server
✅ Automatic x402 payment handling
✅ Sally AI chat integration
✅ Server-Sent Events (SSE) support
✅ Docker containerized
✅ Ready for Fly.io, Railway, Render deployment
✅ Health checks and monitoring

Quick Start

Local Development

  1. Install dependencies:
pnpm install
  1. Configure environment:
cp .env.example .env
# Edit .env and add your PRIVATE_KEY
  1. Build and run:
pnpm run build
pnpm start

Server runs on http://localhost:3000

Deploy to Production

See DEPLOYMENT_GUIDE.md for complete deployment instructions for:

  • Fly.io (recommended)
  • Railway
  • Render

Quick deploy to Fly.io:

fly launch --no-deploy
fly secrets set PRIVATE_KEY=0xYOUR_KEY
fly deploy

Configuration

Environment Variables

Variable Required Description
PRIVATE_KEY Yes Your wallet's private key (with 0x prefix) for x402 payments
PORT No Server port (default: 3000)
SALLY_API_URL No Sally API endpoint (default: https://api-x402.asksally.xyz)

Security Notes

⚠️ IMPORTANT:

  • Use a dedicated wallet for this service
  • Never use your main wallet
  • Keep only small amounts ($10-20) in the wallet
  • Never commit .env file to git
  • Use secrets management in production

API Endpoints

Endpoint Method Description
/ GET Health check
/.well-known/oauth-authorization-server GET OAuth discovery
/oauth/authorize GET OAuth authorization (auto-approved)
/oauth/token POST OAuth token exchange
/sse GET MCP Server-Sent Events
/message POST MCP message handling

MCP Tools

chat-with-sally

Chat with Sally AI about metabolic health, A1C management, nutrition, and wellness.

Parameters:

  • message (string, required): Your question for Sally

Example:

{
  "message": "What is A1C and how can I improve it?"
}

Topics Sally can help with:

  • Metabolic health and A1C management
  • Blood sugar and insulin sensitivity
  • Low-carb, high-protein nutrition
  • Exercise for metabolic health
  • Sleep optimization
  • Lab result interpretation
  • Supplement guidance
  • Longevity science

Usage from Manus

  1. Deploy the bridge (see DEPLOYMENT_GUIDE.md)

  2. Add to Manus MCP configuration:

    • Server URL: https://your-deployment-url.fly.dev
    • No headers needed!
  3. Call Sally through Manus:

    • The chat-with-sally tool will be available
    • Use it like any other MCP tool

Testing

Test health check:

curl https://your-deployment-url.fly.dev/

Test Sally chat:

curl -X POST https://your-deployment-url.fly.dev/message \
  -H "Content-Type: application/json" \
  -d '{
    "method": "tools/call",
    "params": {
      "name": "chat-with-sally",
      "arguments": {
        "message": "What is A1C?"
      }
    }
  }'

Architecture

┌─────────┐         ┌──────────────────┐         ┌──────────┐
│  Manus  │ ◄─────► │  OAuth Bridge    │ ◄─────► │  Sally   │
│ (OAuth) │         │ (This Server)    │         │  (x402)  │
└─────────┘         └──────────────────┘         └──────────┘
                            │
                            ▼
                    ┌──────────────┐
                    │ Your Wallet  │
                    │ (USDC/Base)  │
                    └──────────────┘

Flow:

  1. Manus connects via OAuth (mock auth, auto-approved)
  2. Manus calls chat-with-sally tool
  3. Bridge signs x402 payment using your private key
  4. Bridge calls Sally API with payment
  5. Sally responds
  6. Response returned to Manus

Cost

Hosting

  • Fly.io: Free (within free tier)
  • Railway: Free ($5 credit/month)
  • Render: Free (750 hours/month)

Sally API Usage

  • Per chat: ~$0.05 USDC
  • 100 chats: ~$5 USDC
  • Paid from your configured wallet on Base network

Monitoring

Check logs:

Fly.io:

fly logs

Railway/Render:

  • Check logs in dashboard

Monitor wallet:

  • Check USDC balance on Base network regularly
  • Add funds when running low

Troubleshooting

Issue Solution
402 Payment Required Add USDC to your wallet on Base network
API client not initialized Set PRIVATE_KEY environment variable
Deployment fails Check logs, verify environment variables
Manus can't connect Verify URL, check server logs

Development

Project Structure

sally-oauth-bridge/
├── src/
│   └── server.ts          # Main server code
├── dist/                  # Compiled JavaScript (generated)
├── package.json           # Dependencies
├── tsconfig.json          # TypeScript config
├── Dockerfile             # Container config
├── fly.toml               # Fly.io config
├── railway.json           # Railway config
├── render.yaml            # Render config
├── .env.example           # Environment template
├── DEPLOYMENT_GUIDE.md    # Deployment instructions
├── MANUS_CONFIG.md        # Manus configuration
└── README.md              # This file

Tech Stack

  • Runtime: Node.js 22
  • Language: TypeScript
  • Framework: Express.js
  • MCP SDK: @modelcontextprotocol/sdk
  • Payment: x402-axios, viem
  • HTTP Client: axios

Contributing

This is a bridge server for personal use. If you find issues:

  1. Check the logs
  2. Verify environment variables
  3. Test endpoints manually
  4. Check wallet balance

License

MIT

Related Projects

Support

For issues:


Built with ❤️ to bridge OAuth and x402 authentication

About

OAuth to x402 bridge MCP server. Lets OAuth only MCP clients such as Manus call Sally AI, with the x402 crypto payment signing handled server side.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages