togello-mcp-server 1.0.24 → 1.0.27
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 +60 -23
- package/build/handlers/tool/completeActivityLogHandler.js +8 -18
- package/build/handlers/tool/createTaskHandler.js +6 -16
- package/build/handlers/tool/getActivityItemListHandler.js +8 -23
- package/build/handlers/tool/getActivityLogListHandler.js +10 -27
- package/build/handlers/tool/getCalendarDateMemoHandler.js +17 -0
- package/build/handlers/tool/getJapanCurrentTimeHandler.js +7 -17
- package/build/handlers/tool/getTodayCalendarHandler.js +15 -47
- package/build/handlers/tool/getTodoCategoryListHandler.js +8 -23
- package/build/handlers/tool/getTodoListHandler.js +17 -37
- package/build/handlers/tool/startActivityLogHandler.js +7 -17
- package/build/handlers/tool/toolResponse.js +28 -0
- package/build/handlers/tool/updateCalendarDateMemoHandler.js +22 -0
- package/build/handlers/tool/updateTaskHandler.js +8 -17
- package/build/index.js +75 -5
- package/build/mcpServer.js +137 -55
- package/build/remoteServer.js +57 -2
- package/package.json +28 -8
- package/build/handlers/tasksHandler.js +0 -36
package/README.md
CHANGED
|
@@ -1,54 +1,91 @@
|
|
|
1
1
|
# Togello MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Togello MCP Server exposes Togello tasks, categories, calendar memos, Google Calendar events, activity items, and activity logs through the Model Context Protocol.
|
|
4
4
|
|
|
5
5
|
https://togello.com/sign
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Requirements
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Node.js 22 or later
|
|
10
|
+
- A Togello API token
|
|
11
|
+
|
|
12
|
+
## Local MCP With npm
|
|
13
|
+
|
|
14
|
+
Use this for desktop clients and local developer tools that launch MCP servers over stdio.
|
|
15
|
+
|
|
16
|
+
```json
|
|
10
17
|
{
|
|
11
18
|
"mcpServers": {
|
|
12
19
|
"togello": {
|
|
13
20
|
"command": "npx",
|
|
14
21
|
"args": ["-y", "togello-mcp-server"],
|
|
15
22
|
"env": {
|
|
16
|
-
"TOGELLO_API_TOKEN": "replace_with_your_token"
|
|
23
|
+
"TOGELLO_API_TOKEN": "replace_with_your_token"
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
28
|
```
|
|
22
29
|
|
|
23
|
-
##
|
|
30
|
+
## Remote MCP
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
Remote mode exposes an SSE endpoint at `/sse` and a message endpoint at `/message`.
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
```bash
|
|
35
|
+
TOGELLO_MCP_MODE=remote \
|
|
36
|
+
TOGELLO_MCP_AUTH_MODE=passthrough \
|
|
37
|
+
TOGELLO_MCP_HOST=0.0.0.0 \
|
|
38
|
+
TOGELLO_MCP_PORT=8081 \
|
|
39
|
+
npm start
|
|
40
|
+
```
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
Connect remote MCP clients to:
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
- get-todo-category-list: TODO 機能からカテゴリーリストを取得します。カテゴリー名 / カテゴリー UUID を認識できます。
|
|
36
|
-
- get-today-calendar: 連携している Google カレンダーの昨日/今日/明日の予定を取得します。予定名 / 開始日時 / 終了日時 を認識できます。
|
|
37
|
-
- get-activity-item-list: 統合機能からアクティビティ項目のリストを取得します。アクティビティ項目 UUID / 項目名 を認識できます。
|
|
38
|
-
- get-activity-log-list: 統合機能からアクティビティログのリストを取得します。すべてのログの終了日時が入力されている場合、現在何も実行していないことを意味します。終了日時が null のものがある場合(最大で 1 つ)、現在その活動を実行中であることを意味します。アクティビティログ UUID / 開始日時 / 終了日時 / 項目名 を認識できます。
|
|
39
|
-
- start-activity-log: アクティビティログを開始します。`get-activity-item-list` で取得した項目名(`activityItemName`)を指定する必要があります。`get-activity-log-list` で取得したログリストの全ての `endDateTime` に値がある場合(現在実行中のアクティビティがない場合)に呼び出すことができます。
|
|
40
|
-
- complete-activity-log: アクティビティログを完了します。`get-activity-log-list` で取得した、現在実行中のアクティビティログの UUID(`activityLogUUID`)を指定する必要があります。
|
|
41
|
-
- get-japan-current-time: Returns the current time in Japan (JST). No parameters are required.
|
|
44
|
+
```text
|
|
45
|
+
https://your-domain.example/sse
|
|
46
|
+
```
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
`passthrough` auth expects each remote client request to send its own Togello API token as an `Authorization: Bearer ...` header. Use this mode for published remote MCP servers.
|
|
49
|
+
|
|
50
|
+
`env` auth uses one server-side `TOGELLO_API_TOKEN` for every remote client. It is intended only for trusted local or single-user deployments. When binding to a non-local host, `TOGELLO_MCP_AUTH_MODE=env` also requires `TOGELLO_MCP_ALLOW_ENV_AUTH=true` so public deployments cannot enable shared-token auth by accident.
|
|
51
|
+
|
|
52
|
+
ChatGPT developer mode can add remote MCP servers that use SSE. For production ChatGPT apps or connectors, use `passthrough` auth or a deployment that authenticates each user separately before forwarding requests to Togello.
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
https://mcpreview.com/mcp-servers/toru-takagi/togello-mcp-server
|
|
54
|
+
## Tools
|
|
47
55
|
|
|
56
|
+
Read-only tools include MCP `readOnlyHint` annotations and return stable JSON in both `structuredContent` and text content.
|
|
48
57
|
|
|
49
|
-
|
|
58
|
+
- `get-tasks-list`: Retrieves incomplete TODO tasks. Optional `categoryUUIDs` filters by category UUID.
|
|
59
|
+
- `get-calendar-date-memo`: Retrieves a calendar date memo for a `YYYY-MM-DD` date.
|
|
60
|
+
- `get-todo-category-list`: Retrieves TODO categories.
|
|
61
|
+
- `get-today-calendar`: Retrieves linked Google Calendar events and scheduled tasks.
|
|
62
|
+
- `get-activity-item-list`: Retrieves enabled activity items.
|
|
63
|
+
- `get-activity-log-list`: Retrieves activity logs.
|
|
64
|
+
- `get-japan-current-time`: Returns the current time in Japan.
|
|
50
65
|
|
|
66
|
+
Write tools return JSON. Failed tool responses also return JSON and are marked with `isError: true`.
|
|
67
|
+
|
|
68
|
+
- `create-task`: Creates a TODO task.
|
|
69
|
+
- `update-task`: Updates a TODO task.
|
|
70
|
+
- `update-calendar-date-memo`: Updates or clears a calendar date memo.
|
|
71
|
+
- `start-activity-log`: Starts an activity log.
|
|
72
|
+
- `complete-activity-log`: Completes an activity log.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm install
|
|
78
|
+
npm run build
|
|
51
79
|
```
|
|
80
|
+
|
|
81
|
+
## MCP Review
|
|
82
|
+
|
|
83
|
+
Certified
|
|
84
|
+
https://mcpreview.com/mcp-servers/toru-takagi/togello-mcp-server
|
|
85
|
+
|
|
86
|
+
## Publish
|
|
87
|
+
|
|
88
|
+
```bash
|
|
52
89
|
npm run build
|
|
53
90
|
npm version patch
|
|
54
91
|
npm publish --access public
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
-
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
+
export const completeActivityLogHandler = async ({ activityLogUUID, }) => {
|
|
3
4
|
try {
|
|
4
5
|
await httpClient.putJson({
|
|
5
|
-
path: `/v2/integration/activity-logs/${activityLogUUID}/work-complete`,
|
|
6
|
+
path: `/v2/integration/activity-logs/${encodeURIComponent(activityLogUUID)}/work-complete`,
|
|
6
7
|
body: {},
|
|
7
8
|
});
|
|
8
|
-
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
text: `Activity log with UUID "${activityLogUUID}" completed successfully.`,
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
};
|
|
9
|
+
return jsonToolResponse({
|
|
10
|
+
activityLogUUID,
|
|
11
|
+
completed: true,
|
|
12
|
+
});
|
|
16
13
|
}
|
|
17
14
|
catch (error) {
|
|
18
15
|
console.error('Error completing activity log:', error);
|
|
19
|
-
return
|
|
20
|
-
content: [
|
|
21
|
-
{
|
|
22
|
-
type: 'text',
|
|
23
|
-
text: `Error completing activity log: ${error}`,
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
};
|
|
16
|
+
return errorToolResponse('Error completing activity log');
|
|
27
17
|
}
|
|
28
18
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
2
3
|
export const createTaskHandler = async ({ taskName, categoryUUID, scheduledStartDate, scheduledEndDate, url, detail, }) => {
|
|
3
4
|
try {
|
|
4
5
|
await httpClient.postJson({
|
|
@@ -12,24 +13,13 @@ export const createTaskHandler = async ({ taskName, categoryUUID, scheduledStart
|
|
|
12
13
|
detail: detail,
|
|
13
14
|
},
|
|
14
15
|
});
|
|
15
|
-
return {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
text: `Task "${taskName}" created successfully.`,
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
|
16
|
+
return jsonToolResponse({
|
|
17
|
+
taskName,
|
|
18
|
+
created: true,
|
|
19
|
+
});
|
|
23
20
|
}
|
|
24
21
|
catch (error) {
|
|
25
22
|
console.error('Error creating task:', error);
|
|
26
|
-
return
|
|
27
|
-
content: [
|
|
28
|
-
{
|
|
29
|
-
type: 'text',
|
|
30
|
-
text: `Error creating task: ${error}`,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
};
|
|
23
|
+
return errorToolResponse('Error creating task');
|
|
34
24
|
}
|
|
35
25
|
};
|
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
2
3
|
export const getActivityItemListHandler = async () => {
|
|
3
4
|
try {
|
|
4
5
|
const activityItemList = await httpClient.fetchURL({
|
|
5
6
|
path: '/v2/integration/activity-items',
|
|
6
7
|
});
|
|
7
8
|
const enabledActivityItemList = activityItemList.filter((item) => item.enabled === 'true');
|
|
8
|
-
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: 'text',
|
|
17
|
-
text: enabledActivityItemList
|
|
18
|
-
.map((item) => [item.activityItemUUID, item.itemName])
|
|
19
|
-
.join(','),
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
|
9
|
+
return jsonToolResponse({
|
|
10
|
+
activityItems: enabledActivityItemList.map((item) => ({
|
|
11
|
+
activityItemUUID: item.activityItemUUID,
|
|
12
|
+
itemName: item.itemName,
|
|
13
|
+
})),
|
|
14
|
+
});
|
|
23
15
|
}
|
|
24
16
|
catch (error) {
|
|
25
17
|
console.error('Error in tool handler:', error);
|
|
26
|
-
return
|
|
27
|
-
content: [
|
|
28
|
-
{
|
|
29
|
-
type: 'text',
|
|
30
|
-
text: `Error in tool handler: ${error}`,
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
};
|
|
18
|
+
return errorToolResponse('Error retrieving activity items');
|
|
34
19
|
}
|
|
35
20
|
};
|
|
@@ -1,38 +1,21 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
2
3
|
export const getActivityLogListHandler = async () => {
|
|
3
4
|
try {
|
|
4
5
|
const activityLogList = await httpClient.fetchURL({
|
|
5
6
|
path: '/v2/integration/activity-logs',
|
|
6
7
|
});
|
|
7
|
-
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
text: activityLogList
|
|
16
|
-
.map((log) => [
|
|
17
|
-
log.activityLogUUID,
|
|
18
|
-
log.startDateTime,
|
|
19
|
-
log.endDateTime,
|
|
20
|
-
log.itemName,
|
|
21
|
-
])
|
|
22
|
-
.join('\n'),
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
};
|
|
8
|
+
return jsonToolResponse({
|
|
9
|
+
activityLogs: activityLogList.map((log) => ({
|
|
10
|
+
activityLogUUID: log.activityLogUUID,
|
|
11
|
+
startDateTime: log.startDateTime,
|
|
12
|
+
endDateTime: log.endDateTime,
|
|
13
|
+
itemName: log.itemName,
|
|
14
|
+
})),
|
|
15
|
+
});
|
|
26
16
|
}
|
|
27
17
|
catch (error) {
|
|
28
18
|
console.error('Error in activity log list handler:', error);
|
|
29
|
-
return
|
|
30
|
-
content: [
|
|
31
|
-
{
|
|
32
|
-
type: 'text',
|
|
33
|
-
text: `アクティビティログの取得中にエラーが発生しました: ${error}`,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
};
|
|
19
|
+
return errorToolResponse('Error retrieving activity logs');
|
|
37
20
|
}
|
|
38
21
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
+
export const getCalendarDateMemoHandler = async ({ date, }) => {
|
|
4
|
+
try {
|
|
5
|
+
const calendarDateMemo = await httpClient.fetchURL({
|
|
6
|
+
path: `/v2/integration/calendar-date-memo/${encodeURIComponent(date)}`,
|
|
7
|
+
});
|
|
8
|
+
return jsonToolResponse({
|
|
9
|
+
targetDate: calendarDateMemo.targetDate,
|
|
10
|
+
memo: calendarDateMemo.memo ?? '',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error('Error getting calendar date memo:', error);
|
|
15
|
+
return errorToolResponse('Error getting calendar date memo');
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
1
2
|
export const getJapanCurrentTimeHandler = async () => {
|
|
2
3
|
try {
|
|
3
4
|
const now = new Date();
|
|
4
|
-
// 日本標準時(JST)でフォーマット
|
|
5
5
|
const jstTime = now.toLocaleString('ja-JP', { timeZone: 'Asia/Tokyo' });
|
|
6
|
-
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
text: `現在の日本時刻(JST)は: ${jstTime}`,
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
};
|
|
6
|
+
return jsonToolResponse({
|
|
7
|
+
timeZone: 'Asia/Tokyo',
|
|
8
|
+
currentTime: jstTime,
|
|
9
|
+
});
|
|
14
10
|
}
|
|
15
11
|
catch (error) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
type: 'text',
|
|
20
|
-
text: `日本時刻取得中にエラーが発生しました: ${error}`,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
};
|
|
12
|
+
console.error('Error getting Japan current time:', error);
|
|
13
|
+
return errorToolResponse('Error getting Japan current time');
|
|
24
14
|
}
|
|
25
15
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
2
3
|
export const getTodayCalendarHandler = async () => {
|
|
3
4
|
try {
|
|
4
5
|
const googleEvents = await httpClient.fetchURL({
|
|
@@ -8,62 +9,29 @@ export const getTodayCalendarHandler = async () => {
|
|
|
8
9
|
path: '/v2/integration/todo',
|
|
9
10
|
});
|
|
10
11
|
const filteredTasks = tasks.filter((task) => task.scheduledStartDate != null);
|
|
11
|
-
return {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
formatEventTime(event.start),
|
|
24
|
-
formatEventTime(event.end),
|
|
25
|
-
])
|
|
26
|
-
.join(','),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
type: 'text',
|
|
30
|
-
text: 'en: The following is a task. The following is the order:[task name, scheduled start date, scheduled end date]',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
type: 'text',
|
|
34
|
-
text: filteredTasks
|
|
35
|
-
.map((task) => [
|
|
36
|
-
task.label,
|
|
37
|
-
task.scheduledStartDate,
|
|
38
|
-
task.scheduledEndDate,
|
|
39
|
-
])
|
|
40
|
-
.join(','),
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
};
|
|
12
|
+
return jsonToolResponse({
|
|
13
|
+
events: (googleEvents.items ?? []).map((event) => ({
|
|
14
|
+
title: event.summary,
|
|
15
|
+
startDateTime: formatEventTime(event.start),
|
|
16
|
+
endDateTime: formatEventTime(event.end),
|
|
17
|
+
})),
|
|
18
|
+
tasks: filteredTasks.map((task) => ({
|
|
19
|
+
taskName: task.label,
|
|
20
|
+
scheduledStartDate: task.scheduledStartDate,
|
|
21
|
+
scheduledEndDate: task.scheduledEndDate,
|
|
22
|
+
})),
|
|
23
|
+
});
|
|
44
24
|
}
|
|
45
25
|
catch (error) {
|
|
46
26
|
console.error('Error in tool handler:', error);
|
|
47
|
-
return
|
|
48
|
-
content: [
|
|
49
|
-
{
|
|
50
|
-
type: 'text',
|
|
51
|
-
text: `Error in tool handler: ${error}`,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
};
|
|
27
|
+
return errorToolResponse('Error retrieving calendar events');
|
|
55
28
|
}
|
|
56
29
|
};
|
|
57
|
-
/**
|
|
58
|
-
* EventDateTime型から表示用の日時文字列を取得する
|
|
59
|
-
*/
|
|
60
30
|
const formatEventTime = (dateTime) => {
|
|
61
|
-
// 全日イベントの場合はdate、そうでない場合はdateTimeを使用
|
|
62
31
|
if (dateTime.date) {
|
|
63
|
-
return dateTime.date;
|
|
32
|
+
return dateTime.date;
|
|
64
33
|
}
|
|
65
34
|
if (dateTime.dateTime) {
|
|
66
|
-
// RFC3339形式の日時をより読みやすい形式に変換
|
|
67
35
|
const dt = new Date(dateTime.dateTime);
|
|
68
36
|
return dt.toLocaleString('ja-JP', {
|
|
69
37
|
year: 'numeric',
|
|
@@ -1,34 +1,19 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
2
3
|
export const getTodoCategoryListHandler = async () => {
|
|
3
4
|
try {
|
|
4
5
|
const categoryList = await httpClient.fetchURL({
|
|
5
6
|
path: '/v2/integration/categories',
|
|
6
7
|
});
|
|
7
|
-
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: 'text',
|
|
16
|
-
text: categoryList
|
|
17
|
-
.map((category) => [category.categoryUUID, category.label])
|
|
18
|
-
.join(','),
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
8
|
+
return jsonToolResponse({
|
|
9
|
+
categories: categoryList.map((category) => ({
|
|
10
|
+
categoryUUID: category.categoryUUID,
|
|
11
|
+
label: category.label,
|
|
12
|
+
})),
|
|
13
|
+
});
|
|
22
14
|
}
|
|
23
15
|
catch (error) {
|
|
24
16
|
console.error('Error in tool handler:', error);
|
|
25
|
-
return
|
|
26
|
-
content: [
|
|
27
|
-
{
|
|
28
|
-
type: 'text',
|
|
29
|
-
text: `Error in tool handler: ${error}`,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
17
|
+
return errorToolResponse('Error retrieving todo categories');
|
|
33
18
|
}
|
|
34
19
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
-
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
+
export const getTodoListHandler = async ({ categoryUUIDs, }) => {
|
|
3
4
|
try {
|
|
4
5
|
const categoryUUIDArray = categoryUUIDs ?? [];
|
|
5
6
|
const qs = categoryUUIDArray.length > 0
|
|
@@ -8,44 +9,23 @@ export const getTodoListHandler = async ({ categoryUUIDs }) => {
|
|
|
8
9
|
const tasks = await httpClient.fetchURL({
|
|
9
10
|
path: `/v2/integration/todo${qs}`,
|
|
10
11
|
});
|
|
11
|
-
return {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.map((todo) => [
|
|
26
|
-
todo.todoUUID,
|
|
27
|
-
todo.label,
|
|
28
|
-
todo.detail,
|
|
29
|
-
todo.scheduledStartDate,
|
|
30
|
-
todo.scheduledEndDate,
|
|
31
|
-
todo.priorityNumber,
|
|
32
|
-
todo.categoryLabel,
|
|
33
|
-
todo.url,
|
|
34
|
-
])
|
|
35
|
-
.join(','),
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
12
|
+
return jsonToolResponse({
|
|
13
|
+
tasks: tasks.map((todo) => ({
|
|
14
|
+
todoUUID: todo.todoUUID,
|
|
15
|
+
label: todo.label,
|
|
16
|
+
detail: todo.detail,
|
|
17
|
+
scheduledStartDate: todo.scheduledStartDate,
|
|
18
|
+
scheduledEndDate: todo.scheduledEndDate,
|
|
19
|
+
priorityNumber: todo.priorityNumber,
|
|
20
|
+
categoryUUID: todo.categoryUUID,
|
|
21
|
+
categoryLabel: todo.categoryLabel,
|
|
22
|
+
url: todo.url,
|
|
23
|
+
})),
|
|
24
|
+
guidance: 'The tasks with scheduled start dates that are today or in the past, and those with a priority of 2, should be addressed as soon as possible.',
|
|
25
|
+
});
|
|
39
26
|
}
|
|
40
27
|
catch (error) {
|
|
41
28
|
console.error('Error in tool handler:', error);
|
|
42
|
-
return
|
|
43
|
-
content: [
|
|
44
|
-
{
|
|
45
|
-
type: 'text',
|
|
46
|
-
text: `Error in tool handler: ${error}`,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
};
|
|
29
|
+
return errorToolResponse('Error retrieving tasks');
|
|
50
30
|
}
|
|
51
31
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
-
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
+
export const startActivityLogHandler = async ({ activityItemName, }) => {
|
|
3
4
|
try {
|
|
4
5
|
await httpClient.postJson({
|
|
5
6
|
path: '/v2/integration/activity-logs',
|
|
@@ -7,24 +8,13 @@ export const startActivityLogHandler = async ({ activityItemName }) => {
|
|
|
7
8
|
activityItemName: activityItemName,
|
|
8
9
|
},
|
|
9
10
|
});
|
|
10
|
-
return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
text: `Activity log for "${activityItemName}" started successfully.`,
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
};
|
|
11
|
+
return jsonToolResponse({
|
|
12
|
+
activityItemName,
|
|
13
|
+
started: true,
|
|
14
|
+
});
|
|
18
15
|
}
|
|
19
16
|
catch (error) {
|
|
20
17
|
console.error('Error starting activity log:', error);
|
|
21
|
-
return
|
|
22
|
-
content: [
|
|
23
|
-
{
|
|
24
|
-
type: 'text',
|
|
25
|
-
text: `Error starting activity log: ${error}`,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
};
|
|
18
|
+
return errorToolResponse('Error starting activity log');
|
|
29
19
|
}
|
|
30
20
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function jsonToolResponse(structuredContent) {
|
|
2
|
+
return {
|
|
3
|
+
structuredContent,
|
|
4
|
+
content: [
|
|
5
|
+
{
|
|
6
|
+
type: 'text',
|
|
7
|
+
text: JSON.stringify(structuredContent, null, 2),
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export function errorToolResponse(message) {
|
|
13
|
+
const structuredContent = {
|
|
14
|
+
error: {
|
|
15
|
+
message,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
structuredContent,
|
|
20
|
+
isError: true,
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: JSON.stringify(structuredContent, null, 2),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
+
export const updateCalendarDateMemoHandler = async ({ date, memo, }) => {
|
|
4
|
+
try {
|
|
5
|
+
const normalizedMemo = memo.trim();
|
|
6
|
+
await httpClient.putJson({
|
|
7
|
+
path: `/v2/integration/calendar-date-memo/${encodeURIComponent(date)}`,
|
|
8
|
+
body: {
|
|
9
|
+
memo: normalizedMemo,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
return jsonToolResponse({
|
|
13
|
+
targetDate: date,
|
|
14
|
+
memo: normalizedMemo,
|
|
15
|
+
updated: true,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error('Error updating calendar date memo:', error);
|
|
20
|
+
return errorToolResponse('Error updating calendar date memo');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
2
3
|
export const updateTaskHandler = async ({ todoUUID, isCompleted, scheduledStartDate, scheduledEndDate, url, detail, }) => {
|
|
3
4
|
try {
|
|
4
5
|
await httpClient.putJson({
|
|
5
|
-
path: `/v2/integration/todo/${todoUUID}`,
|
|
6
|
+
path: `/v2/integration/todo/${encodeURIComponent(todoUUID)}`,
|
|
6
7
|
body: {
|
|
7
8
|
isCompleted,
|
|
8
9
|
scheduledStartDate,
|
|
@@ -11,24 +12,14 @@ export const updateTaskHandler = async ({ todoUUID, isCompleted, scheduledStartD
|
|
|
11
12
|
detail,
|
|
12
13
|
},
|
|
13
14
|
});
|
|
14
|
-
return {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
15
|
+
return jsonToolResponse({
|
|
16
|
+
todoUUID,
|
|
17
|
+
isCompleted,
|
|
18
|
+
updated: true,
|
|
19
|
+
});
|
|
22
20
|
}
|
|
23
21
|
catch (error) {
|
|
24
22
|
console.error('Error updating task:', error);
|
|
25
|
-
return
|
|
26
|
-
content: [
|
|
27
|
-
{
|
|
28
|
-
type: 'text',
|
|
29
|
-
text: `Error updating task: ${error}`,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
};
|
|
23
|
+
return errorToolResponse('Error updating task');
|
|
33
24
|
}
|
|
34
25
|
};
|
package/build/index.js
CHANGED
|
@@ -5,17 +5,21 @@ import { startRemoteServer } from './remoteServer.js';
|
|
|
5
5
|
async function main() {
|
|
6
6
|
const args = process.argv.slice(2);
|
|
7
7
|
const firstArg = args[0];
|
|
8
|
-
const mode = (getArgValue(args, '--mode')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const mode = (getArgValue(args, '--mode') ??
|
|
9
|
+
(!firstArg || firstArg.startsWith('--') ? undefined : firstArg) ??
|
|
10
|
+
process.env.TOGELLO_MCP_MODE ??
|
|
11
|
+
'stdio').toLowerCase();
|
|
12
12
|
if (mode === 'remote') {
|
|
13
13
|
const host = getArgValue(args, '--host') ?? process.env.TOGELLO_MCP_HOST ?? '0.0.0.0';
|
|
14
14
|
const portString = getArgValue(args, '--port') ?? process.env.TOGELLO_MCP_PORT ?? '8081';
|
|
15
15
|
const authMode = parseRemoteAuthMode(getArgValue(args, '--auth-mode') ?? process.env.TOGELLO_MCP_AUTH_MODE);
|
|
16
16
|
const keepAliveMsString = process.env.TOGELLO_MCP_SSE_KEEPALIVE_MS;
|
|
17
|
+
validateRemoteAuthMode({ host, authMode });
|
|
17
18
|
const port = Number(portString);
|
|
18
|
-
if (!Number.isFinite(port) ||
|
|
19
|
+
if (!Number.isFinite(port) ||
|
|
20
|
+
!Number.isInteger(port) ||
|
|
21
|
+
port < 1 ||
|
|
22
|
+
port > 65535) {
|
|
19
23
|
throw new Error(`Invalid port: ${portString}`);
|
|
20
24
|
}
|
|
21
25
|
let keepAliveMs;
|
|
@@ -25,10 +29,14 @@ async function main() {
|
|
|
25
29
|
throw new Error(`Invalid TOGELLO_MCP_SSE_KEEPALIVE_MS: ${keepAliveMsString}`);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
32
|
+
const publicBaseUrl = getRemotePublicBaseUrl(port);
|
|
33
|
+
const oauthIssuer = getRemoteOAuthIssuer();
|
|
28
34
|
await startRemoteServer({
|
|
29
35
|
host,
|
|
30
36
|
port,
|
|
31
37
|
authMode,
|
|
38
|
+
publicBaseUrl,
|
|
39
|
+
oauthIssuer,
|
|
32
40
|
sseKeepAliveMs: keepAliveMs,
|
|
33
41
|
});
|
|
34
42
|
return;
|
|
@@ -50,6 +58,47 @@ function getArgValue(args, key) {
|
|
|
50
58
|
}
|
|
51
59
|
return args[index + 1];
|
|
52
60
|
}
|
|
61
|
+
function getEnvValue(name) {
|
|
62
|
+
const value = process.env[name]?.trim();
|
|
63
|
+
return value ? value : undefined;
|
|
64
|
+
}
|
|
65
|
+
function getRemotePublicBaseUrl(port) {
|
|
66
|
+
const publicBaseUrl = getEnvValue('TOGELLO_MCP_PUBLIC_BASE_URL');
|
|
67
|
+
if (publicBaseUrl) {
|
|
68
|
+
return assertAbsoluteHttpUrl('TOGELLO_MCP_PUBLIC_BASE_URL', publicBaseUrl);
|
|
69
|
+
}
|
|
70
|
+
if (getEnvValue('ENV') === 'production') {
|
|
71
|
+
throw new Error('TOGELLO_MCP_PUBLIC_BASE_URL is required in production');
|
|
72
|
+
}
|
|
73
|
+
return `http://localhost:${port}`;
|
|
74
|
+
}
|
|
75
|
+
function getRemoteOAuthIssuer() {
|
|
76
|
+
const oauthIssuer = getEnvValue('TOGELLO_OAUTH_ISSUER');
|
|
77
|
+
if (oauthIssuer) {
|
|
78
|
+
return assertAbsoluteHttpUrl('TOGELLO_OAUTH_ISSUER', oauthIssuer);
|
|
79
|
+
}
|
|
80
|
+
const apiBaseUrl = getEnvValue('TOGELLO_API_BASE_URL');
|
|
81
|
+
if (apiBaseUrl) {
|
|
82
|
+
return assertAbsoluteHttpUrl('TOGELLO_API_BASE_URL', apiBaseUrl);
|
|
83
|
+
}
|
|
84
|
+
if (getEnvValue('ENV') === 'production') {
|
|
85
|
+
throw new Error('TOGELLO_OAUTH_ISSUER or TOGELLO_API_BASE_URL is required in production');
|
|
86
|
+
}
|
|
87
|
+
return 'http://localhost:8000';
|
|
88
|
+
}
|
|
89
|
+
function assertAbsoluteHttpUrl(name, value) {
|
|
90
|
+
let parsed;
|
|
91
|
+
try {
|
|
92
|
+
parsed = new URL(value);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
throw new Error(`Invalid ${name}: ${value}`);
|
|
96
|
+
}
|
|
97
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
98
|
+
throw new Error(`Invalid ${name}: ${value}`);
|
|
99
|
+
}
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
53
102
|
function parseRemoteAuthMode(value) {
|
|
54
103
|
if (value === undefined) {
|
|
55
104
|
return 'passthrough';
|
|
@@ -60,3 +109,24 @@ function parseRemoteAuthMode(value) {
|
|
|
60
109
|
}
|
|
61
110
|
throw new Error(`Invalid TOGELLO_MCP_AUTH_MODE: ${value}`);
|
|
62
111
|
}
|
|
112
|
+
function validateRemoteAuthMode({ host, authMode, }) {
|
|
113
|
+
if (authMode !== 'env') {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!process.env.TOGELLO_API_TOKEN) {
|
|
117
|
+
throw new Error('TOGELLO_MCP_AUTH_MODE=env requires TOGELLO_API_TOKEN');
|
|
118
|
+
}
|
|
119
|
+
if (isLocalHost(host)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (process.env.TOGELLO_MCP_ALLOW_ENV_AUTH === 'true') {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
throw new Error('TOGELLO_MCP_AUTH_MODE=env shares one TOGELLO_API_TOKEN with every remote client. Use passthrough auth for public remote MCP, or set TOGELLO_MCP_ALLOW_ENV_AUTH=true explicitly for a trusted deployment.');
|
|
126
|
+
}
|
|
127
|
+
function isLocalHost(host) {
|
|
128
|
+
const normalizedHost = host.trim().toLowerCase();
|
|
129
|
+
return (normalizedHost === 'localhost' ||
|
|
130
|
+
normalizedHost === '127.0.0.1' ||
|
|
131
|
+
normalizedHost === '::1');
|
|
132
|
+
}
|
package/build/mcpServer.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { runWithUpstreamToken } from './upstreamTokenContext.js';
|
|
4
3
|
import { completeActivityLogHandler } from './handlers/tool/completeActivityLogHandler.js';
|
|
5
4
|
import { createTaskHandler } from './handlers/tool/createTaskHandler.js';
|
|
6
5
|
import { getActivityItemListHandler } from './handlers/tool/getActivityItemListHandler.js';
|
|
7
6
|
import { getActivityLogListHandler } from './handlers/tool/getActivityLogListHandler.js';
|
|
7
|
+
import { getCalendarDateMemoHandler } from './handlers/tool/getCalendarDateMemoHandler.js';
|
|
8
8
|
import { getJapanCurrentTimeHandler } from './handlers/tool/getJapanCurrentTimeHandler.js';
|
|
9
9
|
import { getTodayCalendarHandler } from './handlers/tool/getTodayCalendarHandler.js';
|
|
10
10
|
import { getTodoCategoryListHandler } from './handlers/tool/getTodoCategoryListHandler.js';
|
|
11
11
|
import { getTodoListHandler } from './handlers/tool/getTodoListHandler.js';
|
|
12
12
|
import { startActivityLogHandler } from './handlers/tool/startActivityLogHandler.js';
|
|
13
|
+
import { errorToolResponse } from './handlers/tool/toolResponse.js';
|
|
14
|
+
import { updateCalendarDateMemoHandler } from './handlers/tool/updateCalendarDateMemoHandler.js';
|
|
13
15
|
import { updateTaskHandler } from './handlers/tool/updateTaskHandler.js';
|
|
14
|
-
|
|
16
|
+
import { runWithUpstreamToken } from './upstreamTokenContext.js';
|
|
17
|
+
const calendarDateMemoDateSchema = z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(/^\d{4}-\d{2}-\d{2}$/, 'Invalid date format, expected YYYY-MM-DD');
|
|
20
|
+
const readOnlyToolAnnotations = {
|
|
21
|
+
readOnlyHint: true,
|
|
22
|
+
};
|
|
23
|
+
function withUpstreamToken(cb, resolveUpstreamToken, requireUpstreamToken = false) {
|
|
15
24
|
return async (args, extra) => {
|
|
16
25
|
const token = resolveUpstreamToken?.(extra.sessionId);
|
|
26
|
+
if (!token && requireUpstreamToken) {
|
|
27
|
+
return errorToolResponse('Remote passthrough auth requires a Togello API token from the client Authorization header.');
|
|
28
|
+
}
|
|
17
29
|
if (!token) {
|
|
18
30
|
return await cb(args, extra);
|
|
19
31
|
}
|
|
@@ -24,63 +36,133 @@ export function createMcpServer(options = {}) {
|
|
|
24
36
|
const server = new McpServer({
|
|
25
37
|
name: 'togello',
|
|
26
38
|
version: '1.0.0',
|
|
39
|
+
}, {
|
|
27
40
|
capabilities: {
|
|
28
41
|
resources: {},
|
|
29
42
|
tools: {},
|
|
30
43
|
},
|
|
31
44
|
});
|
|
32
|
-
server.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
45
|
+
server.registerTool('get-tasks-list', {
|
|
46
|
+
description: 'Retrieves incomplete tasks from the TODO feature. Recognizes task uuid / task name / detail / scheduled start date and time / scheduled end date and time / priority / category',
|
|
47
|
+
inputSchema: {
|
|
48
|
+
categoryUUIDs: z
|
|
49
|
+
.array(z.string())
|
|
50
|
+
.optional()
|
|
51
|
+
.describe('Filters tasks by specified category UUIDs.'),
|
|
52
|
+
},
|
|
53
|
+
annotations: readOnlyToolAnnotations,
|
|
54
|
+
}, withUpstreamToken(getTodoListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
55
|
+
server.registerTool('create-task', {
|
|
56
|
+
description: 'Creates a new task in the TODO feature.',
|
|
57
|
+
inputSchema: {
|
|
58
|
+
taskName: z.string().describe('create task name'),
|
|
59
|
+
categoryUUID: z
|
|
60
|
+
.string()
|
|
61
|
+
.optional()
|
|
62
|
+
.describe('category UUID. category UUID of get-todo-category-list'),
|
|
63
|
+
scheduledStartDate: z
|
|
64
|
+
.string()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('Scheduled start date in ISO format.'),
|
|
67
|
+
scheduledEndDate: z
|
|
68
|
+
.string()
|
|
69
|
+
.optional()
|
|
70
|
+
.describe('Scheduled end date in ISO format.'),
|
|
71
|
+
url: z
|
|
72
|
+
.string()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe('Optional URL associated with the task.'),
|
|
75
|
+
detail: z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Optional detail associated with the task.'),
|
|
79
|
+
},
|
|
80
|
+
}, withUpstreamToken(createTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
81
|
+
server.registerTool('update-task', {
|
|
82
|
+
description: 'Updates a task in the TODO feature.',
|
|
83
|
+
inputSchema: {
|
|
84
|
+
todoUUID: z
|
|
85
|
+
.string()
|
|
86
|
+
.uuid()
|
|
87
|
+
.describe('Task UUID. Please specify the task uuid (todo uuid) obtained from get-tasks-list. You cannot use this tool without specifying it.'),
|
|
88
|
+
isCompleted: z
|
|
89
|
+
.boolean()
|
|
90
|
+
.describe('Required. Updates the completion status of the task. If true, it is completed.'),
|
|
91
|
+
scheduledStartDate: z
|
|
92
|
+
.string()
|
|
93
|
+
.optional()
|
|
94
|
+
.describe('Scheduled start date in ISO format. If the user does not specify, the information obtained from get-tasks-list is passed.'),
|
|
95
|
+
scheduledEndDate: z
|
|
96
|
+
.string()
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Scheduled end date in ISO format. If the user does not specify, the information obtained from get-tasks-list is passed.'),
|
|
99
|
+
url: z
|
|
100
|
+
.string()
|
|
101
|
+
.optional()
|
|
102
|
+
.describe('Optional URL associated with the task. If the user does not specify, the information obtained from get-tasks-list is passed.'),
|
|
103
|
+
detail: z
|
|
104
|
+
.string()
|
|
105
|
+
.optional()
|
|
106
|
+
.describe('Optional detail associated with the task. If the user does not specify, the information obtained from get-tasks-list is passed.'),
|
|
107
|
+
},
|
|
108
|
+
}, withUpstreamToken(updateTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
109
|
+
server.registerTool('get-calendar-date-memo', {
|
|
110
|
+
description: 'Retrieves a calendar date memo for the specified date. Recognizes target date and memo content.',
|
|
111
|
+
inputSchema: {
|
|
112
|
+
date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
|
|
113
|
+
},
|
|
114
|
+
annotations: readOnlyToolAnnotations,
|
|
115
|
+
}, withUpstreamToken(getCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
116
|
+
server.registerTool('update-calendar-date-memo', {
|
|
117
|
+
description: 'Updates a calendar date memo for the specified date.',
|
|
118
|
+
inputSchema: {
|
|
119
|
+
date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
|
|
120
|
+
memo: z
|
|
121
|
+
.string()
|
|
122
|
+
.describe('Memo content for the date. Pass an empty or whitespace-only string to clear the memo.'),
|
|
123
|
+
},
|
|
124
|
+
}, withUpstreamToken(updateCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
125
|
+
server.registerTool('get-todo-category-list', {
|
|
126
|
+
description: 'Retrieves the list of categories from the TODO feature. Recognizes category name / category UUID',
|
|
127
|
+
inputSchema: {},
|
|
128
|
+
annotations: readOnlyToolAnnotations,
|
|
129
|
+
}, withUpstreamToken(getTodoCategoryListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
130
|
+
server.registerTool('get-today-calendar', {
|
|
131
|
+
description: 'Retrieves scheduled events for yesterday/today/tomorrow from the linked Google Calendar. Recognizes event name / start date and time / end date and time. ',
|
|
132
|
+
inputSchema: {},
|
|
133
|
+
annotations: readOnlyToolAnnotations,
|
|
134
|
+
}, withUpstreamToken(getTodayCalendarHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
135
|
+
server.registerTool('get-activity-item-list', {
|
|
136
|
+
description: 'Retrieves the list of activity items from the integration feature. Recognizes activity item UUID / item name',
|
|
137
|
+
inputSchema: {},
|
|
138
|
+
annotations: readOnlyToolAnnotations,
|
|
139
|
+
}, withUpstreamToken(getActivityItemListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
140
|
+
server.registerTool('get-activity-log-list', {
|
|
141
|
+
description: 'Retrieves the list of activity logs from the integration feature. Since it is a record of what the person has done, if all the end dates are filled in, this person is not doing anything now. If there is one with a null end date, there should be at most one, and if there is one, it means that the person is doing it now. Recognizes activity log UUID / start date and time / end date and time / item name.',
|
|
142
|
+
inputSchema: {},
|
|
143
|
+
annotations: readOnlyToolAnnotations,
|
|
144
|
+
}, withUpstreamToken(getActivityLogListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
145
|
+
server.registerTool('start-activity-log', {
|
|
146
|
+
description: 'Starts an activity log.',
|
|
147
|
+
inputSchema: {
|
|
148
|
+
activityItemName: z
|
|
149
|
+
.string()
|
|
150
|
+
.describe('You must specify a valid itemName obtained from get-activity-item-list. This tool requires a pre-existing activity item.'),
|
|
151
|
+
},
|
|
152
|
+
}, withUpstreamToken(startActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
153
|
+
server.registerTool('complete-activity-log', {
|
|
154
|
+
description: 'Completes an activity log.',
|
|
155
|
+
inputSchema: {
|
|
156
|
+
activityLogUUID: z
|
|
157
|
+
.string()
|
|
158
|
+
.uuid()
|
|
159
|
+
.describe('You must specify a valid activityLogUUID obtained from get-activity-log-list. This tool requires an existing activity log.'),
|
|
160
|
+
},
|
|
161
|
+
}, withUpstreamToken(completeActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
162
|
+
server.registerTool('get-japan-current-time', {
|
|
163
|
+
description: 'Returns the current time in Japan (JST).',
|
|
164
|
+
inputSchema: {},
|
|
165
|
+
annotations: readOnlyToolAnnotations,
|
|
166
|
+
}, withUpstreamToken(getJapanCurrentTimeHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
85
167
|
return server;
|
|
86
168
|
}
|
package/build/remoteServer.js
CHANGED
|
@@ -2,9 +2,21 @@ import { createServer } from 'node:http';
|
|
|
2
2
|
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
3
3
|
import { parseBearerToken } from './bearerToken.js';
|
|
4
4
|
import { createMcpServer } from './mcpServer.js';
|
|
5
|
+
const protectedResourceMetadataPath = '/.well-known/oauth-protected-resource';
|
|
6
|
+
const supportedScopes = [
|
|
7
|
+
'offline_access',
|
|
8
|
+
'tasks:read',
|
|
9
|
+
'tasks:write',
|
|
10
|
+
'activity:read',
|
|
11
|
+
'activity:write',
|
|
12
|
+
'calendar:read',
|
|
13
|
+
];
|
|
5
14
|
export async function startRemoteServer(options) {
|
|
6
15
|
const ssePath = options.ssePath ?? '/sse';
|
|
7
16
|
const messagePath = options.messagePath ?? '/message';
|
|
17
|
+
const publicBaseUrl = trimTrailingSlash(options.publicBaseUrl);
|
|
18
|
+
const oauthIssuer = options.oauthIssuer;
|
|
19
|
+
const protectedResourceMetadataUrl = `${publicBaseUrl}${protectedResourceMetadataPath}`;
|
|
8
20
|
const sessions = new Map();
|
|
9
21
|
const resolveUpstreamToken = (sessionId) => {
|
|
10
22
|
if (!sessionId) {
|
|
@@ -15,15 +27,37 @@ export async function startRemoteServer(options) {
|
|
|
15
27
|
const server = createServer(async (req, res) => {
|
|
16
28
|
try {
|
|
17
29
|
const requestUrl = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
30
|
+
if (requestUrl.pathname === protectedResourceMetadataPath) {
|
|
31
|
+
if (req.method === 'OPTIONS') {
|
|
32
|
+
writeOptionsResponse(res);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (req.method === 'GET') {
|
|
36
|
+
writeJsonResponse(res, {
|
|
37
|
+
resource: publicBaseUrl,
|
|
38
|
+
authorization_servers: [oauthIssuer],
|
|
39
|
+
scopes_supported: supportedScopes,
|
|
40
|
+
bearer_methods_supported: ['header'],
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
18
45
|
if (req.method === 'GET' && requestUrl.pathname === ssePath) {
|
|
19
46
|
const upstreamToken = getUpstreamTokenForSse(req.headers.authorization, options.authMode);
|
|
20
47
|
if (options.authMode === 'passthrough' && !upstreamToken) {
|
|
21
|
-
res
|
|
48
|
+
res
|
|
49
|
+
.writeHead(401, {
|
|
50
|
+
'WWW-Authenticate': `Bearer resource_metadata="${protectedResourceMetadataUrl}"`,
|
|
51
|
+
})
|
|
52
|
+
.end('Unauthorized');
|
|
22
53
|
return;
|
|
23
54
|
}
|
|
24
55
|
const transport = new SSEServerTransport(messagePath, res);
|
|
25
56
|
sessions.set(transport.sessionId, { transport, upstreamToken });
|
|
26
|
-
const mcpServer = createMcpServer({
|
|
57
|
+
const mcpServer = createMcpServer({
|
|
58
|
+
resolveUpstreamToken,
|
|
59
|
+
requireUpstreamToken: options.authMode === 'passthrough',
|
|
60
|
+
});
|
|
27
61
|
let closed = false;
|
|
28
62
|
const keepAliveMs = options.sseKeepAliveMs;
|
|
29
63
|
const keepAliveTimer = keepAliveMs && keepAliveMs > 0
|
|
@@ -90,6 +124,27 @@ export async function startRemoteServer(options) {
|
|
|
90
124
|
});
|
|
91
125
|
console.log(`Remote MCP server listening on http://${options.host}:${options.port}${ssePath}`);
|
|
92
126
|
}
|
|
127
|
+
function trimTrailingSlash(url) {
|
|
128
|
+
return url.replace(/\/+$/, '');
|
|
129
|
+
}
|
|
130
|
+
function writeJsonResponse(res, body) {
|
|
131
|
+
res.writeHead(200, {
|
|
132
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
133
|
+
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
|
134
|
+
'Access-Control-Allow-Origin': '*',
|
|
135
|
+
'Cache-Control': 'no-store',
|
|
136
|
+
'Content-Type': 'application/json',
|
|
137
|
+
});
|
|
138
|
+
res.end(JSON.stringify(body));
|
|
139
|
+
}
|
|
140
|
+
function writeOptionsResponse(res) {
|
|
141
|
+
res.writeHead(204, {
|
|
142
|
+
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
143
|
+
'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
|
144
|
+
'Access-Control-Allow-Origin': '*',
|
|
145
|
+
});
|
|
146
|
+
res.end();
|
|
147
|
+
}
|
|
93
148
|
function getUpstreamTokenForSse(authorizationHeader, authMode) {
|
|
94
149
|
if (authMode === 'env') {
|
|
95
150
|
return process.env.TOGELLO_API_TOKEN;
|
package/package.json
CHANGED
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "togello-mcp-server",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"
|
|
4
|
+
"version": "1.0.27",
|
|
5
|
+
"description": "MCP server for Togello tasks, calendar memos, calendar events, and activity logs.",
|
|
6
|
+
"main": "build/index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"build": "tsc && chmod 755 build/index.js",
|
|
8
9
|
"codex:preclone": "bash scripts/codex-cloud/preclone.sh",
|
|
9
10
|
"start": "node build/index.js",
|
|
10
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
12
|
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"togello",
|
|
17
|
+
"chatgpt",
|
|
18
|
+
"tasks",
|
|
19
|
+
"calendar",
|
|
20
|
+
"activity"
|
|
21
|
+
],
|
|
22
|
+
"author": "Toru Takagi",
|
|
14
23
|
"license": "ISC",
|
|
15
|
-
"
|
|
24
|
+
"homepage": "https://togello.com/sign",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/Toru-Takagi/togello-mcp-server.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/Toru-Takagi/togello-mcp-server/issues"
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22"
|
|
34
|
+
},
|
|
16
35
|
"dependencies": {
|
|
17
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
18
|
-
"zod": "^3.
|
|
36
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
37
|
+
"zod": "^3.25.76"
|
|
19
38
|
},
|
|
20
39
|
"devDependencies": {
|
|
21
40
|
"@types/node": "^22.14.1",
|
|
22
41
|
"typescript": "^5.8.3"
|
|
23
42
|
},
|
|
24
43
|
"bin": {
|
|
25
|
-
"togello": "build/index.js"
|
|
44
|
+
"togello": "build/index.js",
|
|
45
|
+
"togello-mcp-server": "build/index.js"
|
|
26
46
|
},
|
|
27
47
|
"files": [
|
|
28
48
|
"build"
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { httpClient } from "../client.js";
|
|
2
|
-
export const tasksHandler = async (uri, {}) => {
|
|
3
|
-
try {
|
|
4
|
-
const tasks = await httpClient.fetchURL({
|
|
5
|
-
path: "/v2/integration/todo",
|
|
6
|
-
});
|
|
7
|
-
return {
|
|
8
|
-
contents: [
|
|
9
|
-
{
|
|
10
|
-
type: "text",
|
|
11
|
-
uri: uri.href,
|
|
12
|
-
text: tasks
|
|
13
|
-
.map((todo) => JSON.stringify({
|
|
14
|
-
label: todo.label,
|
|
15
|
-
scheduledStartDate: todo.scheduledStartDate,
|
|
16
|
-
scheduledEndDate: todo.scheduledEndDate,
|
|
17
|
-
priorityNumber: todo.priorityNumber,
|
|
18
|
-
}))
|
|
19
|
-
.join(","),
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error("Error in resource handler:", error);
|
|
26
|
-
return {
|
|
27
|
-
contents: [
|
|
28
|
-
{
|
|
29
|
-
type: "text",
|
|
30
|
-
uri: uri.href,
|
|
31
|
-
text: `Error in resource handler: ${error}`,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
};
|