Skip to content

Conversation

@jonathanhefner
Copy link
Member

Split server startup logic into two functions in each server-utils.ts:

  • startStdioServer(createServer) - handles stdio transport
  • startHttpServer(createServer) - handles HTTP transport

And keep the transport selection visible in each server.ts:

process.argv.includes("--stdio")
  ? await startStdioServer(createServer)
  : await startHttpServer(createServer);

Split server startup logic into two functions in each `server-utils.ts`:

- `startStdioServer(createServer)` - handles stdio transport
- `startHttpServer(createServer)` - handles HTTP transport

And keep the transport selection visible in each `server.ts`:

```typescript
process.argv.includes("--stdio")
  ? await startStdioServer(createServer)
  : await startHttpServer(createServer);
```

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 9, 2026

Open in StackBlitz

@modelcontextprotocol/ext-apps

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/ext-apps@229

@modelcontextprotocol/server-basic-react

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-basic-react@229

@modelcontextprotocol/server-basic-vanillajs

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-basic-vanillajs@229

@modelcontextprotocol/server-budget-allocator

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-budget-allocator@229

@modelcontextprotocol/server-cohort-heatmap

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-cohort-heatmap@229

@modelcontextprotocol/server-customer-segmentation

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-customer-segmentation@229

@modelcontextprotocol/server-scenario-modeler

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-scenario-modeler@229

@modelcontextprotocol/server-system-monitor

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-system-monitor@229

@modelcontextprotocol/server-threejs

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-threejs@229

@modelcontextprotocol/server-wiki-explorer

npm i https://pkg.pr.new/modelcontextprotocol/ext-apps/@modelcontextprotocol/server-wiki-explorer@229

commit: 0388d6a

options: ServerOptions,
): Promise<void> {
const { port, name = "MCP Server" } = options;
const port = parseInt(process.env.PORT ?? "3001", 10);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces process.env again in server-utils, I don't like this direction tbh

And the startStdioServer method is a lot of lines to replace a one-liner.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces process.env again in server-utils, I don't like this direction tbh

The PORT env variable is very widely used, so reading from wherever in the code base is pretty typical for web servers.

And the startStdioServer method is a lot of lines to replace a one-liner.

The intent is instant clarity. Compare:

  if (process.argv.includes("--stdio")) {
    await createServer().connect(new StdioServerTransport());
  } else {
    const port = parseInt(process.env.PORT ?? "3001", 10);
    await startServer(createServer, { port, name: "Basic MCP App Server (Preact)" });
  }

vs

  process.argv.includes("--stdio")
    ? await startStdioServer(createServer)
    : await startHttpServer(createServer);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants