togello-mcp-server 1.0.42 → 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 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 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.
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
 
@@ -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 install
86
- npm run build
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
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
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
- const server = createMcpServer();
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);
@@ -1,5 +1,6 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
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 rfc3339DateTimeSchema = z.string().datetime({ offset: true });
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
- .string()
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()
@@ -130,8 +134,7 @@ export function createMcpServer(options = {}) {
130
134
  .optional()
131
135
  .describe('Optional. Updates the todo status directly. Use this to switch tasks between TODO, PENDING, DOING, and DONE.'),
132
136
  categoryUUID: z
133
- .string()
134
- .uuid()
137
+ .guid()
135
138
  .nullable()
136
139
  .optional()
137
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.'),
@@ -155,44 +158,44 @@ export function createMcpServer(options = {}) {
155
158
  .string()
156
159
  .optional()
157
160
  .describe('Optional detail associated with the task. If omitted, the current value is kept.'),
158
- },
161
+ }),
159
162
  annotations: privateOverwriteToolAnnotations,
160
163
  }, withUpstreamToken(updateTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
161
164
  server.registerTool('get-calendar-date-memo', {
162
165
  description: 'Retrieves a calendar date memo for the specified date. Recognizes target date and memo content.',
163
- inputSchema: {
166
+ inputSchema: z.object({
164
167
  date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
165
- },
168
+ }),
166
169
  annotations: readOnlyToolAnnotations,
167
170
  }, withUpstreamToken(getCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
168
171
  server.registerTool('update-calendar-date-memo', {
169
172
  description: 'Updates a calendar date memo for the specified date.',
170
- inputSchema: {
173
+ inputSchema: z.object({
171
174
  date: calendarDateMemoDateSchema.describe('Target date in YYYY-MM-DD format.'),
172
175
  memo: z
173
176
  .string()
174
177
  .describe('Memo content for the date. Pass an empty or whitespace-only string to clear the memo.'),
175
- },
178
+ }),
176
179
  annotations: privateOverwriteToolAnnotations,
177
180
  }, withUpstreamToken(updateCalendarDateMemoHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
178
181
  server.registerTool('get-todo-category-list', {
179
182
  description: 'Retrieves the list of categories from the TODO feature. Recognizes category name / category UUID',
180
- inputSchema: {},
183
+ inputSchema: z.object({}),
181
184
  annotations: readOnlyToolAnnotations,
182
185
  }, withUpstreamToken(getTodoCategoryListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
183
186
  server.registerTool('get-today-calendar', {
184
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. ',
185
- inputSchema: {},
188
+ inputSchema: z.object({}),
186
189
  annotations: readOnlyToolAnnotations,
187
190
  }, withUpstreamToken(getTodayCalendarHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
188
191
  server.registerTool('get-activity-item-list', {
189
192
  description: 'Retrieves the list of activity items from the integration feature. Recognizes activity item UUID / item name',
190
- inputSchema: {},
193
+ inputSchema: z.object({}),
191
194
  annotations: readOnlyToolAnnotations,
192
195
  }, withUpstreamToken(getActivityItemListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
193
196
  server.registerTool('get-activity-log-list', {
194
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.',
195
- inputSchema: {
198
+ inputSchema: z.object({
196
199
  limit: z
197
200
  .number()
198
201
  .int()
@@ -200,31 +203,30 @@ export function createMcpServer(options = {}) {
200
203
  .max(300)
201
204
  .optional()
202
205
  .describe('Optional maximum number of activity logs to retrieve. Defaults to 300.'),
203
- },
206
+ }),
204
207
  annotations: readOnlyToolAnnotations,
205
208
  }, withUpstreamToken(getActivityLogListHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
206
209
  server.registerTool('start-activity-log', {
207
210
  description: 'Starts an activity log.',
208
- inputSchema: {
211
+ inputSchema: z.object({
209
212
  activityItemName: z
210
213
  .string()
211
214
  .describe('You must specify a valid itemName obtained from get-activity-item-list. This tool requires a pre-existing activity item.'),
212
- },
215
+ }),
213
216
  annotations: privateWriteToolAnnotations,
214
217
  }, withUpstreamToken(startActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
215
218
  server.registerTool('complete-activity-log', {
216
219
  description: 'Completes an activity log.',
217
- inputSchema: {
220
+ inputSchema: z.object({
218
221
  activityLogUUID: z
219
- .string()
220
- .uuid()
222
+ .guid()
221
223
  .describe('You must specify a valid activityLogUUID obtained from get-activity-log-list. This tool requires an existing activity log.'),
222
- },
224
+ }),
223
225
  annotations: privateOverwriteToolAnnotations,
224
226
  }, withUpstreamToken(completeActivityLogHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
225
227
  server.registerTool('get-japan-current-time', {
226
228
  description: 'Returns the current time in Japan (JST).',
227
- inputSchema: {},
229
+ inputSchema: z.object({}),
228
230
  annotations: readOnlyToolAnnotations,
229
231
  }, withUpstreamToken(getJapanCurrentTimeHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
230
232
  return server;
@@ -1,8 +1,8 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { createServer } from 'node:http';
3
- import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
4
- import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
5
- import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
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 StreamableHTTPServerTransport({
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.42",
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": {
@@ -33,18 +33,20 @@
33
33
  "node": ">=22"
34
34
  },
35
35
  "dependencies": {
36
- "@modelcontextprotocol/sdk": "^1.29.0",
37
- "zod": "^3.25.76"
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
  }