GC-101 · Module 3
MCP Servers & External Tools
3 min read
MCP (Model Context Protocol) servers extend Gemini CLI with external tools. An MCP server is a process that exposes tools, resources, and prompts over a standardized protocol. Gemini CLI connects to these servers and makes their tools available alongside built-in tools. This is how you give Gemini CLI access to databases, APIs, cloud services, and any custom tooling your team has built.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb"
}
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}
Managing MCP servers is done through the gemini mcp subcommands. Add a server with gemini mcp add, list configured servers with gemini mcp list, and remove them with gemini mcp remove. For remote MCP servers, Gemini CLI supports OAuth 2.0 authentication — essential for cloud-hosted tools that require secure access.
# Add an MCP server
gemini mcp add my-server -- npx -y @some/mcp-server
# List configured servers
gemini mcp list
# Remove a server
gemini mcp remove my-server
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"includeTools": ["create_pull_request", "list_issues", "get_file_contents"],
"excludeTools": ["search_code"]
}
}
}