MCP Demo 1 - Hello World
A simple Model Context Protocol server demonstration that provides SSE streaming communication and basic message handling with a Hello World example.
README
MCP Demo 1 - Hello World
这是一个简单的 MCP (Model Context Protocol) 演示项目,使用 Node.js + TypeScript 实现,支持 SSE (Server-Sent Events) 调用。
功能
- ✅ SSE 端点 (
/sse) - 支持实时流式通信 - ✅ POST 消息端点 (
/messages) - 处理 MCP 请求 - ✅ 健康检查端点 (
/health) - ✅ 输出 "Hello World" 消息
快速开始
1. 安装依赖
npm install
2. 编译 TypeScript
npm run build
3. 运行服务器
npm start
或者使用开发模式(自动重新编译):
npm run dev
服务器将在 http://localhost:3000 启动。
端点说明
GET /sse
SSE 端点,用于实时流式通信。
示例:
curl http://localhost:3000/sse
POST /messages
处理 MCP 协议请求。
请求示例:
curl -X POST http://localhost:3000/messages \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "hello",
"params": {},
"id": 1
}'
响应示例:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"message": "Hello World",
"greeting": "Welcome to MCP Demo!"
}
}
GET /health
健康检查端点。
示例:
curl http://localhost:3000/health
环境变量
PORT: 服务器端口(默认: 3000)
项目结构
demo1/
├── src/
│ └── index.ts # 主服务器文件
├── dist/ # 编译输出目录
├── package.json
├── tsconfig.json
└── README.md
开发
监听模式编译
npm run watch
使用 ts-node 直接运行(开发模式)
npm run dev
Docker 支持
如果需要 Docker 运行,可以创建 Dockerfile:
FROM node:18-slim
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
注意事项
- SSE 连接会保持打开状态,定期发送心跳消息
- 客户端断开连接时,服务器会自动清理资源
- 支持 CORS,可以从任何来源访问
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.