ML

microsoft/local-email-agent

开发工具官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 9 forks 质量 57 趋势 10MIT

本地电子邮件代理,使用 Python、Foundry Local、MCP 和 LangChain

概览

一款智能邮件助手,基于 Microsoft 的 Phi-4 本地模型,具备现代化的网页界面、人工审核、日历集成,以及通过 MCP(模型上下文协议)连接 Microsoft 365。 本项目演示如何利用以下方法构建本地电子邮件代理: - (完全运行在您的机器上),本项目展示了phi-4,但您可以使用任何模型——用于语义邮件搜索——用于邮件/日历操作——用于带人工循环(HITL)审批的代理编排——支持实时更新的SSE流式——- 用于管理对话和批准的代理收件箱UI。 1. 2.(针对PostgreSQL)3. (针对MCP服务器和前端) 注意:Foundry Local 目前不支持 Linux 如果成功,你应该会看到列出的向量扩展: 编辑 .env 文件并添加你的 Azure OpenAI 凭证: 然后在浏览器中打开http://localhost:3000。

概述(AI 翻译)

一款智能邮件助手,基于 Microsoft 的 Phi-4 本地模型,具备现代化的网页界面、人工审核、日历集成,以及通过 MCP(模型上下文协议)连接 Microsoft 365。

概述

本项目演示如何利用以下方法构建本地电子邮件代理:

  • Foundry Local(完全运行在你的机器上),这个项目展示了phi-4,但你可以使用任何你喜欢的模型
  • PostgreSQL + pgvector 用于语义邮件搜索
  • Microsoft 365 MCP 服务器用于电子邮件/日历操作
  • LangGraph 用于带有人工循环(HITL)批准的代理编排
  • **FastAPI 后端支持SSE流式实时更新
  • Next.js 前端 - 用于管理对话和审批的代理收件箱界面

🌱 快速启动

先决条件

  1. Python 3.11+
  2. Docker (for PostgreSQL)
  3. Node.js 18+(用于MCP服务器和前端)

布置

1.安装Foundry Local:

Windows:

MacOS:

注:Foundry Local 目前不支持 Linux

2.安装依赖:

3.Start PostgreSQL + pgvector:

如果成功,你应该会看到列出的vector扩展:

4.配置环境:

编辑’。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Local Email Agent

An intelligent email assistant powered by Microsoft’s Phi-4 local model, featuring a modern web UI, human-in-the-loop approvals, calendar integration, and Microsoft 365 connectivity via MCP (Model Context Protocol).

Overview

This project demonstrates how to build a local email agent using:

  • Foundry Local (runs entirely on your machine), this project shows phi-4 but you can use any model you like
  • PostgreSQL + pgvector for semantic email search
  • Microsoft 365 MCP Server for email/calendar operations
  • LangGraph for agent orchestration with Human-in-the-Loop (HITL) approvals
  • FastAPI Backend with SSE streaming for real-time updates
  • Next.js Frontend - Agent Inbox UI for managing conversations and approvals

🌱 Quick Start

Prerequisites

  1. Python 3.11+
  2. Docker (for PostgreSQL)
  3. Node.js 18+ (for MCP server and frontend)

Setup

1. Install Foundry Local:

Windows:

winget install Microsoft.FoundryLocal

MacOS:

brew install microsoft/foundrylocal/foundrylocal

Note: Foundry Local doesn’t currently support Linux

2. Install Dependencies:

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install Python packages
pip install -r email_agent/requirements.txt

# Install Microsoft 365 MCP Server
npm install -g @softeria/ms-365-mcp-server

# Login to the M365 account you want to use
npx @softeria/ms-365-mcp-server --login

# Install frontend dependencies
cd email_agent/frontend
npm install
cd ../..

3. Start PostgreSQL + pgvector:

# Start Docker container
docker compose up -d

# Wait ~10 seconds for PostgreSQL to initialize

# Enable pgvector extension
docker exec -it email-postgres psql -U postgres -d emaildb -c "CREATE EXTENSION IF NOT EXISTS vector;"

# Verify
docker exec -it email-postgres psql -U postgres -d emaildb -c "\dx"

If successful, you should see the vector extension listed:

  Name   | Version |   Schema   |                        Description
---------+---------+------------+-----------------------------------------------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 vector  | 0.5.0   | public     | vector data type and ivfflat and hnsw access methods

4. Configure Environment:

# Copy local env template
cp email_agent/.env.local.example email_agent/.env

Edit the .env file and add your Azure OpenAI credentials:

AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com/
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-ada-002

5. Import Your Emails (Optional)

# Import last 3 months of emails from Outlook
python3 -m email_agent.import_emails --months 3 --batch-size 50 --storage local

6. Run the Agent:

Start both the backend and frontend:

在 GitHub 查看完整 README

安装

npx @softeria/ms-365-mcp-server --login
新手?先看 mcpskill.org 教程 →