Token导航 LogoToken导航TokenDH.com
Pydantic AI Agent With Notion MCP Server logo
文档知识stdio官方级别未说明来源级核验

Pydantic AI Agent With Notion MCP Server

MCP Server

一个使用Pydantic AI和本地Notion MCP服务器构建的食谱对话代理,可从Notion工作区获取食谱并提供结构化响应。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
Python结构化数据Notion集成

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

anybody84

提供方

anybody84

最后核验

2026/5/17 20:19

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run src/pydantic_ai_agent/main.py

详细介绍

带有本地Notion MCP服务器的Pydantic AI代理

该项目演示了如何使用以下命令构建会话式配方代理 Pydantic AI 以及当地 MCP概念(模型上下文协议)在Docker容器中运行的服务器。

特性

  • 对话式AI:与代理交互,按名称查找食谱。
  • 概念整合:使用本地MCP服务器直接从Notion工作区获取食谱。
  • 结构化响应:以清晰易读的格式返回成分和说明。
  • 优雅的操控:如果找不到食谱,会通知您。

先决条件

  • python 版本 3.11 或更高
  • uv 版本 0.7.19 (用于包管理)
  • Docker(用于在本地运行Notion MCP服务器)
  • 有权访问食谱数据库的Notion帐户

输出示例

假设你的食谱数据库看起来像这样:

Notion Recipes Example

这是运行代理时的示例输出:

========================================
      Pydantic AI Recipe Agent
========================================

Welcome to the Pydantic AI Recipe Agent!
You can ask for recipes and I will retrieve them from Notion.
Type 'exit', 'quit', 'stop', or 'end' to terminate the conversation.

What would you like to cook today?

> pizza
Recipe not found in Notion.

> spaghetti carbonara
- Title: Spaghetti carbonara
- Ingredients:
  - 400g spaghetti
  - 150g pancetta or guanciale, diced
  - 3 large eggs
  - 100g Parmesan cheese, grated
  - 2 cloves garlic, minced (optional)
  - Salt and freshly ground black pepper
  - Fresh parsley, chopped (for garnish, optional)
- Instructions:
  1. **Cook the Spaghetti**: Bring a large pot of salted water to a boil. Add the spaghetti and cook according to package instructions until al dente. Reserve 1 cup of the pasta water before draining.
  2. **Prepare the Sauce**: In a bowl, whisk together the eggs, grated Parmesan cheese, a pinch of salt, and a generous amount of black pepper. Set aside.
  3. **Cook the Pancetta/Guanciale**: In a large skillet over medium heat, add the diced pancetta or guanciale. Cook until crispy, about 5-7 minutes. If using garlic, add it during the last minute of cooking to avoid burning.
  4. **Combine Pasta and Sauce**: Once the spaghetti is cooked and drained, add it directly to the skillet with the pancetta. Remove from heat and quickly pour the egg and cheese mixture over the hot pasta. Toss immediately to combine.
  5. **Adjust Consistency**: If the sauce is too thick, add reserved pasta water until desired consistency is reached.
  6. **Serve**: Plate the pasta and garnish with more Parmesan, black pepper, and parsley if desired.
- Link: [Spaghetti carbonara](https://www.notion.so/Spaghetti-carbonara-*********************************)

> exit
Ending conversation. Goodbye!

安装

  1. 克隆存储库:
   git clone https://github.com/anybody84/pydantic-ai-agent-with-notion-mcp-server.git
   cd pydantic-ai-agent-with-notion-mcp-server
  1. 使用安装依赖项 uv:
   uv sync
  1. 获取您的Notion API代币(ntn_*****)从您的Notion集成设置中。

有关如何设置此设置的更多详细信息,请参阅 MCP服务器概念文档.

注: 确保您授予了对食谱数据库的集成访问权限。
  1. 获取OpenAI API密钥(sk-*****)从 OpenAI API密钥页.
  1. 创建一个 .env 根目录中的文件,内容如下:
   NOTION_TOKEN=your_notion_api_token
   OPENAI_API_KEY=your_openai_api_key

   # Optional: Set the OpenAI model and the temperature you want to use. Default values are as follows:
   # OPENAI_MODEL="gpt-4o-mini"
   # OPENAI_MODEL_TEMPERATURE=0.0

   # Optional: Set the Logfire token if you want to leverage the observability features.
   # LOGFIRE_TOKEN=your_logfire_token

用法

从项目的根目录,您可以使用以下命令运行代理:

uv run src/pydantic_ai_agent/main.py

可观测性

此项目使用 Pydantic Logfire 为了可观察性。 您可以通过设置 LOGFIRE_TOKEN 在你的 .env 文件。 这将允许您跟踪代理的交互和性能指标。 这是可选的,但强烈推荐。

启用后,您可以在Logfire仪表板中查看日志和指标。

Logfire Example Logs

目录标签

目录标签

Python结构化数据Notion集成食谱管理本地部署对话AI

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP