@zhihand/mcp 0.16.3 → 0.17.0

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.
@@ -321,17 +321,37 @@ export function killActiveChild() {
321
321
  setTimeout(() => resolve(), SIGKILL_DELAY + 1000);
322
322
  });
323
323
  }
324
+ // ── System Prompt ─────────────────────────────────────────
325
+ /**
326
+ * Wrap the user's raw prompt with system context so the CLI backend
327
+ * knows about the connected phone and how to use zhihand MCP tools.
328
+ */
329
+ function wrapPrompt(userPrompt) {
330
+ return `You are ZhiHand, an AI assistant connected to the user's mobile phone via MCP tools.
331
+
332
+ You have the following MCP tools to interact with the phone:
333
+ - zhihand_screenshot: Take a screenshot of the phone screen. Use this when the user asks to see, check, or look at their screen.
334
+ - zhihand_control: Control the phone — click, type, swipe, scroll, key combos, clipboard, wait. Requires "action" parameter. For clicks, provide xRatio/yRatio (0-1 normalized coordinates).
335
+ - zhihand_pair: Pair a new device (rarely needed).
336
+
337
+ When the user asks you to see their screen, look at something, or check what's on the phone, ALWAYS call zhihand_screenshot first.
338
+ When the user asks you to tap, click, type, swipe, or interact with the phone, use zhihand_control.
339
+
340
+ User message:
341
+ ${userPrompt}`;
342
+ }
324
343
  // ── Dispatch Entrypoint ────────────────────────────────────
325
344
  export function dispatchToCLI(backend, prompt, log, model) {
326
345
  const startTime = Date.now();
346
+ const wrappedPrompt = wrapPrompt(prompt);
327
347
  if (backend === "gemini") {
328
- return dispatchGemini(prompt, startTime, log, model);
348
+ return dispatchGemini(wrappedPrompt, startTime, log, model);
329
349
  }
330
350
  if (backend === "codex") {
331
- return dispatchCodex(prompt, startTime, model);
351
+ return dispatchCodex(wrappedPrompt, startTime, model);
332
352
  }
333
353
  if (backend === "claudecode") {
334
- return dispatchClaude(prompt, startTime, model);
354
+ return dispatchClaude(wrappedPrompt, startTime, model);
335
355
  }
336
356
  return Promise.resolve({
337
357
  text: `Unsupported backend: ${backend}`,
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { controlSchema, screenshotSchema, pairSchema } from "./tools/schemas.js"
5
5
  import { executeControl } from "./tools/control.js";
6
6
  import { handleScreenshot } from "./tools/screenshot.js";
7
7
  import { handlePair } from "./tools/pair.js";
8
- const PACKAGE_VERSION = "0.16.3";
8
+ const PACKAGE_VERSION = "0.17.0";
9
9
  export function createServer(deviceName) {
10
10
  const server = new McpServer({
11
11
  name: "zhihand",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhihand/mcp",
3
- "version": "0.16.3",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "ZhiHand MCP Server — phone control tools for Claude Code, Codex, Gemini CLI, and OpenClaw",