内容
# <img src="https://res.cloudinary.com/brandpad/image/upload/c_scale,dpr_auto,f_auto,w_1792/v1713826774/28444/tachometer-white-png" alt="Fastly Logo" height="25"> FastlyMCP [](https://www.linkedin.com/in/jack-w-richards/) [](https://smithery.ai/server/@Arodoid/fastlymcp)
Fastly MCP 通过模型上下文协议(Model Context Protocol,MCP)将 Fastly 的 API 的强大功能直接带入您的 AI 助手。
[](https://modelcontextprotocol.io/introduction)
[](https://nodejs.org/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/yourusername/fastly-mcp)
<a href="https://github.com/Arodoid/FastlyMCP/stargazers"><img src="https://img.shields.io/github/stars/Arodoid/FastlyMCP" alt="Stars Badge"/></a>
<a href="https://github.com/Arodoid/FastlyMCP/network/members"><img src="https://img.shields.io/github/forks/Arodoid/FastlyMCP" alt="Forks Badge"/></a>
<a href="https://github.com/Arodoid/FastlyMCP/pulls"><img src="https://img.shields.io/github/issues-pr/Arodoid/FastlyMCP" alt="Pull Requests Badge"/></a>
<a href="https://github.com/Arodoid/FastlyMCP/issues"><img src="https://img.shields.io/github/issues/Arodoid/FastlyMCP" alt="Issues Badge"/></a>

### Fastly 的 API 优先方法
Fastly 的 API 优先设计理念意味着:
- **一切皆为 API** - Fastly UI 中的每个功能都可以通过 API 访问
- **程序化控制** - 完全控制服务、配置和边缘逻辑
- **自动化准备就绪** - 支持 CI/CD 工作流和基础设施即代码
- **实时更改** - API 更改在几秒钟内全球传播,而不是几分钟或几小时
## 我可以用 Fastly API 做什么?
Fastly 的 [全面 API](https://www.fastly.com/documentation/reference/api/) 允许您:
- **管理 CDN 服务** - 创建、配置和部署内容交付服务
- **控制缓存** - 设置缓存策略并执行即时清除
- **配置安全性** - 管理 WAF、DDoS 保护和 TLS 证书
- **监控性能** - 访问实时指标和历史统计数据
- **实现边缘逻辑** - 部署自定义 VCL 或 Compute@Edge 应用程序
- **自动化工作流** - 与 CI/CD 管道和基础设施工具集成
### 您的 API 密钥保持安全!
AI 助手永远不会看到您的 Fastly API 密钥。它与一个本地助手(FastlyMCP)进行通信,该助手安全地使用该密钥。
### 您可以问 AI 的问题
配置好 Fastly MCP 后,您可以向 AI 助手提出如下问题:
| 您想做的事情 | 示例 AI 请求 |
| ------------------- | ------------------------------------------------------------ |
| 列出您的服务 | "显示我所有的 Fastly 服务" |
| 获取域名详情 | "我的电子商务服务配置了哪些域名?" |
| 清除缓存 | "清除我产品服务的缓存" |
| 检查流量 | "我主站点过去一周的流量模式是什么?" |
| 查看配置 | "显示我 API 服务的后端服务器" |
| 检查性能 | "我当前的缓存命中率是多少?" |
### "我服务的流量模式在过去一周是什么?"
<img src="https://github.com/user-attachments/assets/14958973-b8a9-426b-aa27-470bea012d7d" alt="2025-04-16-09-13-35" width="500"/>
### "列出我所有的 Fastly 服务及其域名。"
<img src="https://github.com/user-attachments/assets/08550182-b3d9-4534-8bf4-bec7cb951465" alt="2025-04-16-09-13-35" width="500"/>
### "构建一个关于我的 Fastly 服务的互动性能仪表板。"
<img src="https://github.com/user-attachments/assets/542b0b42-af5e-4a18-b88a-5ab2eee22214" alt="2025-04-16-09-13-35" width="600"/>
## 开始使用
### 先决条件
- 一个 Fastly 账户和 API 密钥([开始使用 Fastly](https://www.fastly.com/signup/))
- 一个支持 MCP 的 AI 助手(例如,Claude、带插件的 GPT)
- 安装 Fastly CLI([安装指南](https://www.fastly.com/documentation/reference/cli/))
### 连接您的 AI 助手
使用以下配置您的 AI 助手:
```json
{
"mcpServers": {
"fastly": {
"command": "node",
"args": ["path/to/fastly-mcp.mjs"],
"env": {
"FASTLY_API_KEY": "your_fastly_api_key"
}
}
}
}
```
## 高级操作示例
| 任务目标 | 示例 AI 请求 |
| :------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| 根据流量优化服务 | "分析 `[service_id/name]` 的配置,并根据其流量特征建议优化,优先考虑低延迟。" |
| 为直播视频配置 | "为 `[service_id/name]` 配置最佳直播视频流,遵循 `[link_to_guide_or_doc]` 中概述的最佳实践。" |
| 查找配置冲突 | "识别 `[service_id/name]` 中可能的配置冲突,与标准电子商务交付模式进行比较。" |
| 优化视频块缓存 | "优化 `[service_id/name]` 的缓存,以高效处理 10 秒的视频块,最小化源负载。" |
| 增强 WAF 安全性 | "审查 `[service_id/name]` 的 WAF 规则,并建议更严格的设置以减轻潜在的 SQL 注入攻击。" |
| 设置源 mTLS | "为 `[service_id/name]` 设置 Fastly 与源服务器之间的互信 TLS(mTLS)身份验证。" |
| 实施 A/B 测试(边缘) | "部署一个 Compute@Edge 函数到 `[service_id/name]`,通过将 10% 的用户路由到后端 `[backend_name]` 来进行 A/B 测试。" |
| 添加动态图像重写(VCL) | "为 `[service_id/name]` 编写并部署 VCL,以根据请求设备的用户代理动态重写图像 URL。" |
| 排查 5xx 错误 | "分析过去 24 小时内 `[service_id/name]` 的日志,以识别最近 5xx 错误激增的根本原因。" |
## 了解更多
- [Fastly API 文档](https://www.fastly.com/documentation/reference/api/)
- [模型上下文协议](https://modelcontextprotocol.io/introduction)
- [开始使用 Fastly](https://docs.fastly.com/en/guides/start-here)
## 许可证
本项目根据 MIT 许可证授权 - 详见 LICENSE 文件。