使用说明
📒 带FastMCP的笔记管理器
此项目使用 FastMCP 创建一个简单的Notes管理系统。
它提供了通过MCP协议添加、读取和管理笔记的工具、资源和提示。
✅ 特性
1.️⃣ 添加注释工具
向添加新消息 note.txt.
用途:
AddNote("Your message here")
2.️⃣ ReadNote工具
倒像 所有消息 从 note.txt.
退货 None 如果文件为空。
用途:
ReadNote()
3.️⃣ GetLatestNotes资源
获取 只有最新的笔记 从 note.txt.
退货 "No notes yet" 如果文件为空。
用途:
GetLatestNotes()
4.️⃣ 总结提示
生成文件中所有笔记的简单摘要。
退货 None 如果文件为空。
用途:
Summerize()
⚙️ 运作原理
- 检查是否
note.txt存在;如果没有,则创建它。 - 逐行附加每个新注释。
- 提供与MCP兼容的工具、资源和提示。
- 所有数据都存储在
note.txt与脚本位于同一目录中。
📂 文件
- 文件名:
note.txt - 地点: 与Python脚本相同的目录。
🚀 需求
fastmcp模块(FastMCP从mcp.server.fastmcp)- 标准Python
os模块
📝 示例
from mcp.server.fastmcp import FastMCP
import os
mcp = FastMCP("Notes")
# Add a note
AddNote("Remember to buy milk.")
# Read all notes
print(ReadNote())
# Get the latest note
print(GetLatestNotes())
# Summarize notes
print(Summerize())
记笔记快乐! 📚✨