A Python application that uses the Model Context Protocol (MCP) to interact with Freeform on macOS, allowing for automated drawing and text placement.
- Opens and manages Freeform application
- Creates new boards
- Draws squares with specified dimensions
- Adds text to squares
- Uses AppleScript for macOS automation
- Integrates with Model Context Protocol (MCP)
- macOS operating system
- Python 3.7 or higher
- Freeform application installed
cliclickcommand-line tool installed (brew install cliclick)
- Clone the repository:
git clone https://github.com/RohinSequeira/mcp_draw.git
cd mcp_draw- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On macOS/Linux- Install dependencies:
pip install -r requirements.txt- Create a
.envfile in the project root and add your Gemini API key:
GEMINI_API_KEY=your_api_key_here
Run the main application:
python talk2mcp-2.pyThe application will:
- Connect to the MCP server
- Initialize the session
- Process commands through the Gemini model
- Execute drawing operations in Freeform
example2-3.py: Contains the MCP server implementation and tool definitionstalk2mcp-2.py: Main client application that interfaces with the MCP server.env: Configuration file for API keys (create this file)
open_freeform(): Opens the Freeform applicationcreate_board_in_freeform(): Creates a new board in Freeformcreate_square_in_freeform(): Draws a square with specified dimensionswrite_text_in_square_in_freeform(text): Adds text to the square
The application includes comprehensive error handling for:
- Freeform application state
- Tool execution
- API communication
- Parameter validation
Feel free to submit issues and enhancement requests!