Skip to main content
Glama

Hello World MCP Server

by jageenshukla

Hello World MCP Server

Welcome to the Hello World MCP Server! This project demonstrates how to set up a server using the Model Context Protocol (MCP) SDK. It includes tools, prompts, and endpoints for handling server-sent events (SSE) and messages.

This project is part of the blog post: Building a TypeScript MCP Server: A Guide for Integrating Existing Services. Visit the blog to learn more about the concepts and implementation details behind this project.


Features

  • MCP Integration: Uses the MCP SDK to create a server with tools and prompts.
  • Express Framework: Handles HTTP endpoints for SSE and message communication.
  • Environment Configuration: Uses .env files for easy configuration.
  • TypeScript Support: Fully typed codebase for better developer experience.

Prerequisites

Before you begin, ensure you have the following installed:

  1. Node.js (v16 or higher) - Download here
  2. npm (comes with Node.js) or yarn

Getting Started

Follow these steps to set up and run the project:

1. Clone the Repository

If you haven't already, clone the repository to your local machine:

git clone https://github.com/your-username/hello-world-mcp-server.git cd hello-world-mcp-server

2. Install Dependencies

Install the required dependencies using npm or yarn:

npm install

or

yarn install

3. Configure Environment Variables

The project uses a .env file to configure the server's port. A sample .env.example file is provided.

  1. Copy the .env.example file to .env:
    cp .env.example .env
  2. Open the .env file and update the PORT variable if needed. The default is 4000.
    PORT=4000

4. Build the Project

Compile the TypeScript code into JavaScript:

npm run build

This will generate the compiled files in the dist directory.

5. Run the Server

Start the server in production mode:

npm start

Alternatively, for development mode with live reloading, use:

npm run dev

Testing the Server

1. Using the MCP Inspector

The MCP Inspector is a tool to test and inspect your MCP server. You can use it to verify that your tools and prompts are registered correctly.

Run the following command to inspect your server:

npx @modelcontextprotocol/inspector ./dist/server.js

This will open an interactive interface where you can test the tools and prompts registered in your server like below.

Hello World MCP Server


Project Structure

Here’s an overview of the project structure:

hello-world-mcp-server/ ├── src/ │ ├── server.ts # Main server entry point │ ├── modules/ │ │ ├── tools.ts # Registers MCP tools │ │ ├── prompts.ts # Registers MCP prompts │ │ └── transports.ts # Handles SSE and message endpoints ├── .env # Environment variables ├── .env.example # Example environment variables ├── package.json # Project metadata and scripts ├── tsconfig.json # TypeScript configuration └── README.md # Project documentation

Troubleshooting

Common Issues

  1. Port Already in Use: If you see an error about the port being in use, update the PORT variable in the .env file.
  2. TypeScript Errors: Ensure you’ve installed all dependencies and are using the correct Node.js version.

Debugging

Use the following command to debug the server:

npm run dev

This will start the server with live reloading and detailed logs.



Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.


License

This project is licensed under the MIT License. See the LICENSE file for details.

-
security - not tested
A
license - permissive license
-
quality - not tested

서버에서 전송된 이벤트와 메시지 처리를 위한 도구와 엔드포인트를 제공하는 MCP(Model Context Protocol) SDK를 구현하는 데모 서버입니다.

  1. 특징
    1. 필수 조건
      1. 시작하기
        1. 1. 저장소 복제
        2. 2. 종속성 설치
        3. 3. 환경 변수 구성
        4. 4. 프로젝트 구축
        5. 5. 서버 실행
      2. 서버 테스트
        1. 1. MCP 검사기 사용
      3. 프로젝트 구조
        1. 문제 해결
          1. 일반적인 문제
          2. 디버깅
        2. 관련 프로젝트
          1. 기여하다
            1. 특허

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
                Last updated -
                3
                44
                61
                Apache 2.0
              • A
                security
                A
                license
                A
                quality
                A simple server implementing the Model Context Protocol (MCP) that echoes messages back, designed for testing MCP clients.
                Last updated -
                1
                2
                MIT License
              • -
                security
                A
                license
                -
                quality
                An implementation of the Model Context Protocol (MCP) server that enables multiple clients to connect simultaneously and handles basic context management and messaging with an extendable architecture.
                Last updated -
                MIT License
              • -
                security
                F
                license
                -
                quality
                A minimal example server implementing the Model Context Protocol, providing addition and multiplication tools for learning and experimentation with MCP clients.
                Last updated -

              View all related MCP servers

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/jageenshukla/hello-world-mcp-server'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server