Set up a TypeScript MCP server with Express, SSE endpoints, environment configuration, and MCP SDK integration
The Hello World MCP Server is a demonstration project that showcases how to integrate existing services into AI applications using the Model Context Protocol (MCP). By leveraging the MCP SDK and Express.js framework, this server enables seamless communication between AI applications and external data sources or tools. This documentation provides comprehensive guidance on setting up, configuring, and testing the Hello World MCP Server.
The Hello World MCP Server is designed to integrate advanced features of Model Context Protocol (MCP), including:
.env
file for easy configuration of environment variables such as the server's port.The internal architecture and protocol implementation of the Hello World MCP Server are structured to ensure high compatibility with multiple AI clients. Here’s how it works:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
This matrix highlights the compatibility of various MCP clients, making it easy to identify which clients are fully supported and which have limited support.
To set up and run the Hello World MCP Server, follow these steps:
Clone the Repository
git clone https://github.com/your-username/hello-world-mcp-server.git
cd hello-world-mcp-server
Install Dependencies
Use npm or yarn to install the required dependencies:
npm install
Or
yarn install
Configure Environment Variables
The project uses a .env
file for configuration, with an example provided in .env.example
.
Copy the .env.example
file to .env
:
cp .env.example .env
Open and update the PORT
variable if necessary. The default is 4000
:
PORT=4000
Build the Project
Compile the TypeScript code into JavaScript:
npm run build
This will generate the compiled files in the dist
directory.
Run the Server
Start the server in production mode:
npm start
Alternatively, for development mode with live reloading, use:
npm run dev
Imagine you have a data source that contains customer feedback. You want to integrate this into an AI application like Claude Desktop for automatic sentiment analysis. With the Hello World MCP Server, you can register your data retrieval module as an MCP tool.
// src/modules/tools.ts
import { Tool } from '@modelcontextprotocol/typescript-sdk';
export const registerDataRetrievalTool = () => {
return new Tool({
name: 'CustomerFeedback',
execute: async (input) => ({
feedback: await fetchCustomerFeedback(input.id),
}),
});
};
Suppose you want to create an application that allows users to request specific actions, such as booking a hotel. You can register a prompt for this action, which will be triggered by the MCP client.
// src/modules/prompts.ts
import { Prompt } from '@modelcontextprotocol/typescript-sdk';
export const registerHotelBookingPrompt = () => {
return new Prompt({
name: 'BookHotel',
title: "Let's book a hotel!",
description: "Enter your preferences to book a hotel.",
handler: async (input) => ({
success: await bookHotel(input);
}),
});
};
The Hello World MCP Server is designed to work seamlessly with various MCP clients, enhancing their capabilities. For instance, the Claude Desktop client can use this server to access external data sources and tools.
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | ✅ | Full Support |
Cursor | ❌ | ✅ | ❌ | Tools Only |
This table provides a detailed compatibility matrix, ensuring that developers can make informed decisions about which clients to integrate with the MCP server.
To ensure optimal performance and compatibility, we have designed the Hello World MCP Server with robust testing and configuration mechanisms. The following matrix details the key metrics:
Metric | Value | Description |
---|---|---|
Port Usage | Dynamic (configurable) | Ensures port availability for multiple instances. |
Response Time | < 200 ms | Fast response times to ensure smooth user experience. |
Compatibility | Full with MCP 1.x | Fully compatible with the latest version of the protocol. |
To further enhance security and configuration, you can make use of the following advanced settings:
HTTPS Certificate: Ensure secure data transmission by enabling HTTPS.
API Key Management: Store sensitive API keys securely using environment variables or secret management tools.
.env
HTTPS=false # Disable HTTPS for local development
API_KEY=your-secret-api-key
How do I resolve port conflicts?
PORT
variable in the .env
file to a different value.Why does my MCP Client not work with the Hello World Server?
Can I integrate multiple tools at once?
src/modules
. Each tool or prompt must be registered separately.How do I debug issues with the MCP Server?
npm run dev
) to get detailed logs and live reloading for easier debugging.What if I need custom configuration options?
src/modules
.Contributions are welcome! Here’s how you can help:
By following these guidelines and contributing, you can help make the Hello World MCP Server even more robust and versatile.
To stay up-to-date with the latest developments in Model Context Protocol and related technologies, consider exploring the official documents and community resources:
By leveraging the resources in the MCP ecosystem, you can integrate advanced features into your AI workflows more effectively.
Learn to connect to MCP servers over HTTP with Python SDK using SSE for efficient protocol communication
Next-generation MCP server enhances documentation analysis with AI-powered neural processing and multi-language support
Build a local personal knowledge base with Markdown files for seamless AI conversations and organized information.
Integrate AI with GitHub using MCP Server for profiles repos and issue creation
Python MCP client for testing servers avoid message limits and customize with API key
Explore MCP servers for weather data and DigitalOcean management with easy setup and API tools