togello-mcp-server 1.0.42 → 1.0.44
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 +16 -3
- package/build/client.js +13 -0
- package/build/handlers/tool/deleteTaskHandler.js +13 -0
- package/build/index.js +2 -3
- package/build/mcpServer.js +41 -28
- package/build/remoteServer.js +48 -20
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -9,6 +9,14 @@ https://togello.com/sign
|
|
|
9
9
|
- Node.js 22 or later
|
|
10
10
|
- A Togello API token
|
|
11
11
|
|
|
12
|
+
## Protocol compatibility
|
|
13
|
+
|
|
14
|
+
The server uses MCP TypeScript SDK v2. Stdio and `/mcp` support the MCP `2026-07-28` protocol and legacy clients using the `initialize` handshake. The `/mcp` endpoint retains sessions for legacy clients; modern requests are stateless. `/sse` and `/message` remain available for legacy clients.
|
|
15
|
+
|
|
16
|
+
Modern remote requests must each include an `Authorization: Bearer ...` header. Their credentials are isolated per request, including when a legacy session ID is supplied. Legacy connections retain the token provided when their session was created. The existing OAuth metadata URLs and authentication modes are unchanged.
|
|
17
|
+
|
|
18
|
+
MCP Events are not implemented.
|
|
19
|
+
|
|
12
20
|
## Local MCP With npm
|
|
13
21
|
|
|
14
22
|
Use this for desktop clients and local developer tools that launch MCP servers over stdio.
|
|
@@ -45,7 +53,7 @@ Connect remote MCP clients to:
|
|
|
45
53
|
https://your-domain.example/mcp
|
|
46
54
|
```
|
|
47
55
|
|
|
48
|
-
`passthrough` auth
|
|
56
|
+
`passthrough` auth uses the connecting user's Togello API token from the `Authorization: Bearer ...` header. Modern requests require this header on every request; legacy sessions retain the connection's token. Use this mode for published remote MCP servers.
|
|
49
57
|
|
|
50
58
|
`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
59
|
|
|
@@ -75,6 +83,7 @@ Write tools return JSON. Failed tool responses also return JSON and are marked w
|
|
|
75
83
|
|
|
76
84
|
- `create-task`: Creates a TODO task.
|
|
77
85
|
- `update-task`: Updates a TODO task, including category assignment or removal.
|
|
86
|
+
- `delete-task`: Permanently deletes one TODO task by `todoUUID` from `get-tasks-list`. Use `update-task` with `status: "DONE"` to complete a task. To find completed tasks for deletion, use `completionStatus: "COMPLETED"`. This destructive, idempotent tool returns `{ "todoUUID": "...", "deleted": true }` after a successful API response, including when no task owned by the caller matches. Success does not prove that a task previously existed. Ambiguous targets must be clarified before deletion.
|
|
78
87
|
- `update-calendar-date-memo`: Updates or clears a calendar date memo.
|
|
79
88
|
- `start-activity-log`: Starts an activity log.
|
|
80
89
|
- `complete-activity-log`: Completes an activity log.
|
|
@@ -82,10 +91,14 @@ Write tools return JSON. Failed tool responses also return JSON and are marked w
|
|
|
82
91
|
## Development
|
|
83
92
|
|
|
84
93
|
```bash
|
|
85
|
-
npm
|
|
86
|
-
npm
|
|
94
|
+
npm ci
|
|
95
|
+
npm test
|
|
87
96
|
```
|
|
88
97
|
|
|
98
|
+
The protocol tests exercise SDK v2 modern clients and SDK v1.29.0 legacy clients over stdio, Streamable HTTP, and legacy SSE against a local mock API. They verify the 12 existing tool contracts and the added deletion tool, read/write/delete results, request credential isolation, protocol header errors, body limits, metadata, and legacy session lifecycle. `test/fixtures/v1-tools.json` records `tools/list` from server 1.0.42 at commit `558c2c2fda81f7c8b20f443afa1bf5e554a72dad`; comparisons allow the SDK's JSON Schema dialect and wire-format changes.
|
|
99
|
+
|
|
100
|
+
SDK-facing schemas use Zod 4. UUID fields retain the prior permissive UUID syntax, and date-time fields retain their previous Zod 3 validation through the compatibility export included in the Zod package.
|
|
101
|
+
|
|
89
102
|
## MCP Review
|
|
90
103
|
|
|
91
104
|
Certified
|
package/build/client.js
CHANGED
|
@@ -8,6 +8,19 @@ function getApiTokenOrThrow() {
|
|
|
8
8
|
return token;
|
|
9
9
|
}
|
|
10
10
|
export const httpClient = {
|
|
11
|
+
delete: async ({ path }) => {
|
|
12
|
+
const token = getApiTokenOrThrow();
|
|
13
|
+
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
14
|
+
method: 'DELETE',
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${token}`,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
throw new Error(`response status: ${response.status}`);
|
|
21
|
+
}
|
|
22
|
+
await response.arrayBuffer();
|
|
23
|
+
},
|
|
11
24
|
fetchURL: async ({ path }) => {
|
|
12
25
|
const token = getApiTokenOrThrow();
|
|
13
26
|
const url = `${API_BASE_URL}${path}`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { httpClient } from '../../client.js';
|
|
2
|
+
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
+
export const deleteTaskHandler = async ({ todoUUID }) => {
|
|
4
|
+
try {
|
|
5
|
+
await httpClient.delete({
|
|
6
|
+
path: `/v2/integration/todo/${encodeURIComponent(todoUUID)}`,
|
|
7
|
+
});
|
|
8
|
+
return jsonToolResponse({ todoUUID, deleted: true });
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return errorToolResponse('Error deleting task');
|
|
12
|
+
}
|
|
13
|
+
};
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { serveStdio } from '@modelcontextprotocol/server/stdio';
|
|
3
3
|
import { createMcpServer } from './mcpServer.js';
|
|
4
4
|
import { startRemoteServer } from './remoteServer.js';
|
|
5
5
|
async function main() {
|
|
@@ -47,8 +47,7 @@ async function main() {
|
|
|
47
47
|
if (mode !== 'stdio') {
|
|
48
48
|
throw new Error(`Unknown mode: ${mode}`);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
await server.connect(new StdioServerTransport());
|
|
50
|
+
serveStdio(() => createMcpServer());
|
|
52
51
|
}
|
|
53
52
|
main().catch((error) => {
|
|
54
53
|
console.error('Fatal error in main():', error);
|
package/build/mcpServer.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { z as legacyZod } from 'zod/v3';
|
|
3
4
|
import { completeActivityLogHandler } from './handlers/tool/completeActivityLogHandler.js';
|
|
4
5
|
import { createTaskHandler } from './handlers/tool/createTaskHandler.js';
|
|
6
|
+
import { deleteTaskHandler } from './handlers/tool/deleteTaskHandler.js';
|
|
5
7
|
import { getActivityItemListHandler } from './handlers/tool/getActivityItemListHandler.js';
|
|
6
8
|
import { getActivityLogListHandler } from './handlers/tool/getActivityLogListHandler.js';
|
|
7
9
|
import { getCalendarDateMemoHandler } from './handlers/tool/getCalendarDateMemoHandler.js';
|
|
@@ -17,7 +19,11 @@ import { runWithUpstreamToken } from './upstreamTokenContext.js';
|
|
|
17
19
|
const calendarDateMemoDateSchema = z
|
|
18
20
|
.string()
|
|
19
21
|
.regex(/^\d{4}-\d{2}-\d{2}$/, 'Invalid date format, expected YYYY-MM-DD');
|
|
20
|
-
const
|
|
22
|
+
const legacyDateTimeSchema = legacyZod.string().datetime({ offset: true });
|
|
23
|
+
const rfc3339DateTimeSchema = z
|
|
24
|
+
.string()
|
|
25
|
+
.refine((value) => legacyDateTimeSchema.safeParse(value).success)
|
|
26
|
+
.meta({ format: 'date-time' });
|
|
21
27
|
const readOnlyToolAnnotations = {
|
|
22
28
|
readOnlyHint: true,
|
|
23
29
|
openWorldHint: false,
|
|
@@ -57,7 +63,7 @@ export function createMcpServer(options = {}) {
|
|
|
57
63
|
});
|
|
58
64
|
server.registerTool('get-tasks-list', {
|
|
59
65
|
description: 'Retrieves tasks from the TODO feature. By default it returns incomplete tasks. For tasks completed yesterday or during another period, set completionStatus to COMPLETED and pass completedStartDate and completedEndDate as RFC3339 date-times. Recognizes task uuid / task name / status / detail / completed date and time / scheduled start date and time / scheduled end date and time / deadline date and time / priority / category',
|
|
60
|
-
inputSchema: {
|
|
66
|
+
inputSchema: z.object({
|
|
61
67
|
categoryUUIDs: z
|
|
62
68
|
.array(z.string())
|
|
63
69
|
.optional()
|
|
@@ -72,12 +78,12 @@ export function createMcpServer(options = {}) {
|
|
|
72
78
|
completedEndDate: rfc3339DateTimeSchema
|
|
73
79
|
.optional()
|
|
74
80
|
.describe('Exclusive completed-at range end in RFC3339 format, for example today at 00:00:00+09:00 when retrieving yesterday.'),
|
|
75
|
-
},
|
|
81
|
+
}),
|
|
76
82
|
annotations: readOnlyToolAnnotations,
|
|
77
83
|
}, withUpstreamToken(getTodoListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
78
84
|
server.registerTool('create-task', {
|
|
79
85
|
description: 'Creates a new task in the TODO feature.',
|
|
80
|
-
inputSchema: {
|
|
86
|
+
inputSchema: z.object({
|
|
81
87
|
taskName: z.string().describe('create task name'),
|
|
82
88
|
status: z
|
|
83
89
|
.enum(['TODO', 'PENDING', 'DOING', 'DONE'])
|
|
@@ -107,15 +113,14 @@ export function createMcpServer(options = {}) {
|
|
|
107
113
|
.string()
|
|
108
114
|
.optional()
|
|
109
115
|
.describe('Optional detail associated with the task.'),
|
|
110
|
-
},
|
|
116
|
+
}),
|
|
111
117
|
annotations: privateWriteToolAnnotations,
|
|
112
118
|
}, withUpstreamToken(createTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
113
119
|
server.registerTool('update-task', {
|
|
114
120
|
description: 'Updates a task in the TODO feature.',
|
|
115
|
-
inputSchema: {
|
|
121
|
+
inputSchema: z.object({
|
|
116
122
|
todoUUID: z
|
|
117
|
-
.
|
|
118
|
-
.uuid()
|
|
123
|
+
.guid()
|
|
119
124
|
.describe('Task UUID. Please specify the task uuid (todo uuid) obtained from get-tasks-list. You cannot use this tool without specifying it.'),
|
|
120
125
|
taskName: z
|
|
121
126
|
.string()
|
|
@@ -130,8 +135,7 @@ export function createMcpServer(options = {}) {
|
|
|
130
135
|
.optional()
|
|
131
136
|
.describe('Optional. Updates the todo status directly. Use this to switch tasks between TODO, PENDING, DOING, and DONE.'),
|
|
132
137
|
categoryUUID: z
|
|
133
|
-
.
|
|
134
|
-
.uuid()
|
|
138
|
+
.guid()
|
|
135
139
|
.nullable()
|
|
136
140
|
.optional()
|
|
137
141
|
.describe('Optional category UUID associated with the task. Use get-todo-category-list to obtain a valid category UUID. Set to null to remove the current category. If omitted, the current value is kept.'),
|
|
@@ -155,44 +159,54 @@ export function createMcpServer(options = {}) {
|
|
|
155
159
|
.string()
|
|
156
160
|
.optional()
|
|
157
161
|
.describe('Optional detail associated with the task. If omitted, the current value is kept.'),
|
|
158
|
-
},
|
|
162
|
+
}),
|
|
159
163
|
annotations: privateOverwriteToolAnnotations,
|
|
160
164
|
}, withUpstreamToken(updateTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
165
|
+
server.registerTool('delete-task', {
|
|
166
|
+
description: 'Permanently deletes a single task from the TODO feature. Use only when the user requests deletion or removal. Specify the todoUUID obtained from get-tasks-list; clarify the target if ambiguous. To complete a task, use update-task with status DONE. To find completed tasks, call get-tasks-list with completionStatus COMPLETED. Repeated deletion succeeds when no task owned by the caller matches; success does not confirm that a task previously existed.',
|
|
167
|
+
inputSchema: z.strictObject({
|
|
168
|
+
todoUUID: z.guid().describe('Task UUID obtained from get-tasks-list.'),
|
|
169
|
+
}),
|
|
170
|
+
annotations: {
|
|
171
|
+
...privateOverwriteToolAnnotations,
|
|
172
|
+
idempotentHint: true,
|
|
173
|
+
},
|
|
174
|
+
}, withUpstreamToken(deleteTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
161
175
|
server.registerTool('get-calendar-date-memo', {
|
|
162
176
|
description: 'Retrieves a calendar date memo for the specified date. Recognizes target date and memo content.',
|
|
163
|
-
inputSchema: {
|
|
177
|
+
inputSchema: z.object({
|
|
164
178
|
date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
|
|
165
|
-
},
|
|
179
|
+
}),
|
|
166
180
|
annotations: readOnlyToolAnnotations,
|
|
167
181
|
}, withUpstreamToken(getCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
168
182
|
server.registerTool('update-calendar-date-memo', {
|
|
169
183
|
description: 'Updates a calendar date memo for the specified date.',
|
|
170
|
-
inputSchema: {
|
|
184
|
+
inputSchema: z.object({
|
|
171
185
|
date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
|
|
172
186
|
memo: z
|
|
173
187
|
.string()
|
|
174
188
|
.describe('Memo content for the date. Pass an empty or whitespace-only string to clear the memo.'),
|
|
175
|
-
},
|
|
189
|
+
}),
|
|
176
190
|
annotations: privateOverwriteToolAnnotations,
|
|
177
191
|
}, withUpstreamToken(updateCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
178
192
|
server.registerTool('get-todo-category-list', {
|
|
179
193
|
description: 'Retrieves the list of categories from the TODO feature. Recognizes category name / category UUID',
|
|
180
|
-
inputSchema: {},
|
|
194
|
+
inputSchema: z.object({}),
|
|
181
195
|
annotations: readOnlyToolAnnotations,
|
|
182
196
|
}, withUpstreamToken(getTodoCategoryListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
183
197
|
server.registerTool('get-today-calendar', {
|
|
184
198
|
description: 'Retrieves scheduled events for yesterday/today/tomorrow from the linked Google Calendar. Recognizes event name / start date and time / end date and time. ',
|
|
185
|
-
inputSchema: {},
|
|
199
|
+
inputSchema: z.object({}),
|
|
186
200
|
annotations: readOnlyToolAnnotations,
|
|
187
201
|
}, withUpstreamToken(getTodayCalendarHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
188
202
|
server.registerTool('get-activity-item-list', {
|
|
189
203
|
description: 'Retrieves the list of activity items from the integration feature. Recognizes activity item UUID / item name',
|
|
190
|
-
inputSchema: {},
|
|
204
|
+
inputSchema: z.object({}),
|
|
191
205
|
annotations: readOnlyToolAnnotations,
|
|
192
206
|
}, withUpstreamToken(getActivityItemListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
193
207
|
server.registerTool('get-activity-log-list', {
|
|
194
208
|
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.',
|
|
195
|
-
inputSchema: {
|
|
209
|
+
inputSchema: z.object({
|
|
196
210
|
limit: z
|
|
197
211
|
.number()
|
|
198
212
|
.int()
|
|
@@ -200,31 +214,30 @@ export function createMcpServer(options = {}) {
|
|
|
200
214
|
.max(300)
|
|
201
215
|
.optional()
|
|
202
216
|
.describe('Optional maximum number of activity logs to retrieve. Defaults to 300.'),
|
|
203
|
-
},
|
|
217
|
+
}),
|
|
204
218
|
annotations: readOnlyToolAnnotations,
|
|
205
219
|
}, withUpstreamToken(getActivityLogListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
206
220
|
server.registerTool('start-activity-log', {
|
|
207
221
|
description: 'Starts an activity log.',
|
|
208
|
-
inputSchema: {
|
|
222
|
+
inputSchema: z.object({
|
|
209
223
|
activityItemName: z
|
|
210
224
|
.string()
|
|
211
225
|
.describe('You must specify a valid itemName obtained from get-activity-item-list. This tool requires a pre-existing activity item.'),
|
|
212
|
-
},
|
|
226
|
+
}),
|
|
213
227
|
annotations: privateWriteToolAnnotations,
|
|
214
228
|
}, withUpstreamToken(startActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
215
229
|
server.registerTool('complete-activity-log', {
|
|
216
230
|
description: 'Completes an activity log.',
|
|
217
|
-
inputSchema: {
|
|
231
|
+
inputSchema: z.object({
|
|
218
232
|
activityLogUUID: z
|
|
219
|
-
.
|
|
220
|
-
.uuid()
|
|
233
|
+
.guid()
|
|
221
234
|
.describe('You must specify a valid activityLogUUID obtained from get-activity-log-list. This tool requires an existing activity log.'),
|
|
222
|
-
},
|
|
235
|
+
}),
|
|
223
236
|
annotations: privateOverwriteToolAnnotations,
|
|
224
237
|
}, withUpstreamToken(completeActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
225
238
|
server.registerTool('get-japan-current-time', {
|
|
226
239
|
description: 'Returns the current time in Japan (JST).',
|
|
227
|
-
inputSchema: {},
|
|
240
|
+
inputSchema: z.object({}),
|
|
228
241
|
annotations: readOnlyToolAnnotations,
|
|
229
242
|
}, withUpstreamToken(getJapanCurrentTimeHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
230
243
|
return server;
|
package/build/remoteServer.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { NodeStreamableHTTPServerTransport, toNodeHandler, toWebRequest, } from '@modelcontextprotocol/node';
|
|
4
|
+
import { createMcpHandler, isInitializeRequest, isLegacyRequest, } from '@modelcontextprotocol/server';
|
|
5
|
+
import { SSEServerTransport } from '@modelcontextprotocol/server-legacy/sse';
|
|
6
6
|
import { parseBearerToken } from './bearerToken.js';
|
|
7
7
|
import { createMcpServer } from './mcpServer.js';
|
|
8
8
|
const authorizationServerMetadataPath = '/.well-known/oauth-authorization-server';
|
|
@@ -68,6 +68,13 @@ export async function startRemoteServer(options) {
|
|
|
68
68
|
return (streamableSessions.get(sessionId)?.upstreamToken ??
|
|
69
69
|
sseSessions.get(sessionId)?.upstreamToken);
|
|
70
70
|
};
|
|
71
|
+
const modernHandler = createMcpHandler(({ requestInfo }) => createMcpServer({
|
|
72
|
+
resolveUpstreamToken: () => getUpstreamToken(requestInfo?.headers.get('authorization') ?? undefined, options.authMode),
|
|
73
|
+
requireUpstreamToken: options.authMode === 'passthrough',
|
|
74
|
+
}), { legacy: 'reject', maxRequestBodySize: maxRequestBodyBytes });
|
|
75
|
+
const handleModernRequest = toNodeHandler(modernHandler, {
|
|
76
|
+
maxRequestBodySize: maxRequestBodyBytes,
|
|
77
|
+
});
|
|
71
78
|
const server = createServer(async (req, res) => {
|
|
72
79
|
try {
|
|
73
80
|
const requestUrl = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
@@ -107,7 +114,35 @@ export async function startRemoteServer(options) {
|
|
|
107
114
|
writeMcpOptionsResponse(res);
|
|
108
115
|
return;
|
|
109
116
|
}
|
|
117
|
+
writeMcpCorsHeaders(res);
|
|
118
|
+
let body = null;
|
|
119
|
+
if (req.method === 'POST') {
|
|
120
|
+
try {
|
|
121
|
+
body = (await readJsonBody(req)) ?? null;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
writeJsonRpcError(res, error instanceof RequestBodyTooLargeError ? 413 : 400, error instanceof RequestBodyTooLargeError
|
|
125
|
+
? 'Payload too large'
|
|
126
|
+
: 'Bad Request: Invalid JSON body');
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const request = await toWebRequest(req, body);
|
|
131
|
+
if (!(await isLegacyRequest(request, body))) {
|
|
132
|
+
const token = getUpstreamToken(req.headers.authorization, options.authMode);
|
|
133
|
+
if (options.authMode === 'passthrough' && !token) {
|
|
134
|
+
res
|
|
135
|
+
.writeHead(401, {
|
|
136
|
+
'WWW-Authenticate': `Bearer resource_metadata="${mcpProtectedResourceMetadataUrl}"`,
|
|
137
|
+
})
|
|
138
|
+
.end('Unauthorized');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
await handleModernRequest(req, res, body);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
110
144
|
await handleStreamableHttpRequest({
|
|
145
|
+
body,
|
|
111
146
|
req,
|
|
112
147
|
res,
|
|
113
148
|
authMode: options.authMode,
|
|
@@ -193,18 +228,22 @@ export async function startRemoteServer(options) {
|
|
|
193
228
|
res.end('Internal server error');
|
|
194
229
|
}
|
|
195
230
|
});
|
|
231
|
+
server.once('close', () => {
|
|
232
|
+
void modernHandler.close();
|
|
233
|
+
});
|
|
196
234
|
await new Promise((resolve, reject) => {
|
|
197
235
|
server.once('error', reject);
|
|
198
236
|
server.listen(options.port, options.host, () => resolve());
|
|
199
237
|
});
|
|
200
238
|
console.log(`Remote MCP server listening on http://${options.host}:${options.port}${mcpPath}`);
|
|
239
|
+
return server;
|
|
201
240
|
}
|
|
202
|
-
async function handleStreamableHttpRequest({ req, res, authMode, protectedResourceMetadataUrl, resolveUpstreamToken, sessions, }) {
|
|
241
|
+
async function handleStreamableHttpRequest({ body, req, res, authMode, protectedResourceMetadataUrl, resolveUpstreamToken, sessions, }) {
|
|
203
242
|
writeMcpCorsHeaders(res);
|
|
204
243
|
const sessionId = getHeaderValue(req.headers['mcp-session-id']);
|
|
205
244
|
const existingSession = sessionId ? sessions.get(sessionId) : undefined;
|
|
206
245
|
if (existingSession) {
|
|
207
|
-
await existingSession.transport.handleRequest(req, res);
|
|
246
|
+
await existingSession.transport.handleRequest(req, res, body);
|
|
208
247
|
return;
|
|
209
248
|
}
|
|
210
249
|
if (sessionId) {
|
|
@@ -224,23 +263,11 @@ async function handleStreamableHttpRequest({ req, res, authMode, protectedResour
|
|
|
224
263
|
writeJsonRpcError(res, 405, 'Method not allowed');
|
|
225
264
|
return;
|
|
226
265
|
}
|
|
227
|
-
let body;
|
|
228
|
-
try {
|
|
229
|
-
body = await readJsonBody(req);
|
|
230
|
-
}
|
|
231
|
-
catch (error) {
|
|
232
|
-
if (error instanceof RequestBodyTooLargeError) {
|
|
233
|
-
writeJsonRpcError(res, 413, 'Payload too large');
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
writeJsonRpcError(res, 400, 'Bad Request: Invalid JSON body');
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
266
|
if (!includesInitializeRequest(body)) {
|
|
240
267
|
writeJsonRpcError(res, 400, 'Bad Request: Missing or invalid initialize request');
|
|
241
268
|
return;
|
|
242
269
|
}
|
|
243
|
-
const transport = new
|
|
270
|
+
const transport = new NodeStreamableHTTPServerTransport({
|
|
244
271
|
sessionIdGenerator: () => randomUUID(),
|
|
245
272
|
onsessioninitialized: (initializedSessionId) => {
|
|
246
273
|
sessions.set(initializedSessionId, {
|
|
@@ -333,7 +360,7 @@ function writeOptionsResponse(res) {
|
|
|
333
360
|
}
|
|
334
361
|
function writeMcpCorsHeaders(res) {
|
|
335
362
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
336
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, Mcp-Session-Id, mcp-session-id, Last-Event-ID, mcp-protocol-version');
|
|
363
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, Mcp-Session-Id, mcp-session-id, Last-Event-ID, mcp-protocol-version, Mcp-Method, Mcp-Name');
|
|
337
364
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
|
|
338
365
|
res.setHeader('Access-Control-Expose-Headers', 'Mcp-Session-Id, mcp-session-id, mcp-protocol-version');
|
|
339
366
|
}
|
|
@@ -364,10 +391,11 @@ function getHeaderValue(header) {
|
|
|
364
391
|
async function readJsonBody(req) {
|
|
365
392
|
const chunks = [];
|
|
366
393
|
let totalBytes = 0;
|
|
367
|
-
for await (const chunk of req) {
|
|
394
|
+
for await (const chunk of req.iterator({ destroyOnReturn: false })) {
|
|
368
395
|
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
369
396
|
totalBytes += buffer.byteLength;
|
|
370
397
|
if (totalBytes > maxRequestBodyBytes) {
|
|
398
|
+
req.resume();
|
|
371
399
|
throw new RequestBodyTooLargeError();
|
|
372
400
|
}
|
|
373
401
|
chunks.push(buffer);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "togello-mcp-server",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.44",
|
|
5
5
|
"description": "MCP server for Togello tasks, calendar memos, calendar events, and activity logs.",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -33,11 +33,15 @@
|
|
|
33
33
|
"node": ">=22"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@modelcontextprotocol/
|
|
37
|
-
"
|
|
36
|
+
"@modelcontextprotocol/node": "^2.1.0",
|
|
37
|
+
"@modelcontextprotocol/server": "^2.2.0",
|
|
38
|
+
"@modelcontextprotocol/server-legacy": "^2.2.0",
|
|
39
|
+
"zod": "^4.6.5"
|
|
38
40
|
},
|
|
39
41
|
"devDependencies": {
|
|
42
|
+
"@modelcontextprotocol/client": "^2.2.0",
|
|
40
43
|
"@types/node": "^22.14.1",
|
|
44
|
+
"mcp-sdk-v1": "npm:@modelcontextprotocol/sdk@1.29.0",
|
|
41
45
|
"typescript": "^5.8.3"
|
|
42
46
|
},
|
|
43
47
|
"bin": {
|