@danwahl/gemini-cli-mcp 0.1.2 → 0.1.4
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/dist/index.js +18 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { z } from "zod";
|
|
3
5
|
import { spawn } from "node:child_process";
|
|
4
6
|
import { existsSync } from "node:fs";
|
|
5
|
-
import { z } from "zod";
|
|
6
7
|
|
|
7
|
-
//#region src/
|
|
8
|
+
//#region src/lib.ts
|
|
8
9
|
function buildGeminiArgs(prompt, model, sessionId, outputFormat = "json") {
|
|
9
10
|
const args = [
|
|
10
11
|
"-p",
|
|
@@ -163,9 +164,13 @@ function runGemini(prompt, cwd, model, timeoutMs, sessionId) {
|
|
|
163
164
|
});
|
|
164
165
|
});
|
|
165
166
|
}
|
|
167
|
+
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/index.ts
|
|
170
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
166
171
|
const server = new McpServer({
|
|
167
172
|
name: "gemini-cli-mcp",
|
|
168
|
-
version
|
|
173
|
+
version
|
|
169
174
|
});
|
|
170
175
|
server.registerTool("cli", {
|
|
171
176
|
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 +198,13 @@ server.registerTool("cli", {
|
|
|
193
198
|
content: [{
|
|
194
199
|
type: "text",
|
|
195
200
|
text: result.errorMessage ?? "Unknown error"
|
|
196
|
-
}]
|
|
201
|
+
}],
|
|
202
|
+
structuredContent: {
|
|
203
|
+
sessionId: null,
|
|
204
|
+
response: "",
|
|
205
|
+
models: {},
|
|
206
|
+
tools: {}
|
|
207
|
+
}
|
|
197
208
|
};
|
|
198
209
|
const structured = extractStructuredOutput(result.output);
|
|
199
210
|
return {
|
|
@@ -204,11 +215,7 @@ server.registerTool("cli", {
|
|
|
204
215
|
structuredContent: structured
|
|
205
216
|
};
|
|
206
217
|
});
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
const transport = new StdioServerTransport();
|
|
210
|
-
await server.connect(transport);
|
|
211
|
-
}
|
|
218
|
+
const transport = new StdioServerTransport();
|
|
219
|
+
await server.connect(transport);
|
|
212
220
|
|
|
213
|
-
//#endregion
|
|
214
|
-
export { buildGeminiArgs, extractStructuredOutput, parseGeminiOutput, runGemini };
|
|
221
|
+
//#endregion
|