README
🚀 TextEdit MCP
TextEdit MCP 是一个模型上下文协议(MCP)服务器,它能让 Claude Desktop 创建格式精美的富文本格式(RTF)文档,并且与原生 macOS TextEdit 兼容。
✨ 主要特性
-
📝 丰富的文本格式设置
- 支持粗体、斜体、下划线和删除线
- 支持标题(H1 - H2)
- 可自定义段落间距
-
🎨 颜色与高亮显示
- 文本颜色:红色、蓝色、绿色
- 高亮颜色:黄色、青色、绿色、橙色
- 表格支持全色彩显示
-
📊 表格
- 带有边框的真实 RTF 表格
- 支持表头行样式设置
- 单元格内支持完整格式设置
- 自动设置单元格内边距和对齐方式
-
🔗 超链接
- 可点击的 URL
- 格式化的链接文本
- 在 TextEdit、Pages 和 Word 中均可正常使用
-
📋 列表
- 项目符号列表
- 编号列表
- 正确的缩进
-
🎯 模板
- 商务模板(默认)
- 技术模板(等宽字体)
- 会议模板(增加行间距)
📦 安装指南
前提条件
- macOS(NSAttributedString 和 RTF 生成需要)
- Swift 5.0 或更高版本
- Claude Desktop
快速安装
- 克隆仓库:
git clone https://github.com/M-Pineapple/TextEdit-MCP.git
cd TextEdit-MCP
- 运行安装脚本:
./install.sh
- 重启 Claude Desktop
安装脚本将执行以下操作:
- 构建 Swift 项目
- 安装 MCP 服务器二进制文件
- 更新你的 Claude Desktop 配置
- 备份你现有的配置
💻 使用示例
基础用法
在 Claude Desktop 中,你可以使用自然语言创建 RTF 文档:
"Create an RTF document with my meeting notes"
"Make a formatted report with tables and highlights"
"Generate a technical document with code examples"
或者直接使用工具:
Use textedit:create_rtf_document to create a document at ~/Desktop/MyDoc.rtf
高级用法
你可以在使用时利用各种格式化语法来创建更复杂的文档。以下是 TextEdit MCP 使用的类似 Markdown 的直观语法示例:
文本格式设置
**Bold text***Italic text****Bold italic text***~~Strikethrough text~~
颜色设置
{red}Red text{/red}{blue}Blue text{/blue}{green}Green text{/green}
高亮显示
==Yellow highlight==[[Cyan highlight]]{{Green highlight}}((Orange highlight))
标题
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
列表
• Bullet point (or use - )
1. Numbered item
2. Another item
表格
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Data 1 | Data 2 | Data 3 |
| More | Data | Here |
链接
[Link text](https://example.com)
示例文档
简单文档
# Meeting Notes
## Agenda
- Review **Q4 results**
- Discuss {red}urgent issues{/red}
- Plan for next quarter
## Action Items
1. ==Update documentation==
2. [[Review code changes]]
3. Schedule follow-up
带格式的表格
| Task | Status | Owner |
|------|--------|-------|
| **Documentation** | {green}✅ Complete{/green} | Team A |
| *Testing* | ==In Progress== | Team B |
| Deployment | {red}Blocked{/red} | DevOps |
🔧 技术细节
从源代码构建
swift build -c release
运行测试
swift test
项目结构
TextEdit-MCP/
├── Sources/
│ └── TextEditMCP/
│ ├── main.swift # 入口点
│ ├── MCPServer.swift # MCP 协议处理程序
│ ├── RTFDocumentService.swift # RTF 生成
│ └── MCPLogger.swift # 日志工具
├── Package.swift
├── README.md
├── FORMATTING_GUIDE.md
└── install.sh
工作原理
- MCP 协议:实现模型上下文协议以与 Claude Desktop 通信
- NSAttributedString:使用 macOS 原生 API 进行富文本格式设置
- NSTextTable:创建带有适当边框和单元格格式的真实 RTF 表格
- RTF 导出:生成与 TextEdit、Pages 和 Word 兼容的标准 RTF 文件
🤝 贡献指南
欢迎贡献代码!请随时提交拉取请求。
贡献准则
- 保持与 macOS TextEdit 的兼容性
- 遵循 Swift 命名约定
- 为新功能添加测试
- 更新文档
📄 许可证
本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。
🙏 致谢
- 为配合 Claude Desktop 使用而创建
- 使用 Swift 和 AppKit 构建
- 使用模型上下文协议(MCP)
Created by Pineapple 🍍
Scan to contact