Python Apple MCP

Python Apple MCP

一个 Python 服务器,通过 AppleScript 实现与 macOS 原生应用程序(通讯录、备忘录、邮件、信息、提醒事项、日历和地图)的交互,并具有异步操作和类型安全接口的特性。

Category
访问服务器

README

Python Apple MCP (模型上下文协议)

一个 Python 实现的服务端,用于处理与 macOS 应用程序(如通讯录、备忘录、邮件、信息、提醒事项、日历和地图)的交互,使用 FastMCP。

特性

  • 通过 AppleScript 与 macOS 原生应用程序交互
  • 异步操作以获得更好的性能
  • 完善的错误处理
  • 使用 Pydantic 模型实现类型安全的接口
  • 广泛的测试覆盖率
  • 模块化设计,易于扩展

支持的应用程序

  • 通讯录
  • 备忘录
  • 邮件
  • 信息
  • 提醒事项
  • 日历
  • 地图

安装

  1. 克隆仓库:
git clone https://github.com/jxnl/python-apple-mcp.git
cd python-apple-mcp
  1. 创建一个虚拟环境:
python -m venv venv
source venv/bin/activate  # 在 Windows 上:venv\Scripts\activate
  1. 安装依赖:
pip install -r requirements.txt
  1. 安装测试依赖(可选):
pip install -r requirements-test.txt

使用

基本示例

from apple_mcp import FastMCP, Context

# 初始化 FastMCP 服务器
mcp = FastMCP("Apple MCP")

# 使用工具
@mcp.tool()
def find_contact(name: str) -> List[Contact]:
    """按姓名搜索联系人"""
    # 在这里实现
    pass

# 运行服务器
if __name__ == "__main__":
    mcp.run()

使用单个模块

from utils.contacts import ContactsModule
from utils.notes import NotesModule

# 初始化模块
contacts = ContactsModule()
notes = NotesModule()

# 使用模块
async def main():
    # 查找联系人
    contact = await contacts.find_contact("John")
    
    # 创建一个备忘录
    await notes.create_note(
        title="会议记录",
        body="讨论要点...",
        folder_name="工作"
    )

# 运行异步代码
import asyncio
asyncio.run(main())

测试

运行测试套件:

pytest

运行带有覆盖率的测试:

pytest --cov=utils tests/

运行特定的测试文件:

pytest tests/test_contacts.py

API 文档

Contacts 模块

  • find_contact(name: str) -> List[Contact]: 按姓名搜索联系人
  • get_all_contacts() -> List[Contact]: 获取所有联系人
  • create_contact(name: str, phones: List[str]) -> Contact: 创建一个新的联系人

Notes 模块

  • find_note(query: str) -> List[Note]: 搜索备忘录
  • create_note(title: str, body: str, folder_name: str) -> Note: 创建一个新的备忘录
  • get_all_notes() -> List[Note]: 获取所有备忘录

Mail 模块

  • send_email(to: str, subject: str, body: str) -> str: 发送电子邮件
  • search_emails(query: str) -> List[Email]: 搜索电子邮件
  • get_unread_mails() -> List[Email]: 获取未读邮件

Messages 模块

  • send_message(to: str, content: str) -> bool: 发送 iMessage
  • read_messages(phone_number: str) -> List[Message]: 读取消息
  • schedule_message(to: str, content: str, scheduled_time: str) -> Dict: 安排消息

Reminders 模块

  • create_reminder(name: str, list_name: str, notes: str, due_date: str) -> Dict: 创建一个提醒事项
  • search_reminders(query: str) -> List[Dict]: 搜索提醒事项
  • get_all_reminders() -> List[Dict]: 获取所有提醒事项

Calendar 模块

  • create_event(title: str, start_date: str, end_date: str, location: str, notes: str) -> Dict: 创建一个事件
  • search_events(query: str) -> List[Dict]: 搜索事件
  • get_events() -> List[Dict]: 获取所有事件

Maps 模块

  • search_locations(query: str) -> List[Location]: 搜索位置
  • get_directions(from_address: str, to_address: str, transport_type: str) -> str: 获取路线
  • save_location(name: str, address: str) -> Dict: 将位置保存到收藏夹

贡献

  1. Fork 仓库
  2. 创建一个特性分支
  3. 提交你的更改
  4. 推送到分支
  5. 创建一个 Pull Request

许可证

该项目根据 MIT 许可证授权 - 有关详细信息,请参阅 LICENSE 文件。

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选