Express REST API and MCP Server Framework is a comprehensive development framework for building RESTful APIs with Express.js. It provides a complete template for creating production-ready APIs using Node.js, Express, Mongoose (MongoDB), and Sequelize (SQL databases). Every generated service exposes both REST endpoints and an MCP (Model Context Protocol) server so LLMs can interact with your API directly.
Express REST API and MCP Server Framework is a comprehensive development framework for building RESTful APIs and MCP servers with Express.js. It provides a complete template for creating production-ready APIs using Node.js, Express, Mongoose (MongoDB), and Sequelize (SQL databases).
In computer programming, an application programming interface (API) is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer. An API may be for a web-based system, operating system, database system, computer hardware or software library. Just as a graphical user interface makes it easier for people to use programs, application programming interfaces make it easier for developers to use certain technologies in building applications. - Wikipedia
What is REST?
Representational state transfer (REST) or RESTful web services is a way of providing interoperability between computer systems on the Internet. REST-compliant Web services allow requesting systems to access and manipulate textual representations of Web resources using a uniform and predefined set of stateless operations. - Wikipedia
NOTE: The use of this project requires that you have a basic knowledge of using Express in building a REST API.
What is MCP?
MCP (Model Context Protocol) is an open protocol that lets AI assistants (e.g. Claude, ChatGPT, Cursor) interact with your application through a standard interface. Instead of the LLM calling your REST API with raw HTTP, it uses MCP to discover and use tools (actions like create, update, delete) and resources (read-only data like list and get-by-id). - Wikipedia
This framework ships with a built-in MCP server. When you generate a service with npm run generate -- --name users, the same data is exposed as:
REST API — GET/POST/PUT/DELETE /users for apps and integrations
MCP tools — e.g. create_users, update_users, list_users for LLMs
MCP resources — e.g. users://list, users://{id} for LLM context
You get one codebase, dual access: traditional REST for clients and MCP for AI. See MCP Guide for setup (including Cursor) and details.
Why use Express REST API and MCP Server Framework?
Fast development — Generate full CRUD + MCP with one command (npm run generate -- --name <Name>)
Dual interface — Every generated service exposes both REST API and MCP (tools + resources) for LLMs
LLM-ready — Connect Cursor, Claude, or other MCP clients via HTTP; no extra glue code
TypeScript — Full type safety, strict mode, and a clear structure for controllers and models
API versioning — Route files like users.v1.ts map to /v1/users; latest stays at /users
Testing — Auto-generated tests for routes, controllers, and models; run with npm test
Generate a MongoDB CRUD endpoint (route, controller, model, MCP registration, tests). Use -n for short.
npm run generate -- --name <Name> --sql
Generate a SQL CRUD endpoint (Sequelize model, SQL controller/routes/tests).
npm run generate -- --name <Name> --baseurl <URL> --endpoint <path>
Generate an API-as-DB endpoint (proxy to external API). Short: -n, -b, -e.
npm run dev
Start development server with hot reload
npm run build
Compile TypeScript to dist/
npm start
Run production server
npm test
Run unit tests (Mocha, spec reporter)
npm run type-check
Run TypeScript type-check only
npm run release -- --release-type patch
Bump version, changelog, tag, and GitHub release (use minor or major for --release-type as needed)
For release to create the GitHub release, set GITHUB_TOKEN, GIT_OAUTH_TOKEN, or CONVENTIONAL_GITHUB_RELEASER_TOKEN to a Personal Access Token: classic token needs repo scope; fine-grained token needs Releases: Read and write for this repository. Example: GITHUB_TOKEN=ghp_xxx npm run release -- --release-type patch. You can also use RELEASE_TYPE=minor npm run release (no extra args).
The generate script runs npx gulp --gulpfile gulpfile.cjs service so the correct gulpfile is always used (avoids "No gulpfile found" when running gulp directly).
Generate Your First Service
Generate a complete CRUD service with both REST API and MCP server support using the generate script (runs the gulp service task with the correct config via npx):
$ npm run generate -- --name yourFirstEndpoint
Or using the short form:
$ npm run generate -- -n yourFirstEndpoint
This single command generates:
✅ REST API endpoints (routes, controllers, models)
✅ MCP server tools and resources (for LLM integration)
✅ Complete test suites
✅ TypeScript type definitions (when TypeScript migration is complete)
Why npm run generate? The project uses gulpfile.cjs. Running gulp service directly can fail with "No gulpfile found". The generate script runs npx gulp --gulpfile gulpfile.cjs service, so you don't need to install gulp globally or remember the gulpfile path.
With the generate command, you have the option of using either Mongo DB, an SQL compatible DB or using an API generated by this framework as a database model. To use an API as a database you can pass the baseurl and the endpoint option; for an SQL compatible db, pass the sql option. See examples below.
See API as DB specification for the contract your API must implement and how to test for compliance.
Important for MCP: After generating an API-based model, you need to:
Inspect the actual API response structure
Update the schemaObject in the generated model file to match the real data structure
Add description and mcpDescription fields for each schema field
This ensures the MCP server has proper context about the data structure
The generated template includes a schema definition section with examples - replace them with your actual API response fields. The schema endpoint (GET /{service}/schema) can optionally discover schema from the external API at GET {baseurl}/{endpoint}/schema; if that fails or is not available, it falls back to the _schema defined in the model file.
Using an SQL compatible database
$ npm run generate -- --name yourEndpointWITHSQL --sql
Note: You can use -n instead of --name, -b instead of --baseurl, -e instead of --endpoint.
Try out your new endpoint.
Start the app
$ npm start
by default, the app will start on POST 8080
You can change the PORT by adding a PORT environment variable.
eg.
$ PORT=6000 npm start
now the app will start on PORT 6000
To start the app for development, run
$ npm run dev
This will automatically restart your app whenever a change is detected using tsx watch.
Generated Service Features
When you generate a service, you get access to:
REST API Endpoints
[POST] http://localhost:8080/yourFirstEndpoint - Create resources (single or bulk)
MCP Resources (read-only; LLMs read via resource URIs):
<model>://list — List records (optional ?limit=N&skip=M for pagination; response includes pagination.nextPageUri)
<model>://{id} — Get one record by id
<model>://search — Search (e.g. ?q=... or ?query=...)
Example for a generated Items service: tools create_items, create_many_items, update_items, delete_items; resources items://list, items://search, items://{id}.
Note: For every POST API call, you need to send an x-tag value in the header. This value is used for secure communication between the server and client. It is used for AES encryption when secure mode is enabled. To get a valid x-tag, call the [GET] /initialize endpoint.
Background Job Processing
Queue System
The framework includes a distributed job queue system for background processing.
Current: Uses Bull queue system (Redis-based) for robust job processing
Start the Clock
The clock dispatches scheduled tasks to workers (similar to a crontab). Only run one instance at a time.
$ npm run clock
To define a scheduled job, create a record in the Clock collection in MongoDB (connected via LOG_MONGOLAB_URL):
Note: After changing clock configuration in the database, restart the clock process.
Start the Workers
Workers process background jobs from the queue:
$ npm run workers
Workers are useful for:
Long-running processes
Background tasks
Async operations
Scheduled jobs
See src/services/queue/jobs.ts for sample tasks and src/services/queue/workers.ts for worker configuration.
Versioning your API endpoints
You can create multiple versions of your API endpoints by simply adding the version number to your route file name. eg. users.v1.ts will put a version of the users resources on the /v1/users endpoint. users.v2.ts will put a version of the users resources on the /v2/users endpoint. The latest version of the resources will always be available at the /users endpoint.
NOTE: This project will automatically load route files found in the src/routes/ folder.
MCP (Model Context Protocol) allows LLMs to interact with your API directly. Instead of making HTTP requests, LLMs can call tools and access resources through the MCP protocol. This enables AI-powered features like:
Natural language data queries
Automated data operations
Intelligent API interactions
AI assistants that understand your data model
Do I need to write MCP code manually?
No! When you generate a service with npm run generate -- --name users, the framework automatically generates all MCP server code. Your service is immediately available to LLMs without any additional configuration.
What's the difference between REST API and MCP?
REST API: Traditional HTTP/JSON interface for web and mobile apps
MCP: Protocol for LLM integration, enabling AI assistants to interact with your data
Both are generated automatically and work together seamlessly.
When will TypeScript migration be complete?
The TypeScript migration is complete! All source files have been migrated to TypeScript. Test files are being migrated next.
E
Express REST API And MCP Server Framework
iolufemi·148 顆星·
Express REST API and MCP Server Framework is a comprehensive development framework for building RESTful APIs and MCP servers with Express.js. It provides a complete template for creating production-re
Express REST API and MCP Server Framework is a comprehensive development framework for building RESTful APIs and MCP servers with Express.js. It provides a complete template for creating production-ready APIs using Node.js, Express, Mongoose (MongoDB), and Sequelize (SQL databases).
Express REST API And MCP Server Framework 需要 API 金鑰嗎?
這筆記錄未列出必要的環境變數。
Express REST API And MCP Server Framework 使用哪種傳輸方式?
Express REST API And MCP Server Framework 透過 stdio 在本機執行。
Express REST API And MCP Server Framework 上次檢查是什麼時候?
上次檢查時間:2026-10-26。 Express REST API and MCP Server Framework is a comprehensive development framework for building RESTful APIs and MCP servers with Express.js. It provides a complete template for creating production-ready APIs using Node.js, Express, Mongoose (MongoDB), and Sequelize (SQL databases).