|
| 1 | +--- |
| 2 | +title: "Environment Variables" |
| 3 | +description: "Configure Sei MCP Server with environment variables for wallet access and custom RPC endpoints" |
| 4 | +icon: "gear" |
| 5 | +--- |
| 6 | + |
| 7 | +The Sei MCP Server supports configuration through environment variables, which can be set in your MCP configuration JSON or passed directly to the Node.js command. |
| 8 | + |
| 9 | +## Configuration Methods |
| 10 | + |
| 11 | +<Tabs> |
| 12 | + <Tab title="JSON Configuration"> |
| 13 | + Add environment variables to your MCP server configuration: |
| 14 | + |
| 15 | + ```json |
| 16 | + { |
| 17 | + "mcpServers": { |
| 18 | + "sei": { |
| 19 | + "command": "npx", |
| 20 | + "args": ["-y", "@sei-js/mcp-server"], |
| 21 | + "env": { |
| 22 | + "WALLET_MODE": "private-key", |
| 23 | + "PRIVATE_KEY": "0x123...", |
| 24 | + "MAINNET_RPC_URL": "https://your-custom-rpc.com" |
| 25 | + } |
| 26 | + } |
| 27 | + } |
| 28 | + } |
| 29 | + ``` |
| 30 | + </Tab> |
| 31 | + |
| 32 | + <Tab title="Command Line"> |
| 33 | + Pass environment variables directly to the Node.js command: |
| 34 | + |
| 35 | + ```bash |
| 36 | + # Streamable HTTP with custom path (recommended) |
| 37 | + SERVER_TRANSPORT=streamable-http SERVER_PORT=8080 SERVER_PATH=/api/mcp npx @sei-js/mcp-server |
| 38 | + |
| 39 | + # Or export them first |
| 40 | + export SERVER_TRANSPORT=streamable-http |
| 41 | + export SERVER_PORT=8080 |
| 42 | + export SERVER_PATH=/mcp |
| 43 | + npx @sei-js/mcp-server |
| 44 | + ``` |
| 45 | + |
| 46 | + For Claude CLI: |
| 47 | + ```bash |
| 48 | + # Add server to Claude CLI |
| 49 | + claude mcp add sei-http npx @sei-js/mcp-server --env SERVER_TRANSPORT=streamable-http SERVER_PORT=8080 |
| 50 | + |
| 51 | + # Start Claude |
| 52 | + claude |
| 53 | + ``` |
| 54 | + </Tab> |
| 55 | +</Tabs> |
| 56 | + |
| 57 | +## Available Variables |
| 58 | + |
| 59 | +### Wallet Configuration |
| 60 | + |
| 61 | +#### `WALLET_MODE` |
| 62 | +- **Type**: `string` |
| 63 | +- **Default**: `"disabled"` |
| 64 | +- **Description**: Controls wallet functionality and transaction capabilities |
| 65 | +- **Options**: |
| 66 | + - `"disabled"` - Read-only mode, no transaction capabilities |
| 67 | + - `"private-key"` - Enable wallet tools using private key |
| 68 | + |
| 69 | +#### `PRIVATE_KEY` |
| 70 | +- **Type**: `string` |
| 71 | +- **Default**: `-` |
| 72 | +- **Description**: Private key for wallet operations (required when WALLET_MODE="private-key") |
| 73 | +- **Format**: 0x-prefixed hex string (64 characters after 0x) |
| 74 | + |
| 75 | +<Warning> |
| 76 | +**Security Critical**: Never commit private keys to version control. Use a dedicated test wallet with minimal funds. |
| 77 | +</Warning> |
| 78 | + |
| 79 | +### Network Configuration |
| 80 | + |
| 81 | +#### `MAINNET_RPC_URL` |
| 82 | +- **Type**: `string` |
| 83 | +- **Default**: `"https://evm-rpc.sei-apis.com"` |
| 84 | +- **Description**: Custom RPC endpoint for Sei mainnet |
| 85 | +- **Use Case**: Private RPC providers, local nodes, or custom endpoints |
| 86 | + |
| 87 | +#### `TESTNET_RPC_URL` |
| 88 | +- **Type**: `string` |
| 89 | +- **Default**: `"https://evm-rpc-testnet.sei-apis.com"` |
| 90 | +- **Description**: Custom RPC endpoint for Sei testnet (Atlantic-2) |
| 91 | +- **Use Case**: Testing with custom infrastructure |
| 92 | + |
| 93 | +#### `DEVNET_RPC_URL` |
| 94 | +- **Type**: `string` |
| 95 | +- **Default**: `"https://evm-rpc-arctic-1.sei-apis.com"` |
| 96 | +- **Description**: Custom RPC endpoint for Sei devnet |
| 97 | +- **Use Case**: Development and experimental features |
| 98 | + |
| 99 | +### Server Configuration |
| 100 | + |
| 101 | +#### `SERVER_TRANSPORT` |
| 102 | +- **Type**: `string` |
| 103 | +- **Default**: `"stdio"` |
| 104 | +- **Description**: Transport mode for the MCP server |
| 105 | +- **Options**: |
| 106 | + - `"stdio"` - Standard input/output (default for AI assistants) |
| 107 | + - `"streamable-http"` - Streamable HTTP transport (recommended for web apps) |
| 108 | + - `"http-sse"` - HTTP Server-Sent Events (deprecated) |
| 109 | + |
| 110 | +#### `SERVER_PORT` |
| 111 | +- **Type**: `number` |
| 112 | +- **Default**: `8080` |
| 113 | +- **Description**: Port number for HTTP transports (http-sse, streamable-http) |
| 114 | +- **Range**: 1-65535 |
| 115 | + |
| 116 | +#### `SERVER_HOST` |
| 117 | +- **Type**: `string` |
| 118 | +- **Default**: `"localhost"` |
| 119 | +- **Description**: Host address for HTTP server |
| 120 | +- **Use Case**: Bind to specific network interfaces |
| 121 | + |
| 122 | +#### `SERVER_PATH` |
| 123 | +- **Type**: `string` |
| 124 | +- **Default**: `"/mcp"` |
| 125 | +- **Description**: Base path for HTTP endpoints |
| 126 | +- **Format**: Must start with `/` (automatically normalized) |
| 127 | + |
| 128 | +### System Configuration |
| 129 | + |
| 130 | +#### `PATH` |
| 131 | +- **Type**: `string` |
| 132 | +- **Default**: System PATH |
| 133 | +- **Description**: Override PATH to specify Node.js version |
| 134 | +- **Use Case**: Troubleshooting Node.js version conflicts |
| 135 | + |
| 136 | +## Configuration Examples |
| 137 | + |
| 138 | +<AccordionGroup> |
| 139 | + <Accordion title="Default STDIO Mode"> |
| 140 | + No environment variables needed for AI assistant integration: |
| 141 | + |
| 142 | + <Tabs> |
| 143 | + <Tab title="JSON Config"> |
| 144 | + ```json |
| 145 | + { |
| 146 | + "mcpServers": { |
| 147 | + "sei": { |
| 148 | + "command": "npx", |
| 149 | + "args": ["-y", "@sei-js/mcp-server"] |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + ``` |
| 154 | + </Tab> |
| 155 | + <Tab title="CLI"> |
| 156 | + ```bash |
| 157 | + # Default STDIO mode (no environment variables needed) |
| 158 | + npx @sei-js/mcp-server |
| 159 | + |
| 160 | + # Or with Claude CLI |
| 161 | + claude mcp add sei npx @sei-js/mcp-server |
| 162 | + ``` |
| 163 | + </Tab> |
| 164 | + </Tabs> |
| 165 | + |
| 166 | + **Transport**: Standard input/output for Claude Desktop, Cursor, Windsurf |
| 167 | + </Accordion> |
| 168 | + |
| 169 | + <Accordion title="Streamable HTTP Transport"> |
| 170 | + Use streamable HTTP when you need API access over HTTP: |
| 171 | + |
| 172 | + <Tabs> |
| 173 | + <Tab title="JSON Config"> |
| 174 | + ```json |
| 175 | + { |
| 176 | + "mcpServers": { |
| 177 | + "sei": { |
| 178 | + "command": "npx", |
| 179 | + "args": ["-y", "@sei-js/mcp-server"], |
| 180 | + "env": { |
| 181 | + "SERVER_TRANSPORT": "streamable-http", |
| 182 | + "SERVER_PORT": "8080", |
| 183 | + "SERVER_PATH": "/api/mcp", |
| 184 | + "SERVER_HOST": "0.0.0.0" |
| 185 | + } |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + ``` |
| 190 | + </Tab> |
| 191 | + <Tab title="CLI"> |
| 192 | + ```bash |
| 193 | + # Streamable HTTP with custom configuration |
| 194 | + SERVER_TRANSPORT=streamable-http \ |
| 195 | + SERVER_PORT=8080 \ |
| 196 | + SERVER_PATH=/api/mcp \ |
| 197 | + SERVER_HOST=0.0.0.0 \ |
| 198 | + npx @sei-js/mcp-server |
| 199 | + |
| 200 | + # Or with Claude CLI |
| 201 | + claude mcp add sei-http npx @sei-js/mcp-server \ |
| 202 | + --env SERVER_TRANSPORT=streamable-http \ |
| 203 | + --env SERVER_PORT=8080 \ |
| 204 | + --env SERVER_PATH=/api/mcp |
| 205 | + ``` |
| 206 | + </Tab> |
| 207 | + </Tabs> |
| 208 | + |
| 209 | + **Use Case**: Web applications, custom integrations, API access |
| 210 | + </Accordion> |
| 211 | + |
| 212 | + <Accordion title="HTTP SSE Transport (Deprecated)"> |
| 213 | + HTTP Server-Sent Events transport - use streamable-http instead: |
| 214 | + |
| 215 | + <Tabs> |
| 216 | + <Tab title="JSON Config"> |
| 217 | + ```json |
| 218 | + { |
| 219 | + "mcpServers": { |
| 220 | + "sei": { |
| 221 | + "command": "npx", |
| 222 | + "args": ["-y", "@sei-js/mcp-server"], |
| 223 | + "env": { |
| 224 | + "SERVER_TRANSPORT": "http-sse", |
| 225 | + "SERVER_PORT": "3001", |
| 226 | + "SERVER_PATH": "/mcp" |
| 227 | + } |
| 228 | + } |
| 229 | + } |
| 230 | + } |
| 231 | + ``` |
| 232 | + </Tab> |
| 233 | + <Tab title="CLI"> |
| 234 | + ```bash |
| 235 | + # HTTP SSE (deprecated - use streamable-http instead) |
| 236 | + SERVER_TRANSPORT=http-sse \ |
| 237 | + SERVER_PORT=3001 \ |
| 238 | + SERVER_PATH=/mcp \ |
| 239 | + npx @sei-js/mcp-server |
| 240 | + |
| 241 | + # Or with Claude CLI |
| 242 | + claude mcp add sei-sse npx @sei-js/mcp-server \ |
| 243 | + --env SERVER_TRANSPORT=http-sse \ |
| 244 | + --env SERVER_PORT=3001 |
| 245 | + ``` |
| 246 | + </Tab> |
| 247 | + </Tabs> |
| 248 | + |
| 249 | + **Status**: Deprecated - migrate to streamable-http for better performance |
| 250 | + </Accordion> |
| 251 | +</AccordionGroup> |
| 252 | + |
| 253 | +## Security Best Practices |
| 254 | + |
| 255 | +<CardGroup cols={2}> |
| 256 | + <Card title="Test Wallet Only" icon="shield-check"> |
| 257 | + Use a dedicated wallet for testing, not your main holdings |
| 258 | + </Card> |
| 259 | + <Card title="Minimal Funds" icon="coins"> |
| 260 | + Keep only small amounts needed for testing transactions |
| 261 | + </Card> |
| 262 | + <Card title="Secure Storage" icon="lock"> |
| 263 | + Never commit private keys to version control or share them |
| 264 | + </Card> |
| 265 | + <Card title="Regular Rotation" icon="arrows-rotate"> |
| 266 | + Rotate test wallet keys periodically for security |
| 267 | + </Card> |
| 268 | +</CardGroup> |
| 269 | + |
| 270 | +## Troubleshooting |
| 271 | + |
| 272 | +### Common Issues |
| 273 | + |
| 274 | +**Private Key Format** |
| 275 | +- Must start with `0x` |
| 276 | +- Must be exactly 66 characters (0x + 64 hex characters) |
| 277 | +- Use lowercase hex characters |
| 278 | + |
| 279 | +**RPC Connection** |
| 280 | +- Verify custom RPC URLs are accessible |
| 281 | +- Check for rate limiting on custom endpoints |
| 282 | +- Ensure RPC supports required methods |
| 283 | + |
| 284 | +**Environment Variables Not Loading** |
| 285 | +- Restart your AI assistant after configuration changes |
| 286 | +- Verify JSON syntax in MCP configuration |
| 287 | +- Check for typos in variable names |
| 288 | + |
| 289 | +<Card title="Need More Help?" icon="bug" href="/mcp-server/troubleshooting"> |
| 290 | + Check our comprehensive troubleshooting guide for solutions to specific problems. |
| 291 | +</Card> |
0 commit comments