MCP恢复生成器服务器
一个生产就绪的模型上下文协议(MCP)服务器,使用OpenAI GPT-4.1、LaTeX编译和AWS S3存储生成ATS优化的简历。
特性
- 人工智能驱动的内容生成:使用OpenAI GPT-4.1创建量身定制的简历内容
- 专业LaTeX编译:使用TinyTeX和ModernCV模板将简历编译为PDF
- 云存储集成:使用预签名的URL将PDF上传到AWS S3
- MCP协议支持:与MCP客户端和AI代理完全兼容
- 安全第一:沙盒LaTeX编译和输入验证
- Docker就绪:通过多阶段构建完成集装箱化
- 综合测试:包括单元和集成测试
快速开始
先决条件
- Python 3.9+
- Docker和Docker Compose
- AWS S3存储桶
- OpenAI API密钥
安装
- 克隆存储库
git clone https://github.com/reetp14/ai-resume-mcp.git
cd ai-resume-mcp- 设置环境变量
cp .env.example .env
# Edit .env with your actual API keys and configuration- 使用Docker Compose运行
# Development mode
docker-compose up mcp-resume-server
# Production mode
docker-compose --profile production up mcp-resume-server-prod手动安装
- 安装Python依赖项
pip install -r requirements.txt- 安装TinyTeX(用于LaTeX编译)
# Linux/macOS
wget -qO- "https://yihui.org/tinytex/install-bin-unix.sh" | sh
# Add to PATH: export PATH="$HOME/.TinyTeX/bin/x86_64-linux:$PATH"
# Install required LaTeX packages
tlmgr install moderncv fontawesome academicons multirow arydshln- 运行服务器
python -m src.server配置
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
OPENAI_API_KEY | OpenAI API密钥 | 必需 |
AWS_ACCESS_KEY_ID | AWS访问密钥 | 必填 |
AWS_SECRET_ACCESS_KEY | AWS密钥 | 必填 |
AWS_REGION | AWS区域 | us-east-1 |
S3_BUCKET_NAME | S3存储桶名称 | 必填 |
SERVER_HOST | 服务器主机 | 0.0.0.0 |
SERVER_PORT | 服务器端口 | 8000 |
DEBUG | 调试模式 | false |
LATEX_TIMEOUT | LaTeX编译超时(秒) | 10 |
MAX_RESUME_SIZE_MB | 最大PDF大小(MB) | 5 |
🚀 现场演示
尝试AI简历生成器:
- 输入:您的个人资料数据+职位描述
- 人工智能处理:GPT-4.1分析和优化内容
- 输出:几秒钟内即可获得专业PDF简历
API使用
MCP工具: generate_resume
根据用户数据和职位描述生成ATS优化的简历PDF。
输入架构:
{
"form_data": {
"personal_info": {
"name": "John Doe",
"email": "john.doe@example.com",
"phone": "+1-555-0123",
"location": "San Francisco, CA",
"linkedin": "linkedin.com/in/johndoe",
"github": "github.com/johndoe"
},
"summary": "Experienced software engineer...",
"skills": ["Python", "JavaScript", "React"],
"work_experience": [...],
"education": [...],
"projects": [...],
"certifications": [...],
"languages": [...]
},
"job_description": "We are looking for a Senior Software Engineer...",
"template_style": "modern"
}输出:
{
"pdf_url": "https://s3.amazonaws.com/bucket/presigned-url",
"resume_id": "uuid-string",
"generated_at": "2024-01-01T12:00:00Z",
"expires_at": "2024-01-02T12:00:00Z"
}MCP工具: health_check
对所有系统组件执行运行状况检查。
输出:
{
"status": "healthy",
"timestamp": "2024-01-01T12:00:00Z",
"version": "1.0.0",
"dependencies": {
"openai": "healthy",
"latex": "healthy",
"s3": "healthy"
}
}客户端集成示例
from mcp_sdk import MCPClient
# Initialize client
client = MCPClient(server_url="ws://localhost:8000/mcp")
# Generate resume
result = await client.call_tool("generate_resume", {
"form_data": {
"personal_info": {
"name": "John Doe",
"email": "john.doe@example.com"
},
"skills": ["Python", "AWS", "Docker"],
"work_experience": [...],
"education": [...]
},
"job_description": "Looking for a DevOps Engineer with Python and AWS experience..."
})
print(f"Resume generated: {result['pdf_url']}")发展
运行测试
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest tests/
# Run with coverage
pytest --cov=src tests/
# Run specific test file
pytest tests/test_server.py -v代码质量
# Format code
black src/ tests/
# Lint code
flake8 src/ tests/
# Type checking
mypy src/Docker开发
# Build development image
docker-compose build mcp-resume-server
# Run with volume mounting for live reload
docker-compose up mcp-resume-server
# Run tests in container
docker-compose exec mcp-resume-server pytest建筑
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ AI Agent/ │ │ MCP Resume │ │ External │
│ Client │◄──►│ Generator │◄──►│ Services │
└─────────────────┘ │ Server │ └─────────────────┘
└──────────────────┘
│
▼
┌──────────────────────┐
│ Components │
├──────────────────────┤
│ • OpenAI Service │
│ • LaTeX Service │
│ • S3 Service │
│ • Input Validation │
│ • Error Handling │
└──────────────────────┘关键组件
- MCP服务器:处理协议通信和工具注册
- OpenAI服务:使用GPT-4.1生成定制的简历内容
- LaTeX服务:使用安全沙盒将LaTeX编译为PDF
- S3服务:管理文件上传和预签名URL生成
- 输入验证:用于数据验证的Pydantic模式
- 错误处理:全面的错误处理和记录
安全
- 输入消毒:所有输入都经过验证和消毒
- 沙盒编译:LaTeX在禁用网络的子进程中运行
- 超时保护:LaTeX编译有10秒超时
- 文件大小限制:PDF默认限制为5MB
- 非根容器:Docker容器以非root用户身份运行
- 安全依赖关系:定期依赖关系更新和安全扫描
部署
生产部署
- 塑造生产形象
docker build --target production -t mcp-resume-server:prod .- 使用生产设置运行
docker run -d \
--name mcp-resume-server \
-p 8000:8000 \
--env-file .env \
mcp-resume-server:prod- 使用Docker Compose
docker-compose --profile production up -d缩放注意事项
- 当扩展到单实例之外时,使用Redis作为作业队列
- 考虑使用AWS ECS或Kubernetes进行容器编排
- 为多个实例设置负载平衡
- 监控LaTeX编译期间的内存使用情况
故障排除
常见问题
- LaTeX编译失败
- 检查TinyTeX安装 - 验证所需的软件包是否已安装 - 检查生成内容中的LaTeX语法
- S3上传错误
- 验证AWS凭据和权限 - 检查铲斗是否存在且可接近 - 验证网络连接
- OpenAI API错误
- 检查API密钥的有效性 - 验证未超过速率限制 - 监控API的使用和计费
日志
查看服务器日志:
# Docker logs
docker-compose logs mcp-resume-server
# Local development
python -m src.server # Logs to stdout贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 添加新功能的测试
- 运行测试套件
- 提交拉取请求
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
支持
对于问题和疑问:
- 在GitHub上创建问题
- 检查故障排除部分
- 查看测试套件中的使用示例
