@danwahl/gemini-cli-mcp 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +3 -1
- package/dist/index.js +11 -9
- package/package.json +1 -1
package/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
2
|
import { spawn } from "node:child_process";
|
|
4
3
|
import { existsSync } from "node:fs";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
7
|
//#region src/index.ts
|
|
8
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
8
9
|
function buildGeminiArgs(prompt, model, sessionId, outputFormat = "json") {
|
|
9
10
|
const args = [
|
|
10
11
|
"-p",
|
|
@@ -165,7 +166,7 @@ function runGemini(prompt, cwd, model, timeoutMs, sessionId) {
|
|
|
165
166
|
}
|
|
166
167
|
const server = new McpServer({
|
|
167
168
|
name: "gemini-cli-mcp",
|
|
168
|
-
version
|
|
169
|
+
version
|
|
169
170
|
});
|
|
170
171
|
server.registerTool("cli", {
|
|
171
172
|
description: "Send a task or question to Gemini CLI and return the response. Gemini runs headlessly with full tool access (file read/write, web search, shell commands). Use this to delegate tasks that benefit from Gemini's capabilities or to get a second opinion.",
|
|
@@ -193,7 +194,13 @@ server.registerTool("cli", {
|
|
|
193
194
|
content: [{
|
|
194
195
|
type: "text",
|
|
195
196
|
text: result.errorMessage ?? "Unknown error"
|
|
196
|
-
}]
|
|
197
|
+
}],
|
|
198
|
+
structuredContent: {
|
|
199
|
+
sessionId: null,
|
|
200
|
+
response: "",
|
|
201
|
+
models: {},
|
|
202
|
+
tools: {}
|
|
203
|
+
}
|
|
197
204
|
};
|
|
198
205
|
const structured = extractStructuredOutput(result.output);
|
|
199
206
|
return {
|
|
@@ -204,11 +211,6 @@ server.registerTool("cli", {
|
|
|
204
211
|
structuredContent: structured
|
|
205
212
|
};
|
|
206
213
|
});
|
|
207
|
-
const isMain = process.argv[1] !== void 0 && (import.meta.url === `file://${process.argv[1]}` || process.argv[1].endsWith("cli.js") || process.argv[1].endsWith("dist/index.js"));
|
|
208
|
-
if (isMain) {
|
|
209
|
-
const transport = new StdioServerTransport();
|
|
210
|
-
await server.connect(transport);
|
|
211
|
-
}
|
|
212
214
|
|
|
213
215
|
//#endregion
|
|
214
|
-
export { buildGeminiArgs, extractStructuredOutput, parseGeminiOutput, runGemini };
|
|
216
|
+
export { buildGeminiArgs, extractStructuredOutput, parseGeminiOutput, runGemini, server };
|