@whmpro/helloworld-mcp
v1.0.1
Published
A simple Hello World MCP server
Downloads
4
Readme
Hello World MCP Server
A simple Model Context Protocol (MCP) server built with Node.js and TypeScript to demonstrate basic MCP concepts.
What is MCP?
Model Context Protocol (MCP) is a protocol that allows AI models to securely access external tools, resources, and prompts. This server demonstrates the three main MCP capabilities:
- Tools: Functions that can be called by the AI model
- Resources: Static content that can be read by the AI model
- Prompts: Templates that can be used to generate responses
Setup
Install dependencies:
npm installBuild the TypeScript code:
npm run buildRun the server:
npm start
Features
Tools
This server provides three simple tools:
hello - Returns a personalized greeting
- Input:
name(string) - Example:
{"name": "Alice"}
- Input:
current_time - Returns the current date and time
- Input: No parameters required
calculate - Performs basic arithmetic operations
- Input:
operation(add/subtract/multiply/divide),a(number),b(number) - Example:
{"operation": "add", "a": 5, "b": 3}
- Input:
Resources
The server provides two static resources:
- info://server - Information about the server
- greeting://welcome - A welcome message for new users
Prompts
The server includes one prompt template:
- greeting - Generates personalized greetings
- Arguments:
name(required),style(optional: formal/casual/friendly)
- Arguments:
How MCP Works
- Client Connection: An MCP client (like Claude Desktop) connects to the server via stdio
- Capability Discovery: The client asks what tools, resources, and prompts are available
- Tool Execution: The client can call tools with specific parameters
- Resource Reading: The client can read static resources
- Prompt Generation: The client can use prompts to generate responses
Testing with Claude Desktop
To test this server with Claude Desktop:
- Build and start the server
- Configure Claude Desktop to connect to your MCP server
- The server will be available as a tool provider in Claude Desktop
Project Structure
hello-world-mcp/
├── src/
│ └── index.ts # Main server implementation
├── build/ # Compiled JavaScript (generated)
├── package.json # Node.js dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # This fileKey MCP Concepts Demonstrated
- Server Setup: Creating an MCP server with capabilities
- Request Handlers: Handling different types of MCP requests
- Error Handling: Proper error responses
- Type Safety: Using TypeScript for better development experience
- Transport: Using stdio transport for communication
Next Steps
After understanding this basic example, you can:
- Add more complex tools that interact with external APIs
- Create resources that read from files or databases
- Build more sophisticated prompt templates
- Add authentication and security features
- Implement more advanced MCP features like progress reporting
