Skip to content

Instantly share code, notes, and snippets.

@alonhar
alonhar / express-mcp-integrator.js
Created May 9, 2025 00:16
/ This module integrates Express with an HTTP server (like one used by FastMCP) by monkey-patching `http.createServer`. // It must be imported at the very beginning of your main server file, before any other library that might create an HTTP server (e.g., FastMCP).
import http from 'http';
import express from 'express';
const app = express();
(function() {
const originalCreateServerInternal = http.createServer;
http.createServer = function patchedHttpCreateServer(...createServerArgs) {
const fastMcpOriginalListener = createServerArgs[0];