togello-mcp-server 1.0.27 → 1.0.30

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
@@ -29,7 +29,7 @@ Use this for desktop clients and local developer tools that launch MCP servers o
29
29
 
30
30
  ## Remote MCP
31
31
 
32
- Remote mode exposes an SSE endpoint at `/sse` and a message endpoint at `/message`.
32
+ Remote mode exposes a Streamable HTTP endpoint at `/mcp`. It also keeps the legacy SSE endpoint at `/sse` and message endpoint at `/message` for older MCP clients.
33
33
 
34
34
  ```bash
35
35
  TOGELLO_MCP_MODE=remote \
@@ -42,7 +42,7 @@ npm start
42
42
  Connect remote MCP clients to:
43
43
 
44
44
  ```text
45
- https://your-domain.example/sse
45
+ https://your-domain.example/mcp
46
46
  ```
47
47
 
48
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.
@@ -51,6 +51,8 @@ https://your-domain.example/sse
51
51
 
52
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.
53
53
 
54
+ For OpenAI Apps domain verification, set `TOGELLO_MCP_OPENAI_APPS_CHALLENGE_TOKEN` to the verification token. Remote mode then serves it from `/.well-known/openai-apps-challenge` as `text/plain`. If both `TOGELLO_MCP_OPENAI_APPS_CHALLENGE_TOKEN` and `OPENAI_APPS_CHALLENGE_TOKEN` are set, the Togello-scoped variable takes precedence.
55
+
54
56
  ## Tools
55
57
 
56
58
  Read-only tools include MCP `readOnlyHint` annotations and return stable JSON in both `structuredContent` and text content.
@@ -13,6 +13,7 @@ export const getTodoListHandler = async ({ categoryUUIDs, }) => {
13
13
  tasks: tasks.map((todo) => ({
14
14
  todoUUID: todo.todoUUID,
15
15
  label: todo.label,
16
+ status: todo.status,
16
17
  detail: todo.detail,
17
18
  scheduledStartDate: todo.scheduledStartDate,
18
19
  scheduledEndDate: todo.scheduledEndDate,
@@ -1,11 +1,23 @@
1
1
  import { httpClient } from '../../client.js';
2
2
  import { errorToolResponse, jsonToolResponse } from './toolResponse.js';
3
- export const updateTaskHandler = async ({ todoUUID, isCompleted, scheduledStartDate, scheduledEndDate, url, detail, }) => {
3
+ export const updateTaskHandler = async ({ todoUUID, isCompleted, status, scheduledStartDate, scheduledEndDate, url, detail, }) => {
4
4
  try {
5
+ if (isCompleted === undefined &&
6
+ status === undefined &&
7
+ scheduledStartDate === undefined &&
8
+ scheduledEndDate === undefined &&
9
+ url === undefined &&
10
+ detail === undefined) {
11
+ return errorToolResponse('At least one update field is required');
12
+ }
13
+ if (isCompleted !== undefined && status !== undefined) {
14
+ return errorToolResponse('Specify either isCompleted or status, not both');
15
+ }
5
16
  await httpClient.putJson({
6
17
  path: `/v2/integration/todo/${encodeURIComponent(todoUUID)}`,
7
18
  body: {
8
19
  isCompleted,
20
+ status,
9
21
  scheduledStartDate,
10
22
  scheduledEndDate,
11
23
  url,
@@ -15,6 +27,7 @@ export const updateTaskHandler = async ({ todoUUID, isCompleted, scheduledStartD
15
27
  return jsonToolResponse({
16
28
  todoUUID,
17
29
  isCompleted,
30
+ status,
18
31
  updated: true,
19
32
  });
20
33
  }
package/build/index.js CHANGED
@@ -31,6 +31,8 @@ async function main() {
31
31
  }
32
32
  const publicBaseUrl = getRemotePublicBaseUrl(port);
33
33
  const oauthIssuer = getRemoteOAuthIssuer();
34
+ const openaiAppsChallengeToken = getEnvValue('TOGELLO_MCP_OPENAI_APPS_CHALLENGE_TOKEN') ??
35
+ getEnvValue('OPENAI_APPS_CHALLENGE_TOKEN');
34
36
  await startRemoteServer({
35
37
  host,
36
38
  port,
@@ -38,6 +40,7 @@ async function main() {
38
40
  publicBaseUrl,
39
41
  oauthIssuer,
40
42
  sseKeepAliveMs: keepAliveMs,
43
+ openaiAppsChallengeToken,
41
44
  });
42
45
  return;
43
46
  }
@@ -43,7 +43,7 @@ export function createMcpServer(options = {}) {
43
43
  },
44
44
  });
45
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',
46
+ description: 'Retrieves incomplete tasks from the TODO feature. Recognizes task uuid / task name / status / detail / scheduled start date and time / scheduled end date and time / priority / category',
47
47
  inputSchema: {
48
48
  categoryUUIDs: z
49
49
  .array(z.string())
@@ -87,23 +87,28 @@ export function createMcpServer(options = {}) {
87
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
88
  isCompleted: z
89
89
  .boolean()
90
- .describe('Required. Updates the completion status of the task. If true, it is completed.'),
90
+ .optional()
91
+ .describe('Optional. Backward-compatible completion update. true marks the task done. false preserves existing TODO or DOING tasks and reopens DONE tasks to TODO.'),
92
+ status: z
93
+ .enum(['TODO', 'DOING', 'DONE'])
94
+ .optional()
95
+ .describe('Optional. Updates the todo status directly. Use this to switch tasks between TODO, DOING, and DONE.'),
91
96
  scheduledStartDate: z
92
97
  .string()
93
98
  .optional()
94
- .describe('Scheduled start date in ISO format. If the user does not specify, the information obtained from get-tasks-list is passed.'),
99
+ .describe('Scheduled start date in ISO format. If omitted, the current value is kept.'),
95
100
  scheduledEndDate: z
96
101
  .string()
97
102
  .optional()
98
- .describe('Scheduled end date in ISO format. If the user does not specify, the information obtained from get-tasks-list is passed.'),
103
+ .describe('Scheduled end date in ISO format. If omitted, the current value is kept.'),
99
104
  url: z
100
105
  .string()
101
106
  .optional()
102
- .describe('Optional URL associated with the task. If the user does not specify, the information obtained from get-tasks-list is passed.'),
107
+ .describe('Optional URL associated with the task. If omitted, the current value is kept.'),
103
108
  detail: z
104
109
  .string()
105
110
  .optional()
106
- .describe('Optional detail associated with the task. If the user does not specify, the information obtained from get-tasks-list is passed.'),
111
+ .describe('Optional detail associated with the task. If omitted, the current value is kept.'),
107
112
  },
108
113
  }, withUpstreamToken(updateTaskHandler, options.resolveUpstreamToken, options.requireUpstreamToken));
109
114
  server.registerTool('get-calendar-date-memo', {
@@ -1,8 +1,13 @@
1
+ import { randomUUID } from 'node:crypto';
1
2
  import { createServer } from 'node:http';
2
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
6
  import { parseBearerToken } from './bearerToken.js';
4
7
  import { createMcpServer } from './mcpServer.js';
5
8
  const protectedResourceMetadataPath = '/.well-known/oauth-protected-resource';
9
+ const openaiAppsChallengePath = '/.well-known/openai-apps-challenge';
10
+ const maxRequestBodyBytes = 1_000_000;
6
11
  const supportedScopes = [
7
12
  'offline_access',
8
13
  'tasks:read',
@@ -12,21 +17,35 @@ const supportedScopes = [
12
17
  'calendar:read',
13
18
  ];
14
19
  export async function startRemoteServer(options) {
20
+ const mcpPath = options.mcpPath ?? '/mcp';
15
21
  const ssePath = options.ssePath ?? '/sse';
16
22
  const messagePath = options.messagePath ?? '/message';
17
23
  const publicBaseUrl = trimTrailingSlash(options.publicBaseUrl);
18
24
  const oauthIssuer = options.oauthIssuer;
19
25
  const protectedResourceMetadataUrl = `${publicBaseUrl}${protectedResourceMetadataPath}`;
20
- const sessions = new Map();
26
+ const openaiAppsChallengeToken = options.openaiAppsChallengeToken?.trim();
27
+ const sseSessions = new Map();
28
+ const streamableSessions = new Map();
21
29
  const resolveUpstreamToken = (sessionId) => {
22
30
  if (!sessionId) {
23
31
  return undefined;
24
32
  }
25
- return sessions.get(sessionId)?.upstreamToken;
33
+ return (streamableSessions.get(sessionId)?.upstreamToken ??
34
+ sseSessions.get(sessionId)?.upstreamToken);
26
35
  };
27
36
  const server = createServer(async (req, res) => {
28
37
  try {
29
38
  const requestUrl = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
39
+ if (requestUrl.pathname === openaiAppsChallengePath) {
40
+ if (req.method === 'OPTIONS') {
41
+ writeOptionsResponse(res);
42
+ return;
43
+ }
44
+ if (req.method === 'GET' && openaiAppsChallengeToken) {
45
+ writeTextResponse(res, openaiAppsChallengeToken);
46
+ return;
47
+ }
48
+ }
30
49
  if (requestUrl.pathname === protectedResourceMetadataPath) {
31
50
  if (req.method === 'OPTIONS') {
32
51
  writeOptionsResponse(res);
@@ -42,8 +61,23 @@ export async function startRemoteServer(options) {
42
61
  return;
43
62
  }
44
63
  }
64
+ if (requestUrl.pathname === mcpPath) {
65
+ if (req.method === 'OPTIONS') {
66
+ writeMcpOptionsResponse(res);
67
+ return;
68
+ }
69
+ await handleStreamableHttpRequest({
70
+ req,
71
+ res,
72
+ authMode: options.authMode,
73
+ protectedResourceMetadataUrl,
74
+ resolveUpstreamToken,
75
+ sessions: streamableSessions,
76
+ });
77
+ return;
78
+ }
45
79
  if (req.method === 'GET' && requestUrl.pathname === ssePath) {
46
- const upstreamToken = getUpstreamTokenForSse(req.headers.authorization, options.authMode);
80
+ const upstreamToken = getUpstreamToken(req.headers.authorization, options.authMode);
47
81
  if (options.authMode === 'passthrough' && !upstreamToken) {
48
82
  res
49
83
  .writeHead(401, {
@@ -53,7 +87,7 @@ export async function startRemoteServer(options) {
53
87
  return;
54
88
  }
55
89
  const transport = new SSEServerTransport(messagePath, res);
56
- sessions.set(transport.sessionId, { transport, upstreamToken });
90
+ sseSessions.set(transport.sessionId, { transport, upstreamToken });
57
91
  const mcpServer = createMcpServer({
58
92
  resolveUpstreamToken,
59
93
  requireUpstreamToken: options.authMode === 'passthrough',
@@ -72,7 +106,7 @@ export async function startRemoteServer(options) {
72
106
  return;
73
107
  }
74
108
  closed = true;
75
- sessions.delete(transport.sessionId);
109
+ sseSessions.delete(transport.sessionId);
76
110
  if (keepAliveTimer) {
77
111
  clearInterval(keepAliveTimer);
78
112
  }
@@ -84,7 +118,7 @@ export async function startRemoteServer(options) {
84
118
  catch (error) {
85
119
  if (!closed) {
86
120
  closed = true;
87
- sessions.delete(transport.sessionId);
121
+ sseSessions.delete(transport.sessionId);
88
122
  if (keepAliveTimer) {
89
123
  clearInterval(keepAliveTimer);
90
124
  }
@@ -100,7 +134,7 @@ export async function startRemoteServer(options) {
100
134
  res.writeHead(400).end('Missing sessionId');
101
135
  return;
102
136
  }
103
- const session = sessions.get(sessionId);
137
+ const session = sseSessions.get(sessionId);
104
138
  if (!session) {
105
139
  res.writeHead(404).end('Session not found');
106
140
  return;
@@ -122,7 +156,87 @@ export async function startRemoteServer(options) {
122
156
  server.once('error', reject);
123
157
  server.listen(options.port, options.host, () => resolve());
124
158
  });
125
- console.log(`Remote MCP server listening on http://${options.host}:${options.port}${ssePath}`);
159
+ console.log(`Remote MCP server listening on http://${options.host}:${options.port}${mcpPath}`);
160
+ }
161
+ async function handleStreamableHttpRequest({ req, res, authMode, protectedResourceMetadataUrl, resolveUpstreamToken, sessions, }) {
162
+ writeMcpCorsHeaders(res);
163
+ const sessionId = getHeaderValue(req.headers['mcp-session-id']);
164
+ const existingSession = sessionId ? sessions.get(sessionId) : undefined;
165
+ if (existingSession) {
166
+ await existingSession.transport.handleRequest(req, res);
167
+ return;
168
+ }
169
+ if (sessionId) {
170
+ writeJsonRpcError(res, 404, 'Session not found');
171
+ return;
172
+ }
173
+ if (req.method !== 'POST') {
174
+ writeJsonRpcError(res, 405, 'Method not allowed');
175
+ return;
176
+ }
177
+ let body;
178
+ try {
179
+ body = await readJsonBody(req);
180
+ }
181
+ catch (error) {
182
+ if (error instanceof RequestBodyTooLargeError) {
183
+ writeJsonRpcError(res, 413, 'Payload too large');
184
+ return;
185
+ }
186
+ writeJsonRpcError(res, 400, 'Bad Request: Invalid JSON body');
187
+ return;
188
+ }
189
+ if (!includesInitializeRequest(body)) {
190
+ writeJsonRpcError(res, 400, 'Bad Request: Missing or invalid initialize request');
191
+ return;
192
+ }
193
+ const upstreamToken = getUpstreamToken(req.headers.authorization, authMode);
194
+ if (authMode === 'passthrough' && !upstreamToken) {
195
+ res
196
+ .writeHead(401, {
197
+ 'WWW-Authenticate': `Bearer resource_metadata="${protectedResourceMetadataUrl}"`,
198
+ })
199
+ .end('Unauthorized');
200
+ return;
201
+ }
202
+ const transport = new StreamableHTTPServerTransport({
203
+ sessionIdGenerator: () => randomUUID(),
204
+ onsessioninitialized: (initializedSessionId) => {
205
+ sessions.set(initializedSessionId, {
206
+ transport,
207
+ upstreamToken,
208
+ closeMcpServer: () => mcpServer.close(),
209
+ });
210
+ },
211
+ onsessionclosed: async (closedSessionId) => {
212
+ const session = sessions.get(closedSessionId);
213
+ sessions.delete(closedSessionId);
214
+ await session?.closeMcpServer().catch(() => undefined);
215
+ },
216
+ });
217
+ const mcpServer = createMcpServer({
218
+ resolveUpstreamToken,
219
+ requireUpstreamToken: authMode === 'passthrough',
220
+ });
221
+ transport.onclose = () => {
222
+ const initializedSessionId = transport.sessionId;
223
+ if (initializedSessionId) {
224
+ sessions.delete(initializedSessionId);
225
+ }
226
+ void mcpServer.close().catch(() => undefined);
227
+ };
228
+ try {
229
+ await mcpServer.connect(transport);
230
+ await transport.handleRequest(req, res, body);
231
+ }
232
+ catch (error) {
233
+ const initializedSessionId = transport.sessionId;
234
+ if (initializedSessionId) {
235
+ sessions.delete(initializedSessionId);
236
+ }
237
+ await mcpServer.close().catch(() => undefined);
238
+ throw error;
239
+ }
126
240
  }
127
241
  function trimTrailingSlash(url) {
128
242
  return url.replace(/\/+$/, '');
@@ -137,6 +251,14 @@ function writeJsonResponse(res, body) {
137
251
  });
138
252
  res.end(JSON.stringify(body));
139
253
  }
254
+ function writeTextResponse(res, body) {
255
+ res.writeHead(200, {
256
+ 'Access-Control-Allow-Origin': '*',
257
+ 'Cache-Control': 'no-store',
258
+ 'Content-Type': 'text/plain; charset=utf-8',
259
+ });
260
+ res.end(body);
261
+ }
140
262
  function writeOptionsResponse(res) {
141
263
  res.writeHead(204, {
142
264
  'Access-Control-Allow-Headers': 'Content-Type, Authorization',
@@ -145,7 +267,62 @@ function writeOptionsResponse(res) {
145
267
  });
146
268
  res.end();
147
269
  }
148
- function getUpstreamTokenForSse(authorizationHeader, authMode) {
270
+ function writeMcpCorsHeaders(res) {
271
+ res.setHeader('Access-Control-Allow-Origin', '*');
272
+ res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, Mcp-Session-Id, mcp-session-id, Last-Event-ID, mcp-protocol-version');
273
+ res.setHeader('Access-Control-Allow-Methods', 'GET, POST, DELETE, OPTIONS');
274
+ res.setHeader('Access-Control-Expose-Headers', 'Mcp-Session-Id, mcp-session-id, mcp-protocol-version');
275
+ }
276
+ function writeMcpOptionsResponse(res) {
277
+ writeMcpCorsHeaders(res);
278
+ res.writeHead(204);
279
+ res.end();
280
+ }
281
+ function writeJsonRpcError(res, httpStatus, message) {
282
+ res.writeHead(httpStatus, {
283
+ 'Content-Type': 'application/json',
284
+ });
285
+ res.end(JSON.stringify({
286
+ jsonrpc: '2.0',
287
+ error: {
288
+ code: -32000,
289
+ message,
290
+ },
291
+ id: null,
292
+ }));
293
+ }
294
+ function getHeaderValue(header) {
295
+ if (Array.isArray(header)) {
296
+ return header[0];
297
+ }
298
+ return header;
299
+ }
300
+ async function readJsonBody(req) {
301
+ const chunks = [];
302
+ let totalBytes = 0;
303
+ for await (const chunk of req) {
304
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
305
+ totalBytes += buffer.byteLength;
306
+ if (totalBytes > maxRequestBodyBytes) {
307
+ throw new RequestBodyTooLargeError();
308
+ }
309
+ chunks.push(buffer);
310
+ }
311
+ const rawBody = Buffer.concat(chunks).toString('utf8').trim();
312
+ if (!rawBody) {
313
+ return undefined;
314
+ }
315
+ return JSON.parse(rawBody);
316
+ }
317
+ function includesInitializeRequest(body) {
318
+ if (Array.isArray(body)) {
319
+ return body.some((item) => isInitializeRequest(item));
320
+ }
321
+ return isInitializeRequest(body);
322
+ }
323
+ class RequestBodyTooLargeError extends Error {
324
+ }
325
+ function getUpstreamToken(authorizationHeader, authMode) {
149
326
  if (authMode === 'env') {
150
327
  return process.env.TOGELLO_API_TOKEN;
151
328
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "togello-mcp-server",
4
- "version": "1.0.27",
4
+ "version": "1.0.30",
5
5
  "description": "MCP server for Togello tasks, calendar memos, calendar events, and activity logs.",
6
6
  "main": "build/index.js",
7
7
  "scripts": {