computer-use-mcp

repository·master·Indexed 43 days ago

https://github.com/domdomegg/computer-use-mcp

A Model Context Protocol (MCP) server version 1.8.0 that allows Claude models to control a computer locally via mouse and keyboard interaction. It utilizes the nut.js library and provides tools for integration into MCP clients such as Claude Desktop, Cursor, and VS Code.

Tokens
1.2K
Snippets
4
Records
7
Agent score
57%

What's inside computer-use-mcp

  1. Security Warning for computer-use-mcp

    master

    ⚠️ WARNING

    This MCP server gives the model complete control of your computer. Models can make frequent mistakes and are vulnerable to prompt injections.

    Best Practices:

    • Treat the model like a 'hyperactive toddler'—supervise its actions closely.
    • Consider running the MCP server only within a sandboxed user account to prevent potential damage to your system.
  2. Optimize computer-use-mcp performance

    master

    For the best results when using the computer control capabilities, follow these recommendations:

    • Model Selection: Use high-capability models, specifically the latest Claude models.
    • Screen Resolution: Use a small, common resolution like 720p. On macOS, you can use displayoverride-mac to achieve this. If resolution cannot be changed, try zooming in on active windows.
    • Web Navigation: Install and enable the Rango browser extension. This enables keyboard navigation for websites, which is significantly more reliable than the model attempting to click specific coordinates. You can increase the font size in Rango to make navigation hints more visible.
  3. Install computer-use-mcp

    master

    To install computer-use-mcp and generate the appropriate configuration for your MCP client (such as Claude Code, Claude Desktop, Cursor, Cline, or VS Code), use the install-mcp utility. This ensures the server is correctly registered with your specific environment.

    Follow the instructions on https://adamjones.me/install-mcp/?config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNvbXB1dGVyLXVzZS1tY3AiXSwibmFtZSI6ImNvbXB1dGVyLXVzZSJ9 to generate the right config for your MCP client.
  4. Register all computer control tools with registerAll()

    master

    Use the registerAll function to attach all available computer control tools to an existing Model Context Protocol (MCP) server instance. This is the primary entrypoint for integrating the full suite of computer-use capabilities into your MCP server implementation.

    import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
    import { registerAll } from './path/to/computer-use-mcp/src/tools/index.js';
    
    const server = new McpServer({
      name: 'my-computer-server',
      version: '1.0.0',
    });
    
    // Register all computer control tools
    registerAll(server);
  5. Create an MCP server instance with createServer()

    master

    Use the createServer() function to initialize a new McpServer instance pre-configured with all available computer-use tools. The returned server instance is ready to be connected to an MCP client (like Claude Desktop) after you handle the transport layer (e.g., via Stdio).

    import { createServer } from 'computer-use-mcp';
    
    const server = createServer();
    
    // From here, you would typically connect the server to a transport,
    // such as the StdioServerTransport from the MCP SDK.
  6. Format tool results using jsonResult

    master

    The jsonResult utility function is used to format tool execution data into a CallToolResult object compatible with the Model Context Protocol (MCP) SDK. It performs two actions:

    1. It creates a content array containing a single text object where the input data is stringified as a formatted JSON string.
    2. It attaches the original data object to a structuredContent property.

    This is useful when building MCP tools that need to return structured data to a client while ensuring the data is also readable as text in the tool's response.

    import { jsonResult } from './utils/response';
    
    const myData = { success: true, count: 42 };
    const result = jsonResult(myData);
    
    // result is equivalent to:
    // {
    //   content: [{ type: 'text', text: '{\n  "success": true,\n  "count": 42\n}' }],
    //   structuredContent: { success: true, count: 42 }
    // }