Skip to content

Commit f26c0c6

Browse files
authored
Merge pull request #22 from Beyond-Better/staging
Fixes for docs endpoint handler
2 parents f1c2a56 + 11a1369 commit f26c0c6

File tree

7 files changed

+34
-19
lines changed

7 files changed

+34
-19
lines changed

deno.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@beyondbetter/bb-mcp-server",
3-
"version": "0.1.10",
3+
"version": "0.1.11",
44
"description": "Comprehensive library for building Deno-based MCP servers",
55
"license": "MIT",
66
"copyright": "2025 - Beyond Better <charlie@beyondbetter.app>",

src/lib/config/ConfigManager.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export class ConfigManager {
8686
if (oauthProvider) {
8787
this.config.oauthProvider = oauthProvider;
8888
}
89-
this._logger?.info('Configuration oauthProvider:', oauthProvider);
89+
this._logger?.info('ConfigManager: oauthProvider:', oauthProvider);
9090

9191
const oauthConsumer = this.loadOAuthConsumerConfig();
9292
if (oauthConsumer) {
@@ -99,6 +99,7 @@ export class ConfigManager {
9999
}
100100

101101
const docsEndpoint = this.loadDocsEndpointConfig();
102+
this._logger?.info('ConfigManager: docsEndpoint:', docsEndpoint);
102103
if (docsEndpoint) {
103104
this.config.docsEndpoint = docsEndpoint;
104105
}
@@ -238,12 +239,16 @@ export class ConfigManager {
238239
* Load server configuration from environment
239240
*/
240241
private loadServerConfig(): ServerConfig {
242+
const httpHost = this.getEnvOptional('HTTP_HOST', 'localhost');
243+
const httpPort = parseInt(this.getEnvOptional('HTTP_PORT', '3000'));
244+
241245
return {
242246
name: this.getEnvOptional('SERVER_NAME', 'mcp-server'),
243247
version: this.getEnvOptional('SERVER_VERSION', '1.0.0'),
244248
transport: this.getEnvOptional('MCP_TRANSPORT', 'stdio') as 'stdio' | 'http',
245-
httpPort: parseInt(this.getEnvOptional('HTTP_PORT', '3000')),
246-
httpHost: this.getEnvOptional('HTTP_HOST', 'localhost'),
249+
httpHost,
250+
httpPort,
251+
publicUrl: this.getEnvOptional('SERVER_PUBLIC_URL', `http://${httpHost}:${httpPort}`),
247252
devMode: this.getEnvBoolean('DEV_MODE', false),
248253
};
249254
}

src/lib/config/ConfigTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface ServerConfig {
1414
transport: 'stdio' | 'http';
1515
httpPort?: number;
1616
httpHost?: string;
17+
publicUrl?: string;
1718
devMode: boolean;
1819
}
1920

src/lib/server/AppServer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ export class AppServer {
255255
oauthConsumer: this.dependencies.oauthConsumer,
256256
workflowRegistry: this.dependencies.workflowRegistry,
257257
httpServerConfig: this.dependencies.httpServerConfig,
258+
docsEndpointHandler: this.dependencies.docsEndpointHandler,
258259
});
259260

260261
// Start HTTP server (handles MCP via /mcp endpoint)

src/lib/server/DependencyHelpers.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,23 @@ export function getTransportPersistenceStore(
380380
* Consuming apps can provide their own DocsEndpointHandler or use this default
381381
*/
382382
export function getDocsEndpointHandler(
383-
configManager: ConfigManager,
383+
docsEndpointConfig: DocsEndpointConfig,
384384
logger: Logger,
385-
docsConfig?: DocsEndpointConfig,
386385
): DocsEndpointHandler | undefined {
387-
// Use provided config or load from ConfigManager
388-
const config = docsConfig || configManager.get<DocsEndpointConfig>('docsEndpoint');
389-
390-
if (!config || !config.enabled) {
386+
// logger.info('DependencyHelper: Documentation endpoint', {
387+
// enabled: docsEndpointConfig.enabled,
388+
// path: docsEndpointConfig.path,
389+
// availableDocs: docsEndpointConfig.contentModule?.list(),
390+
// totalDocs: docsEndpointConfig.contentModule?.stats().total,
391+
// });
392+
393+
if (!docsEndpointConfig || !docsEndpointConfig.enabled) {
391394
logger.debug('DependencyHelper: Documentation endpoint not enabled');
392395
return undefined;
393396
}
394397

395398
// Validate that content source is provided
396-
if (!config.contentModule && !config.content) {
399+
if (!docsEndpointConfig.contentModule && !docsEndpointConfig.content) {
397400
logger.warn(
398401
'DependencyHelper: Documentation endpoint enabled but no content provided',
399402
{
@@ -404,14 +407,14 @@ export function getDocsEndpointHandler(
404407
}
405408

406409
logger.info('DependencyHelper: Creating documentation endpoint handler', {
407-
path: config.path,
408-
hasContentModule: !!config.contentModule,
409-
hasContent: !!config.content,
410-
allowListing: config.allowListing,
411-
cacheEnabled: config.enableCache,
410+
path: docsEndpointConfig.path,
411+
hasContentModule: !!docsEndpointConfig.contentModule,
412+
hasContent: !!docsEndpointConfig.content,
413+
allowListing: docsEndpointConfig.allowListing,
414+
cacheEnabled: docsEndpointConfig.enableCache,
412415
});
413416

414-
return new DocsEndpointHandler(config, logger);
417+
return new DocsEndpointHandler(docsEndpointConfig, logger);
415418
}
416419

417420
/**
@@ -873,8 +876,10 @@ export async function getAllDependencies(
873876
const httpServerConfig = overrides.httpServerConfig || getHttpServerConfig(configManager);
874877

875878
// Create docs endpoint handler if needed (can be overridden by consumer)
879+
const docsEndpointConfig = overrides.docsEndpointConfig ||
880+
configManager.get<DocsEndpointConfig>('docsEndpoint');
876881
const docsEndpointHandler = overrides.docsEndpointHandler ||
877-
getDocsEndpointHandler(configManager, logger, overrides.docsEndpointConfig);
882+
getDocsEndpointHandler(docsEndpointConfig, logger);
878883

879884
// Create MCP server (either from class or default)
880885
const serverConfig = overrides.serverConfig || {
@@ -899,6 +904,7 @@ export async function getAllDependencies(
899904
oauthProvider,
900905
transportManager,
901906
httpServerConfig,
907+
docsEndpointConfig,
902908
docsEndpointHandler,
903909
...consumerDeps,
904910
};

src/lib/server/HttpServer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface HttpServerDependencies {
7171
/** Server configuration */
7272
httpServerConfig: HttpServerConfig;
7373
/** Documentation endpoint handler (optional) */
74-
docsEndpointHandler?: DocsEndpointHandler;
74+
docsEndpointHandler?: DocsEndpointHandler | undefined;
7575
// TODO: Future - Generic custom endpoints
7676
// /** Custom endpoint handlers */
7777
// customEndpoints?: Array<{
@@ -132,6 +132,7 @@ export class HttpServer {
132132
port: this.httpServerConfig.port,
133133
name: this.httpServerConfig.name,
134134
version: this.httpServerConfig.version,
135+
usingDocsHandler: !!this.docsHandler,
135136
});
136137
}
137138

src/lib/types/AppServerTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface AppServerDependencies {
6868
httpServerConfig?: HttpServerConfig;
6969

7070
// Documentation endpoint handler (optional)
71+
docsEndpointConfig?: DocsEndpointConfig;
7172
docsEndpointHandler?: DocsEndpointHandler;
7273

7374
// Consumer-specific dependencies (pre-built instances

0 commit comments

Comments
 (0)