conductor-node-mcp 15.0.1 → 15.2.0

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/src/oauth.ts CHANGED
@@ -9,9 +9,12 @@
9
9
  // envelope says so (api.conductor.is sits behind Cloudflare; an edge 401/403
10
10
  // page must fail open). Every gate decision and every probe is logged as one
11
11
  // structured line because http.ts redacts www-authenticate from Render logs.
12
- // The URLs are hardcoded: every customer's connector stores them, so they
13
- // never change. The rest of the config is read from non-MCP_SERVER_ env names
14
- // (see code-tool.ts for why) with production defaults baked in.
12
+ // The authorization server URL is hardcoded. The resource URL defaults to the
13
+ // listed hostname and can be moved with CONDUCTOR_MCP_RESOURCE_URL (the
14
+ // developer code-mode hostname runs this same package at another origin); it
15
+ // is read per request like the rest of the config, which comes from
16
+ // non-MCP_SERVER_ env names (see code-tool.ts for why) with production
17
+ // defaults baked in.
15
18
  import cors from 'cors';
16
19
  import { createHash } from 'node:crypto';
17
20
  import express from 'express';
@@ -20,9 +23,10 @@ import { sdkMethods } from './methods';
20
23
  import { rpcMethodProps, sanitizeUserAgent } from './telemetry';
21
24
  import { readEnv } from './util';
22
25
 
23
- // A local end-to-end run edits these two temporarily (see the dashboard's src/lib/oauth/README.md).
26
+ // A local end-to-end run edits AUTHORIZATION_SERVER_URL temporarily and sets CONDUCTOR_MCP_RESOURCE_URL
27
+ // (see the dashboard's src/lib/oauth/README.md).
24
28
  const AUTHORIZATION_SERVER_URL = 'https://dashboard.conductor.is';
25
- const RESOURCE_URL = 'https://mcp.conductor.is/';
29
+ const DEFAULT_RESOURCE_URL = 'https://mcp.conductor.is/';
26
30
  const DEFAULT_API_BASE_URL = 'https://api.conductor.is/v1'; // conductor-node's own default (src/client.ts)
27
31
  const PROTECTED_RESOURCE_METADATA_PATH = '/.well-known/oauth-protected-resource';
28
32
  // The read-only connector URL. POST /read-only (Express also matches /read-only/) allows only reads (see
@@ -57,7 +61,7 @@ export type OAuthResource = 'root' | 'read-only';
57
61
 
58
62
  export interface OAuthResourceConfig {
59
63
  authorizationServerUrl: string; // no trailing slash
60
- resourceUrl: string; // root: RESOURCE_URL, trailing slash kept; read-only: `${origin}/read-only`, no slash
64
+ resourceUrl: string; // root: getRootResourceUrl(), trailing slash kept; read-only: `${origin}/read-only`, no slash
61
65
  resourceMetadataUrl: string; // `${origin}/.well-known/oauth-protected-resource`, plus READ_ONLY_PATH for read-only
62
66
  apiBaseUrl: string; // no trailing slash
63
67
  keyProbeEnabled: boolean;
@@ -89,14 +93,15 @@ type KeyProbeResult = { verdict: KeyProbeVerdict; code?: string; error?: string
89
93
  // The read-only resource is derived from the root.
90
94
  export function getOAuthResourceConfig(resource: OAuthResource = 'root'): OAuthResourceConfig {
91
95
  const isReadOnly = resource === 'read-only';
96
+ const rootResourceUrl = getRootResourceUrl();
92
97
  // Absolute paths resolved against the root, so the identifier and the path-inserted RFC 9728 metadata URL
93
98
  // both come from READ_ONLY_PATH; http.ts's '/read-only' route literals must match it (the seal test pins them).
94
99
  return {
95
100
  authorizationServerUrl: AUTHORIZATION_SERVER_URL,
96
- resourceUrl: isReadOnly ? new URL(READ_ONLY_PATH, RESOURCE_URL).href : RESOURCE_URL,
101
+ resourceUrl: isReadOnly ? new URL(READ_ONLY_PATH, rootResourceUrl).href : rootResourceUrl,
97
102
  resourceMetadataUrl: new URL(
98
103
  PROTECTED_RESOURCE_METADATA_PATH + (isReadOnly ? READ_ONLY_PATH : ''),
99
- RESOURCE_URL,
104
+ rootResourceUrl,
100
105
  ).href,
101
106
  apiBaseUrl: (readEnv('CONDUCTOR_BASE_URL') ?? DEFAULT_API_BASE_URL).replace(/\/+$/, ''),
102
107
  keyProbeEnabled: !['off', 'false', '0', 'no'].includes(
@@ -105,6 +110,39 @@ export function getOAuthResourceConfig(resource: OAuthResource = 'root'): OAuthR
105
110
  };
106
111
  }
107
112
 
113
+ // The root resource identifier: CONDUCTOR_MCP_RESOURCE_URL when it is an absolute http(s) origin (any path,
114
+ // query or fragment is dropped and the trailing slash kept, the form hosted Claude connects with), else the
115
+ // listed hostname. The read-only identifier and both RFC 9728 documents derive from it.
116
+ export function getRootResourceUrl(): string {
117
+ const configured = readEnv('CONDUCTOR_MCP_RESOURCE_URL');
118
+ if (configured === undefined) return DEFAULT_RESOURCE_URL;
119
+ if (configured === resourceUrlMemo.raw) return resourceUrlMemo.resolved;
120
+ let resolved = DEFAULT_RESOURCE_URL;
121
+ let rejected: string | undefined;
122
+ try {
123
+ const url = new URL(configured);
124
+ if (url.protocol === 'https:' || url.protocol === 'http:') resolved = `${url.origin}/`;
125
+ else rejected = `unsupported protocol ${url.protocol}`;
126
+ } catch {
127
+ rejected = 'not an absolute URL';
128
+ }
129
+ if (rejected !== undefined) {
130
+ // Logged once per distinct value: the variable is deployment config, and a silent fallback would leave
131
+ // a server at another hostname advertising the listed resource with nothing in the logs to say why.
132
+ getLogger().warn(
133
+ { configured, fallback: DEFAULT_RESOURCE_URL },
134
+ `Ignoring CONDUCTOR_MCP_RESOURCE_URL (${rejected}); advertising the default resource`,
135
+ );
136
+ }
137
+ resourceUrlMemo = { raw: configured, resolved };
138
+ return resolved;
139
+ }
140
+
141
+ let resourceUrlMemo: { raw: string | undefined; resolved: string } = {
142
+ raw: undefined,
143
+ resolved: DEFAULT_RESOURCE_URL,
144
+ };
145
+
108
146
  // No scopes_supported: read-only is decided by the URL the client POSTs to, never by the token, and listing
109
147
  // none keeps Claude from requesting offline_access (a refresh token this server never issues).
110
148
  export function buildProtectedResourceMetadata(config: OAuthResourceConfig): Record<string, unknown> {
package/src/server.ts CHANGED
@@ -18,7 +18,7 @@ import { McpOptions } from './options';
18
18
  import { blockedMethodsForCodeTool } from './methods';
19
19
  import { HandlerFunction, McpRequestContext, ToolCallResult, McpTool } from './types';
20
20
 
21
- export const VERSION = '15.0.1'; // x-release-please-version
21
+ export const VERSION = '15.2.0'; // x-release-please-version
22
22
 
23
23
  export const newMcpServer = async ({
24
24
  stainlessApiKey,
@@ -30,7 +30,7 @@ export const newMcpServer = async ({
30
30
  new McpServer(
31
31
  {
32
32
  name: 'conductor_node_api',
33
- version: '15.0.1', // x-release-please-version
33
+ version: '15.2.0', // x-release-please-version
34
34
  },
35
35
  {
36
36
  instructions: await getInstructions({ stainlessApiKey, customInstructionsPath }),