
mcp_tutorial
干中学|| build_mcp_from_scratch
Repository Info
About This Server
干中学|| build_mcp_from_scratch
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP 教程项目
本项目是一个基于微服务架构的应用程序,通过模型-控制器-提供者(MCP)架构展示各种集成功能。
中文 | English
📺 在 Bilibili 观看教程视频
项目结构
mcp_tutorial/
├── mcp-client/ # 客户端应用
├── mcp-server/ # 服务端微服务
│ ├── podcast/ # 播客服务
│ ├── weather/ # 天气服务
│ ├── gmail/ # Gmail服务
│ └── filesystem/ # 文件管理服务
└── need/ # 附加资源和工具
功能特性
- 多语言支持(英文/中文)
- 天气服务集成
- 文件管理系统
- 基于Coze API的播客生成
- Gmail服务集成:
- 发送和接收邮件
- 邮件通知
- 附件处理
- (待开发)多存储后端支持:
- Redis
- PostgreSQL
- 内存存储
- Google Drive
- GitHub
- GitLab
- Slack集成
- 现代化客户端界面
环境要求
- Node.js (v14或更高版本)
- npm或yarn
- Redis (可选)
- PostgreSQL (可选)
- Google Cloud Platform账户 (用于Gmail API)
安装说明
- 克隆仓库:
git clone https://github.com/fak111/mcp_tutorial.git
cd mcp_tutorial
- 安装各服务依赖:
# 安装客户端依赖
cd mcp-client
npm install
# 安装服务端依赖
cd ../mcp-server
npm install
- 配置环境变量:
- 在相应的服务目录中创建
.env文件 - 设置必要的API密钥和连接字符串
- 配置Gmail API凭据:
- 在Google Cloud Console中创建项目
- 启用Gmail API
- 设置OAuth 2.0凭据
- 将凭据添加到
.env文件中
运行应用
- 启动服务器:
cd mcp-server
# 如果可以使用node
node ..js
- 启动客户端:
cd mcp-client
# 创建虚拟环境
uv venv
# 激活虚拟环境
# Windows系统:
.venv\Scripts\activate
# Unix或MacOS系统:
source .venv/bin/activate
# 安装所需包
uv add mcp anthropic python-dotenv google-api-python-client google-auth-oauthlib
# 运行
uv run client_no_api.py dumy.js
语言支持
应用程序支持英文和中文两种语言。您可以通过用户界面中的语言选择器切换语言。所有文档都提供两种语言版本:
- 英文:README.md
- 中文:README_zh.md
开发说明
- 项目使用TypeScript确保类型安全
- 每个服务可以独立开发和部署
- 遵循微服务架构模式
- 支持i18n多语言实现
贡献指南
- Fork本仓库
- 创建特性分支 (
git checkout -b feature/amazing-feature) - 提交更改 (
git commit -m '添加某个很棒的特性') - 推送到分支 (
git push origin feature/amazing-feature) - 创建Pull Request
许可证
本项目基于MIT许可证 - 详情请查看LICENSE文件。
致谢
- 感谢所有贡献者
- 使用现代网络技术和最佳实践构建
安全提示
敏感信息处理
为确保安全性,本项目中的敏感信息(如API密钥、客户端密钥等)不应直接存储在代码库中。请按照以下步骤操作:
- 复制各目录下的
.env.example文件为.env,并填入您的实际密钥 - 复制
password.py.example文件为password.py,并填入您的API密钥 - 复制示例JS/TS文件(如
index.example.js)并按照文件中的说明填入敏感信息
所有包含实际密钥的文件已添加到.gitignore中,确保不会意外上传到公共仓库。
⚠️ 警告: 永远不要将包含真实密钥的文件提交到代码库中,即使是私有仓库也要谨慎处理。
密钥轮换
定期轮换您的API密钥,尤其是在以下情况下:
- 怀疑密钥可能已泄露
- 项目协作者离开团队
- 经过较长时间未更改(建议至少每90天轮换一次)
Quick Start
Clone the repository
git clone https://github.com/fak111/mcp_tutorialInstall dependencies
cd mcp_tutorial
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.