Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apps/e2e/demo-e2e-direct/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Demo E2E Direct - Shared Server Configuration
*
* This file contains the base configuration shared between:
* - HTTP server (main.ts)
* - Stdio transport (stdio-entrypoint.ts)
* - Direct usage tests
*
* Separating this from main.ts prevents auto-bootstrapping of HTTP server
* when only the config is needed (e.g., for stdio mode).
*/
import { LogLevel } from '@frontmcp/sdk';
import { NotesApp } from './apps/notes';

/**
* Base configuration shared between HTTP server and direct usage.
* This ensures consistency and prevents config drift.
*/
export const serverConfig = {
info: { name: 'Demo E2E Direct', version: '0.1.0' },
apps: [NotesApp],
logging: { level: LogLevel.Verbose, enableConsole: true },
auth: { mode: 'public' as const },
};
21 changes: 5 additions & 16 deletions apps/e2e/demo-e2e-direct/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,21 @@
* - createInMemoryServer() for MCP SDK Client integration
* - FrontMcpInstance.runStdio() for stdio transport (Claude Code)
*/
import { FrontMcp, LogLevel } from '@frontmcp/sdk';
import { NotesApp } from './apps/notes';
import { FrontMcp } from '@frontmcp/sdk';
import { serverConfig } from './config.js';

// Validate port - fallback to 3117 if invalid
const rawPort = parseInt(process.env['PORT'] ?? '3117', 10);
const port = Number.isFinite(rawPort) && rawPort > 0 ? rawPort : 3117;

/**
* Base configuration shared between HTTP server and direct usage.
* This ensures consistency and prevents config drift.
*/
const baseConfig = {
info: { name: 'Demo E2E Direct', version: '0.1.0' },
apps: [NotesApp],
logging: { level: LogLevel.Verbose, enableConsole: true },
auth: { mode: 'public' as const },
};

@FrontMcp({
...baseConfig,
...serverConfig,
http: { port },
})
export default class Server {}

/**
* Export the configuration for direct usage testing.
* Re-export the configuration for direct usage testing.
* This allows tests to import the config directly.
*/
export const serverConfig = baseConfig;
export { serverConfig } from './config.js';
5 changes: 4 additions & 1 deletion apps/e2e/demo-e2e-direct/src/stdio-entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
* Usage:
* npx ts-node --esm src/stdio-entrypoint.ts
* node dist/stdio-entrypoint.js
*
* NOTE: This imports from config.js (not main.js) to avoid triggering
* auto-bootstrap of the HTTP server via the @FrontMcp decorator.
*/
import { FrontMcpInstance } from '@frontmcp/sdk';
import { serverConfig } from './main.js';
import { serverConfig } from './config.js';

// Run the server in stdio mode
FrontMcpInstance.runStdio(serverConfig).catch((err) => {
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e/demo-e2e-openapi/src/security-test-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { FrontMcp, App, LogLevel } from '@frontmcp/sdk';
import { OpenapiAdapter } from '@frontmcp/adapters';

const port = parseInt(process.env['PORT'] ?? '3015', 10);
const port = parseInt(process.env['PORT'] ?? '3122', 10);
const apiBaseUrl = process.env['OPENAPI_BASE_URL'] || 'http://localhost:3000';
const openapiUrl = process.env['OPENAPI_SPEC_URL'] || `${apiBaseUrl}/openapi.json`;
const staticJwt = process.env['STATIC_AUTH_JWT'];
Expand Down
Loading