Skip to content

Commit 7a1eb61

Browse files
ochafikclaude
andcommitted
fix(examples): allow connections from any host for development
Use host: "0.0.0.0" in createMcpExpressApp to disable DNS rebinding protection, allowing connections from Android emulators and other devices on the network. Also re-add CORS middleware. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c251e40 commit 7a1eb61

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/shared/server-utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
1313
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
1414
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1515
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
16+
import cors from "cors";
1617
import { randomUUID } from "node:crypto";
1718
import type { Request, Response } from "express";
1819

@@ -49,8 +50,10 @@ export async function startServer(
4950
// Unified session store for both transport types
5051
const sessions = new Map<string, Transport>();
5152

52-
// Express with DNS rebinding protection
53-
const app = createMcpExpressApp();
53+
// Express app - bind to all interfaces for development/testing
54+
// (allows connections from Android emulators, other devices, etc.)
55+
const app = createMcpExpressApp({ host: "0.0.0.0" });
56+
app.use(cors());
5457

5558
// Streamable HTTP (stateful)
5659
app.all("/mcp", async (req: Request, res: Response) => {

0 commit comments

Comments
 (0)