TuneIt人工智能代理
一个基于LangGraph的智能人工智能代理,使用MCP(模型上下文协议)服务器工具根据职位描述自动定制简历。
概述
TuneIt AI Agent持续监控指定目录中的新职位描述文件,并自动:
- 格式 使用
format_job_descriptionMCP工具 - 生成 使用
generate_tailored_resumeMCP工具 - 保存 使用
save_tailored_resumeMCP工具 - 保存 使用
save_job_descriptionMCP工具
特性
- LangGraph工作流:具有清晰状态图的结构化AI代理
- 文件监视:自动检测新的职位描述文件
- MCP集成:通过HTTP与MCP服务器无缝集成
- 后台运行程序:连续处理服务
- 综合录井:用于监控和调试的详细日志
- 可配置的:基于环境的配置
建筑
该代理使用LangGraph构建,由几个组件组成:
┌─────────────────────────────────────────────────┐
│ Background Runner (run.py) │
│ - Manages lifecycle of agent and file watcher │
└────────────────┬────────────────────────────────┘
│
┌────────┴────────┐
│ │
┌───────▼──────┐ ┌──────▼────────┐
│ File Watcher │ │ TuneIt Agent │
│ │ │ (LangGraph) │
│ - Monitors │──▶│ │
│ directory │ │ - State graph │
│ - Triggers │ │ - MCP client │
│ agent │ │ - Workflow │
└──────────────┘ └───────┬───────┘
│
┌──────▼──────┐
│ MCP Server │
│ (HTTP API) │
└─────────────┘工作流程
Start
│
▼
Read Job Description
│
▼
Format Job Description (MCP)
│
▼
Generate Tailored Resume (MCP)
│
▼
Save Outputs (MCP x2)
│
▼
End先决条件
- Python 3.11或更高版本
- 本地运行的MCP服务器(默认值:http://localhost:8000)
- MCP服务器必须公开以下工具:
- format_job_description - generate_tailored_resume - save_tailored_resume - save_job_description
安装
1.克隆存储库
git clone https://github.com/mcuellar/tuneit-ai-agent.git
cd tuneit-ai-agent2.创建虚拟环境
python3 -m venv .venv
source .venv/bin/activate # On Windows: venv\Scripts\activate3.安装依赖项
pip install -r requirements.txt4.配置环境
cp .env.example .env编辑 .env 要配置设置,请执行以下操作:
# MCP Server URL
MCP_SERVER_URL=http://localhost:8000
# Directory to watch for job descriptions
WATCH_DIRECTORY=./job_descriptions
# Allowed file extensions
ALLOWED_EXTENSIONS=.txt,.md,.pdf用法
运行后台服务
启动后台运行程序,持续监控新的职位描述:
python run.py代理人将:
- 如果监视目录不存在,则创建该目录
- 监视具有允许扩展名(.txt、.md、.pdf)的新文件
- 自动处理每个新的职位描述文件
- 将所有活动记录到控制台和
tuneit_agent.log
处理职位描述
只需将职位描述文件放入关注的目录中:
# Example
echo "Software Engineer position at XYZ Corp..." > job_descriptions/software_engineer.txt代理将自动:
- 检测新文件
- 通过完整的工作流程进行处理
- 生成并保存定制简历
- 保存格式化的职位描述
停止服务
按 Ctrl+C 优雅地停止后台服务。
项目结构
tuneit-ai-agent/
├── agent.py # Core LangGraph agent implementation
├── file_watcher.py # File monitoring using watchdog
├── run.py # Background runner / main entry point
├── requirements.txt # Python dependencies
├── .env.example # Environment configuration template
├── .gitignore # Git ignore rules
└── README.md # This fileMCP服务器集成
代理通过HTTP连接到MCP服务器。MCP服务器必须实现以下端点:
预期的工具端点
- 发布
/tools/format_job_description
- 输入: {"arguments": {"job_description": "..."}} - 输出: {"formatted_job_description": "..."}
- 发布
/tools/generate_tailored_resume
- 输入: {"arguments": {"job_description": "..."}} - 输出: {"tailored_resume": "..."}
- 发布
/tools/save_tailored_resume
- 输入: {"arguments": {"resume_content": "...", "job_title": "..."}} - 输出: {"status": "success"}
- 发布
/tools/save_job_description
- 输入: {"arguments": {"job_description": "...", "job_title": "..."}} - 输出: {"status": "success"}
发展
以开发模式运行
# Activate virtual environment
source venv/bin/activate
# Run with debug logging
python run.py测试单个组件
# Test the agent
from agent import TuneItAgent
agent = TuneItAgent("http://localhost:8000")
result = agent.process_job_description("path/to/job_description.txt")
print(result)
agent.close()# Test the MCP client
from agent import MCPClient
client = MCPClient("http://localhost:8000")
result = client.format_job_description("Sample job description")
print(result)
client.close()日志记录
日志将写入:
- 控制台:实时监控
- 文件:
tuneit_agent.log用于持久日志
日志级别:
INFO:正常操作ERROR:错误和失败DEBUG:详细的调试信息
错误处理
该代理包括全面的错误处理:
- 记录失败的文件处理,可以重试
- 捕获并记录MCP工具故障
- SIGINT/SIGTERM上的优雅关机
- 所有错误都包括日志中的堆栈跟踪
故障排除
代理无法连接到MCP服务器
- 验证MCP服务器是否正在运行:
curl http://localhost:8000 - 检查
MCP_SERVER_URL在.env - 查看连接错误日志
文件未被处理
- 检查文件扩展名是否匹配
ALLOWED_EXTENSIONS - 验证文件是否正确
WATCH_DIRECTORY - 检查文件权限
- 查看日志以了解处理错误
MCP工具调用失败
- 验证MCP服务器是否实现了所有必需的工具
- 检查MCP服务器日志是否有错误
- 验证工具输入/输出格式是否符合预期
许可证
该项目根据MIT许可证获得许可。
贡献
欢迎投稿!请随时提交拉取请求。
支持
有关问题和疑问,请在GitHub上打开问题。
