loading…
Search for a command to run...
loading…
A stateless MCP server that wraps the headless Gemini CLI, providing tools to send prompts to Google's Gemini models and receive text responses. It supports bot
A stateless MCP server that wraps the headless Gemini CLI, providing tools to send prompts to Google's Gemini models and receive text responses. It supports both simple prompts and prompts with contextual information.
CI npm version Node.js Version License: MIT
Stateless stdio MCP server wrapping the headless Gemini CLI.
gemini_prompt, gemini_prompt_with_context,
gemini_prompt_structuredworking_dir, no timeout enforcementcwdGEMINI_API_KEY flows through) and
pins NO_COLOR=1, TERM=dumb; prompt is always a single argv element —
never interpolated into a shell string@modelcontextprotocol/sdk--output-format json, which is only
recognised by gemini-cli 0.6.1 and newer
(upstream PR #8119).npm install -g geminicli-mcp
This exposes the geminicli-mcp binary on your PATH. Point your MCP client
at it:
// e.g. ~/.config/<your-client>/mcp.json
{
"mcpServers": {
"gemini": {
"command": "geminicli-mcp"
}
}
}
You also need the headless Gemini CLI installed and authenticated:
npm install -g @google/gemini-cli
gemini # one-time interactive auth
git clone https://github.com/trevoraspencer/geminicli-mcp.git
cd geminicli-mcp
npm install
npm run build
node dist/index.js
gemini_prompt| field | type | required | notes |
|---|---|---|---|
| prompt | string | yes | prompt text |
| model | string | no | e.g. gemini-2.5-pro |
Returns the CLI's response text.
gemini_prompt_with_context| field | type | required | notes |
|---|---|---|---|
| prompt | string | yes | prompt text |
| context | string | yes | prepended to the prompt inside <context> |
| model | string | no | e.g. gemini-2.5-pro |
Returns the CLI's response text.
gemini_prompt_structured| field | type | required | notes |
|---|---|---|---|
| prompt | string | yes | prompt text |
| schema | object | yes | JSON Schema the response must conform to (see below) |
| context | string | no | optional context block prepended inside <context> |
| model | string | no | e.g. gemini-2.5-pro |
The server appends an explicit "respond with JSON conforming to this schema"
instruction to your prompt, extracts JSON from the model's response (it
tolerates surrounding prose or a ```json fence), and validates the
result against schema. On success the tool returns the canonical JSON
string. On failure the result is isError: true with a diagnostic that
includes both the validation errors and the raw response.
A minimal schema looks like:
{
"type": "object",
"required": ["title", "tags"],
"properties": {
"title": { "type": "string" },
"tags": { "type": "array", "items": { "type": "string" } }
},
"additionalProperties": false
}
The bundled validator supports a useful subset of JSON Schema: type (with
all primitive types plus array and object), required, properties,
items, additionalProperties, enum, const, minLength/maxLength,
minItems/maxItems, minimum/maximum, pattern, and the anyOf /
oneOf / allOf combinators. It is deliberately small — if you need full
JSON Schema 2020-12, pre-validate on the caller side.
The examples/ directory contains runnable JSON-RPC request files you can pipe into the server over stdio. See examples/README.md for a one-liner that lists tools or invokes a tool from the command line.
GEMINI_CLI_BIN — override the gemini binary path (default: gemini on
PATH).GEMINICLI_MCP_MAX_OUTPUT_BYTES — cap (per stream) on bytes accumulated
from the gemini child's stdout/stderr before the server kills it (default:
33554432 / 32 MiB). Guards against a runaway child OOM-ing the server.GEMINICLI_MCP_DEBUG — when set to 1, true, or yes, emits structured
JSON diagnostics to stderr (invocation args, exit codes, durations, stderr
content, kill-failure markers). Safe for MCP use: diagnostics go to stderr
only and never corrupt the stdio protocol on stdout. Leave unset in
production; enable only for targeted debugging.NO_COLOR=1 / TERM=dumb. Anything the server can read — including
GEMINI_API_KEY and friends — the gemini CLI can read.The server surfaces the gemini CLI's exit code via the errorKind /
exit= prefix on error responses (e.g. [error exit=1] ...).
| code | errorKind |
meaning |
|---|---|---|
0 |
ok |
success |
1 |
error |
general model error or API failure |
41 |
auth_required |
gemini CLI is not authenticated; run gemini once |
42 |
input_validation |
bad arguments (or bad schema, for the structured tool) |
53 |
turn_limit |
gemini's turn / tool-call budget was exhausted |
127 |
error |
gemini binary not found (set GEMINI_CLI_BIN) |
| other | unknown |
gemini reported a code outside the documented set |
--approval-mode yolo is always on. The server hardcodes this flag so
it can run non-interactively. Any tool calls or file edits the gemini CLI
performs are auto-approved. Do not expose this MCP server to MCP clients
you don't trust.Unknown arguments: output-format / Unknown arguments: outputFormatYour @google/gemini-cli is older than 0.6.1, which is when
--output-format json was added
(upstream PR #8119).
Upgrade:
npm install -g @google/gemini-cli@latest
gemini --version # confirm ≥ 0.6.1
The server could not spawn the gemini executable. Either:
npm install -g @google/gemini-cli), then verify with
which gemini && gemini --version; orGEMINI_CLI_BIN=/absolute/path/to/gemini in the server's environment.If you launch the MCP server from a GUI (Claude Desktop, IDE), it may not
inherit your shell PATH. Either pass an absolute path via GEMINI_CLI_BIN
or configure your MCP client's env block, e.g.:
{
"mcpServers": {
"gemini": {
"command": "geminicli-mcp",
"env": {
"PATH": "/usr/local/bin:/usr/bin",
"GEMINI_CLI_BIN": "/usr/local/bin/gemini"
}
}
}
}
The Gemini CLI handles its own auth (Google account, API key, or Vertex AI). This server does not touch credentials. Run the CLI directly once to authenticate:
gemini # follow the interactive prompts
echo "ping" | gemini -p "Reply with the single word: ping"
If you're using an API key, make sure the relevant env vars (e.g.
GEMINI_API_KEY, GOOGLE_APPLICATION_CREDENTIALS) are present in the MCP
server's env block — children inherit the server's environment but the
server's environment is whatever your MCP client gave it.
The error text includes both the validation errors and the raw response so you can see what the model produced. Common fixes:
additionalProperties: true for
fields you don't need to constrain.model: "gemini-2.5-pro").These are intentional, not omissions. See CONTRIBUTING.md for the full list.
--resume, no working_dir.@modelcontextprotocol/sdk).Выполни в терминале:
claude mcp add geminicli-mcp -- npx CSA PROJECT - FZCO © 2026 IFZA Business Park, DDP, Premises Number 31174 - 001
Безопасность
Низкий рискАвтоматическая эвристика по публичным данным — не гарантия безопасности.