Simple MCP Server - Learning Edition
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Simple MCP Server - Learning Editionadd 5 and 3"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Simple MCP Server - Learning Edition
A minimal, well-commented MCP (Model Context Protocol) server designed to teach you how MCP servers work.
What is MCP?
Model Context Protocol is a protocol that allows AI models (like Claude) to interact with external systems. Think of it like creating a bridge between Claude and custom tools/services you build.
Claude ←→ MCP Protocol ←→ Your ServerWhen Claude needs to do something, it can call your server's "tools" instead of being limited to its built-in capabilities.
Related MCP server: Basic MCP Server
Project Structure
mcp-server-example/
├── package.json # Project configuration and dependencies
├── server.js # The MCP server (heavily commented!)
└── README.md # This fileHow This Server Works
The 3 Core Components
Server Setup (
server.jslines 21-28)Creates an MCP server instance
Gives it a name and version
Tool Definitions (
server.jslines 30-80)Each tool has: name, description, and input schema (what parameters it accepts)
The description helps Claude understand when to use the tool
The input schema validates that Claude provides the right parameters
Tool Implementations (
server.jslines 90-155)The actual logic that runs when Claude calls a tool
Processes the input and returns results
Must return a
TextContentobject with the result
The Three Example Tools
1. add_numbers
Adds two numbers together.
Input:
a(number),b(number)Output: The sum
2. format_text
Formats text in different ways.
Input:
text(string),style(uppercase | lowercase | titlecase)Output: The formatted text
3. get_current_time
Returns the current date and time.
Input: None
Output: Current ISO timestamp
Setting Up and Running
Prerequisites
Node.js 18+
npm or yarn
Installation
cd /Users/ythabti/Desktop/mcp-server-example
npm installRunning the Server
npm startYou'll see output like:
[MCP Server] Starting simple learning server...
[MCP Server] Available tools: add_numbers, format_text, get_current_time
[MCP Server] Successfully connected and ready to receive requests!The server is now running and waiting for Claude to call its tools.
How to Connect This Server to Claude Code
In Claude Code, you can configure this server to be available to Claude by:
Create a configuration file for your MCP server
Point Claude Code to your server
Claude can now call your tools!
Key Concepts to Learn
1. Request Handlers
server.setRequestHandler(CallToolRequestSchema, async (request) => {
// Handle tool calls here
});This tells the server what to do when Claude wants to call a tool.
2. Tool Response Format
All tool results must follow this structure:
{
content: [
{
type: "text",
text: "Your response here"
}
]
}3. Input Validation
The inputSchema uses JSON Schema to validate what Claude provides:
{
type: "object",
properties: {
parameter_name: {
type: "string", // or number, boolean, etc.
description: "What this parameter does"
}
},
required: ["parameter_name"]
}4. Error Handling
Return isError: true to signal a failed tool call:
{
content: [{
type: "text",
text: "Error message"
}],
isError: true
}Next Steps - Extending This Server
Try adding these features:
1. Add a Multiply Tool
// Define the tool
const multiplyTool = {
name: "multiply_numbers",
description: "Multiplies two numbers",
inputSchema: {
type: "object",
properties: {
a: { type: "number" },
b: { type: "number" }
},
required: ["a", "b"]
}
};
// Register it in the tools/list handler
// Add the implementation in the CallToolRequest handler2. Add a Weather Tool (mock data)
Return fake weather data to understand how tools work with real-world data.
3. Add File Reading Tool
Read files from the system and return their contents.
4. Add Database Tool
Connect to a database (SQLite, PostgreSQL, etc.) and run queries.
Common Mistakes to Avoid
❌ Forgetting to register tools in the tools/list handler
✅ Use the same tool names in definition and implementation
❌ Wrong response format
✅ Always wrap responses in { content: [{type: "text", text: "..."}] }
❌ Not describing tools properly ✅ Clear descriptions help Claude use tools correctly
❌ Missing required fields in schema
✅ Mark all required parameters with "required": ["field1", "field2"]
Debugging Tips
Check stderr output
The server logs to stderr (console.error) so you can see what's happening
Add logging
Add
console.error()statements to track what tools are being called
Test responses
Verify your response format matches the expected structure
Resources
Summary
This simple MCP server demonstrates:
✅ How to define tools Claude can use
✅ How to handle tool calls
✅ How to return results in the proper format
✅ The basic protocol structure
✅ Input validation using JSON schemas
Use this as a foundation to build more complex servers that connect Claude to your custom systems!
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
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/ythabti/MCP-Server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server