### Build MCP Server Source: https://developer.gemini.com/get-started Navigate to the MCP server directory and install dependencies, then build the project. Ensure you have Node.js and npm installed. ```bash cd developer-platform/packages/mcp-server npm install npm run build ``` -------------------------------- ### Clone Gemini Samples and Install Dependencies Source: https://developer.gemini.com/get-started Clone the Gemini API samples repository and install Python dependencies using pip. This sets up the necessary libraries for running the provided examples. ```Python git clone https://github.com/gemini/developer-platform.git cd developer-platform/samples/python pip install -r requirements.txt ``` -------------------------------- ### Run Gemini Place Order Example Source: https://developer.gemini.com/get-started Execute the Python script to place a sandbox limit order. The script automatically handles HMAC-SHA384 signing for the request. ```Terminal python place_order.py ``` -------------------------------- ### Gemini Order Confirmation Source: https://developer.gemini.com/get-started Example output showing a confirmed order with an order ID. This ID can be used to query the order status or cancel it. ```Python # Order confirmed ✓ Order placed: {'order_id': '7651834', 'symbol': 'btcusd', 'side': 'buy', ...} ``` -------------------------------- ### Configure Environment Variables for Gemini API Source: https://developer.gemini.com/get-started Create a .env file to store your API credentials and the sandbox base URL. The python-dotenv library will load these automatically. ```Python cat > .env << 'EOF' GEMINI_API_KEY=account-xxxxxxxxxxxxxxxx GEMINI_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx GEMINI_BASE_URL=https://api.sandbox.gemini.com/v1 EOF ``` -------------------------------- ### Clone Gemini Developer Repository Source: https://developer.gemini.com/get-started Clone the official Gemini developer platform repository to your local machine. This is the first step to setting up the development environment. ```bash git clone https://github.com/gemini/developer-platform.git ``` -------------------------------- ### Listen for Order Fills and Cancel Source: https://developer.gemini.com/get-started This Python snippet demonstrates how to subscribe to order lifecycle events, print status updates, and send a cancellation request once an order is filled. It requires the `websockets` library and assumes a WebSocket connection `ws` is established. ```python # Watch order updates # X = status, S = side, p = price, q = quantity async for msg in ws: data = json.loads(msg) if data.get("X") in ("NEW", "OPEN", "FILLED", "PARTIALLY_FILLED"): print(f"Order {data['X']}: side={data.get('S')} price=${data.get('p')} qty={data.get('q')}") # Cancel once filled if data.get("X") == "FILLED": await ws.send(json.dumps({ "id": "3", "method": "order.cancel", "params": { "orderId": data.get("i") }, })) break ``` -------------------------------- ### Connect and Stream Prices via Gemini WebSocket Source: https://developer.gemini.com/get-started Connect to the Gemini WebSocket API to stream real-time price updates. Requires account-scoped keys with time-based nonces enabled for authentication. ```Python # pip install websockets import asyncio, websockets, hmac, hashlib, base64, json, time API_KEY = "your-api-key" API_SECRET = "your-api-secret" SYMBOL = "BTCUSD" def auth_headers(): nonce = str(int(time.time())) payload = base64.b64encode(nonce.encode()) signature = hmac.new(API_SECRET.encode(), payload, hashlib.sha384).hexdigest() return { "X-GEMINI-APIKEY": API_KEY, "X-GEMINI-NONCE": nonce, "X-GEMINI-PAYLOAD": payload.decode(), "X-GEMINI-SIGNATURE": signature, } async def stream_prices(): async with websockets.connect("wss://ws.gemini.com", additional_headers=auth_headers()) as ws: await ws.send(json.dumps({ "id": "1", "method": "subscribe", "params": [f"{SYMBOL}@bookTicker"], })) async for msg in ws: data = json.loads(msg) if "b" in data and "a" in data: print(f"{data['s']} bid: ${data['b']} ({data['B']} BTC) ask: ${data['a']} ({data['A']} BTC)") asyncio.run(stream_prices()) ``` -------------------------------- ### Configure MCP Server with Gemini API Keys Source: https://developer.gemini.com/get-started Configure the MCP server to use your Gemini API key and secret for authentication. This command is specific to Claude Code and may differ for other tools. ```bash # For Claude Code: (This will be be different for other tools.) claude mcp add gemini -s user -e GEMINI_API_KEY= -e \ GEMINI_API_SECRET= -- node /packages/mcp-server/dist/index.js ``` -------------------------------- ### Set Gemini API Credentials Source: https://developer.gemini.com/get-started Export your Gemini API key and secret as environment variables for use in applications. Ensure the API key has the 'Trading' scope enabled. ```Terminal export GEMINI_API_KEY="account-xxxxxxxxxxxxxxxx" export GEMINI_API_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ``` -------------------------------- ### Place an Order via Gemini WebSocket Source: https://developer.gemini.com/get-started Subscribe to order updates and place a limit order through the Gemini WebSocket API. Use 'cancelOnDisconnect=true' to automatically cancel orders if the connection drops. ```Python async def trade(): url = "wss://ws.gemini.com?cancelOnDisconnect=true" async with websockets.connect(url, additional_headers=auth_headers()) as ws: await ws.send(json.dumps({ "id": "1", "method": "subscribe", "params": [ f"{SYMBOL}@bookTicker", # live prices "orders@account", # your order updates ], })) # Wait for a price, then place an order async for msg in ws: data = json.loads(msg) if "b" in data and "a" in data and data.get("s") == SYMBOL: break await ws.send(json.dumps({ "id": "2", "method": "order.place", "params": { "symbol": SYMBOL, "side": "BUY", "type": "LIMIT", "timeInForce": "GTC", "price": "95000.00", "quantity": "0.01", "clientOrderId": "my-first-ws-order", }, })) ``` -------------------------------- ### List Claude MCP Source: https://developer.gemini.com/get-started Use this command to list Claude MCP. This is a terminal command. ```bash claude mcp list ``` -------------------------------- ### Gemini Account Balances Display Source: https://developer.gemini.com/get-started This snippet shows the output format for displaying current Gemini account balances, including currency, amount, and available funds. ```text ⎿  [ { "type": "exchange", … +60 lines (ctrl+o to expand) ⏺ Here are your current Gemini account balances: ┌──────────┬─────────────┬─────────────┐ │ Currency │ Amount │ Available │ ├──────────┼─────────────┼─────────────┤ │ USD │ $334,801.93 │ $334,801.93 │ ├──────────┼─────────────┼─────────────┤ │ BTC │ 998 │ 998 │ ├──────────┼─────────────┼─────────────┤ │ ETH │ 20,001 │ 20,001 │ ├──────────┼─────────────┼─────────────┤ │ LTC │ 20,000 │ 20,000 │ ├──────────┼─────────────┼─────────────┤ │ ZEC │ 20,000 │ 20,000 │ ├──────────┼─────────────┼─────────────┤ │ BCH │ 20,000 │ 20,000 │ ├──────────┼─────────────┼─────────────┤ │ DOGE │ 52 │ 52 │ ├──────────┼─────────────┼─────────────┤ │ SOL │ 100 │ 100 │ └──────────┴─────────────┴─────────────┘ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── esc to interrupt ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.