EmailTemplateMCP
Generates email templates via Claude, turning a description (with optional tone and brand name) into a subject, plain-text, and HTML email body.
README
EmailTemplateMCP
A minimal MCP server that generates email templates with Claude — one tool, one file, deployed as a single AWS Lambda function behind a public Function URL. No framework, no MCP SDK dependency: the JSON-RPC dispatch is ~130 lines of plain JavaScript.
This is the reference implementation used in the "Build an MCP server from scratch" video series.
What it does
Exposes a single tool, create_email_template, which takes a description of an email's purpose
(plus optional tone and brand name) and returns a subject line, a plain-text body, and an
inline-styled HTML body — generated by Claude in one call.
{
"name": "create_email_template",
"arguments": {
"description": "welcome email for new SaaS signups",
"tone": "friendly",
"brand_name": "Acme"
}
}
Why no MCP SDK?
MCP isn't a library you install — it's a protocol: JSON-RPC 2.0 over HTTP. This project implements
initialize, tools/list, and tools/call directly in the Lambda handler, so there's nothing to
learn beyond reading index.mjs top to bottom. The only real dependency is the
Anthropic SDK, used to actually generate
the email content.
Output shape is enforced server-side via Anthropic's structured output
(output_config.format.json_schema), so there's no fragile hand-rolled JSON parsing of the model's
response.
Why a Function URL, not API Gateway?
Generating an email is a real model call — it can take 10-20+ seconds. API Gateway's HTTP API has a hard, non-configurable 30-second integration timeout. A Lambda Function URL has no such ceiling; the only limit is the function's own configured timeout (set here to ~2 minutes).
Deploying
Option A — one command, via AWS SAM
template.yaml in this repo defines the whole thing — the function, its Function URL, and both
environment variables — so you don't have to click through the console at all.
sam build
sam deploy --guided
--guided walks you through stack name, region, and the two secret parameters (AnthropicApiKey,
McpApiKey — both NoEcho, never printed or stored in plain text in the template) on first run,
then remembers your answers in samconfig.toml for future deploys. On success it prints the
Function URL as an output.
Requires the AWS SAM CLI and valid AWS credentials configured locally.
Option B — manual, via the Lambda console
npm install— pulls in the Anthropic SDK.- Zip the folder's contents (not the folder itself) —
index.mjs,node_modules,package.json,package-lock.jsonshould sit at the zip's top level. - In the Lambda console: Create function → author from scratch → Node.js 22+ → upload the zip.
- Configuration → General configuration: raise Timeout (e.g. 2 min) and Memory (e.g. 256 MB) — the defaults (3s / 128MB) aren't enough for a real generation call.
- Configuration → Environment variables:
ANTHROPIC_API_KEY— from the Anthropic console.MCP_API_KEY— a secret you invent (any long random string). This is the shared secret every caller must present.ANTHROPIC_MODEL— optional, defaults toclaude-opus-5.
- Configuration → Function URL: create one with Auth type
NONE. This doesn't mean unauthenticated — it means AWS isn't checking IAM signatures.MCP_API_KEYis the actual gate, checked on every request inside the handler.
Authentication
Every request must include the shared secret, either as a header:
x-api-key: <MCP_API_KEY>
or a query parameter:
?key=<MCP_API_KEY>
Requests without a valid key get a 401 before anything else runs — including before any call to
Anthropic, so a bad key never costs you a generation.
Testing it directly
# List tools
curl -s https://<your-function-url> \
-H "x-api-key: <MCP_API_KEY>" \
-H "content-type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
# Call the tool
curl -s https://<your-function-url> \
-H "x-api-key: <MCP_API_KEY>" \
-H "content-type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"create_email_template","arguments":{"description":"welcome email for new signups"}}}'
Connecting an MCP client
For Claude Code:
claude mcp add --transport http email-template https://<your-function-url> \
--header "x-api-key: <MCP_API_KEY>"
Any MCP-compatible client that supports plain header auth over Streamable HTTP works the same way.
Project structure
index.mjs — the entire server: tool definition, Anthropic call, JSON-RPC dispatch
package.json — the one runtime dependency
Security note
MCP_API_KEY and ANTHROPIC_API_KEY are both plain environment variables — never hardcode them in
index.mjs. If you've ever shown this function's configuration on screen (a demo, a screen
recording), rotate both values afterward.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。