togello-mcp-server 1.0.41 → 1.0.43
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 -4
- package/build/handlers/tool/updateTaskHandler.js +4 -1
- package/build/index.js +2 -3
- package/build/mcpServer.js +34 -26
- package/build/remoteServer.js +48 -20
- package/package.json +9 -7
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
|
|
|
@@ -74,7 +82,7 @@ All tools set MCP `readOnlyHint`, `openWorldHint`, and `destructiveHint` annotat
|
|
|
74
82
|
Write tools return JSON. Failed tool responses also return JSON and are marked with `isError: true`. Tools that can overwrite existing private Togello data set `destructiveHint: true`; create/start tools set `destructiveHint: false`.
|
|
75
83
|
|
|
76
84
|
- `create-task`: Creates a TODO task.
|
|
77
|
-
- `update-task`: Updates a TODO task.
|
|
85
|
+
- `update-task`: Updates a TODO task, including category assignment or removal.
|
|
78
86
|
- `update-calendar-date-memo`: Updates or clears a calendar date memo.
|
|
79
87
|
- `start-activity-log`: Starts an activity log.
|
|
80
88
|
- `complete-activity-log`: Completes an activity log.
|
|
@@ -82,10 +90,14 @@ Write tools return JSON. Failed tool responses also return JSON and are marked w
|
|
|
82
90
|
## Development
|
|
83
91
|
|
|
84
92
|
```bash
|
|
85
|
-
npm
|
|
86
|
-
npm
|
|
93
|
+
npm ci
|
|
94
|
+
npm test
|
|
87
95
|
```
|
|
88
96
|
|
|
97
|
+
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, read/write 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.
|
|
98
|
+
|
|
99
|
+
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.
|
|
100
|
+
|
|
89
101
|
## MCP Review
|
|
90
102
|
|
|
91
103
|
Certified
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { httpClient } from '../../client.js';
|
|
2
2
|
import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
|
|
3
|
-
export const updateTaskHandler = async ({ todoUUID, taskName, isCompleted, status, scheduledStartDate, scheduledEndDate, deadlineDateTime, url, detail, }) => {
|
|
3
|
+
export const updateTaskHandler = async ({ todoUUID, taskName, isCompleted, status, categoryUUID, scheduledStartDate, scheduledEndDate, deadlineDateTime, url, detail, }) => {
|
|
4
4
|
try {
|
|
5
5
|
if (taskName === undefined &&
|
|
6
6
|
isCompleted === undefined &&
|
|
7
7
|
status === undefined &&
|
|
8
|
+
categoryUUID === undefined &&
|
|
8
9
|
scheduledStartDate === undefined &&
|
|
9
10
|
scheduledEndDate === undefined &&
|
|
10
11
|
deadlineDateTime === undefined &&
|
|
@@ -21,6 +22,7 @@ export const updateTaskHandler = async ({ todoUUID, taskName, isCompleted, statu
|
|
|
21
22
|
label: taskName,
|
|
22
23
|
isCompleted,
|
|
23
24
|
status,
|
|
25
|
+
categoryUUID,
|
|
24
26
|
scheduledStartDate,
|
|
25
27
|
scheduledEndDate,
|
|
26
28
|
deadlineDateTime,
|
|
@@ -33,6 +35,7 @@ export const updateTaskHandler = async ({ todoUUID, taskName, isCompleted, statu
|
|
|
33
35
|
taskName,
|
|
34
36
|
isCompleted,
|
|
35
37
|
status,
|
|
38
|
+
categoryUUID,
|
|
36
39
|
deadlineDateTime,
|
|
37
40
|
updated: true,
|
|
38
41
|
});
|
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,5 +1,6 @@
|
|
|
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';
|
|
5
6
|
import { getActivityItemListHandler } from './handlers/tool/getActivityItemListHandler.js';
|
|
@@ -17,7 +18,11 @@ import { runWithUpstreamToken } from './upstreamTokenContext.js';
|
|
|
17
18
|
const calendarDateMemoDateSchema = z
|
|
18
19
|
.string()
|
|
19
20
|
.regex(/^\d{4}-\d{2}-\d{2}$/, 'Invalid date format, expected YYYY-MM-DD');
|
|
20
|
-
const
|
|
21
|
+
const legacyDateTimeSchema = legacyZod.string().datetime({ offset: true });
|
|
22
|
+
const rfc3339DateTimeSchema = z
|
|
23
|
+
.string()
|
|
24
|
+
.refine((value) => legacyDateTimeSchema.safeParse(value).success)
|
|
25
|
+
.meta({ format: 'date-time' });
|
|
21
26
|
const readOnlyToolAnnotations = {
|
|
22
27
|
readOnlyHint: true,
|
|
23
28
|
openWorldHint: false,
|
|
@@ -57,7 +62,7 @@ export function createMcpServer(options = {}) {
|
|
|
57
62
|
});
|
|
58
63
|
server.registerTool('get-tasks-list', {
|
|
59
64
|
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: {
|
|
65
|
+
inputSchema: z.object({
|
|
61
66
|
categoryUUIDs: z
|
|
62
67
|
.array(z.string())
|
|
63
68
|
.optional()
|
|
@@ -72,12 +77,12 @@ export function createMcpServer(options = {}) {
|
|
|
72
77
|
completedEndDate: rfc3339DateTimeSchema
|
|
73
78
|
.optional()
|
|
74
79
|
.describe('Exclusive completed-at range end in RFC3339 format, for example today at 00:00:00+09:00 when retrieving yesterday.'),
|
|
75
|
-
},
|
|
80
|
+
}),
|
|
76
81
|
annotations: readOnlyToolAnnotations,
|
|
77
82
|
}, withUpstreamToken(getTodoListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
78
83
|
server.registerTool('create-task', {
|
|
79
84
|
description: 'Creates a new task in the TODO feature.',
|
|
80
|
-
inputSchema: {
|
|
85
|
+
inputSchema: z.object({
|
|
81
86
|
taskName: z.string().describe('create task name'),
|
|
82
87
|
status: z
|
|
83
88
|
.enum(['TODO', 'PENDING', 'DOING', 'DONE'])
|
|
@@ -107,15 +112,14 @@ export function createMcpServer(options = {}) {
|
|
|
107
112
|
.string()
|
|
108
113
|
.optional()
|
|
109
114
|
.describe('Optional detail associated with the task.'),
|
|
110
|
-
},
|
|
115
|
+
}),
|
|
111
116
|
annotations: privateWriteToolAnnotations,
|
|
112
117
|
}, withUpstreamToken(createTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
113
118
|
server.registerTool('update-task', {
|
|
114
119
|
description: 'Updates a task in the TODO feature.',
|
|
115
|
-
inputSchema: {
|
|
120
|
+
inputSchema: z.object({
|
|
116
121
|
todoUUID: z
|
|
117
|
-
.
|
|
118
|
-
.uuid()
|
|
122
|
+
.guid()
|
|
119
123
|
.describe('Task UUID. Please specify the task uuid (todo uuid) obtained from get-tasks-list. You cannot use this tool without specifying it.'),
|
|
120
124
|
taskName: z
|
|
121
125
|
.string()
|
|
@@ -129,6 +133,11 @@ export function createMcpServer(options = {}) {
|
|
|
129
133
|
.enum(['TODO', 'PENDING', 'DOING', 'DONE'])
|
|
130
134
|
.optional()
|
|
131
135
|
.describe('Optional. Updates the todo status directly. Use this to switch tasks between TODO, PENDING, DOING, and DONE.'),
|
|
136
|
+
categoryUUID: z
|
|
137
|
+
.guid()
|
|
138
|
+
.nullable()
|
|
139
|
+
.optional()
|
|
140
|
+
.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.'),
|
|
132
141
|
scheduledStartDate: z
|
|
133
142
|
.string()
|
|
134
143
|
.optional()
|
|
@@ -149,44 +158,44 @@ export function createMcpServer(options = {}) {
|
|
|
149
158
|
.string()
|
|
150
159
|
.optional()
|
|
151
160
|
.describe('Optional detail associated with the task. If omitted, the current value is kept.'),
|
|
152
|
-
},
|
|
161
|
+
}),
|
|
153
162
|
annotations: privateOverwriteToolAnnotations,
|
|
154
163
|
}, withUpstreamToken(updateTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
155
164
|
server.registerTool('get-calendar-date-memo', {
|
|
156
165
|
description: 'Retrieves a calendar date memo for the specified date. Recognizes target date and memo content.',
|
|
157
|
-
inputSchema: {
|
|
166
|
+
inputSchema: z.object({
|
|
158
167
|
date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
|
|
159
|
-
},
|
|
168
|
+
}),
|
|
160
169
|
annotations: readOnlyToolAnnotations,
|
|
161
170
|
}, withUpstreamToken(getCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
162
171
|
server.registerTool('update-calendar-date-memo', {
|
|
163
172
|
description: 'Updates a calendar date memo for the specified date.',
|
|
164
|
-
inputSchema: {
|
|
173
|
+
inputSchema: z.object({
|
|
165
174
|
date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
|
|
166
175
|
memo: z
|
|
167
176
|
.string()
|
|
168
177
|
.describe('Memo content for the date. Pass an empty or whitespace-only string to clear the memo.'),
|
|
169
|
-
},
|
|
178
|
+
}),
|
|
170
179
|
annotations: privateOverwriteToolAnnotations,
|
|
171
180
|
}, withUpstreamToken(updateCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
172
181
|
server.registerTool('get-todo-category-list', {
|
|
173
182
|
description: 'Retrieves the list of categories from the TODO feature. Recognizes category name / category UUID',
|
|
174
|
-
inputSchema: {},
|
|
183
|
+
inputSchema: z.object({}),
|
|
175
184
|
annotations: readOnlyToolAnnotations,
|
|
176
185
|
}, withUpstreamToken(getTodoCategoryListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
177
186
|
server.registerTool('get-today-calendar', {
|
|
178
187
|
description: 'Retrieves scheduled events for yesterday/today/tomorrow from the linked Google Calendar. Recognizes event name / start date and time / end date and time. ',
|
|
179
|
-
inputSchema: {},
|
|
188
|
+
inputSchema: z.object({}),
|
|
180
189
|
annotations: readOnlyToolAnnotations,
|
|
181
190
|
}, withUpstreamToken(getTodayCalendarHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
182
191
|
server.registerTool('get-activity-item-list', {
|
|
183
192
|
description: 'Retrieves the list of activity items from the integration feature. Recognizes activity item UUID / item name',
|
|
184
|
-
inputSchema: {},
|
|
193
|
+
inputSchema: z.object({}),
|
|
185
194
|
annotations: readOnlyToolAnnotations,
|
|
186
195
|
}, withUpstreamToken(getActivityItemListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
187
196
|
server.registerTool('get-activity-log-list', {
|
|
188
197
|
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.',
|
|
189
|
-
inputSchema: {
|
|
198
|
+
inputSchema: z.object({
|
|
190
199
|
limit: z
|
|
191
200
|
.number()
|
|
192
201
|
.int()
|
|
@@ -194,31 +203,30 @@ export function createMcpServer(options = {}) {
|
|
|
194
203
|
.max(300)
|
|
195
204
|
.optional()
|
|
196
205
|
.describe('Optional maximum number of activity logs to retrieve. Defaults to 300.'),
|
|
197
|
-
},
|
|
206
|
+
}),
|
|
198
207
|
annotations: readOnlyToolAnnotations,
|
|
199
208
|
}, withUpstreamToken(getActivityLogListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
200
209
|
server.registerTool('start-activity-log', {
|
|
201
210
|
description: 'Starts an activity log.',
|
|
202
|
-
inputSchema: {
|
|
211
|
+
inputSchema: z.object({
|
|
203
212
|
activityItemName: z
|
|
204
213
|
.string()
|
|
205
214
|
.describe('You must specify a valid itemName obtained from get-activity-item-list. This tool requires a pre-existing activity item.'),
|
|
206
|
-
},
|
|
215
|
+
}),
|
|
207
216
|
annotations: privateWriteToolAnnotations,
|
|
208
217
|
}, withUpstreamToken(startActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
209
218
|
server.registerTool('complete-activity-log', {
|
|
210
219
|
description: 'Completes an activity log.',
|
|
211
|
-
inputSchema: {
|
|
220
|
+
inputSchema: z.object({
|
|
212
221
|
activityLogUUID: z
|
|
213
|
-
.
|
|
214
|
-
.uuid()
|
|
222
|
+
.guid()
|
|
215
223
|
.describe('You must specify a valid activityLogUUID obtained from get-activity-log-list. This tool requires an existing activity log.'),
|
|
216
|
-
},
|
|
224
|
+
}),
|
|
217
225
|
annotations: privateOverwriteToolAnnotations,
|
|
218
226
|
}, withUpstreamToken(completeActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
219
227
|
server.registerTool('get-japan-current-time', {
|
|
220
228
|
description: 'Returns the current time in Japan (JST).',
|
|
221
|
-
inputSchema: {},
|
|
229
|
+
inputSchema: z.object({}),
|
|
222
230
|
annotations: readOnlyToolAnnotations,
|
|
223
231
|
}, withUpstreamToken(getJapanCurrentTimeHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
|
|
224
232
|
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,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "togello-mcp-server",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.43",
|
|
5
5
|
"description": "MCP server for Togello tasks, calendar memos, calendar events, and activity logs.",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc && chmod 755 build/index.js",
|
|
9
9
|
"codex:preclone": "bash scripts/codex-cloud/preclone.sh",
|
|
10
10
|
"start": "node build/index.js",
|
|
11
|
-
"test": "
|
|
11
|
+
"test": "npm run build && node --test"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"mcp",
|
|
@@ -33,18 +33,20 @@
|
|
|
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": {
|
|
44
48
|
"togello": "build/index.js",
|
|
45
49
|
"togello-mcp-server": "build/index.js"
|
|
46
50
|
},
|
|
47
|
-
"files": [
|
|
48
|
-
"build"
|
|
49
|
-
]
|
|
51
|
+
"files": ["build"]
|
|
50
52
|
}
|