johnhenry
MCP Serverjohnhenrypublic

mcp create express app

一个用于创建支持模型上下文协议(MCP)的 Express 应用程序的工具模块。

Repository Info

0
Stars
1
Forks
0
Watchers
2
Issues
JavaScript
Language
-
License

About This Server

一个用于创建支持模型上下文协议(MCP)的 Express 应用程序的工具模块。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

MCP Create Express App

A utility module for creating Express applications with Model Context Protocol (MCP) support.

Installation

npm install mcp-create-express-app express

Usage

Stateless Mode

import express from "express";
import createExpressApp from "mcp-create-express-app";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

// Create an MCP server
const server = new McpServer({
  name: "my-server",
  version: "1.0.0",
});

// Define tools, prompts, and resources
server.tool("greet", { name: "string" }, async ({ name }) => {
  return { content: [{ type: "text", text: `Hello, ${name}!` }] };
});

const app = await createExpressApp(server);

// Start the Express server
const port = 3000;
app.listen(port, () => {
  console.log(`MCP server available at http://localhost:${port}${mcpPath}`);
});

Stateful Mode

import express from "express";
import { createStateful } from "mcp-client-router/create-express-app";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

// Create an Express app
const app = express();

// Create an MCP server
const server = new McpServer({
  name: "my-server",
  version: "1.0.0",
});

// Define tools, prompts, and resources
server.tool("greet", { name: "string" }, async ({ name }) => {
  return { content: [{ type: "text", text: `Hello, ${name}!` }] };
});

// Mount the MCP server to the Express app with stateful behavior
const mcpPath = "/mcp";
createStateful(app, server, {
  path: mcpPath,
  sessionTimeout: 300000, // 5 minutes
});

// Start the Express server
const port = 3000;
app.listen(port, () => {
  console.log(
    `Stateful MCP server available at http://localhost:${port}${mcpPath}`
  );
});

API Reference

createStateless

function createStateless(app, server, options)

Creates a stateless HTTP endpoint for an MCP server in an Express app. Each request is treated as independent.

Parameters

  • app (Express app): The Express application
  • server (McpServer): The MCP server to expose
  • options (object): Configuration options
    • path (string): The URL path to mount the MCP server (default: '/mcp')
    • corsOptions (object): CORS configuration options

createStateful

function createStateful(app, server, options)

Creates a stateful HTTP endpoint for an MCP server in an Express app. Maintains session state between requests.

Parameters

  • app (Express app): The Express application
  • server (McpServer): The MCP server to expose
  • options (object): Configuration options
    • path (string): The URL path to mount the MCP server (default: '/mcp')
    • sessionTimeout (number): Session timeout in milliseconds (default: 30 minutes)
    • corsOptions (object): CORS configuration options

License

ISC

Quick Start

1

Clone the repository

git clone https://github.com/johnhenry/mcp-create-express-app
2

Install dependencies

cd mcp-create-express-app
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownerjohnhenry
Repomcp-create-express-app
LanguageJavaScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation