Python Apple MCP(모델 컨텍스트 프로토콜)
FastMCP를 사용하여 연락처, 메모, 메일, 메시지, 알림, 캘린더, 지도와 같은 macOS 애플리케이션과의 상호작용을 처리하는 서버의 Python 구현입니다.
특징
- AppleScript를 통해 macOS 기본 애플리케이션과 상호 작용
- 더 나은 성능을 위한 비동기 작업
- 포괄적인 오류 처리
- Pydantic 모델을 사용한 유형 안전 인터페이스
- 광범위한 테스트 범위
- 쉬운 확장을 위한 모듈식 디자인
지원되는 애플리케이션
설치
- 저장소를 복제합니다.
지엑스피1
- 가상 환경 만들기:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- 종속성 설치:
pip install -r requirements.txt
- 테스트 종속성 설치(선택 사항):
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 --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
: 즐겨찾기에 위치 저장
기여하다
- 저장소를 포크하세요
- 기능 브랜치 생성
- 변경 사항을 커밋하세요
- 지점으로 밀어 넣기
- 풀 리퀘스트 만들기
특허
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여되었습니다. 자세한 내용은 라이선스 파일을 참조하세요.