Skip to main content
Glama

Python Apple MCP

by jxnl

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

服务器的 Python 实现,使用 FastMCP 处理与 macOS 应用程序(如联系人、备忘录、邮件、消息、提醒、日历和地图)的交互。

特征

  • 通过 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 # On Windows: venv\Scripts\activate
  1. 安装依赖项:
pip install -r requirements.txt
  1. 安装测试依赖项(可选):
pip install -r requirements-test.txt

用法

基本示例

from apple_mcp import FastMCP, Context # Initialize FastMCP server mcp = FastMCP("Apple MCP") # Use the tools @mcp.tool() def find_contact(name: str) -> List[Contact]: """Search for contacts by name""" # Implementation here pass # Run the server if __name__ == "__main__": mcp.run()

使用单独的模块

from utils.contacts import ContactsModule from utils.notes import NotesModule # Initialize modules contacts = ContactsModule() notes = NotesModule() # Use the modules async def main(): # Find a contact contact = await contacts.find_contact("John") # Create a note await notes.create_note( title="Meeting Notes", body="Discussion points...", folder_name="Work" ) # Run the async code import asyncio asyncio.run(main())

测试

运行测试套件:

pytest

运行覆盖测试:

pytest --cov=utils tests/

运行特定的测试文件:

pytest tests/test_contacts.py

API 文档

联系人模块

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

注释模块

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

邮件模块

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

消息模块

  • 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 : 安排消息

提醒模块

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

日历模块

  • 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] :获取所有事件

地图模块

  • 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. 分叉存储库
  2. 创建功能分支
  3. 提交你的更改
  4. 推送到分支
  5. 创建拉取请求

执照

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

-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

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

  1. 特征
    1. 支持的应用程序
      1. 安装
        1. 用法
          1. 基本示例
          2. 使用单独的模块
        2. 测试
          1. API 文档
            1. 联系人模块
            2. 注释模块
            3. 邮件模块
            4. 消息模块
            5. 提醒模块
            6. 日历模块
            7. 地图模块
          2. 贡献
            1. 执照

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                A Model Context Protocol server that enables running AppleScript code to interact with Mac applications and system features including Notes, Calendar, Contacts, Messages, file management, and more.
                Last updated -
                1
                1,060
                329
                JavaScript
                MIT License
                • Apple
              • A
                security
                F
                license
                A
                quality
                A collection of tools that enable AI assistants to interact with Apple applications and services including Contacts, Notes, Messages, Mail, Reminders, Calendar, Maps, and Web Search through the Model Context Protocol.
                Last updated -
                8
                TypeScript
                • Apple
              • A
                security
                A
                license
                A
                quality
                Provides a Model Context Protocol server for executing AppleScript and JavaScript for Automation scripts on macOS, featuring a knowledge base of pre-defined scripts and supporting automation of macOS applications and system functions.
                Last updated -
                2
                698
                410
                TypeScript
                MIT License
                • Apple
              • -
                security
                F
                license
                -
                quality
                A modern, extensible server that provides a unified interface to control and interact with various macOS applications through plugins.
                Last updated -
                Python
                • Apple

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/jxnl/python-apple-mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server