@open-sunsama/mcp 1.0.0 → 1.2.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.md +48 -14
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -18
- package/build/index.js.map +1 -1
- package/build/lib/api-client.d.ts +66 -26
- package/build/lib/api-client.d.ts.map +1 -1
- package/build/lib/api-client.js +17 -4
- package/build/lib/api-client.js.map +1 -1
- package/build/lib/define-tool.d.ts +14 -0
- package/build/lib/define-tool.d.ts.map +1 -0
- package/build/lib/define-tool.js +77 -0
- package/build/lib/define-tool.js.map +1 -0
- package/build/server.d.ts +19 -0
- package/build/server.d.ts.map +1 -0
- package/build/server.js +37 -0
- package/build/server.js.map +1 -0
- package/build/tools/calendar-events.d.ts +28 -0
- package/build/tools/calendar-events.d.ts.map +1 -0
- package/build/tools/calendar-events.js +209 -0
- package/build/tools/calendar-events.js.map +1 -0
- package/build/tools/subtasks.d.ts.map +1 -1
- package/build/tools/subtasks.js +6 -5
- package/build/tools/subtasks.js.map +1 -1
- package/build/tools/tasks.d.ts.map +1 -1
- package/build/tools/tasks.js +24 -12
- package/build/tools/tasks.js.map +1 -1
- package/build/tools/time-blocks.d.ts.map +1 -1
- package/build/tools/time-blocks.js +44 -28
- package/build/tools/time-blocks.js.map +1 -1
- package/build/tools/user.d.ts.map +1 -1
- package/build/tools/user.js +3 -2
- package/build/tools/user.js.map +1 -1
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
# Open Sunsama MCP Server
|
|
2
2
|
|
|
3
|
-
An MCP (Model Context Protocol) server that enables AI agents like Claude, Cursor, and other AI assistants to manage your tasks, time blocks, and calendar through the Open Sunsama API.
|
|
3
|
+
An MCP (Model Context Protocol) server that enables AI agents like Claude, ChatGPT, Cursor, and other AI assistants to manage your tasks, time blocks, and calendar through the Open Sunsama API.
|
|
4
|
+
|
|
5
|
+
> **Most people don't need this package.** Open Sunsama hosts the same server at
|
|
6
|
+
> **`https://api.opensunsama.com/mcp`** with OAuth sign-in. Add that URL to Claude
|
|
7
|
+
> (Settings → Customize → Connectors), ChatGPT (Developer mode → Plugins), Claude Code, or
|
|
8
|
+
> Cursor, then sign in and allow access. There's no API key. See the
|
|
9
|
+
> [setup guides](https://opensunsama.com/docs/mcp/overview).
|
|
10
|
+
>
|
|
11
|
+
> Use this npm package (the local stdio server + API key) for clients without OAuth
|
|
12
|
+
> support, scripts, CI, or self-hosted instances that aren't reachable from the internet.
|
|
4
13
|
|
|
5
14
|
## Features
|
|
6
15
|
|
|
@@ -18,9 +27,9 @@ An MCP (Model Context Protocol) server that enables AI agents like Claude, Curso
|
|
|
18
27
|
|
|
19
28
|
## Installation
|
|
20
29
|
|
|
21
|
-
### Quick Start (
|
|
30
|
+
### Quick Start (local server)
|
|
22
31
|
|
|
23
|
-
No installation required
|
|
32
|
+
No installation required. Use `npx` to run it directly:
|
|
24
33
|
|
|
25
34
|
```json
|
|
26
35
|
{
|
|
@@ -39,25 +48,31 @@ No installation required! Use `npx` to run directly:
|
|
|
39
48
|
### From Source (Development)
|
|
40
49
|
|
|
41
50
|
```bash
|
|
42
|
-
# Clone the repository
|
|
51
|
+
# Clone the repository (the mcp package is a workspace of the monorepo)
|
|
43
52
|
git clone https://github.com/ShadowWalker2014/open-sunsama.git
|
|
44
|
-
cd open-sunsama
|
|
45
|
-
|
|
46
|
-
# Install dependencies
|
|
53
|
+
cd open-sunsama
|
|
47
54
|
bun install
|
|
48
55
|
|
|
49
56
|
# Build
|
|
50
|
-
bun run build
|
|
57
|
+
bun run --filter=@open-sunsama/mcp build
|
|
51
58
|
```
|
|
52
59
|
|
|
60
|
+
The tools live in `src/tools/` and are shared with the hosted server: the API imports
|
|
61
|
+
`createOpenSunsamaMcpServer` from `@open-sunsama/mcp/server` and serves it at `/mcp`.
|
|
62
|
+
|
|
53
63
|
### Getting an API Key
|
|
54
64
|
|
|
65
|
+
The fastest way: in the web app, open **Settings → MCP**, expand **Use an API key instead**, and click **Generate key**. The configs are filled in for you.
|
|
66
|
+
|
|
67
|
+
Or create one with custom scopes:
|
|
68
|
+
|
|
55
69
|
1. Open the Open Sunsama web app
|
|
56
70
|
2. Go to **Settings** → **API Keys**
|
|
57
71
|
3. Click **"Generate New Key"**
|
|
58
72
|
4. Select scopes:
|
|
59
73
|
- `tasks:read` and `tasks:write` for task management
|
|
60
|
-
- `time-blocks:read` and `time-blocks:write` for
|
|
74
|
+
- `time-blocks:read` and `time-blocks:write` for time blocks
|
|
75
|
+
- `calendar:read` for events from connected Google, Outlook and iCloud calendars
|
|
61
76
|
- `user:read` and `user:write` for profile access
|
|
62
77
|
5. Copy the key (it's only shown once!)
|
|
63
78
|
|
|
@@ -221,7 +236,13 @@ If you prefer Bun over Node.js:
|
|
|
221
236
|
| `update_time_block` | Update time block details |
|
|
222
237
|
| `delete_time_block` | Remove a time block |
|
|
223
238
|
| `link_task_to_time_block` | Link/unlink a task to a time block |
|
|
224
|
-
| `get_schedule_for_day` | Get
|
|
239
|
+
| `get_schedule_for_day` | Get a day's calendar events and time blocks in one view |
|
|
240
|
+
|
|
241
|
+
### Calendar Events (read-only)
|
|
242
|
+
|
|
243
|
+
| Tool | Description |
|
|
244
|
+
|------|-------------|
|
|
245
|
+
| `list_calendar_events` | List events from connected Google, Outlook and iCloud calendars for a day or range |
|
|
225
246
|
|
|
226
247
|
### User Profile
|
|
227
248
|
|
|
@@ -253,7 +274,8 @@ Once configured, you can ask your AI assistant things like:
|
|
|
253
274
|
- "What subtasks are left on my project task?"
|
|
254
275
|
|
|
255
276
|
### Planning
|
|
256
|
-
- "Help me plan my day - I need to do code review
|
|
277
|
+
- "Help me plan my day around my meetings - I need to do code review and write docs"
|
|
278
|
+
- "When am I free tomorrow afternoon?"
|
|
257
279
|
- "Schedule my tasks for this week based on priority"
|
|
258
280
|
|
|
259
281
|
## Testing
|
|
@@ -264,8 +286,8 @@ Run the test suite to verify your setup:
|
|
|
264
286
|
# Set your API key
|
|
265
287
|
export OPENSUNSAMA_API_KEY=os_your-api-key-here
|
|
266
288
|
|
|
267
|
-
# Run all tests
|
|
268
|
-
bun run test
|
|
289
|
+
# Run all tests against the live API
|
|
290
|
+
bun run test:live
|
|
269
291
|
|
|
270
292
|
# Or run individual test suites
|
|
271
293
|
bun run test:tasks
|
|
@@ -273,6 +295,16 @@ bun run test:time-blocks
|
|
|
273
295
|
bun run test:subtasks
|
|
274
296
|
```
|
|
275
297
|
|
|
298
|
+
### Hosted server OAuth flow
|
|
299
|
+
|
|
300
|
+
`tests/oauth-e2e.ts` drives the full OAuth connector flow (discovery, registration, PKCE,
|
|
301
|
+
consent, token refresh, revocation, CIMD clients, API keys) with the official MCP SDK
|
|
302
|
+
client. Point it at a local API, since it creates a throwaway account:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
MCP_E2E_API_URL=http://localhost:3001 bun run tests/oauth-e2e.ts
|
|
306
|
+
```
|
|
307
|
+
|
|
276
308
|
### Using MCP Inspector
|
|
277
309
|
|
|
278
310
|
For interactive testing and debugging:
|
|
@@ -308,7 +340,7 @@ Make sure you've set the API key in your MCP configuration:
|
|
|
308
340
|
|
|
309
341
|
1. Restart your AI assistant after changing the configuration
|
|
310
342
|
2. Check the configuration file path is correct
|
|
311
|
-
3. Verify
|
|
343
|
+
3. Verify `npx` is available in your PATH (try running `npx -v` in terminal)
|
|
312
344
|
|
|
313
345
|
### "Authentication required" or 401 Errors
|
|
314
346
|
|
|
@@ -330,6 +362,7 @@ mcp/
|
|
|
330
362
|
│ ├── tasks.ts # Task management tools
|
|
331
363
|
│ ├── time-blocks.ts# Time block tools
|
|
332
364
|
│ ├── subtasks.ts # Subtask tools
|
|
365
|
+
│ ├── calendar-events.ts # Calendar event tools (read-only)
|
|
333
366
|
│ └── user.ts # User profile tools
|
|
334
367
|
├── tests/
|
|
335
368
|
│ └── test-all.ts # Comprehensive test suite
|
|
@@ -361,6 +394,7 @@ bun run dev # Watch mode for development
|
|
|
361
394
|
| `tasks:write` | Create, update, delete tasks |
|
|
362
395
|
| `time-blocks:read` | List and view time blocks |
|
|
363
396
|
| `time-blocks:write` | Create, update, delete time blocks |
|
|
397
|
+
| `calendar:read` | List events from connected calendars |
|
|
364
398
|
| `user:read` | View user profile |
|
|
365
399
|
| `user:write` | Update user profile |
|
|
366
400
|
|
package/build/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* A Model Context Protocol server that enables AI agents to manage tasks,
|
|
6
6
|
* time blocks, and calendars through the Open Sunsama API.
|
|
7
7
|
*
|
|
8
|
+
* Most users should connect the hosted server instead — no API key needed:
|
|
9
|
+
* https://api.opensunsama.com/mcp (OAuth; see https://opensunsama.com/docs/mcp/overview)
|
|
10
|
+
*
|
|
8
11
|
* Usage:
|
|
9
12
|
* OPENSUNSAMA_API_KEY=os_xxx open-sunsama-mcp
|
|
10
13
|
* OPENSUNSAMA_API_KEY=os_xxx OPENSUNSAMA_API_URL=http://localhost:3001 open-sunsama-mcp (for self-hosted/local)
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG"}
|
package/build/index.js
CHANGED
|
@@ -5,17 +5,15 @@
|
|
|
5
5
|
* A Model Context Protocol server that enables AI agents to manage tasks,
|
|
6
6
|
* time blocks, and calendars through the Open Sunsama API.
|
|
7
7
|
*
|
|
8
|
+
* Most users should connect the hosted server instead — no API key needed:
|
|
9
|
+
* https://api.opensunsama.com/mcp (OAuth; see https://opensunsama.com/docs/mcp/overview)
|
|
10
|
+
*
|
|
8
11
|
* Usage:
|
|
9
12
|
* OPENSUNSAMA_API_KEY=os_xxx open-sunsama-mcp
|
|
10
13
|
* OPENSUNSAMA_API_KEY=os_xxx OPENSUNSAMA_API_URL=http://localhost:3001 open-sunsama-mcp (for self-hosted/local)
|
|
11
14
|
*/
|
|
12
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
15
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
-
import {
|
|
15
|
-
import { registerTaskTools } from "./tools/tasks.js";
|
|
16
|
-
import { registerTimeBlockTools } from "./tools/time-blocks.js";
|
|
17
|
-
import { registerSubtaskTools } from "./tools/subtasks.js";
|
|
18
|
-
import { registerUserTools } from "./tools/user.js";
|
|
16
|
+
import { createOpenSunsamaMcpServer } from "./server.js";
|
|
19
17
|
// Configuration from environment variables
|
|
20
18
|
const API_KEY = process.env.OPENSUNSAMA_API_KEY;
|
|
21
19
|
const API_URL = process.env.OPENSUNSAMA_API_URL || "https://api.opensunsama.com";
|
|
@@ -30,21 +28,10 @@ if (!API_KEY) {
|
|
|
30
28
|
console.error(" Settings → API Keys → Generate New Key");
|
|
31
29
|
process.exit(1);
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
const server = new McpServer({
|
|
35
|
-
name: "open-sunsama",
|
|
36
|
-
version: "1.0.0",
|
|
37
|
-
});
|
|
38
|
-
// Create the API client
|
|
39
|
-
const apiClient = new ApiClient({
|
|
31
|
+
const server = createOpenSunsamaMcpServer({
|
|
40
32
|
baseUrl: API_URL,
|
|
41
33
|
apiKey: API_KEY,
|
|
42
34
|
});
|
|
43
|
-
// Register all tools
|
|
44
|
-
registerTaskTools(server, apiClient);
|
|
45
|
-
registerTimeBlockTools(server, apiClient);
|
|
46
|
-
registerSubtaskTools(server, apiClient);
|
|
47
|
-
registerUserTools(server, apiClient);
|
|
48
35
|
// Log to stderr (safe for stdio transport)
|
|
49
36
|
console.error(`Open Sunsama MCP Server starting...`);
|
|
50
37
|
console.error(`API URL: ${API_URL}`);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD,2CAA2C;AAC3C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAChD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,6BAA6B,CAAC;AAEjF,kCAAkC;AAClC,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAClB,OAAO,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAC;IACvE,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,0BAA0B,CAAC;IACxC,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,OAAO;CAChB,CAAC,CAAC;AAEH,2CAA2C;AAC3C,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACrD,OAAO,CAAC,KAAK,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACrC,OAAO,CAAC,KAAK,CAAC,YAAY,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAEzD,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;AAC5D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,2BAA2B;AAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export interface ApiClientConfig {
|
|
6
6
|
baseUrl: string;
|
|
7
|
-
|
|
7
|
+
/** API key sent as `X-API-Key` (the stdio CLI). */
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
/** Extra headers, e.g. `Authorization: Bearer <oauth token>` (remote MCP). */
|
|
10
|
+
headers?: Record<string, string>;
|
|
11
|
+
/** Custom fetch, e.g. the API's in-process `app.fetch` for the remote MCP. */
|
|
12
|
+
fetch?: typeof globalThis.fetch;
|
|
8
13
|
}
|
|
9
|
-
export interface ApiResponse<T> {
|
|
14
|
+
export interface ApiResponse<T, M = PaginationMeta> {
|
|
10
15
|
success: boolean;
|
|
11
16
|
data?: T;
|
|
12
17
|
error?: {
|
|
@@ -15,17 +20,19 @@ export interface ApiResponse<T> {
|
|
|
15
20
|
statusCode: number;
|
|
16
21
|
errors?: Record<string, string[]>;
|
|
17
22
|
};
|
|
18
|
-
meta?:
|
|
19
|
-
page: number;
|
|
20
|
-
limit: number;
|
|
21
|
-
total: number;
|
|
22
|
-
totalPages: number;
|
|
23
|
-
};
|
|
23
|
+
meta?: M;
|
|
24
24
|
message?: string;
|
|
25
25
|
}
|
|
26
|
+
export interface PaginationMeta {
|
|
27
|
+
page: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
total: number;
|
|
30
|
+
totalPages: number;
|
|
31
|
+
}
|
|
26
32
|
export declare class ApiClient {
|
|
27
33
|
private baseUrl;
|
|
28
|
-
private
|
|
34
|
+
private authHeaders;
|
|
35
|
+
private fetchImpl;
|
|
29
36
|
constructor(config: ApiClientConfig);
|
|
30
37
|
private request;
|
|
31
38
|
listTasks(params?: {
|
|
@@ -37,20 +44,20 @@ export declare class ApiClient {
|
|
|
37
44
|
sortBy?: "priority" | "position" | "createdAt";
|
|
38
45
|
page?: number;
|
|
39
46
|
limit?: number;
|
|
40
|
-
}): Promise<ApiResponse<Task[]>>;
|
|
41
|
-
getTask(id: string): Promise<ApiResponse<Task>>;
|
|
42
|
-
createTask(data: CreateTaskInput): Promise<ApiResponse<Task>>;
|
|
43
|
-
updateTask(id: string, data: UpdateTaskInput): Promise<ApiResponse<Task>>;
|
|
47
|
+
}): Promise<ApiResponse<Task[], PaginationMeta>>;
|
|
48
|
+
getTask(id: string): Promise<ApiResponse<Task, PaginationMeta>>;
|
|
49
|
+
createTask(data: CreateTaskInput): Promise<ApiResponse<Task, PaginationMeta>>;
|
|
50
|
+
updateTask(id: string, data: UpdateTaskInput): Promise<ApiResponse<Task, PaginationMeta>>;
|
|
44
51
|
deleteTask(id: string): Promise<ApiResponse<{
|
|
45
52
|
message: string;
|
|
46
|
-
}>>;
|
|
47
|
-
reorderTasks(date: string | "backlog", taskIds: string[]): Promise<ApiResponse<Task[]>>;
|
|
48
|
-
listSubtasks(taskId: string): Promise<ApiResponse<Subtask[]>>;
|
|
49
|
-
createSubtask(taskId: string, data: CreateSubtaskInput): Promise<ApiResponse<Subtask>>;
|
|
50
|
-
updateSubtask(taskId: string, subtaskId: string, data: UpdateSubtaskInput): Promise<ApiResponse<Subtask>>;
|
|
53
|
+
}, PaginationMeta>>;
|
|
54
|
+
reorderTasks(date: string | "backlog", taskIds: string[]): Promise<ApiResponse<Task[], PaginationMeta>>;
|
|
55
|
+
listSubtasks(taskId: string): Promise<ApiResponse<Subtask[], PaginationMeta>>;
|
|
56
|
+
createSubtask(taskId: string, data: CreateSubtaskInput): Promise<ApiResponse<Subtask, PaginationMeta>>;
|
|
57
|
+
updateSubtask(taskId: string, subtaskId: string, data: UpdateSubtaskInput): Promise<ApiResponse<Subtask, PaginationMeta>>;
|
|
51
58
|
deleteSubtask(taskId: string, subtaskId: string): Promise<ApiResponse<{
|
|
52
59
|
message: string;
|
|
53
|
-
}>>;
|
|
60
|
+
}, PaginationMeta>>;
|
|
54
61
|
listTimeBlocks(params?: {
|
|
55
62
|
date?: string;
|
|
56
63
|
from?: string;
|
|
@@ -58,15 +65,20 @@ export declare class ApiClient {
|
|
|
58
65
|
taskId?: string;
|
|
59
66
|
page?: number;
|
|
60
67
|
limit?: number;
|
|
61
|
-
}): Promise<ApiResponse<TimeBlock[]>>;
|
|
62
|
-
getTimeBlock(id: string): Promise<ApiResponse<TimeBlock>>;
|
|
63
|
-
createTimeBlock(data: CreateTimeBlockInput): Promise<ApiResponse<TimeBlock>>;
|
|
64
|
-
updateTimeBlock(id: string, data: UpdateTimeBlockInput): Promise<ApiResponse<TimeBlock>>;
|
|
68
|
+
}): Promise<ApiResponse<TimeBlock[], PaginationMeta>>;
|
|
69
|
+
getTimeBlock(id: string): Promise<ApiResponse<TimeBlock, PaginationMeta>>;
|
|
70
|
+
createTimeBlock(data: CreateTimeBlockInput): Promise<ApiResponse<TimeBlock, PaginationMeta>>;
|
|
71
|
+
updateTimeBlock(id: string, data: UpdateTimeBlockInput): Promise<ApiResponse<TimeBlock, PaginationMeta>>;
|
|
65
72
|
deleteTimeBlock(id: string): Promise<ApiResponse<{
|
|
66
73
|
message: string;
|
|
67
|
-
}>>;
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
}, PaginationMeta>>;
|
|
75
|
+
listCalendarEvents(params: {
|
|
76
|
+
date?: string;
|
|
77
|
+
from?: string;
|
|
78
|
+
to?: string;
|
|
79
|
+
}): Promise<ApiResponse<CalendarEvent[], CalendarEventsMeta>>;
|
|
80
|
+
getMe(): Promise<ApiResponse<User, PaginationMeta>>;
|
|
81
|
+
updateMe(data: UpdateUserInput): Promise<ApiResponse<User, PaginationMeta>>;
|
|
70
82
|
}
|
|
71
83
|
export type TaskPriority = "P0" | "P1" | "P2" | "P3";
|
|
72
84
|
export interface Task {
|
|
@@ -76,6 +88,7 @@ export interface Task {
|
|
|
76
88
|
notes: string | null;
|
|
77
89
|
scheduledDate: string | null;
|
|
78
90
|
estimatedMins: number | null;
|
|
91
|
+
actualMins: number | null;
|
|
79
92
|
priority: TaskPriority;
|
|
80
93
|
completedAt: string | null;
|
|
81
94
|
position: number;
|
|
@@ -95,6 +108,7 @@ export interface UpdateTaskInput {
|
|
|
95
108
|
notes?: string | null;
|
|
96
109
|
scheduledDate?: string | null;
|
|
97
110
|
estimatedMins?: number | null;
|
|
111
|
+
actualMins?: number | null;
|
|
98
112
|
priority?: TaskPriority;
|
|
99
113
|
completedAt?: string | null;
|
|
100
114
|
position?: number;
|
|
@@ -153,6 +167,32 @@ export interface UpdateTimeBlockInput {
|
|
|
153
167
|
color?: string | null;
|
|
154
168
|
position?: number;
|
|
155
169
|
}
|
|
170
|
+
export interface CalendarEvent {
|
|
171
|
+
id: string;
|
|
172
|
+
calendarId: string;
|
|
173
|
+
title: string;
|
|
174
|
+
description: string | null;
|
|
175
|
+
location: string | null;
|
|
176
|
+
/** ISO instant. All-day events start at UTC midnight of their date. */
|
|
177
|
+
startTime: string;
|
|
178
|
+
/** ISO instant. All-day events end at UTC midnight after their last date. */
|
|
179
|
+
endTime: string;
|
|
180
|
+
isAllDay: boolean;
|
|
181
|
+
status: "confirmed" | "tentative" | "cancelled" | null;
|
|
182
|
+
responseStatus: "accepted" | "declined" | "tentative" | "needsAction" | null;
|
|
183
|
+
calendar: {
|
|
184
|
+
id: string;
|
|
185
|
+
name: string;
|
|
186
|
+
color: string | null;
|
|
187
|
+
} | null;
|
|
188
|
+
}
|
|
189
|
+
export interface CalendarEventsMeta {
|
|
190
|
+
total: number;
|
|
191
|
+
/** The user's timezone, which date-only ranges were interpreted in. */
|
|
192
|
+
timezone: string;
|
|
193
|
+
fromDate?: string;
|
|
194
|
+
toDate?: string;
|
|
195
|
+
}
|
|
156
196
|
export interface User {
|
|
157
197
|
id: string;
|
|
158
198
|
email: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAA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IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACxC"}
|
package/build/lib/api-client.js
CHANGED
|
@@ -4,10 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export class ApiClient {
|
|
6
6
|
baseUrl;
|
|
7
|
-
|
|
7
|
+
authHeaders;
|
|
8
|
+
fetchImpl;
|
|
8
9
|
constructor(config) {
|
|
9
10
|
this.baseUrl = config.baseUrl.replace(/\/$/, ""); // Remove trailing slash
|
|
10
|
-
this.
|
|
11
|
+
this.authHeaders = {
|
|
12
|
+
...(config.apiKey ? { "X-API-Key": config.apiKey } : {}),
|
|
13
|
+
...config.headers,
|
|
14
|
+
};
|
|
15
|
+
this.fetchImpl = config.fetch ?? globalThis.fetch;
|
|
11
16
|
}
|
|
12
17
|
async request(method, path, body, query) {
|
|
13
18
|
let url = `${this.baseUrl}${path}`;
|
|
@@ -25,7 +30,7 @@ export class ApiClient {
|
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
32
|
const headers = {
|
|
28
|
-
|
|
33
|
+
...this.authHeaders,
|
|
29
34
|
"Content-Type": "application/json",
|
|
30
35
|
};
|
|
31
36
|
const options = {
|
|
@@ -36,7 +41,7 @@ export class ApiClient {
|
|
|
36
41
|
options.body = JSON.stringify(body);
|
|
37
42
|
}
|
|
38
43
|
try {
|
|
39
|
-
const response = await
|
|
44
|
+
const response = await this.fetchImpl(url, options);
|
|
40
45
|
const data = await response.json();
|
|
41
46
|
return data;
|
|
42
47
|
}
|
|
@@ -115,6 +120,14 @@ export class ApiClient {
|
|
|
115
120
|
async deleteTimeBlock(id) {
|
|
116
121
|
return this.request("DELETE", `/time-blocks/${id}`);
|
|
117
122
|
}
|
|
123
|
+
// Calendar events (synced from Google, Outlook, iCloud; read-only)
|
|
124
|
+
async listCalendarEvents(params) {
|
|
125
|
+
return this.request("GET", "/calendar-events", undefined, {
|
|
126
|
+
date: params.date,
|
|
127
|
+
from: params.from,
|
|
128
|
+
to: params.to,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
118
131
|
// User
|
|
119
132
|
async getMe() {
|
|
120
133
|
return this.request("GET", "/auth/me");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../../src/lib/api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgCH,MAAM,OAAO,SAAS;IACZ,OAAO,CAAS;IAChB,WAAW,CAAyB;IACpC,SAAS,CAA0B;IAE3C,YAAY,MAAuB;QACjC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,wBAAwB;QAC1E,IAAI,CAAC,WAAW,GAAG;YACjB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACxD,GAAG,MAAM,CAAC,OAAO;SAClB,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IACpD,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,MAAc,EACd,IAAY,EACZ,IAAc,EACd,KAA6D;QAE7D,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QAEnC,uBAAuB;QACvB,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,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,eAAe,CAAC,EAAU;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAsB,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,mEAAmE;IACnE,KAAK,CAAC,kBAAkB,CAAC,MAAqD;QAC5E,OAAO,IAAI,CAAC,OAAO,CAAsC,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE;YAC7F,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,EAAE,EAAE,MAAM,CAAC,EAAE;SACd,CAAC,CAAC;IACL,CAAC;IAED,OAAO;IACP,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,OAAO,CAAO,KAAK,EAAE,UAAU,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAqB;QAClC,OAAO,IAAI,CAAC,OAAO,CAAO,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a tool with the metadata Claude and ChatGPT expect on every
|
|
3
|
+
* tool: a human title, behavior annotations, and the OAuth scopes it needs.
|
|
4
|
+
* Keeping the table in one place means the tool files only carry the
|
|
5
|
+
* description, schema, and handler.
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import type { ZodRawShape } from "zod";
|
|
9
|
+
type ToolScope = "tasks:read" | "tasks:write" | "time-blocks:read" | "time-blocks:write" | "calendar:read" | "user:read" | "user:write";
|
|
10
|
+
/** Union of every scope any tool needs — what an MCP client should request. */
|
|
11
|
+
export declare const MCP_TOOL_SCOPES: ToolScope[];
|
|
12
|
+
export declare function defineTool<Shape extends ZodRawShape>(server: McpServer, name: string, description: string, inputSchema: Shape, handler: ToolCallback<Shape>): void;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=define-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-tool.d.ts","sourceRoot":"","sources":["../../src/lib/define-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAEvC,KAAK,SAAS,GACV,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,mBAAmB,GACnB,eAAe,GACf,WAAW,GACX,YAAY,CAAC;AA2DjB,+EAA+E;AAC/E,eAAO,MAAM,eAAe,EAAE,SAAS,EAEtC,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,SAAS,WAAW,EAClD,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,KAAK,EAClB,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,GAC3B,IAAI,CA2BN"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a tool with the metadata Claude and ChatGPT expect on every
|
|
3
|
+
* tool: a human title, behavior annotations, and the OAuth scopes it needs.
|
|
4
|
+
* Keeping the table in one place means the tool files only carry the
|
|
5
|
+
* description, schema, and handler.
|
|
6
|
+
*/
|
|
7
|
+
const TOOL_METADATA = {
|
|
8
|
+
// Tasks
|
|
9
|
+
list_tasks: { title: "List tasks", scopes: ["tasks:read"], readOnly: true },
|
|
10
|
+
get_task: { title: "Get task", scopes: ["tasks:read"], readOnly: true },
|
|
11
|
+
create_task: { title: "Create task", scopes: ["tasks:write"] },
|
|
12
|
+
update_task: { title: "Update task", scopes: ["tasks:write"], idempotent: true },
|
|
13
|
+
complete_task: { title: "Complete task", scopes: ["tasks:write"], idempotent: true },
|
|
14
|
+
uncomplete_task: { title: "Reopen task", scopes: ["tasks:write"], idempotent: true },
|
|
15
|
+
delete_task: { title: "Delete task", scopes: ["tasks:write"], destructive: true, idempotent: true },
|
|
16
|
+
schedule_task: { title: "Schedule task", scopes: ["tasks:write"], idempotent: true },
|
|
17
|
+
reorder_tasks: { title: "Reorder tasks", scopes: ["tasks:write"], idempotent: true },
|
|
18
|
+
// Subtasks
|
|
19
|
+
list_subtasks: { title: "List subtasks", scopes: ["tasks:read"], readOnly: true },
|
|
20
|
+
create_subtask: { title: "Create subtask", scopes: ["tasks:write"] },
|
|
21
|
+
toggle_subtask: { title: "Toggle subtask", scopes: ["tasks:write"] },
|
|
22
|
+
update_subtask: { title: "Update subtask", scopes: ["tasks:write"], idempotent: true },
|
|
23
|
+
delete_subtask: { title: "Delete subtask", scopes: ["tasks:write"], destructive: true, idempotent: true },
|
|
24
|
+
// Time blocks
|
|
25
|
+
list_time_blocks: { title: "List time blocks", scopes: ["time-blocks:read"], readOnly: true },
|
|
26
|
+
get_time_block: { title: "Get time block", scopes: ["time-blocks:read"], readOnly: true },
|
|
27
|
+
create_time_block: { title: "Create time block", scopes: ["time-blocks:write"] },
|
|
28
|
+
update_time_block: { title: "Update time block", scopes: ["time-blocks:write"], idempotent: true },
|
|
29
|
+
delete_time_block: {
|
|
30
|
+
title: "Delete time block",
|
|
31
|
+
scopes: ["time-blocks:write"],
|
|
32
|
+
destructive: true,
|
|
33
|
+
idempotent: true,
|
|
34
|
+
},
|
|
35
|
+
link_task_to_time_block: {
|
|
36
|
+
title: "Link task to time block",
|
|
37
|
+
scopes: ["time-blocks:write"],
|
|
38
|
+
idempotent: true,
|
|
39
|
+
},
|
|
40
|
+
get_schedule_for_day: {
|
|
41
|
+
title: "Get schedule for a day",
|
|
42
|
+
scopes: ["time-blocks:read", "calendar:read"],
|
|
43
|
+
readOnly: true,
|
|
44
|
+
},
|
|
45
|
+
// Calendar events (synced from Google, Outlook, iCloud)
|
|
46
|
+
list_calendar_events: { title: "List calendar events", scopes: ["calendar:read"], readOnly: true },
|
|
47
|
+
// User
|
|
48
|
+
get_user_profile: { title: "Get profile", scopes: ["user:read"], readOnly: true },
|
|
49
|
+
update_user_profile: { title: "Update profile", scopes: ["user:write"], idempotent: true },
|
|
50
|
+
};
|
|
51
|
+
/** Union of every scope any tool needs — what an MCP client should request. */
|
|
52
|
+
export const MCP_TOOL_SCOPES = [
|
|
53
|
+
...new Set(Object.values(TOOL_METADATA).flatMap((m) => m.scopes)),
|
|
54
|
+
];
|
|
55
|
+
export function defineTool(server, name, description, inputSchema, handler) {
|
|
56
|
+
const meta = TOOL_METADATA[name];
|
|
57
|
+
if (!meta) {
|
|
58
|
+
throw new Error(`Missing TOOL_METADATA entry for MCP tool "${name}"`);
|
|
59
|
+
}
|
|
60
|
+
const securitySchemes = [{ type: "oauth2", scopes: meta.scopes }];
|
|
61
|
+
server.registerTool(name, {
|
|
62
|
+
title: meta.title,
|
|
63
|
+
description,
|
|
64
|
+
inputSchema,
|
|
65
|
+
annotations: {
|
|
66
|
+
title: meta.title,
|
|
67
|
+
readOnlyHint: meta.readOnly ?? false,
|
|
68
|
+
destructiveHint: meta.destructive ?? false,
|
|
69
|
+
idempotentHint: meta.idempotent ?? meta.readOnly ?? false,
|
|
70
|
+
// Tools only touch the user's own Open Sunsama account.
|
|
71
|
+
openWorldHint: false,
|
|
72
|
+
},
|
|
73
|
+
// ChatGPT reads securitySchemes to know the tool needs a linked account.
|
|
74
|
+
_meta: { securitySchemes },
|
|
75
|
+
}, handler);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=define-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-tool.js","sourceRoot":"","sources":["../../src/lib/define-tool.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsBH,MAAM,aAAa,GAAiC;IAClD,QAAQ;IACR,UAAU,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC3E,QAAQ,EAAE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builds the Open Sunsama MCP server with every tool registered.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the stdio CLI (`src/index.ts`, API-key auth) and the API's remote
|
|
5
|
+
* Streamable HTTP endpoint (`/mcp`, OAuth auth). The caller decides how the
|
|
6
|
+
* ApiClient authenticates and which transport to connect.
|
|
7
|
+
*/
|
|
8
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import { ApiClient, type ApiClientConfig } from "./lib/api-client.js";
|
|
10
|
+
export { ApiClient, type ApiClientConfig } from "./lib/api-client.js";
|
|
11
|
+
export { MCP_TOOL_SCOPES } from "./lib/define-tool.js";
|
|
12
|
+
export declare const MCP_SERVER_INFO: {
|
|
13
|
+
readonly name: "open-sunsama";
|
|
14
|
+
readonly title: "Open Sunsama";
|
|
15
|
+
readonly version: "1.2.0";
|
|
16
|
+
readonly websiteUrl: "https://opensunsama.com";
|
|
17
|
+
};
|
|
18
|
+
export declare function createOpenSunsamaMcpServer(client: ApiClient | ApiClientConfig): McpServer;
|
|
19
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOtE,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,eAAe;;;;;CAKlB,CAAC;AAOX,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,GAAG,eAAe,GAClC,SAAS,CAWX"}
|
package/build/server.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the Open Sunsama MCP server with every tool registered.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the stdio CLI (`src/index.ts`, API-key auth) and the API's remote
|
|
5
|
+
* Streamable HTTP endpoint (`/mcp`, OAuth auth). The caller decides how the
|
|
6
|
+
* ApiClient authenticates and which transport to connect.
|
|
7
|
+
*/
|
|
8
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
9
|
+
import { ApiClient } from "./lib/api-client.js";
|
|
10
|
+
import { registerTaskTools } from "./tools/tasks.js";
|
|
11
|
+
import { registerTimeBlockTools } from "./tools/time-blocks.js";
|
|
12
|
+
import { registerSubtaskTools } from "./tools/subtasks.js";
|
|
13
|
+
import { registerUserTools } from "./tools/user.js";
|
|
14
|
+
import { registerCalendarEventTools } from "./tools/calendar-events.js";
|
|
15
|
+
export { ApiClient } from "./lib/api-client.js";
|
|
16
|
+
export { MCP_TOOL_SCOPES } from "./lib/define-tool.js";
|
|
17
|
+
export const MCP_SERVER_INFO = {
|
|
18
|
+
name: "open-sunsama",
|
|
19
|
+
title: "Open Sunsama",
|
|
20
|
+
version: "1.2.0",
|
|
21
|
+
websiteUrl: "https://opensunsama.com",
|
|
22
|
+
};
|
|
23
|
+
const INSTRUCTIONS = `Open Sunsama is the user's daily planner: tasks scheduled on dates (or in the backlog), subtasks, time blocks on a calendar, and read-only events from their connected Google, Outlook and iCloud calendars.
|
|
24
|
+
- Dates are YYYY-MM-DD in the user's timezone; call get_user_profile if you need the timezone.
|
|
25
|
+
- Use get_schedule_for_day to see a whole day at once (meetings and time blocks) before planning it, and plan time blocks around the meetings.
|
|
26
|
+
- Prefer schedule_task to move work between days and link_task_to_time_block to put a task on the calendar.`;
|
|
27
|
+
export function createOpenSunsamaMcpServer(client) {
|
|
28
|
+
const apiClient = client instanceof ApiClient ? client : new ApiClient(client);
|
|
29
|
+
const server = new McpServer(MCP_SERVER_INFO, { instructions: INSTRUCTIONS });
|
|
30
|
+
registerTaskTools(server, apiClient);
|
|
31
|
+
registerTimeBlockTools(server, apiClient);
|
|
32
|
+
registerSubtaskTools(server, apiClient);
|
|
33
|
+
registerCalendarEventTools(server, apiClient);
|
|
34
|
+
registerUserTools(server, apiClient);
|
|
35
|
+
return server;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,SAAS,EAAwB,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,cAAc;IACrB,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,yBAAyB;CAC7B,CAAC;AAEX,MAAM,YAAY,GAAG;;;4GAGuF,CAAC;AAE7G,MAAM,UAAU,0BAA0B,CACxC,MAAmC;IAEnC,MAAM,SAAS,GAAG,MAAM,YAAY,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,eAAe,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CAAC;IAE9E,iBAAiB,CA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