togello-mcp-server 1.0.32 → 1.0.33

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
@@ -53,6 +53,8 @@ ChatGPT developer mode can add remote MCP servers that use SSE. For production C
53
53
 
54
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
55
 
56
+ Remote OAuth clients that connect to `/mcp` should discover protected resource metadata at `/.well-known/oauth-protected-resource/mcp`. That metadata returns `resource` as the full MCP endpoint URL, such as `https://your-domain.example/mcp`. Unauthenticated `/mcp` requests include a `WWW-Authenticate` challenge whose `resource_metadata` value points to that `/mcp` metadata path.
57
+
56
58
  The configured OAuth issuer must be an origin URL without a path component.
57
59
 
58
60
  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.
@@ -30,11 +30,34 @@ export async function startRemoteServer(options) {
30
30
  const oauthIssuer = trimTrailingSlash(options.oauthIssuer);
31
31
  validatePathlessOAuthIssuer(oauthIssuer);
32
32
  const protectedResourceMetadataUrl = `${publicBaseUrl}${protectedResourceMetadataPath}`;
33
+ const mcpResourceUrl = `${publicBaseUrl}${mcpPath}`;
34
+ const mcpProtectedResourceMetadataPath = `${protectedResourceMetadataPath}${mcpPath}`;
35
+ const mcpProtectedResourceMetadataUrl = `${publicBaseUrl}${mcpProtectedResourceMetadataPath}`;
33
36
  const authorizationServerMetadataUrl = `${oauthIssuer}${authorizationServerMetadataPath}`;
34
37
  const authorizationServerMetadataPaths = new Set([
35
38
  authorizationServerMetadataPath,
36
39
  `${authorizationServerMetadataPath}${mcpPath}`,
37
40
  ]);
41
+ const protectedResourceMetadataByPath = new Map([
42
+ [
43
+ protectedResourceMetadataPath,
44
+ {
45
+ resource: publicBaseUrl,
46
+ authorization_servers: [oauthIssuer],
47
+ scopes_supported: supportedScopes,
48
+ bearer_methods_supported: ['header'],
49
+ },
50
+ ],
51
+ [
52
+ mcpProtectedResourceMetadataPath,
53
+ {
54
+ resource: mcpResourceUrl,
55
+ authorization_servers: [oauthIssuer],
56
+ scopes_supported: supportedScopes,
57
+ bearer_methods_supported: ['header'],
58
+ },
59
+ ],
60
+ ]);
38
61
  const openaiAppsChallengeToken = options.openaiAppsChallengeToken?.trim();
39
62
  const sseSessions = new Map();
40
63
  const streamableSessions = new Map();
@@ -68,18 +91,14 @@ export async function startRemoteServer(options) {
68
91
  return;
69
92
  }
70
93
  }
71
- if (requestUrl.pathname === protectedResourceMetadataPath) {
94
+ const protectedResourceMetadata = protectedResourceMetadataByPath.get(requestUrl.pathname);
95
+ if (protectedResourceMetadata) {
72
96
  if (req.method === 'OPTIONS') {
73
97
  writeOptionsResponse(res);
74
98
  return;
75
99
  }
76
100
  if (req.method === 'GET') {
77
- writeJsonResponse(res, {
78
- resource: publicBaseUrl,
79
- authorization_servers: [oauthIssuer],
80
- scopes_supported: supportedScopes,
81
- bearer_methods_supported: ['header'],
82
- });
101
+ writeJsonResponse(res, protectedResourceMetadata);
83
102
  return;
84
103
  }
85
104
  }
@@ -92,7 +111,7 @@ export async function startRemoteServer(options) {
92
111
  req,
93
112
  res,
94
113
  authMode: options.authMode,
95
- protectedResourceMetadataUrl,
114
+ protectedResourceMetadataUrl: mcpProtectedResourceMetadataUrl,
96
115
  resolveUpstreamToken,
97
116
  sessions: streamableSessions,
98
117
  });
@@ -192,6 +211,15 @@ async function handleStreamableHttpRequest({ req, res, authMode, protectedResour
192
211
  writeJsonRpcError(res, 404, 'Session not found');
193
212
  return;
194
213
  }
214
+ const upstreamToken = getUpstreamToken(req.headers.authorization, authMode);
215
+ if (authMode === 'passthrough' && !upstreamToken) {
216
+ res
217
+ .writeHead(401, {
218
+ 'WWW-Authenticate': `Bearer resource_metadata="${protectedResourceMetadataUrl}"`,
219
+ })
220
+ .end('Unauthorized');
221
+ return;
222
+ }
195
223
  if (req.method !== 'POST') {
196
224
  writeJsonRpcError(res, 405, 'Method not allowed');
197
225
  return;
@@ -212,15 +240,6 @@ async function handleStreamableHttpRequest({ req, res, authMode, protectedResour
212
240
  writeJsonRpcError(res, 400, 'Bad Request: Missing or invalid initialize request');
213
241
  return;
214
242
  }
215
- const upstreamToken = getUpstreamToken(req.headers.authorization, authMode);
216
- if (authMode === 'passthrough' && !upstreamToken) {
217
- res
218
- .writeHead(401, {
219
- 'WWW-Authenticate': `Bearer resource_metadata="${protectedResourceMetadataUrl}"`,
220
- })
221
- .end('Unauthorized');
222
- return;
223
- }
224
243
  const transport = new StreamableHTTPServerTransport({
225
244
  sessionIdGenerator: () => randomUUID(),
226
245
  onsessioninitialized: (initializedSessionId) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "togello-mcp-server",
4
- "version": "1.0.32",
4
+ "version": "1.0.33",
5
5
  "description": "MCP server for Togello tasks, calendar memos, calendar events, and activity logs.",
6
6
  "main": "build/index.js",
7
7
  "scripts": {