|
1 |
| -# Email sending MCP 💌 |
| 1 | +# MCP Server Template 🛠️ |
2 | 2 |
|
3 |
| -[](https://smithery.ai/server/@ykhli/mcp-send-email) |
| 3 | +A starter template for building your own Model Context Protocol (MCP) server. This template provides the basic structure and setup needed to create custom MCPs that can be used with Cursor or Claude Desktop. |
4 | 4 |
|
5 |
| -This is a simple MCP server that sends emails using Resend's API. Why? Now you can let Cursor or Claude Desktop compose emails for you and send it right away without having to copy and paste the email content. |
| 5 | +## Features |
6 | 6 |
|
7 |
| -Built with: |
| 7 | +- Basic MCP server setup with TypeScript |
| 8 | +- Sample tool implementation |
| 9 | +- Ready-to-use project structure |
| 10 | +- Built with [@modelcontextprotocol/sdk](https://docs.anthropic.com/en/docs/agents-and-tools/mcp) |
8 | 11 |
|
9 |
| -- [Resend](https://resend.com/) |
10 |
| -- [Anthropic MCP](https://docs.anthropic.com/en/docs/agents-and-tools/mcp) |
11 |
| -- [Cursor](https://cursor.so/) |
| 12 | +## Project Structure |
12 | 13 |
|
13 |
| -**DEMO** |
14 |
| - |
15 |
| -https://github.com/user-attachments/assets/8c05cbf0-1664-4b3b-afb1-663b46af3464 |
| 14 | +``` |
| 15 | +mcp-server-template/ |
| 16 | +├── index.ts # Main server implementation |
| 17 | +├── package.json # Project dependencies |
| 18 | +├── tsconfig.json # TypeScript configuration |
| 19 | +└── build/ # Compiled JavaScript output |
| 20 | +``` |
16 | 21 |
|
17 |
| -**Cursor** |
| 22 | +## Getting Started |
18 | 23 |
|
19 |
| -1. First, you need to authorize Resend to send emails from your domain or email. Follow the steps [here](https://resend.com/docs/send-with-nodejs) to set that up and get a Resend API key. |
20 |
| -2. Clone this project locally. Edit index.ts and replace [email protected] to your own email to send emails from |
21 |
| -3. Run `npm install`, `npm run build` under the project dir. You should now see a /build/index.js generated - this is the MCP server script! |
| 24 | +1. Clone this template: |
| 25 | +```bash |
| 26 | +git clone [your-repo-url] my-mcp-server |
| 27 | +cd my-mcp-server |
| 28 | +``` |
22 | 29 |
|
23 |
| -Then go to Cursor Settings -> MCP -> Add new MCP server |
| 30 | +2. Install dependencies: |
| 31 | +```bash |
| 32 | +pnpm install |
| 33 | +``` |
24 | 34 |
|
25 |
| -- Name = [choose your own name] |
26 |
| -- Type = command |
27 |
| -- Command: `node ABSOLUTE_PATH_TO_MCP_SERVER/build/index.js --key=YOUR_RESEND_API_KEY --sender=OPTIONAL_SENDER_EMAIL_ADDRESS --reply-to=OPTIONAL_REPLY_TO_EMAIL_ADDRESS_ONE --reply-to=OPTIONAL_REPLY_TO_EMAIL_ADDRESS_TWO` |
| 35 | +3. Build the project: |
| 36 | +```bash |
| 37 | +pnpm run build |
| 38 | +``` |
28 | 39 |
|
29 |
| -You can get Resend API key here: https://resend.com/ |
| 40 | +This will generate the `/build/index.js` file - your compiled MCP server script. |
30 | 41 |
|
31 |
| -Now you can test out sending emails by going to email.md, replace the to: email address, select all in email md, and hit cmd+l. You can now tell cursor to "send this as an email" in the chat. Make sure Cursor chat is in Agent mode by selecting "Agent" on lower left side dropdown |
| 42 | +## Using with Cursor |
32 | 43 |
|
33 |
| -<img width="441" alt="Screenshot 2025-02-25 at 9 13 05 AM" src="https://github.com/user-attachments/assets/b07e9cbf-42d8-4910-8e90-3761d8d3bc06" /> |
| 44 | +1. Go to Cursor Settings -> MCP -> Add new MCP server |
| 45 | +2. Configure your MCP: |
| 46 | + - Name: [choose your own name] |
| 47 | + - Type: command |
| 48 | + - Command: `node ABSOLUTE_PATH_TO_MCP_SERVER/build/index.js` |
34 | 49 |
|
35 |
| -**Claude desktop** |
| 50 | +## Using with Claude Desktop |
36 | 51 |
|
37 |
| -Same set up as above, and then add the following MCP config |
| 52 | +Add the following MCP config to your Claude Desktop configuration: |
38 | 53 |
|
39 |
| -``` |
| 54 | +```json |
40 | 55 | {
|
41 | 56 | "mcpServers": {
|
42 |
| - "resend": { |
| 57 | + "your-mcp-name": { |
43 | 58 | "command": "node",
|
44 |
| - "args": ["ABSOLUTE_PATH_TO_MCP_SERVER/build/index.js"], |
45 |
| - "env": { |
46 |
| - "RESEND_API_KEY": [YOUR_API_KEY], |
47 |
| - "SENDER_EMAIL_ADDRESS": [OPTIONAL_SENDER_EMAIL_ADDRESS], |
48 |
| - "REPLY_TO_EMAIL_ADDRESSES": [OPTIONAL_REPLY_TO_EMAIL_ADDRESSES_COMMA_DELIMITED] |
49 |
| - } |
| 59 | + "args": ["ABSOLUTE_PATH_TO_MCP_SERVER/build/index.js"] |
50 | 60 | }
|
51 | 61 | }
|
52 | 62 | }
|
53 | 63 | ```
|
54 | 64 |
|
55 |
| -**Develop** |
| 65 | +## Development |
| 66 | + |
| 67 | +The template includes a sample tool implementation in `index.ts`. To create your own MCP: |
| 68 | + |
| 69 | +1. Modify the server configuration in `index.ts`: |
| 70 | +```typescript |
| 71 | +const server = new McpServer({ |
| 72 | + name: "your-mcp-name", |
| 73 | + version: "0.0.1", |
| 74 | +}); |
| 75 | +``` |
| 76 | + |
| 77 | +2. Define your custom tools using the `server.tool()` method: |
| 78 | +```typescript |
| 79 | +server.tool( |
| 80 | + "your-tool-name", |
| 81 | + "Your tool description", |
| 82 | + { |
| 83 | + // Define your tool's parameters using Zod schema |
| 84 | + parameter: z.string().describe("Parameter description"), |
| 85 | + }, |
| 86 | + async ({ parameter }) => { |
| 87 | + // Implement your tool's logic here |
| 88 | + return { |
| 89 | + content: [ |
| 90 | + { |
| 91 | + type: "text", |
| 92 | + text: "Your tool's response", |
| 93 | + }, |
| 94 | + ], |
| 95 | + }; |
| 96 | + } |
| 97 | +); |
| 98 | +``` |
| 99 | + |
| 100 | +3. Build and test your implementation: |
| 101 | +```bash |
| 102 | +npm run build |
| 103 | +``` |
| 104 | + |
| 105 | +## Contributing |
| 106 | + |
| 107 | +Feel free to submit issues and enhancement requests! |
| 108 | + |
| 109 | +## License |
56 | 110 |
|
57 |
| -`npm install` |
58 |
| -`npm run build` |
| 111 | +MIT |
0 commit comments