Content
# MCP Server.exe
```
+-----------------------------------+
| |
| Node.js MCP Server Code |
| |
+----------------+------------------+
|
v
+----------------+------------------+
| |
| PKG Packaging Process |
| |
+----------------+------------------+
|
v
+----------------+------------------+
| MCP_SERVER.EXE |
| +------------------------+ |
| | | |
| | MCP Server Core Logic | |
| | | |
| +------------------------+ |
| ^ |
| | |
| +------------------------+ |
| | | |
| | --mcp-js Parameter | |
| | Custom Config Loader | |
| | | |
| +------------------------+ |
| |
+-----------------------------------+
| |
v v
+----------------+ +----------------+
| Modern Clients | | Legacy Clients |
| /mcp Endpoint | | /sse Endpoint |
| | | /messages EP |
+----------------+ +----------------+
```
Turn MCP (Model Context Protocol) server into an executable file, supporting both modern and legacy client connections.
## Features
- Supports modern Streamable HTTP endpoint (/mcp)
- Supports legacy SSE endpoint (/sse) and message endpoint (/messages)
- Customizable configuration for tools, resources, and prompts
## Installation
```bash
npm install
```
## Build
```bash
npm run build
```
## Run
```bash
npm start
```
Or in development mode:
```bash
npm run dev
```
## Command Line Arguments
The server supports the following command line arguments to customize its behavior:
| Argument | Description | Default Value |
|-------------------|--------------------------------------------------|------------------|
| `--mcp-js <path>` | Configuration file path (including server config and MCP config) | Built-in config |
| `--port <port>` | Server listening port | 3000 |
Example usage:
```bash
# Run server with custom name and port
node dist/server.js --server-name my-mcp-server --port 8080
# Run server with configuration file (both server and MCP config)
node dist/server.js --mcp-js ./examples/custom-mcp-config.js
# Run server with full command line arguments
node dist/server.js --server-name custom-server --port 8080 --version 2.0.0 --description "My Custom MCP Server" --author "Your Name" --license "Apache-2.0" --homepage "https://example.com/mcp-server"
# Run executable with configuration file
./executables/mcp_server --mcp-js ./examples/custom-mcp-config.js
```
## Unified Configuration File
The server supports using a configuration file to configure both server parameters and MCP functionality. The configuration file can export the following:
1. **Basic Configuration Object** - As the basic configuration for the server
2. **configureServer Function** - Dynamically generates server configuration (takes precedence over the basic configuration object)
3. **configureMcp Function** - Configures resources, tools, and prompts for the MCP server
Command line arguments have higher priority than settings in the configuration file.
### Configuration File Format
```javascript
/**
* MCP Server Unified Configuration File
*/
module.exports = {
// Basic server configuration (static)
serverName: "custom-mcp-server",
port: 8080,
version: "1.1.0",
description: "Custom MCP Server",
author: "yourname",
license: "MIT",
homepage: "https://example.com/mcp-server",
// Dynamic server configuration function (optional, takes precedence over static configuration)
configureServer: function() {
// Return server configuration object
return {
serverName: "dynamic-server",
// Other configurations...
};
},
// MCP configuration function
configureMcp: function(server, ResourceTemplate, z) {
// Configure resources
server.resource(/* ... */);
// Configure tools
server.tool(/* ... */);
// Configure prompts
server.prompt(/* ... */);
}
};
```
Refer to `examples/custom-mcp-config.js` for a sample configuration file.
## MCP Custom Configuration
The server supports loading custom MCP tools configuration files via the command line parameter `--mcp-js`:
```bash
# Using development mode with custom config
node src/server.ts --mcp-js ./examples/custom-mcp-config.js
# Using built program with custom config
node dist/server.js --mcp-js ./examples/custom-mcp-config.js
# Using packaged executable with custom config
./executables/mcp_server --mcp-js ./examples/custom-mcp-config.js
```
### Custom Configuration File Format
The custom configuration file should export a `configureMcp` function that accepts three parameters:
- `server`: MCP server instance
- `ResourceTemplate`: Class for defining resource templates
- `z`: Zod validation library instance
Refer to `examples/custom-mcp-config.js` for a sample configuration file.
## Packaging
Package for macOS:
```bash
npm run package-mac
```
Package for Windows:
```bash
npm run package-win
```
The packaged executable files will be generated in the `executables` directory.
## API Endpoints
- `/mcp`: Modern Streamable HTTP endpoint
- `/sse`: Legacy SSE endpoint
- `/messages`: Legacy message endpoint
## License
ISC
## Environment Variables
- `PORT` - Server port (default: 3000)
You Might Also Like
Ollama
Ollama enables easy access to large language models on various platforms.

n8n
n8n is a secure workflow automation platform for technical teams with 400+...
OpenWebUI
Open WebUI is an extensible web interface for customizable applications.

Dify
Dify is a platform for AI workflows, enabling file uploads and self-hosting.

Zed
Zed is a high-performance multiplayer code editor from the creators of Atom.
MarkItDown MCP
markitdown-mcp is a lightweight MCP server for converting various URIs to Markdown.