bookworm-smart-assistant/docs/mcp-templates.md

212 lines
10 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# MCP 配置指南
## 按需模板 (写入项目 `.claude.json`)
### PostgreSQL MCP
- **触发词**: "连数据库"、"查表"、"跑 SQL"、"数据库调试"
- **配置**: 写入项目 `.claude.json`:
```json
"postgres": {
"args": ["/c", "npx", "-y", "@modelcontextprotocol/server-postgres", "<连接串>"],
"command": "cmd", "type": "stdio"
}
```
- **安全提醒**: 连接只读副本或开发库,避免直连生产主库
- **需重启**: 写入后提示用户重启 Claude Code
### Redis MCP
- **触发词**: "Redis 缓存"、"缓存调试"、"查 Redis"
- **配置**:
```json
"redis": {
"args": ["/c", "npx", "-y", "@modelcontextprotocol/server-redis", "redis://localhost:6379"],
"command": "cmd", "type": "stdio"
}
```
### Kubernetes MCP
- **触发词**: "K8s 部署"、"Pod 状态"、"容器调试"
- **配置**:
```json
"kubernetes": {
"args": ["/c", "npx", "-y", "mcp-server-kubernetes"],
"command": "cmd", "type": "stdio"
}
```
### Terraform MCP
- **触发词**: "Terraform"、"IaC"、"基础设施即代码"、"云资源管理"
- **配置**:
```json
"terraform": {
"args": ["/c", "npx", "-y", "mcp-server-terraform", "--workdir", "."],
"command": "cmd", "type": "stdio"
}
```
- **能力**: Terraform plan/apply/state 管理、HCL 语法辅助、Provider 配置
- **安全提醒**: 建议先 `plan` 审查再 `apply`,避免直接变更生产基础设施
### MCP 启用流程
1. 检测用户意图 → 匹配触发词
2. 询问连接信息 (如有需要)
3. 写入项目级 `.claude.json``mcpServers`
4. 提示用户重启 Claude Code
5. 验证 MCP 工具可用
---
## 插件市场 MCP 安装指南
> 以下 MCP 通过 Claude 官方插件市场 (`claude-plugins-official`) 安装。
> 安装后需在对应平台完成 OAuth 授权或 Token 配置。
### Slack
```shell
/plugin install slack@claude-plugins-official
```
- **能力**: 发送消息、搜索频道/消息、创建 Canvas、获取 Slack 上下文
- **授权**: 安装后 OAuth 授权 Slack Workspace
- **要求**: Claude Pro/Max/Team/Enterprise 计划
### Linear
```shell
/plugin install linear@claude-plugins-official
```
- **能力**: 搜索/创建 Issue、项目管理、Sprint 规划、评论
- **授权**: 安装后 OAuth 授权 Linear Workspace
### Atlassian (Jira + Confluence)
```shell
/plugin install atlassian@claude-plugins-official
```
- **能力**: Jira Issue 管理/Sprint/看板 + Confluence 文档搜索/创建
- **授权**: 安装后 OAuth 授权 Atlassian Cloud
### Supabase
```shell
/plugin install supabase@claude-plugins-official
```
- **能力**: PostgreSQL 查询、Auth 管理、Storage 操作、Realtime 订阅
- **授权**: 安装后输入 Supabase Project URL + Service Role Key
### Firebase
```shell
/plugin install firebase@claude-plugins-official
```
- **能力**: Firestore CRUD、Auth 管理、Cloud Functions、推送通知 (FCM)
- **授权**: 安装后配置 Firebase Project ID + Service Account
---
## 云托管 MCP (claude.ai deferred tools)
> 以下 MCP 由 Claude 平台云托管,通过 ToolSearch 自动发现,无需本地配置。
> 首次使用时通过 `/mcp` 完成 OAuth 授权即可。
| MCP | 能力 | 授权方式 |
|-----|------|---------|
| **Vercel** | 部署管理、构建日志、项目配置、域名管理 | OAuth (Vercel 账号) |
| **Cloudinary** | 图片/视频上传、变换、CDN 分发、资产管理 | OAuth (Cloudinary 账号) |
| **Scholar Gateway** | 学术论文语义搜索、引用分析 | 无需授权 |
| **GraphOS (Apollo)** | GraphQL 文档搜索、Schema 设计指引 | 无需授权 |
---
## 全局 MCP 凭证配置
### GitHub (HTTP Remote)
- **凭证**: `GITHUB_PERSONAL_ACCESS_TOKEN` 系统环境变量
- **获取**: GitHub Settings → Developer settings → Fine-grained PAT
- **权限**: repo, issues, pull_requests, actions
### Sentry (HTTP Remote + OAuth)
- **首次使用**: Claude Code 中输入 `/mcp` → 选择 sentry → Authenticate
- **自动缓存**: OAuth token 由 Claude Code 管理
### Figma (HTTP Remote + OAuth)
- **首次使用**: Claude Code 中输入 `/mcp` → 选择 figma → Allow Access
- **要求**: Figma 账号需有目标文件访问权限
### Notion (stdio)
- **凭证**: 替换 settings.json 中 `<ntn_YOUR_NOTION_TOKEN>`
- **获取**: notion.so/profile/integrations → New Integration → Copy Token
- **连接**: 在 Notion 中对目标页面 Share → 添加 Integration
### Gamma (stdio)
- **凭证**: 替换 settings.json 中 `<YOUR_GAMMA_API_KEY>`
- **获取**: gamma.app → Settings → API
### Canva (stdio)
- **无需凭证**: Dev MCP 仅查询 SDK 文档
---
## MCP 总量控制
| 类型 | 数量 | 上下文影响 |
|------|------|-----------|
| 本地常驻 (settings.json) | 8 | 始终加载 |
| 云托管 (deferred tools) | 9 | 按需懒加载,节省 95% 上下文 |
| 插件市场 | 5 | 按需加载 |
| 按需模板 | 3 | 仅项目级启用 |
| **总计** | **25** | 活跃工具 < 80 (推荐阈值) |
> **最佳实践**: 上下文窗口可能从 200K 缩减至 70K工具过多时
> 保持活跃 MCP < 10、总工具 < 80。云托管和插件市场的懒加载机制确保不超限。
---
## MCP 精准激活关键词索引
> 以下关键词用于路由引擎自动匹配 MCP 服务。说出任意关键词即可激活对应 MCP 工具链。
> 更新日期: 2026-03-30
### 本地 MCP (22 个)
| # | MCP | 路由技能 | 中文触发词 | 英文特异性术语 |
|---|-----|---------|-----------|---------------|
| 1 | **orbination** | workflow-automation-expert | 列出窗口, 读屏幕文字, 点击按钮, 点击菜单, 自动滚动, 桌面截图, 扫描元素, 键盘快捷键, 鼠标拖拽 | OCR, UIAutomation, ocr_window, click_element, list_windows, auto_scroll |
| 2 | **windows-mcp** | workflow-automation-expert | 杀进程, 注册表, 剪贴板, 系统通知, 打开应用, 文件操作 | PowerShell, Registry, Process, Clipboard, Notification |
| 3 | **askui-vision** | workflow-automation-expert | 看到屏幕上, 找到那个按钮, 视觉识别, 视觉点击, 看截图点击 | vision_click, vision_locate, vision_get, vision_type |
| 4 | **mcp-com-server** | workflow-automation-expert | 操控Excel, 操控Word, 发邮件Outlook, COM对象, 写入单元格 | CreateObject, VBA, OLE, ActiveX, COM |
| 5 | **chrome-devtools** | browser-automation-expert | 调试页面, 执行JS, 抓网络请求, 性能分析, 内存快照, 控制台日志 | DevTools, CDP, evaluate_script |
| 6 | **playwright** | browser-automation-expert | 打开网页, 自动化测试, 填表单, 网页截图, 上传文件, E2E测试 | Playwright, browser_navigate, browser_click, browser_snapshot |
| 7 | **browserbase** | browser-automation-expert / browse | 云浏览器, 远程浏览器, 智能提取页面, AI操作网页 | Stagehand, Browserbase, stagehand_act, stagehand_extract |
| 8 | **firecrawl** | browser-automation-expert | 爬取网站, 抓取页面, 提取数据, 站点地图, 批量采集 | Firecrawl, scrape, crawl, sitemap |
| 9 | **github** | developer-expert | 创建PR, 提Issue, 搜索仓库, 创建分支, 合并PR, 代码审查 | GitHub, Pull Request, fork |
| 10 | **slack** | developer-expert | 发Slack消息, 查看频道, 回复线程, Slack历史 | Slack, slack_post, channel |
| 11 | **context7** | developer-expert | 查最新文档, 查API文档, 这个库怎么用, 最新版本用法 | context7, query-docs, resolve-library |
| 12 | **sequential-thinking** | developer-expert | 一步步分析, 逻辑推导, 分步推理, 深度思考 | chain-of-thought, sequential |
| 13 | **notebooklm** | developer-expert | 查笔记本, 问笔记, 搜索笔记, 创建笔记本 | NotebookLM, notebook |
| 14 | **cloudflare** | edge-computing-expert | Cloudflare文档, Workers迁移, Pages转Workers | Cloudflare, Workers, Pages |
| 15 | **deep-research** | (按需) | 深度调研, 全面研究, 多轮搜索, 自主调查 | deep-research |
| 16 | **mobile** | mobile-expert | 手机操作, 安装APK, 手机截图, 模拟器操作 | ADB, Android, iOS |
| 17 | **linear** | (按需) | Linear任务, 创建Issue, 任务看板 | Linear, sprint |
| 18 | **atlassian** | (按需) | Jira工单, Confluence文档, 查看看板 | Jira, Confluence, Atlassian |
| 19 | **supabase** | (按需) | 查数据库, 建表, 用户认证, 存储桶 | Supabase, PostgreSQL, Edge Function |
| 20 | **figma** | (按需) | 设计稿, 读取Figma, UI标注 | Figma, design token |
| 21 | **scrapling** | browser-automation-expert | Python爬虫, 抓取解析 | scrapling, BeautifulSoup |
| 22 | **pywinauto** | workflow-automation-expert | Python控制窗口, 自动化GUI, Win32控件 | pywinauto, win32gui |
### 云托管 MCP (8 个)
| # | MCP | 中文触发词 | 英文特异性术语 |
|---|-----|-----------|---------------|
| 23 | **sentry** | 错误追踪, 异常监控, 线上报错 | Sentry, error tracking |
| 24 | **notion** | 写Notion, 查Notion, Notion数据库 | Notion, page, database |
| 25 | **gamma** | 做PPT, 生成演示文稿, 做幻灯片 | Gamma, presentation |
| 26 | **canva** | 做海报, 做封面图, 社交媒体图 | Canva, template |
| 27 | **vercel** | 部署项目, Vercel部署, 查看部署状态 | Vercel, deploy, serverless |
| 28 | **cloudinary** | 图片处理, 压缩图片, 视频转码, 图床CDN | Cloudinary, transform |
| 29 | **scholar-gateway** | 搜论文, 学术搜索, 查引用, 文献检索 | Scholar, citation, paper |
| 30 | **graphos** | GraphQL网关, API联邦, Schema管理 | GraphOS, Apollo, federation |
### 按需模板 MCP (4 个)
| # | MCP | 中文触发词 | 英文特异性术语 |
|---|-----|-----------|---------------|
| 31 | **postgres** | 连数据库, 查表, 跑SQL, 数据库调试 | PostgreSQL, psql, SQL |
| 32 | **redis** | Redis缓存, 缓存调试, 查Redis | Redis, cache |
| 33 | **kubernetes** | K8s部署, Pod状态, 容器调试 | Kubernetes, K8s, kubectl |
| 34 | **terraform** | Terraform, IaC, 基础设施即代码, 云资源管理 | Terraform, HCL, Provider |