Add end-to-end tests and improve documentation for stdio transport#482
Add end-to-end tests and improve documentation for stdio transport#482frontegg-david wants to merge 3 commits into
Conversation
… clarity and detail
…ypoint and SKILL files
📝 WalkthroughWalkthroughThis PR extends FrontMCP with stdio-only transport support, allowing servers to operate over stdin/stdout without binding HTTP/TCP ports. The decorator gains a ChangesStdio Transport with Decorated Class Support
Sequence Diagram(s)sequenceDiagram
participant ClientCode as Client Code
participant runStdio as runStdio(input)
participant resolveInput as resolveConfigInput
participant getDecor as getDecoratorConfig
participant StdioServer as Stdio Server
ClientCode->>runStdio: pass `@FrontMcp` class or config
runStdio->>resolveInput: resolve input
resolveInput->>getDecor: extract metadata
alt Has `@FrontMcp` metadata
getDecor->>resolveInput: return config
resolveInput->>runStdio: resolved config
else Missing metadata
getDecor->>resolveInput: throw InternalMcpError
resolveInput-->>ClientCode: error
end
runStdio->>runStdio: set FRONTMCP_STDIO=1
runStdio->>runStdio: disable HTTP (http:undefined)
runStdio->>StdioServer: start with resolved config
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@libs/sdk/src/front-mcp/front-mcp.ts`:
- Around line 515-520: The stdio guard (stdioServing) is set to true before
initialization completes in runStdio(), causing retries to be ignored if startup
throws; change runStdio() so stdioServing is only set after successful
initialization or ensure you wrap initialization in try/catch and reset
stdioServing = false on any thrown error so a failed startup does not leave the
guard sticky (refer to runStdio() and the stdioServing variable and the
process.env['FRONTMCP_STDIO'] set-up).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6c11d076-7abc-4711-a81b-4fc723910dca
⛔ Files ignored due to path filters (2)
libs/cli/src/commands/build/exec/__tests__/runner-script.spec.tsis excluded by!**/build/**libs/cli/src/commands/build/exec/runner-script.tsis excluded by!**/build/**
📒 Files selected for processing (28)
apps/e2e/demo-e2e-cli-exec/e2e/cli-stdio.e2e.spec.tsapps/e2e/demo-e2e-stdio-transport/e2e/stdio-no-http-port.e2e.spec.tsapps/e2e/demo-e2e-stdio-transport/src/stdio-class-entrypoint.tsdocs/frontmcp/deployment/mcp-clients.mdxdocs/frontmcp/sdk-reference/core/frontmcp-instance.mdxdocs/frontmcp/sdk-reference/decorators/frontmcp.mdxlibs/sdk/src/common/decorators/__tests__/front-mcp-stdio.decorator.spec.tslibs/sdk/src/common/decorators/front-mcp.decorator.tslibs/sdk/src/front-mcp/__tests__/run-stdio-input.spec.tslibs/sdk/src/front-mcp/front-mcp.tslibs/sdk/src/index.tslibs/skills/catalog/frontmcp-auth-ui/SKILL.mdlibs/skills/catalog/frontmcp-authorities/SKILL.mdlibs/skills/catalog/frontmcp-channels/SKILL.mdlibs/skills/catalog/frontmcp-config/SKILL.mdlibs/skills/catalog/frontmcp-deployment/SKILL.mdlibs/skills/catalog/frontmcp-deployment/references/mcp-client-integration.mdlibs/skills/catalog/frontmcp-development/SKILL.mdlibs/skills/catalog/frontmcp-extensibility/SKILL.mdlibs/skills/catalog/frontmcp-guides/SKILL.mdlibs/skills/catalog/frontmcp-observability/SKILL.mdlibs/skills/catalog/frontmcp-production-readiness/SKILL.mdlibs/skills/catalog/frontmcp-setup/SKILL.mdlibs/skills/catalog/frontmcp-testing/SKILL.mdlibs/skills/catalog/skills-manifest.jsonlibs/testing/src/index.tslibs/testing/src/raw-client/index.tslibs/testing/src/raw-client/port-probe.ts
| process.env['FRONTMCP_STDIO'] = '1'; | ||
| if (stdioServing) { | ||
| console.error('[FrontMCP] runStdio() called more than once; ignoring the duplicate stdio connection.'); | ||
| return; | ||
| } | ||
| stdioServing = true; |
There was a problem hiding this comment.
Reset the stdio guard on startup failure.
If initialization throws after setting stdioServing = true, subsequent runStdio() retries in the same process are permanently ignored. This makes recoverable startup failures sticky.
💡 Proposed fix
process.env['FRONTMCP_STDIO'] = '1';
if (stdioServing) {
console.error('[FrontMCP] runStdio() called more than once; ignoring the duplicate stdio connection.');
return;
}
stdioServing = true;
+ let startupSucceeded = false;
+ try {
// Dynamically import to avoid bundling issues
const { StdioServerTransport, McpServer } = await import('`@frontmcp/protocol`');
@@
// Create stdio transport and connect
const transport = new StdioServerTransport();
await mcpServer.connect(transport);
+ startupSucceeded = true;
@@
process.on('SIGINT', shutdownHandler);
process.on('SIGTERM', shutdownHandler);
+ } catch (err) {
+ if (!startupSucceeded) stdioServing = false;
+ throw err;
+ }
}
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@libs/sdk/src/front-mcp/front-mcp.ts` around lines 515 - 520, The stdio guard
(stdioServing) is set to true before initialization completes in runStdio(),
causing retries to be ignored if startup throws; change runStdio() so
stdioServing is only set after successful initialization or ensure you wrap
initialization in try/catch and reset stdioServing = false on any thrown error
so a failed startup does not leave the guard sticky (refer to runStdio() and the
stdioServing variable and the process.env['FRONTMCP_STDIO'] set-up).
Summary by CodeRabbit
New Features
--stdiomode for direct stdin/stdout communication.Documentation
Tests