togello-mcp-server 1.0.31 → 1.0.32

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
@@ -51,6 +51,10 @@ https://your-domain.example/mcp
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
+ Remote mode redirects OAuth authorization server metadata discovery paths at `/.well-known/oauth-authorization-server` and `/.well-known/oauth-authorization-server/mcp` to the Togello OAuth issuer configured with `TOGELLO_OAUTH_ISSUER` or `TOGELLO_API_BASE_URL`.
55
+
56
+ The configured OAuth issuer must be an origin URL without a path component.
57
+
54
58
  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
59
 
56
60
  ## Tools
@@ -5,6 +5,12 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
5
5
  import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
6
6
  import { parseBearerToken } from './bearerToken.js';
7
7
  import { createMcpServer } from './mcpServer.js';
8
+ const authorizationServerMetadataPath = '/.well-known/oauth-authorization-server';
9
+ const authorizationServerMetadataCorsHeaders = {
10
+ 'Access-Control-Allow-Headers': 'Content-Type, Authorization, MCP-Protocol-Version, mcp-protocol-version',
11
+ 'Access-Control-Allow-Methods': 'GET, OPTIONS',
12
+ 'Access-Control-Allow-Origin': '*',
13
+ };
8
14
  const protectedResourceMetadataPath = '/.well-known/oauth-protected-resource';
9
15
  const openaiAppsChallengePath = '/.well-known/openai-apps-challenge';
10
16
  const maxRequestBodyBytes = 1_000_000;
@@ -21,8 +27,14 @@ export async function startRemoteServer(options) {
21
27
  const ssePath = options.ssePath ?? '/sse';
22
28
  const messagePath = options.messagePath ?? '/message';
23
29
  const publicBaseUrl = trimTrailingSlash(options.publicBaseUrl);
24
- const oauthIssuer = options.oauthIssuer;
30
+ const oauthIssuer = trimTrailingSlash(options.oauthIssuer);
31
+ validatePathlessOAuthIssuer(oauthIssuer);
25
32
  const protectedResourceMetadataUrl = `${publicBaseUrl}${protectedResourceMetadataPath}`;
33
+ const authorizationServerMetadataUrl = `${oauthIssuer}${authorizationServerMetadataPath}`;
34
+ const authorizationServerMetadataPaths = new Set([
35
+ authorizationServerMetadataPath,
36
+ `${authorizationServerMetadataPath}${mcpPath}`,
37
+ ]);
26
38
  const openaiAppsChallengeToken = options.openaiAppsChallengeToken?.trim();
27
39
  const sseSessions = new Map();
28
40
  const streamableSessions = new Map();
@@ -46,6 +58,16 @@ export async function startRemoteServer(options) {
46
58
  return;
47
59
  }
48
60
  }
61
+ if (authorizationServerMetadataPaths.has(requestUrl.pathname)) {
62
+ if (req.method === 'OPTIONS') {
63
+ writeAuthorizationServerMetadataOptionsResponse(res);
64
+ return;
65
+ }
66
+ if (req.method === 'GET') {
67
+ writeRedirectResponse(res, authorizationServerMetadataUrl);
68
+ return;
69
+ }
70
+ }
49
71
  if (requestUrl.pathname === protectedResourceMetadataPath) {
50
72
  if (req.method === 'OPTIONS') {
51
73
  writeOptionsResponse(res);
@@ -241,6 +263,12 @@ async function handleStreamableHttpRequest({ req, res, authMode, protectedResour
241
263
  function trimTrailingSlash(url) {
242
264
  return url.replace(/\/+$/, '');
243
265
  }
266
+ function validatePathlessOAuthIssuer(oauthIssuer) {
267
+ const { pathname } = new URL(oauthIssuer);
268
+ if (pathname !== '/') {
269
+ throw new Error(`Remote OAuth issuer must not include a path: ${oauthIssuer}`);
270
+ }
271
+ }
244
272
  function writeJsonResponse(res, body) {
245
273
  res.writeHead(200, {
246
274
  'Access-Control-Allow-Headers': 'Content-Type, Authorization',
@@ -251,6 +279,18 @@ function writeJsonResponse(res, body) {
251
279
  });
252
280
  res.end(JSON.stringify(body));
253
281
  }
282
+ function writeRedirectResponse(res, location) {
283
+ res.writeHead(302, {
284
+ ...authorizationServerMetadataCorsHeaders,
285
+ 'Cache-Control': 'no-store',
286
+ Location: location,
287
+ });
288
+ res.end();
289
+ }
290
+ function writeAuthorizationServerMetadataOptionsResponse(res) {
291
+ res.writeHead(204, authorizationServerMetadataCorsHeaders);
292
+ res.end();
293
+ }
254
294
  function writeTextResponse(res, body) {
255
295
  res.writeHead(200, {
256
296
  'Access-Control-Allow-Origin': '*',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "togello-mcp-server",
4
- "version": "1.0.31",
4
+ "version": "1.0.32",
5
5
  "description": "MCP server for Togello tasks, calendar memos, calendar events, and activity logs.",
6
6
  "main": "build/index.js",
7
7
  "scripts": {