@github/computer-use-mcp 0.0.0 → 0.1.8

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/README.md CHANGED
@@ -1,4 +1,2 @@
1
- # @github/computer-use-mcp (stub)
2
-
3
- Stub package published to reserve the name.
4
1
 
2
+ # @github/computer-use-mcp
@@ -0,0 +1,14 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+
3
+ /**
4
+ * Creates a computer-use MCP server.
5
+ *
6
+ * The server exposes a single "computer" tool with mouse, keyboard, and
7
+ * screenshot actions mirroring the Anthropic computer-use API.
8
+ *
9
+ * Uses prebuilt native addons (macOS / Windows). Throws on unsupported
10
+ * platforms.
11
+ */
12
+ export declare function createServer(): McpServer;
13
+
14
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ import{McpServer as N}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),R=w($(import.meta.url));function q(){let c=P(R,"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=q();if(!e)throw new Error(`Native computer bindings not available for ${process.platform}-${process.arch}`);return new c(e)}async click(e,o,s,t){this.native.click(e,o,s,t)}async move(e,o){this.native.move(e,o)}async drag(e,o,s,t){this.native.drag(e,o,s,t)}async mouseDown(e,o){this.native.mouseDown(e,o)}async mouseUp(e,o){this.native.mouseUp(e,o)}async type(e){this.native.type(e)}async key(e){this.native.key(e)}async scroll(e,o,s,t){this.native.scroll(e,o,s,t)}async cursorPosition(){return this.native.cursorPosition()}async display(){let{width:e,height:o}=this.native.display();return{width:e,height:o}}async screenshot(){return this.native.screenshot()}};import{z as a}from"zod";function i(c,e){let o=[{type:"text",text:c}];return e?{content:o,isError:!0}:{content:o}}function T(c,e){return{content:[{type:"text",text:c},{type:"image",data:e,mimeType:"image/png"}]}}var S=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"]),x=a.object({x:a.number(),y:a.number()});function h(c,e){c.tool("computer",`Use a mouse and keyboard to interact with a computer, and take screenshots.
2
+
3
+ Take a screenshot before clicking to determine coordinates. After each action, take a screenshot to verify the result.`,{action:S.describe(`The action to perform:
4
+ - screenshot: Capture the current screen. No other parameters.
5
+ - left_click: Click left button. Optional 'coordinate' (clicks at current position if omitted).
6
+ - right_click: Click right button. Optional 'coordinate'.
7
+ - middle_click: Click middle button. Optional 'coordinate'.
8
+ - double_click: Double-click left button. Optional 'coordinate'.
9
+ - triple_click: Triple-click left button. Optional 'coordinate'.
10
+ - left_click_drag: Drag from 'start_coordinate' to 'coordinate'. Both required.
11
+ - mouse_move: Move cursor. Requires 'coordinate'.
12
+ - type: Type text. Requires 'text'. Rejects 'coordinate'.
13
+ - key: Press key combo. Requires 'text' (e.g. 'Return', 'ctrl+s', 'alt+Tab'). Rejects 'coordinate'.
14
+ - scroll: Scroll. Requires 'scroll_direction'. Optional 'coordinate', 'scroll_amount' (default 3).
15
+ - left_mouse_down: Press left button at current position. No 'coordinate'.
16
+ - left_mouse_up: Release left button at current position. No 'coordinate'.
17
+ - hold_key: Hold a key. Requires 'text' (key name) and 'duration' (seconds, max 100).
18
+ - wait: Pause. Requires 'duration' (seconds, max 100).
19
+ - cursor_position: Get current cursor {x, y}. No other parameters.`),coordinate:x.optional().describe("{x, y} pixel coordinate. Required for mouse_move and left_click_drag (end position). Optional for clicks and scroll."),start_coordinate:x.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 o=>{let{action:s,coordinate:t,start_coordinate:d,text:u,scroll_direction:m,scroll_amount:v,duration:p}=o,n=await e();switch(s){case"screenshot":{let r=await n.screenshot();if(!r)return i("Screenshot failed",!0);let l=await n.display();return T(`Display: ${l.width}x${l.height}`,r.toString("base64"))}case"cursor_position":{let r=await n.cursorPosition();return i(`${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",l=s.includes("double")?2:s.includes("triple")?3:1;t&&await n.move(t.x,t.y);let y=t??await n.cursorPosition();return await n.click(y.x,y.y,r,l),i(`${s}${t?` at (${t.x},${t.y})`:""}`)}case"left_click_drag":return!d||!t?i("left_click_drag requires start_coordinate and coordinate",!0):(await n.drag(d.x,d.y,t.x,t.y),i(`Dragged (${d.x},${d.y}) -> (${t.x},${t.y})`));case"mouse_move":return t?(await n.move(t.x,t.y),i(`Moved to (${t.x},${t.y})`)):i("mouse_move requires coordinate",!0);case"type":return u?(await n.type(u),i(`Typed ${u.length} chars`)):i("type requires text",!0);case"key":return u?(await n.key(u),i(`Pressed ${u}`)):i("key requires text",!0);case"scroll":{if(!m)return i("scroll requires scroll_direction",!0);let r=v??3,l=await n.cursorPosition(),y=t?.x??l.x,f=t?.y??l.y,g=m==="left"?-r:m==="right"?r:0,_=m==="down"?r:m==="up"?-r:0;return await n.scroll(y,f,g,_),i(`Scrolled ${m} ${r} at (${y},${f})`)}case"left_mouse_down":{let r=await n.cursorPosition();return await n.mouseDown(r.x,r.y),i(`Mouse down at (${r.x},${r.y})`)}case"left_mouse_up":{let r=await n.cursorPosition();return await n.mouseUp(r.x,r.y),i(`Mouse up at (${r.x},${r.y})`)}case"hold_key":return!u||p==null?i("hold_key requires text and duration",!0):(await n.key(u),i(`Held ${u} for ${p}s`));case"wait":return p==null?i("wait requires duration",!0):(await new Promise(r=>setTimeout(r,p*1e3)),i(`Waited ${p}s`));default:return i(`Unknown action: ${String(s)}`,!0)}})}function E(){let c=new N({name:"computer-use",version:"1.0.0"}),e;return h(c,async()=>(e||(e=b.create()),e)),c}export{E as createServer};
20
+ //# sourceMappingURL=index.js.map
package/dist/main.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{StdioServerTransport as e}from"@modelcontextprotocol/sdk/server/stdio.js";import{createServer as n}from"./index.js";const o=n();async function r(){await o.close(),process.exit(0)}process.on("SIGINT",r),process.on("SIGTERM",r);const s=new e;await o.connect(s);
3
+ //# sourceMappingURL=main.js.map
package/package.json CHANGED
@@ -1,13 +1,51 @@
1
1
  {
2
2
  "name": "@github/computer-use-mcp",
3
- "version": "0.0.0",
4
- "description": "",
5
- "main": "index.js",
3
+ "version": "0.1.8",
4
+ "description": "Computer Use MCP Server",
5
+ "author": "GitHub",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/github/computer-use-mcp.git"
9
+ },
10
+ "type": "module",
11
+ "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "bin": "dist/main.js",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.js",
17
+ "types": "./dist/index.d.ts"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist/index.js",
22
+ "dist/index.d.ts",
23
+ "dist/main.js",
24
+ "dist/prebuilds"
25
+ ],
6
26
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
27
+ "start": "npm run build && node dist/main.js",
28
+ "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
29
+ "build": "esbuild src/index.ts --bundle --minify --sourcemap=linked --format=esm --platform=node --packages=external --outdir=dist && esbuild src/main.ts --minify --sourcemap=linked --format=esm --platform=node --outdir=dist && dts-bundle-generator src/index.ts -o dist/index.d.ts --no-banner",
30
+ "build:mac": "cd computer/mac && bash build.sh",
31
+ "build:win": "cd computer/win && powershell -ExecutionPolicy Bypass -File build.ps1",
32
+ "lint": "eslint src/",
33
+ "test": "echo \"No tests yet\" && exit 0",
34
+ "publish:patch": "npm version patch -m \"v%s\" && git push && git push --tags",
35
+ "publish:minor": "npm version minor -m \"v%s\" && git push && git push --tags",
36
+ "publish:major": "npm version major -m \"v%s\" && git push && git push --tags"
37
+ },
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.27.1",
40
+ "zod": "^3.23.0"
8
41
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "type": "commonjs"
42
+ "devDependencies": {
43
+ "@eslint/js": "^10.0.1",
44
+ "@types/node": "^22.0.0",
45
+ "dts-bundle-generator": "^9.5.1",
46
+ "esbuild": "^0.27.0",
47
+ "eslint": "^10.1.0",
48
+ "typescript": "^5.8.0",
49
+ "typescript-eslint": "^8.58.0"
50
+ }
13
51
  }