
Sketch Context
STDIOMCP server integrating Sketch designs with IDEs for AI-powered design-to-code workflows.
MCP server integrating Sketch designs with IDEs for AI-powered design-to-code workflows.
Note: This project is currently in testing phase and may not be fully stable.
A Model Context Protocol (MCP) server for integrating Sketch designs with IDEs such as Cursor, Cline, or Windsurf.
This tool allows Cursor IDE to access and interpret Sketch design files, enabling AI-powered design-to-code workflows. It works by:
This project consists of two main components:
The server provides the following tools to Cursor:
get_file
: Retrieve contents of a Sketch file or specific node within itlist_components
: List all components/symbols in a Sketch fileget_selection
: Get information about currently selected elementscreate_rectangle
: Create new rectangles with specified dimensions and propertiescreate_text
: Create new text elements with custom content and stylingThese tools enable Cursor to:
# Install globally npm install -g sketch-context-mcp # Run with a local Sketch file sketch-context-mcp --local-file=/path/to/your/file.sketch # Run with Sketch Cloud access sketch-context-mcp --sketch-api-key=<your-sketch-api-key>
Or run directly with npx:
npx sketch-context-mcp --local-file=/path/to/your/file.sketch
.sketchplugin
file to install it in SketchTo use this with Cursor:
Start the MCP server with your Sketch file:
sketch-context-mcp --local-file=/path/to/your/file.sketch
In Sketch, open the plugin:
In Cursor, connect to the MCP server:
http://localhost:3333/sse
In the Cursor composer, you can now:
The Sketch API key is an OAuth access token required for accessing Sketch Cloud-hosted files. Follow these steps to obtain and use the token:
Use your Sketch Cloud credentials (email and password) to generate an access token by making a POST request to the authentication endpoint:
curl -X "POST" "https://auth.sketch.cloud/oauth/token" \ -H 'Content-Type: application/json' \ -d '{ "email": "YOUR_EMAIL", "password": "YOUR_PASSWORD", "grant_type": "password" }'
Replace YOUR_EMAIL
and YOUR_PASSWORD
with your Sketch Cloud account credentials.
The response will include an access_token
. This token serves as your API key for accessing Sketch Cloud-hosted files.
For security, it is recommended to pass the token as an environment variable:
export SKETCH_API_KEY=<your-access-token>
Or include it as a command-line argument:
sketch-context-mcp --sketch-api-key=<your-access-token>
If your token expires, use the refresh_token
provided in the initial response to obtain a new access token.
To ensure your API key is secure, follow these guidelines:
Do Not Hard-Code the Key: Never hard-code an API key into the application or source code. Instead, use environment variables or secret management tools.
Use .env Files for Local Development: Store your API key in a .env
file and load it using a library like dotenv
:
SKETCH_API_KEY=<your-access-token>
Ensure the .env
file is added to .gitignore
to avoid accidental exposure.
Rotate Tokens Regularly: If your token is leaked or compromised, revoke it and generate a new one immediately.
Monitor and Audit: Use tools to scan your repository for exposed credentials (e.g., GitHub’s secret scanning feature).
Use Short-Lived Tokens: If possible, use short-lived tokens and refresh them as needed to minimize the impact of a leaked token.
The Sketch API key is required for accessing Sketch Cloud-hosted files. The server uses this key to authenticate requests to Sketch Cloud and retrieve the necessary design data. The key is passed securely via the Authorization
header when making API requests.
The server can be configured using either environment variables (via .env
file) or command-line arguments. Command-line arguments take precedence over environment variables.
SKETCH_API_KEY
: Your Sketch API access token (required for Sketch Cloud files)PORT
: The port to run the server on (default: 3333)LOCAL_SKETCH_PATH
: Path to local Sketch file (alternative to --local-file argument)DEBUG_LEVEL
: Set logging verbosity (default: 'info')--version
: Show version number--sketch-api-key
: Your Sketch API access token--port
: The port to run the server on--stdio
: Run the server in command mode, instead of default HTTP/SSE--help
: Show help menuThe Connection tab allows you to connect to the Sketch Context MCP server:
The Selection tab displays information about selected layers in your Sketch document:
The About tab provides information about the plugin and how to use it.
Once both Sketch and Cursor are connected to the MCP server:
Example commands in Cursor:
To enable detailed logging, set the DEBUG environment variable:
DEBUG=sketch-mcp:* npx sketch-context-mcp
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.