Notion工作区管理代理

一个生产就绪的代理AI系统,通过模型上下文协议(MCP)将Notion工作区管理与Microsoft AutoGen多代理框架集成。

  • by ebythomas23
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ebythomas23/MCP-Notion--interface

使用说明

AutoGen MCP概念工作区代理

一个生产就绪的代理人工智能系统,通过模型上下文协议(MCP)将Notion工作空间管理与Microsoft AutoGen多代理框架集成在一起。

实时应用程序

前端: https://mcp-notion-chatbot.lovable.app
后端:通过ngrok动态隧道传输(见部署部分)

架构概述

该项目展示了以下方面的先进实施:

  • 模型上下文协议(MCP) 用于标准化工具集成
  • 微软AutoGen 多智能体对话式人工智能
  • 异步Python 具有适当并发处理的架构
  • 生产部署 ngrok隧道

系统组件

Frontend (Lovable) → ngrok Tunnel → Flask API → AutoGen Agent → MCP Tools → Notion API

技术实现

MCP集成

  • MCP服务器: https://mcp.notion.com/mcp 通过 mcp-remote
  • 协议:基于标准的MCP服务器通信
  • 工具:从Notion MCP服务器动态发现和注册工具
  • 认证:基于安全令牌的Notion工作区访问

代理体系结构

  • 框架:带有AssistantAgent实现的Microsoft AutoGen
  • 团队:RoundRobinGroupChat,对话限制为5轮
  • 模型:OpenAI GPT-4o通过 autogen-ext OpenAI客户端
  • 终止:基于文本的终止条件(“TERMINATE”)
  • 反思:启用了工具使用反思,以改进决策

异步架构

# Proper async chain implementation
Flask (sync) → asyncio.run() → AutoGen Team → MCP Tools → Notion API

项目结构

├── main.py                     # Flask API server with ngrok tunneling
├── .env.example                # Environment variables template
├── pyproject.toml              # UV dependency management
├── uv.lock                     # Dependency lock file
├── agents/
│   └── notion_agent.py         # AutoGen AssistantAgent configuration
├── teams/
│   └── notion_team.py          # RoundRobinGroupChat team setup
├── MCP/
│   └── notion_mcp_tools.py     # MCP server connection and tool registration
├── models/
│   └── openai_model_client.py  # OpenAI client configuration
├── config/
│   ├── settings.py             # Environment configuration
│   └── prompt/
│       └── system_prompt.py    # Agent system message
└── images/
    ├── frontend_ui.png         # Frontend interface screenshot
    ├── workflow.png            # System workflow diagram
    └── detailed_workflow_tunnelling.png  # Detailed architecture diagram

API终点

POST/运行

通过Notion代理执行任务

{
  "task": "create a page named 'Project Timeline'"
}

回应:

{
  "status": "success",
  "result": "Agent conversation stream output"
}

GET/健康

健康检查端点

设置和部署

安装

# Clone repository
git clone <repository-url>
cd MCP-Notion-Project

# Install dependencies
uv sync

# Configure environment
cp .env.example .env
# Add your tokens: NOTION_TOKEN, OPENAI_API_KEY, NGROK_AUTH_TOKEN

发展

uv run main.py

该应用程序将:

  1. 在端口7001上启动Flask服务器
  2. 修建ngrok隧道供公众通行
  3. 连接到Notion MCP服务器
  4. 使用MCP工具初始化AutoGen代理

生产部署

您的本地计算机通过ngrok隧道充当生产服务器,在保持本地开发灵活性的同时实现公共访问。