@heznpc/imcp 0.8.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +34 -4
- package/README.md +34 -4
- package/dist/finder/tools.js +3 -3
- package/dist/finder/tools.js.map +1 -1
- package/dist/index.js +119 -30
- package/dist/index.js.map +1 -1
- package/dist/messages/scripts.d.ts +6 -0
- package/dist/messages/scripts.js +103 -0
- package/dist/messages/scripts.js.map +1 -0
- package/dist/messages/tools.d.ts +3 -0
- package/dist/messages/tools.js +100 -0
- package/dist/messages/tools.js.map +1 -0
- package/package.json +6 -2
package/README.ko.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# iMcp
|
|
2
2
|
|
|
3
|
-
Apple 생태계 전체를 위한 MCP 서버 — Notes, Reminders, Calendar, Contacts, Mail, Music, Finder, Safari, System, Photos, Shortcuts, Apple Intelligence. AI를 Mac에 연결합니다.
|
|
3
|
+
Apple 생태계 전체를 위한 MCP 서버 — Notes, Reminders, Calendar, Contacts, Mail, Messages, Music, Finder, Safari, System, Photos, Shortcuts, Apple Intelligence. AI를 Mac에 연결합니다.
|
|
4
4
|
|
|
5
5
|
> [English](README.md)
|
|
6
6
|
|
|
7
7
|
## 특징
|
|
8
8
|
|
|
9
|
-
- **
|
|
9
|
+
- **110개 도구** (13개 모듈) — Apple 앱 CRUD + 시스템 제어 + Apple Intelligence
|
|
10
10
|
- **20개 프롬프트** — 앱별 워크플로우 + 크로스 모듈 + 개발자 워크플로우 (dev-session, debug-loop, build-log)
|
|
11
11
|
- **4개 MCP 리소스** — Notes, Calendar, Reminders 실시간 데이터 URI
|
|
12
12
|
- **JXA + Swift 브릿지** — JXA로 기본 자동화, EventKit/PhotoKit으로 고급 기능
|
|
@@ -15,7 +15,7 @@ Apple 생태계 전체를 위한 MCP 서버 — Notes, Reminders, Calendar, Cont
|
|
|
15
15
|
- **Apple Intelligence** — 온디바이스 요약, 재작성, 교정 (macOS 26+)
|
|
16
16
|
- **네이티브 메뉴바 앱** — SwiftUI 컴패니언 앱으로 상태 모니터링, 권한 설정, 설정 복사
|
|
17
17
|
- **원클릭 셋업** — `setup_permissions` 도구 또는 메뉴바 앱으로 모든 macOS 권한을 한번에 요청
|
|
18
|
-
-
|
|
18
|
+
- **듀얼 전송** — stdio (기본, 안전한 로컬 통신) + HTTP/SSE (`--http`) 원격 에이전트 및 레지스트리 지원
|
|
19
19
|
- **Safety Annotations** — 모든 도구에 readOnly/destructive 힌트 적용
|
|
20
20
|
|
|
21
21
|
## 빠른 시작
|
|
@@ -61,6 +61,21 @@ cd app && swift build -c release
|
|
|
61
61
|
|
|
62
62
|
기능: 서버 상태 표시, 원클릭 권한 설정, Claude 설정 클립보드 복사.
|
|
63
63
|
|
|
64
|
+
### HTTP 모드
|
|
65
|
+
|
|
66
|
+
원격 에이전트, Smithery 레지스트리, 멀티 클라이언트를 위한 HTTP 서버 모드:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx @heznpc/imcp --http --port 3847
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- 엔드포인트: `POST/GET/DELETE /mcp`
|
|
73
|
+
- 전송: Streamable HTTP + SSE (MCP 스펙 2024-11-05)
|
|
74
|
+
- `Mcp-Session-Id` 헤더로 세션 관리
|
|
75
|
+
- 기본 포트: 3847
|
|
76
|
+
|
|
77
|
+
Mac Mini를 "상시 가동 AI 허브"로 활용할 때 유용합니다.
|
|
78
|
+
|
|
64
79
|
## 도구
|
|
65
80
|
|
|
66
81
|
### Notes (12개)
|
|
@@ -165,7 +180,7 @@ cd app && swift build -c release
|
|
|
165
180
|
| `list_directory` | 디렉토리 내 파일 목록 | 읽기 |
|
|
166
181
|
| `move_file` | 파일 이동/이름 변경 | 파괴적 |
|
|
167
182
|
| `trash_file` | 휴지통으로 이동 | 파괴적 |
|
|
168
|
-
| `
|
|
183
|
+
| `create_directory` | 새 디렉토리 생성 | 쓰기 |
|
|
169
184
|
|
|
170
185
|
### Safari (8개)
|
|
171
186
|
|
|
@@ -209,6 +224,17 @@ cd app && swift build -c release
|
|
|
209
224
|
| `import_photo` | 파일에서 사진 가져오기 (Swift/PhotoKit) | 쓰기 |
|
|
210
225
|
| `delete_photos` | ID로 사진 삭제 (Swift/PhotoKit) | 파괴적 |
|
|
211
226
|
|
|
227
|
+
### Messages (6개)
|
|
228
|
+
|
|
229
|
+
| 도구 | 설명 | 타입 |
|
|
230
|
+
|------|------|------|
|
|
231
|
+
| `list_chats` | 최근 대화 목록 (참여자 포함) | 읽기 |
|
|
232
|
+
| `read_chat` | 대화 상세 조회 (참여자, 마지막 업데이트 포함) | 읽기 |
|
|
233
|
+
| `search_chats` | 이름/참여자/핸들로 검색 | 읽기 |
|
|
234
|
+
| `send_message` | iMessage/SMS 텍스트 전송 | 쓰기 |
|
|
235
|
+
| `send_file` | iMessage/SMS 파일 첨부 전송 | 쓰기 |
|
|
236
|
+
| `list_participants` | 대화 참여자 목록 | 읽기 |
|
|
237
|
+
|
|
212
238
|
### Shortcuts (4개)
|
|
213
239
|
|
|
214
240
|
| 도구 | 설명 | 타입 |
|
|
@@ -331,6 +357,10 @@ AI 코딩 에이전트(Claude Code, Cursor, Copilot)가 MCP 프롬프트로 호
|
|
|
331
357
|
### Mail
|
|
332
358
|
- 내용 기본 5000자 제한 (`maxLength` 파라미터로 조절 가능)
|
|
333
359
|
|
|
360
|
+
### Messages
|
|
361
|
+
- 개별 메시지 내용(대화 기록)은 JXA로 접근 불가
|
|
362
|
+
- 전송 시 수신자가 Messages 서비스에 등록된 buddy여야 함
|
|
363
|
+
|
|
334
364
|
### Music
|
|
335
365
|
- 스마트 재생목록 읽기 전용
|
|
336
366
|
- 대기열 조작 불가
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# iMcp
|
|
2
2
|
|
|
3
|
-
MCP server for the entire Apple ecosystem — Notes, Reminders, Calendar, Contacts, Mail, Music, Finder, Safari, System, Photos, Shortcuts, and Apple Intelligence. Connect any AI to your Mac.
|
|
3
|
+
MCP server for the entire Apple ecosystem — Notes, Reminders, Calendar, Contacts, Mail, Messages, Music, Finder, Safari, System, Photos, Shortcuts, and Apple Intelligence. Connect any AI to your Mac.
|
|
4
4
|
|
|
5
5
|
> [한국어](README.ko.md)
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- **
|
|
9
|
+
- **110 tools** across 13 modules — full CRUD for Apple apps + system control + Apple Intelligence
|
|
10
10
|
- **20 prompts** — per-app workflows + cross-module + developer workflows (dev-session, debug-loop, build-log)
|
|
11
11
|
- **4 MCP Resources** — live data URIs for notes, calendar, and reminders
|
|
12
12
|
- **JXA + Swift bridge** — JXA for core automation, EventKit/PhotoKit via Swift for advanced features
|
|
@@ -15,7 +15,7 @@ MCP server for the entire Apple ecosystem — Notes, Reminders, Calendar, Contac
|
|
|
15
15
|
- **Apple Intelligence** — on-device summarization, rewriting, proofreading (macOS 26+)
|
|
16
16
|
- **Native menubar app** — SwiftUI companion app for status monitoring, permission setup, config copy
|
|
17
17
|
- **One-click setup** — `setup_permissions` tool or menubar app triggers all macOS permission prompts at once
|
|
18
|
-
- **
|
|
18
|
+
- **Dual transport** — stdio (default, secure local) + HTTP/SSE (`--http`) for remote agents and registries
|
|
19
19
|
- **Safety annotations** — every tool tagged with readOnly/destructive hints
|
|
20
20
|
|
|
21
21
|
## Quick Start
|
|
@@ -61,6 +61,21 @@ cd app && swift build -c release
|
|
|
61
61
|
|
|
62
62
|
Features: server status indicator, one-click permission setup, copy Claude config to clipboard.
|
|
63
63
|
|
|
64
|
+
### HTTP Mode
|
|
65
|
+
|
|
66
|
+
Run iMcp as an HTTP server for remote agents, Smithery registry, or multi-client setups:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx @heznpc/imcp --http --port 3847
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- Endpoint: `POST/GET/DELETE /mcp`
|
|
73
|
+
- Transport: Streamable HTTP with SSE (MCP spec 2024-11-05)
|
|
74
|
+
- Session management via `Mcp-Session-Id` header
|
|
75
|
+
- Default port: 3847
|
|
76
|
+
|
|
77
|
+
Useful for Mac Mini "always-on AI hub" setups where remote agents connect over the network.
|
|
78
|
+
|
|
64
79
|
## Tools
|
|
65
80
|
|
|
66
81
|
### Notes (12 tools)
|
|
@@ -165,7 +180,7 @@ Features: server status indicator, one-click permission setup, copy Claude confi
|
|
|
165
180
|
| `list_directory` | List files in a directory | read |
|
|
166
181
|
| `move_file` | Move or rename a file | destructive |
|
|
167
182
|
| `trash_file` | Move file to Trash | destructive |
|
|
168
|
-
| `
|
|
183
|
+
| `create_directory` | Create a new directory | write |
|
|
169
184
|
|
|
170
185
|
### Safari (8 tools)
|
|
171
186
|
|
|
@@ -209,6 +224,17 @@ Features: server status indicator, one-click permission setup, copy Claude confi
|
|
|
209
224
|
| `import_photo` | Import from file path (Swift/PhotoKit) | write |
|
|
210
225
|
| `delete_photos` | Delete photos by ID (Swift/PhotoKit) | destructive |
|
|
211
226
|
|
|
227
|
+
### Messages (6 tools)
|
|
228
|
+
|
|
229
|
+
| Tool | Description | Type |
|
|
230
|
+
|------|-------------|------|
|
|
231
|
+
| `list_chats` | List recent chats with participants | read |
|
|
232
|
+
| `read_chat` | Read chat details including participants and last update | read |
|
|
233
|
+
| `search_chats` | Search by name, participant, or handle | read |
|
|
234
|
+
| `send_message` | Send text via iMessage/SMS | write |
|
|
235
|
+
| `send_file` | Send file attachment via iMessage/SMS | write |
|
|
236
|
+
| `list_participants` | List participants in a chat | read |
|
|
237
|
+
|
|
212
238
|
### Shortcuts (4 tools)
|
|
213
239
|
|
|
214
240
|
| Tool | Description | Type |
|
|
@@ -331,6 +357,10 @@ These prompts are designed for AI coding agents (Claude Code, Cursor, Copilot) t
|
|
|
331
357
|
### Mail
|
|
332
358
|
- Content truncated to 5000 characters by default (configurable via `maxLength` parameter)
|
|
333
359
|
|
|
360
|
+
### Messages
|
|
361
|
+
- Chat message history (individual message content) is not accessible via JXA
|
|
362
|
+
- Send requires the recipient to be a known buddy in the Messages service
|
|
363
|
+
|
|
334
364
|
### Music
|
|
335
365
|
- Smart playlists are read-only
|
|
336
366
|
- No queue manipulation
|
package/dist/finder/tools.js
CHANGED
|
@@ -115,9 +115,9 @@ export function registerFinderTools(server, _config) {
|
|
|
115
115
|
return err(`Failed to trash file: ${e instanceof Error ? e.message : String(e)}`);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
|
-
server.registerTool("
|
|
119
|
-
title: "Create
|
|
120
|
-
description: "Create a new
|
|
118
|
+
server.registerTool("create_directory", {
|
|
119
|
+
title: "Create Directory",
|
|
120
|
+
description: "Create a new directory (and intermediate directories if needed).",
|
|
121
121
|
inputSchema: {
|
|
122
122
|
path: z.string().describe("Absolute path of the folder to create"),
|
|
123
123
|
},
|
package/dist/finder/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/finder/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,OAAmB;IACxE,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,KAAK,EAAE,cAAc;QACrB,WAAW,EAAE,yEAAyE;QACtF,WAAW,EAAE;YACX,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;YAC7D,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,C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QACjD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,yBAAyB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACpF,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,kEAAkE;QAC/E,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;SACnE;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;KACzG,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;QACjB,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,4BAA4B,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACvF,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
+
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
4
7
|
import { registerNoteTools } from "./notes/tools.js";
|
|
5
8
|
import { registerNotePrompts } from "./notes/prompts.js";
|
|
6
9
|
import { registerReminderTools } from "./reminders/tools.js";
|
|
@@ -15,43 +18,129 @@ import { registerSafariTools } from "./safari/tools.js";
|
|
|
15
18
|
import { registerSystemTools } from "./system/tools.js";
|
|
16
19
|
import { registerPhotosTools } from "./photos/tools.js";
|
|
17
20
|
import { registerShortcutsTools } from "./shortcuts/tools.js";
|
|
21
|
+
import { registerMessagesTools } from "./messages/tools.js";
|
|
18
22
|
import { registerIntelligenceTools } from "./intelligence/tools.js";
|
|
19
23
|
import { registerCrossPrompts } from "./cross/prompts.js";
|
|
20
24
|
import { registerResources } from "./shared/resources.js";
|
|
21
25
|
import { registerSetupTools } from "./shared/setup.js";
|
|
22
26
|
import { parseConfig } from "./shared/config.js";
|
|
23
27
|
const config = parseConfig();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
|
|
28
|
+
function createServer() {
|
|
29
|
+
const server = new McpServer({
|
|
30
|
+
name: "imcp",
|
|
31
|
+
version: "1.0.0",
|
|
32
|
+
});
|
|
33
|
+
// Apple Apps
|
|
34
|
+
registerNoteTools(server, config);
|
|
35
|
+
registerNotePrompts(server);
|
|
36
|
+
registerReminderTools(server, config);
|
|
37
|
+
registerReminderPrompts(server);
|
|
38
|
+
registerCalendarTools(server, config);
|
|
39
|
+
registerCalendarPrompts(server);
|
|
40
|
+
registerContactTools(server, config);
|
|
41
|
+
registerMailTools(server, config);
|
|
42
|
+
registerMusicTools(server, config);
|
|
43
|
+
registerFinderTools(server, config);
|
|
44
|
+
registerSafariTools(server, config);
|
|
45
|
+
registerSystemTools(server, config);
|
|
46
|
+
registerPhotosTools(server, config);
|
|
47
|
+
registerShortcutsTools(server, config);
|
|
48
|
+
registerMessagesTools(server, config);
|
|
49
|
+
// Apple Intelligence
|
|
50
|
+
registerIntelligenceTools(server, config);
|
|
51
|
+
// Cross-module workflows
|
|
52
|
+
registerCrossPrompts(server);
|
|
53
|
+
// MCP Resources
|
|
54
|
+
registerResources(server);
|
|
55
|
+
// Setup & diagnostics
|
|
56
|
+
registerSetupTools(server);
|
|
57
|
+
return server;
|
|
58
|
+
}
|
|
59
|
+
const args = process.argv.slice(2);
|
|
60
|
+
const httpMode = args.includes("--http");
|
|
61
|
+
const portIdx = args.indexOf("--port");
|
|
62
|
+
const port = portIdx !== -1 && args[portIdx + 1] ? parseInt(args[portIdx + 1], 10) : 3847;
|
|
51
63
|
async function main() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
if (httpMode) {
|
|
65
|
+
const express = (await import("express")).default;
|
|
66
|
+
const app = express();
|
|
67
|
+
app.use(express.json());
|
|
68
|
+
const transports = new Map();
|
|
69
|
+
app.post("/mcp", async (req, res) => {
|
|
70
|
+
try {
|
|
71
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
72
|
+
if (sessionId && transports.has(sessionId)) {
|
|
73
|
+
await transports.get(sessionId).handleRequest(req, res, req.body);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (sessionId || !isInitializeRequest(req.body)) {
|
|
77
|
+
res.status(400).json({
|
|
78
|
+
jsonrpc: "2.0",
|
|
79
|
+
error: { code: -32000, message: "Bad Request: No valid session ID provided" },
|
|
80
|
+
id: null,
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const transport = new StreamableHTTPServerTransport({
|
|
85
|
+
sessionIdGenerator: () => randomUUID(),
|
|
86
|
+
onsessioninitialized: (id) => {
|
|
87
|
+
transports.set(id, transport);
|
|
88
|
+
},
|
|
89
|
+
onsessionclosed: (id) => {
|
|
90
|
+
transports.delete(id);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const server = createServer();
|
|
94
|
+
await server.connect(transport);
|
|
95
|
+
await transport.handleRequest(req, res, req.body);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
console.error("POST /mcp error:", err);
|
|
99
|
+
if (!res.headersSent) {
|
|
100
|
+
res.status(500).json({
|
|
101
|
+
jsonrpc: "2.0",
|
|
102
|
+
error: { code: -32603, message: "Internal error" },
|
|
103
|
+
id: null,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
app.get("/mcp", async (req, res) => {
|
|
109
|
+
try {
|
|
110
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
111
|
+
if (!sessionId || !transports.has(sessionId)) {
|
|
112
|
+
res.status(400).json({ error: "Invalid or missing session ID" });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
await transports.get(sessionId).handleRequest(req, res);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
console.error("GET /mcp error:", err);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
app.delete("/mcp", async (req, res) => {
|
|
122
|
+
try {
|
|
123
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
124
|
+
if (!sessionId || !transports.has(sessionId)) {
|
|
125
|
+
res.status(400).json({ error: "Invalid or missing session ID" });
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
await transports.get(sessionId).handleRequest(req, res);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
console.error("DELETE /mcp error:", err);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
app.listen(port, () => {
|
|
135
|
+
console.error(`iMcp server running on http://localhost:${port}/mcp (shared notes: ${config.includeShared ? "on" : "off"})`);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const server = createServer();
|
|
140
|
+
const transport = new StdioServerTransport();
|
|
141
|
+
await server.connect(transport);
|
|
142
|
+
console.error(`iMcp server running on stdio (shared notes: ${config.includeShared ? "on" : "off"})`);
|
|
143
|
+
}
|
|
55
144
|
}
|
|
56
145
|
main().catch((error) => {
|
|
57
146
|
console.error("Fatal error:", error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE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atId: string): string;
|
|
3
|
+
export declare function searchMessagesScript(query: string, limit: number): string;
|
|
4
|
+
export declare function sendMessageScript(target: string, text: string): string;
|
|
5
|
+
export declare function sendFileScript(target: string, filePath: string): string;
|
|
6
|
+
export declare function listParticipantsScript(chatId: string): string;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// JXA scripts for Apple Messages automation.
|
|
2
|
+
import { esc } from "../shared/esc.js";
|
|
3
|
+
export function listChatsScript(limit) {
|
|
4
|
+
return `
|
|
5
|
+
const Messages = Application('Messages');
|
|
6
|
+
const chats = Messages.chats();
|
|
7
|
+
const count = Math.min(chats.length, ${limit});
|
|
8
|
+
const result = [];
|
|
9
|
+
for (let i = 0; i < count; i++) {
|
|
10
|
+
const c = chats[i];
|
|
11
|
+
const participants = c.participants();
|
|
12
|
+
result.push({
|
|
13
|
+
id: c.id(),
|
|
14
|
+
name: c.name() || null,
|
|
15
|
+
participants: participants.map(p => ({
|
|
16
|
+
name: p.name(),
|
|
17
|
+
handle: p.handle()
|
|
18
|
+
})),
|
|
19
|
+
updated: c.updatedDate() ? c.updatedDate().toISOString() : null
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
JSON.stringify({total: chats.length, returned: count, chats: result});
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
export function readChatScript(chatId) {
|
|
26
|
+
return `
|
|
27
|
+
const Messages = Application('Messages');
|
|
28
|
+
const chats = Messages.chats.whose({id: '${esc(chatId)}'})();
|
|
29
|
+
if (chats.length === 0) throw new Error('Chat not found: ${esc(chatId)}');
|
|
30
|
+
const chat = chats[0];
|
|
31
|
+
const participants = chat.participants();
|
|
32
|
+
JSON.stringify({
|
|
33
|
+
id: chat.id(),
|
|
34
|
+
name: chat.name() || null,
|
|
35
|
+
participants: participants.map(p => ({name: p.name(), handle: p.handle()})),
|
|
36
|
+
updated: chat.updatedDate() ? chat.updatedDate().toISOString() : null
|
|
37
|
+
});
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
export function searchMessagesScript(query, limit) {
|
|
41
|
+
return `
|
|
42
|
+
const Messages = Application('Messages');
|
|
43
|
+
const chats = Messages.chats();
|
|
44
|
+
const q = '${esc(query)}'.toLowerCase();
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const chat of chats) {
|
|
47
|
+
if (result.length >= ${limit}) break;
|
|
48
|
+
const name = chat.name() || '';
|
|
49
|
+
const participants = chat.participants();
|
|
50
|
+
const participantNames = participants.map(p => p.name() || '').join(' ');
|
|
51
|
+
const participantHandles = participants.map(p => p.handle() || '').join(' ');
|
|
52
|
+
if (name.toLowerCase().includes(q) ||
|
|
53
|
+
participantNames.toLowerCase().includes(q) ||
|
|
54
|
+
participantHandles.toLowerCase().includes(q)) {
|
|
55
|
+
result.push({
|
|
56
|
+
id: chat.id(),
|
|
57
|
+
name: name || null,
|
|
58
|
+
participants: participants.map(p => ({name: p.name(), handle: p.handle()})),
|
|
59
|
+
updated: chat.updatedDate() ? chat.updatedDate().toISOString() : null
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
JSON.stringify({returned: result.length, chats: result});
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
export function sendMessageScript(target, text) {
|
|
67
|
+
return `
|
|
68
|
+
const Messages = Application('Messages');
|
|
69
|
+
const service = Messages.services().find(s => s.serviceType() === 'iMessage') || Messages.services()[0];
|
|
70
|
+
if (!service) throw new Error('No messaging service available');
|
|
71
|
+
const buddy = service.buddies.whose({handle: '${esc(target)}'})();
|
|
72
|
+
if (buddy.length === 0) throw new Error('Buddy not found for handle: ${esc(target)}');
|
|
73
|
+
Messages.send('${esc(text)}', {to: buddy[0]});
|
|
74
|
+
JSON.stringify({sent: true, to: '${esc(target)}', text: '${esc(text)}'.substring(0, 100)});
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
export function sendFileScript(target, filePath) {
|
|
78
|
+
return `
|
|
79
|
+
const Messages = Application('Messages');
|
|
80
|
+
const service = Messages.services().find(s => s.serviceType() === 'iMessage') || Messages.services()[0];
|
|
81
|
+
if (!service) throw new Error('No messaging service available');
|
|
82
|
+
const buddy = service.buddies.whose({handle: '${esc(target)}'})();
|
|
83
|
+
if (buddy.length === 0) throw new Error('Buddy not found for handle: ${esc(target)}');
|
|
84
|
+
const file = Path('${esc(filePath)}');
|
|
85
|
+
Messages.send(file, {to: buddy[0]});
|
|
86
|
+
JSON.stringify({sent: true, to: '${esc(target)}', file: '${esc(filePath)}'});
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
export function listParticipantsScript(chatId) {
|
|
90
|
+
return `
|
|
91
|
+
const Messages = Application('Messages');
|
|
92
|
+
const chats = Messages.chats.whose({id: '${esc(chatId)}'})();
|
|
93
|
+
if (chats.length === 0) throw new Error('Chat not found: ${esc(chatId)}');
|
|
94
|
+
const chat = chats[0];
|
|
95
|
+
const participants = chat.participants();
|
|
96
|
+
const result = participants.map(p => ({
|
|
97
|
+
name: p.name(),
|
|
98
|
+
handle: p.handle()
|
|
99
|
+
}));
|
|
100
|
+
JSON.stringify({chatId: '${esc(chatId)}', chatName: chat.name() || null, participants: result});
|
|
101
|
+
`;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.js","sourceRoot":"","sources":["../../src/messages/scripts.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAE7C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO;;;2CAGkC,KAAK;;;;;;;;;;;;;;;;GAgB7C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,MAAc;IAC3C,OAAO;;+CAEsC,GAAG,CAAC,MAAM,CAAC;+DACK,GAAG,CAAC,MAAM,CAAC;;;;;;;;;GASvE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,KAAa;IAEb,OAAO;;;iBAGQ,GAAG,CAAC,KAAK,CAAC;;;6BAGE,KAAK;;;;;;;;;;;;;;;;;GAiB/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,IAAY;IAEZ,OAAO;;;;oDAI2C,GAAG,CAAC,MAAM,CAAC;2EACY,GAAG,CAAC,MAAM,CAAC;qBACjE,GAAG,CAAC,IAAI,CAAC;uCACS,GAAG,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC;GACrE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,QAAgB;IAEhB,OAAO;;;;oDAI2C,GAAG,CAAC,MAAM,CAAC;2EACY,GAAG,CAAC,MAAM,CAAC;yBAC7D,GAAG,CAAC,QAAQ,CAAC;;uCAEC,GAAG,CAAC,MAAM,CAAC,aAAa,GAAG,CAAC,QAAQ,CAAC;GACzE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACnD,OAAO;;+CAEsC,GAAG,CAAC,MAAM,CAAC;+DACK,GAAG,CAAC,MAAM,CAAC;;;;;;;+BAO3C,GAAG,CAAC,MAAM,CAAC;GACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runJxa } from "../shared/jxa.js";
|
|
3
|
+
import { ok, err } from "../shared/result.js";
|
|
4
|
+
import { listChatsScript, readChatScript, searchMessagesScript, sendMessageScript, sendFileScript, listParticipantsScript, } from "./scripts.js";
|
|
5
|
+
export function registerMessagesTools(server, _config) {
|
|
6
|
+
server.registerTool("list_chats", {
|
|
7
|
+
title: "List Chats",
|
|
8
|
+
description: "List recent chats in Messages with participants and last update time.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
limit: z.number().int().min(1).max(200).optional().default(50).describe("Max chats to return (default: 50)"),
|
|
11
|
+
},
|
|
12
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
13
|
+
}, async ({ limit }) => {
|
|
14
|
+
try {
|
|
15
|
+
return ok(await runJxa(listChatsScript(limit)));
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
return err(`Failed to list chats: ${e instanceof Error ? e.message : String(e)}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
server.registerTool("read_chat", {
|
|
22
|
+
title: "Read Chat",
|
|
23
|
+
description: "Read chat details including participants and last update time by chat ID.",
|
|
24
|
+
inputSchema: {
|
|
25
|
+
chatId: z.string().describe("Chat ID"),
|
|
26
|
+
},
|
|
27
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
28
|
+
}, async ({ chatId }) => {
|
|
29
|
+
try {
|
|
30
|
+
return ok(await runJxa(readChatScript(chatId)));
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
return err(`Failed to read chat: ${e instanceof Error ? e.message : String(e)}`);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
server.registerTool("search_chats", {
|
|
37
|
+
title: "Search Chats",
|
|
38
|
+
description: "Search chats by participant name, handle, or chat name.",
|
|
39
|
+
inputSchema: {
|
|
40
|
+
query: z.string().describe("Search keyword (matches chat name, participant name, or handle)"),
|
|
41
|
+
limit: z.number().int().min(1).max(100).optional().default(20).describe("Max results (default: 20)"),
|
|
42
|
+
},
|
|
43
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
44
|
+
}, async ({ query, limit }) => {
|
|
45
|
+
try {
|
|
46
|
+
return ok(await runJxa(searchMessagesScript(query, limit)));
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
return err(`Failed to search chats: ${e instanceof Error ? e.message : String(e)}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
server.registerTool("send_message", {
|
|
53
|
+
title: "Send Message",
|
|
54
|
+
description: "Send a text message via iMessage/SMS. Requires a phone number or email as the target handle.",
|
|
55
|
+
inputSchema: {
|
|
56
|
+
target: z.string().describe("Recipient handle (phone number or email, e.g. '+821012345678' or 'user@example.com')"),
|
|
57
|
+
text: z.string().min(1).max(10000).describe("Message text to send"),
|
|
58
|
+
},
|
|
59
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
60
|
+
}, async ({ target, text }) => {
|
|
61
|
+
try {
|
|
62
|
+
return ok(await runJxa(sendMessageScript(target, text)));
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
return err(`Failed to send message: ${e instanceof Error ? e.message : String(e)}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
server.registerTool("send_file", {
|
|
69
|
+
title: "Send File",
|
|
70
|
+
description: "Send a file attachment via iMessage/SMS. Requires absolute file path and recipient handle.",
|
|
71
|
+
inputSchema: {
|
|
72
|
+
target: z.string().describe("Recipient handle (phone number or email)"),
|
|
73
|
+
filePath: z.string().describe("Absolute path to the file to send"),
|
|
74
|
+
},
|
|
75
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true },
|
|
76
|
+
}, async ({ target, filePath }) => {
|
|
77
|
+
try {
|
|
78
|
+
return ok(await runJxa(sendFileScript(target, filePath)));
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
return err(`Failed to send file: ${e instanceof Error ? e.message : String(e)}`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
server.registerTool("list_participants", {
|
|
85
|
+
title: "List Chat Participants",
|
|
86
|
+
description: "List all participants in a specific chat.",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
chatId: z.string().describe("Chat ID"),
|
|
89
|
+
},
|
|
90
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
91
|
+
}, async ({ chatId }) => {
|
|
92
|
+
try {
|
|
93
|
+
return ok(await runJxa(listParticipantsScript(chatId)));
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
return err(`Failed to list participants: ${e instanceof Error ? e.message : String(e)}`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/messages/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,OAAmB;IAC1E,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,uEAAuE;QACpF,WAAW,EAAE;YACX,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;SAC7G;QACD,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;KACxG,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAClB,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CA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AI,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;KACxG,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACnB,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC1D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,gCAAgC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC,CACF,CAAC;AAEJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heznpc/imcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "MCP server for the entire Apple ecosystem — Notes, Reminders, Calendar, Contacts, Mail, Music, Finder, Safari, Photos, Shortcuts, System, and Apple Intelligence. Connect any AI to your Mac.",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server for the entire Apple ecosystem — Notes, Reminders, Calendar, Contacts, Mail, Messages, Music, Finder, Safari, Photos, Shortcuts, System, and Apple Intelligence. Connect any AI to your Mac.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
7
7
|
"model-context-protocol",
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
"apple-contacts",
|
|
18
18
|
"mail",
|
|
19
19
|
"apple-mail",
|
|
20
|
+
"messages",
|
|
21
|
+
"imessage",
|
|
20
22
|
"music",
|
|
21
23
|
"apple-music",
|
|
22
24
|
"finder",
|
|
@@ -71,11 +73,13 @@
|
|
|
71
73
|
},
|
|
72
74
|
"dependencies": {
|
|
73
75
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
76
|
+
"express": "^5.2.1",
|
|
74
77
|
"zod": "^3.24.0"
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
80
|
"@eslint/js": "^10.0.1",
|
|
78
81
|
"@jest/globals": "^29.7.0",
|
|
82
|
+
"@types/express": "^5.0.6",
|
|
79
83
|
"@types/node": "^22.0.0",
|
|
80
84
|
"eslint": "^10.0.3",
|
|
81
85
|
"globals": "^16.0.0",
|