A Model Context Protocol (MCP) server built with Cloudflare Workers that provides tools for mathematical operations and HeyGen video creation.
- Add Tool: Add two numbers together
- Calculate Tool: Perform mathematical operations (add, subtract, multiply, divide)
- HeyGen Video Tool: Create videos using the HeyGen API
- MCP Protocol Support: Compatible with Cursor and other MCP clients
- Cloudflare Workers: Deployable to Cloudflare's edge network
npm installCreate a .dev.vars file in your project root:
HEYGEN_API_KEY=your_heygen_api_key_herenpm run devThe server will be available at http://localhost:8787
# Test server info
curl http://localhost:8787/mcp
# Test tools list
curl http://localhost:8787/mcp/tools
# Test add tool
curl -X POST http://localhost:8787/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "add", "arguments": {"a": 5, "b": 3}}'
# Test calculate tool
curl -X POST http://localhost:8787/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "calculate", "arguments": {"operation": "multiply", "a": 4, "b": 5}}'
# Test HeyGen video tool (requires valid API key)
curl -X POST http://localhost:8787/mcp/tools/call \
-H "Content-Type: application/json" \
-d '{"name": "create_heygen_video", "arguments": {"avatar_id": "test", "voice_id": "test", "input_text": "Hello world!"}}'# Test initialization
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"clientInfo":{"name":"test","version":"1.0.0"}}}' | node mcp-bridge.js
# Test tools list
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | node mcp-bridge.js
# Test tool call
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"add","arguments":{"a":10,"b":20}}}' | node mcp-bridge.js- Open Cursor Settings
- Go to Extensions > MCP
- Add a new MCP server with the following configuration:
- Name:
heygen-mcp - Command:
node - Args:
[path-to-your-project]/mcp-bridge.js - Working Directory:
[path-to-your-project]
- Name:
Once configured, you can ask Cursor to:
- "Add 5 and 3 using the add tool"
- "Calculate 10 multiplied by 5"
- "Create a HeyGen video with avatar_id 'abc123', voice_id 'xyz789', and text 'Hello world!'"
- Name:
add - Description: Add two numbers together
- Parameters:
a(number): First numberb(number): Second number
- Name:
calculate - Description: Perform mathematical operations on two numbers
- Parameters:
operation(string): One of "add", "subtract", "multiply", "divide"a(number): First numberb(number): Second number
- Name:
create_heygen_video - Description: Create a video using HeyGen API
- Parameters:
avatar_id(string): HeyGen avatar IDvoice_id(string): HeyGen voice IDinput_text(string): Text to convert to speechbackground(string, optional): Background color
npm run deployMake sure to set the HEYGEN_API_KEY environment variable in your Cloudflare Workers dashboard or using Wrangler:
wrangler secret put HEYGEN_API_KEY- Cloudflare Worker: Main server running on Cloudflare's edge network
- Durable Object: Provides stateful behavior and SQL storage
- MCP Bridge: Node.js script that bridges HTTP requests to MCP protocol
- HeyGen API Integration: Direct integration with HeyGen's video generation API
├── src/
│ └── index.ts # Main Cloudflare Worker code
├── mcp-bridge.js # MCP protocol bridge for Cursor
├── wrangler.jsonc # Cloudflare Workers configuration
├── package.json # Dependencies and scripts
└── README.md # This file
npm run dev: Start development servernpm run deploy: Deploy to Cloudflare Workersnpm run format: Format code with Biomenpm run lint:fix: Fix linting issues
- "SQL is not enabled": Make sure the migrations are properly configured in
wrangler.jsonc - "Cannot find module": Run
npm installto install dependencies - "HEYGEN_API_KEY not found": Set the environment variable in your development environment
Enable debug logging by setting the DEBUG environment variable:
DEBUG=* npm run devMIT License - see LICENSE file for details.