@github/computer-use-mcp 0.1.9 → 0.1.10
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{McpServer as
|
|
1
|
+
import{McpServer as S}from"@modelcontextprotocol/sdk/server/mcp.js";import{createRequire as k}from"module";import{dirname as w,join as P}from"path";import{fileURLToPath as $}from"url";var C=k(import.meta.url),q=w($(import.meta.url));function R(){let c=P(q,"prebuilds",`${process.platform}-${process.arch}`,"computer.node");try{return C(c)}catch{return null}}var b=class c{constructor(e){this.native=e}native;static create(){let e=R();if(!e)throw new Error(`Native computer bindings not available for ${process.platform}-${process.arch}`);return e.display(),new c(e)}async click(e,i,s,t){this.native.click(e,i,s,t)}async move(e,i){this.native.move(e,i)}async drag(e,i,s,t){this.native.drag(e,i,s,t)}async mouseDown(e,i){this.native.mouseDown(e,i)}async mouseUp(e,i){this.native.mouseUp(e,i)}async type(e){this.native.type(e)}async key(e){this.native.key(e)}async scroll(e,i,s,t){this.native.scroll(e,i,s,t)}async cursorPosition(){return this.native.cursorPosition()}async display(){let{width:e,height:i}=this.native.display();return{width:e,height:i}}async screenshot(){return this.native.screenshot()}};import{z as a}from"zod";function o(c,e){let i=[{type:"text",text:c}];return e?{content:i,isError:!0}:{content:i}}var T=a.enum(["screenshot","left_click","right_click","middle_click","double_click","triple_click","left_click_drag","mouse_move","type","key","scroll","left_mouse_down","left_mouse_up","hold_key","wait","cursor_position"]),v=a.object({x:a.number(),y:a.number()});function x(c,e){c.tool("computer",`Use a mouse and keyboard to interact with a computer, and take screenshots.
|
|
2
2
|
|
|
3
|
-
Take a screenshot before clicking to determine coordinates. After each action, take a screenshot to verify the result.`,{action:
|
|
3
|
+
Take a screenshot before clicking to determine coordinates. After each action, take a screenshot to verify the result.`,{action:T.describe(`The action to perform:
|
|
4
4
|
- screenshot: Capture the current screen. No other parameters.
|
|
5
5
|
- left_click: Click left button. Optional 'coordinate' (clicks at current position if omitted).
|
|
6
6
|
- right_click: Click right button. Optional 'coordinate'.
|
|
@@ -16,5 +16,5 @@ Take a screenshot before clicking to determine coordinates. After each action, t
|
|
|
16
16
|
- left_mouse_up: Release left button at current position. No 'coordinate'.
|
|
17
17
|
- hold_key: Hold a key. Requires 'text' (key name) and 'duration' (seconds, max 100).
|
|
18
18
|
- wait: Pause. Requires 'duration' (seconds, max 100).
|
|
19
|
-
- cursor_position: Get current cursor {x, y}. No other parameters.`),coordinate:
|
|
19
|
+
- cursor_position: Get current cursor {x, y}. No other parameters.`),coordinate:v.optional().describe("{x, y} pixel coordinate. Required for mouse_move and left_click_drag (end position). Optional for clicks and scroll."),start_coordinate:v.optional().describe("{x, y} drag start position. Required for left_click_drag only."),text:a.string().optional().describe("For 'type': text to type. For 'key': key combo (e.g. 'ctrl+s'). For 'hold_key': key name."),scroll_direction:a.enum(["up","down","left","right"]).optional().describe("Required for 'scroll' action."),scroll_amount:a.number().int().nonnegative().optional().describe("Scroll clicks (default 3). Only for 'scroll'."),duration:a.number().nonnegative().max(100).optional().describe("Seconds. Required for 'hold_key' and 'wait'.")},async i=>{let{action:s,coordinate:t,start_coordinate:d,text:u,scroll_direction:m,scroll_amount:h,duration:p}=i,n=await e();switch(s){case"screenshot":{let r=await n.screenshot();return r?{content:[{type:"image",data:r.toString("base64"),mimeType:"image/png"}]}:o("Screenshot failed",!0)}case"cursor_position":{let r=await n.cursorPosition();return o(`${r.x},${r.y}`)}case"left_click":case"right_click":case"middle_click":case"double_click":case"triple_click":{let r=s.includes("right")?"right":s.includes("middle")?"middle":"left",y=s.includes("double")?2:s.includes("triple")?3:1;t&&await n.move(t.x,t.y);let l=t??await n.cursorPosition();return await n.click(l.x,l.y,r,y),o(`${s}${t?` at (${t.x},${t.y})`:""}`)}case"left_click_drag":return!d||!t?o("left_click_drag requires start_coordinate and coordinate",!0):(await n.drag(d.x,d.y,t.x,t.y),o(`Dragged (${d.x},${d.y}) -> (${t.x},${t.y})`));case"mouse_move":return t?(await n.move(t.x,t.y),o(`Moved to (${t.x},${t.y})`)):o("mouse_move requires coordinate",!0);case"type":return u?(await n.type(u),o(`Typed ${u.length} chars`)):o("type requires text",!0);case"key":return u?(await n.key(u),o(`Pressed ${u}`)):o("key requires text",!0);case"scroll":{if(!m)return o("scroll requires scroll_direction",!0);let r=h??3,y=await n.cursorPosition(),l=t?.x??y.x,f=t?.y??y.y,g=m==="left"?-r:m==="right"?r:0,_=m==="down"?r:m==="up"?-r:0;return await n.scroll(l,f,g,_),o(`Scrolled ${m} ${r} at (${l},${f})`)}case"left_mouse_down":{let r=await n.cursorPosition();return await n.mouseDown(r.x,r.y),o(`Mouse down at (${r.x},${r.y})`)}case"left_mouse_up":{let r=await n.cursorPosition();return await n.mouseUp(r.x,r.y),o(`Mouse up at (${r.x},${r.y})`)}case"hold_key":return!u||p==null?o("hold_key requires text and duration",!0):(await n.key(u),o(`Held ${u} for ${p}s`));case"wait":return p==null?o("wait requires duration",!0):(await new Promise(r=>setTimeout(r,p*1e3)),o(`Waited ${p}s`));default:return o(`Unknown action: ${String(s)}`,!0)}})}function H(){let c=new S({name:"computer-use",version:"1.0.0"}),e;return x(c,async()=>(e||(e=b.create()),e)),c}export{H as createServer};
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|