We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/poguuniverse/42crunch-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
# Token Configuration Guide
## Where `42C_TOKEN` is Set
The `42C_TOKEN` environment variable is read by the MCP server from multiple sources (in order of priority):
### 1. **`.env` file** (Recommended)
Location: `/Users/kbarvind/Documents/workspace/GK/mcp/.env`
```bash
# Create or edit .env file in project root
cd /Users/kbarvind/Documents/workspace/GK/mcp
echo "42C_TOKEN=your_token_here" >> .env
```
The `src/config.py` file automatically loads this using `load_dotenv()`:
```python
from dotenv import load_dotenv
load_dotenv() # Loads .env file
self.token = os.getenv("42C_TOKEN") # Reads from environment
```
### 2. **Environment Variable** (Alternative)
Set it in your shell before running the server:
```bash
export 42C_TOKEN=your_token_here
python http_main.py
```
### 3. **Systemd Service** (For background service)
The systemd service file (`42crunch-mcp-http.service`) reads from `.env`:
```ini
EnvironmentFile=/Users/kbarvind/Documents/workspace/GK/mcp/.env
```
### 4. **Docker/Docker Compose**
Pass it as environment variable:
```bash
# Docker run
docker run -e 42C_TOKEN=your_token_here ...
# Docker Compose (reads from .env or environment)
docker-compose up
```
## Current Status
✅ `.env` file exists at: `/Users/kbarvind/Documents/workspace/GK/mcp/.env`
✅ `42C_TOKEN` is configured (40 characters)
## How It Works
1. **MCP Server Startup** (`http_main.py` or `main.py`):
- Imports `src.config.Config`
- `Config()` calls `load_dotenv()` to load `.env` file
- Reads `42C_TOKEN` from environment
- Validates that token exists
2. **API Client** (`src/client.py`):
- Uses `Config()` to get token
- Adds `X-MCP-AUTH: {token}` header to all requests
- Sends authenticated requests to 42crunch API
3. **UI Tools** (`ui/mcp_tools.py`):
- **DO NOT** need `42C_TOKEN`
- Only call MCP server via HTTP
- Server handles authentication internally
## Verification
Check if token is loaded:
```bash
cd /Users/kbarvind/Documents/workspace/GK/mcp
python3 -c "from src.config import Config; c = Config(); print('Token loaded:', bool(c.token))"
```
## Troubleshooting
If you get "42C_TOKEN environment variable is required":
1. Check `.env` file exists in project root
2. Verify token is set: `grep 42C_TOKEN .env`
3. Make sure you're running server from project root
4. Check file permissions: `chmod 600 .env` (keep it secure)