Create
Gemini CLI
Connect Gemini CLI to a Webex MCP server.
Before configuring, you'll need OAuth 2.0 credentials. See OAuth 2.0 setup instructions in the main guide.
anchorOAuth 2.0
anchorTo configure OAuth for an MCP server in the Gemini CLI, edit the ~/.gemini/settings.json file, then use the /mcp auth command in the CLI to complete authentication through a web browser.
1. Add the MCP server configuration to settings.json
Open or create your Gemini CLI configuration file at ~/.gemini/settings.json. Add an entry in the mcpServers block for your server:
{
"mcpServers": {
"<server-name>": {
"url": "<MCP_SERVER_URL>",
"oauth": {
"enabled": true,
"clientId": "YOUR_CLIENT_ID",
"clientSecret": "YOUR_CLIENT_SECRET",
"authorizationUrl": "https://webexapis.com/v1/authorize",
"tokenUrl": "https://webexapis.com/v1/access_token",
"scopes": ["spark:mcp", "required_scope_1", "required_scope_2"]
}
}
}
}
enabled— Set totrueto enable OAuth for the serverclientIdandclientSecret— Your OAuth 2.0 client credentials from your Webex OAuth 2.0 IntegrationauthorizationUrlandtokenUrl— The endpoints for the OAuth flowscopes— An array of required OAuth scopesredirectUri— Redirect URI will be in this formathttp://localhost:<PORT>/oauth/callback. PORT can be any available port. This needs to be added as the redirect URI in your Webex OAuth 2.0 Integration.
2. Authenticate within the Gemini CLI
After saving the settings.json file, restart the Gemini CLI and authenticate the server:
- Run
geminito start the CLI session - Initiate the authentication flow:
/mcp auth <server-name>
This will open a browser window for you to sign in and grant access. The Gemini CLI stores the access and refresh tokens locally in ~/.gemini/mcp-oauth-tokens.json for future use.
anchorTroubleshooting
anchorMCP server is blocked
If you see an error indicating that the MCP server is blocked, you need to add the server name to the mcp.allowed list in ~/.gemini/settings.json:
{
"mcp": {
"allowed": [
"your-server-name"
],
"excluded": []
}
}
Add the exact server name you used in mcpServers to the allowed array, then restart Gemini CLI.