Appearance
Generate an OAuth 2.0 Token Optional
XMCP's default flow uses OAuth 1.0a consent at startup. If you would rather supply an OAuth 2.0 user access token directly, the repository includes a helper script. This page also covers the optional Grok MCP test client.
Generate an OAuth 2.0 user token
flowchart TD
A[Add CLIENT_ID + CLIENT_SECRET to .env] --> B[Update redirect_uri in generate_authtoken.py]
B --> C[Run python generate_authtoken.py]
C --> D[Follow the prompts to authorize]
D --> E[Copy printed access token into .env]Step 1 - Add OAuth 2.0 app credentials
bash
CLIENT_ID=your_oauth2_client_id
CLIENT_SECRET=your_oauth2_client_secretStep 2 - Match the redirect URI
Update redirect_uri in generate_authtoken.py so it matches the redirect URL configured in your app settings.
Step 3 - Run the generator
bash
python generate_authtoken.pyFollow the prompts to authorize the app in your browser.
Step 4 - Store the token
Copy the printed access token into .env:
bash
X_OAUTH_ACCESS_TOKEN=generated_access_token
X_OAUTH_ACCESS_TOKEN_SECRET=generated_token_secret # only if your flow returns a secretRun the Grok MCP test client
The repository ships an optional client that drives XMCP through the xAI Grok model - useful for validating that your tools work end to end.
flowchart TD
A[Set XAI_API_KEY in .env] --> B[Ensure XMCP server is running]
B --> C{Grok on this machine?}
C -->|Yes| D[Use local MCP_SERVER_URL]
C -->|No| E[Tunnel with ngrok, set public MCP_SERVER_URL]
D --> F[python test_grok_mcp.py]
E --> FStep 1 - Set the xAI key
bash
XAI_API_KEY=your_xai_key
XAI_MODEL=grok-4-1-fast # default
MCP_SERVER_URL=http://127.0.0.1:8000/mcpStep 2 - Make the server reachable by Grok
If Grok is not running on your machine, expose the local MCP server and point MCP_SERVER_URL at the public HTTPS URL ending in /mcp:
bash
ngrok http 8000
# then set: MCP_SERVER_URL=https://<id>.ngrok-free.dev/mcpStep 3 - Run the test client
bash
python test_grok_mcp.pyVerification checklist
- [ ] OAuth 2.0 token generated and stored in
.env(if using OAuth 2.0) - [ ]
XAI_API_KEYset (if running the Grok client) - [ ] XMCP server reachable at
MCP_SERVER_URL - [ ]
test_grok_mcp.pycompletes a tool call