Plugin API
Extend Gemini CLI with MCP servers, custom tools, and powerful integrations. Connect to databases, APIs, file systems, and more using the Model Context Protocol.
Extension Architecture
Gemini CLI uses the Model Context Protocol (MCP) to provide a standardized way to connect AI assistants with external tools and data sources.
MCP Servers
Standalone processes that expose tools and resources through the Model Context Protocol
Tool Integration
Seamlessly integrate external tools and services into your AI workflows
Custom Development
Build your own MCP servers to extend Gemini CLI with custom functionality
MCP Server Types
Explore different types of MCP servers and their capabilities
File System Servers
Servers that provide file system access and operations
filesystem
Read, write, and manage files and directories
Capabilities:
git
Git repository operations and version control
Capabilities:
Web & API Servers
Servers that interact with web services and APIs
web-search
Search the web and retrieve information
Capabilities:
github
GitHub API integration for repository management
Capabilities:
Database Servers
Servers that provide database connectivity and operations
sqlite
SQLite database operations
Capabilities:
postgres
PostgreSQL database integration
Capabilities:
Configuration Examples
Learn how to configure MCP servers in your Gemini CLI setup
Basic Configuration
Add MCP servers to your .gemini/config.json
file:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"]
},
"git": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-git", "--repository", "/path/to/repo"]
},
"web-search": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-web-search"]
}
}
}
Advanced Configuration
Configure custom servers with environment variables and advanced options:
{
"mcpServers": {
"custom-database": {
"command": "node",
"args": ["./custom-mcp-server.js"],
"env": {
"DATABASE_URL": "postgresql://localhost:5432/mydb",
"API_KEY": "your-api-key"
}
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-github-token"
}
}
}
}
Development Configuration
Configuration for local development and debugging:
{
"mcpServers": {
"local-dev": {
"command": "node",
"args": ["./dev-server.js"],
"cwd": "/path/to/development/server",
"env": {
"NODE_ENV": "development",
"DEBUG": "mcp:*"
}
}
}
}
Custom MCP Server Development
Build your own MCP server to extend Gemini CLI with custom functionality
Complete MCP Server Example
Here's a complete example of a custom MCP server that you can use as a starting point:
#!/usr/bin/env node
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
class CustomMCPServer {
constructor() {
this.server = new Server(
{
name: 'custom-server',
version: '0.1.0',
},
{
capabilities: {
tools: {},
},
}
);
this.setupToolHandlers();
}
setupToolHandlers() {
// List available tools
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: 'custom_tool',
description: 'A custom tool that performs specific operations',
inputSchema: {
type: 'object',
properties: {
input: {
type: 'string',
description: 'Input for the custom operation',
},
},
required: ['input'],
},
},
],
};
});
// Handle tool calls
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
if (name === 'custom_tool') {
const result = await this.performCustomOperation(args.input);
return {
content: [
{
type: 'text',
text: `Custom operation result: ${result}`,
},
],
};
}
throw new Error(`Unknown tool: ${name}`);
});
}
async performCustomOperation(input) {
// Your custom logic here
return `Processed: ${input}`;
}
async run() {
const transport = new StdioServerTransport();
await this.server.connect(transport);
console.error('Custom MCP server running on stdio');
}
}
const server = new CustomMCPServer();
server.run().catch(console.error);
Getting Started
Quick steps to start using and developing MCP servers
Using Existing Servers
- 1Install an MCP server package:
npm install -g @modelcontextprotocol/server-filesystem
- 2Add the server to your
.gemini/config.json
- 3Restart Gemini CLI to load the new server
- 4Use
/mcp
command to list available servers
Developing Custom Servers
- 1Install the MCP SDK:
npm install @modelcontextprotocol/sdk
- 2Create your server using the example above
- 3Test your server with the MCP inspector
- 4Configure it in Gemini CLI and start using it
Related Resources
Explore more about MCP servers and plugin development