Echo MCP Server
A simple Model Context Protocol (MCP) server implementation that demonstrates how to create tools and resources using the FastMCP framework.
What is MCP?
The Model Context Protocol (MCP) is a standard for connecting AI assistants to external data sources and tools. This project serves as a starting point for building your own MCP servers.
Features
Echo Tool: A simple tool that echoes back any message you send
Echo Resource: A resource that can be read with custom messages
FastMCP Framework: Built using the modern FastMCP library
Comprehensive Testing: Includes PowerShell and Bash test scripts
Easy Setup: Minimal dependencies and clear structure
Quick Start
Prerequisites
Python 3.13 or higher
jq (for JSON formatting in tests)
Installation
Clone or download this project
Install dependencies:
pip install -r requirements.txtor using uv (recommended):
uv sync
Running the Server
The server runs in stdio mode, waiting for JSON-RPC requests.
Testing the Server
Quick Test with jq
Comprehensive Testing
PowerShell (Windows):
Bash (Linux/macOS):
Project Structure
Understanding the Code
Basic MCP Server Structure
Key Concepts
Tools: Functions that can be called by AI assistants to perform actions
Resources: Data sources that can be read by AI assistants
Transport: How the server communicates (stdio, HTTP, etc.)
JSON-RPC: The protocol used for communication
Creating Your Own MCP Server
1. Start with the Echo Server
Copy this project and modify echo_server.py
:
2. Add More Complex Tools
3. Add Resources
4. Update Dependencies
Add any new dependencies to requirements.txt
:
Integration with AI Assistants
Claude Desktop
Add to your claude_desktop_config.json
:
Other MCP Clients
The server follows the MCP specification and should work with any MCP-compatible client.
Testing Your Server
Manual Testing
Initialize the server:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}Send initialized notification:
{"jsonrpc":"2.0","method":"notifications/initialized","params":{}}List available tools:
{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}Call a tool:
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"echo_tool","arguments":{"message":"Hello!"}}}
Automated Testing
Use the provided test scripts as templates for your own testing:
test_echo_mcp.ps1
- Comprehensive PowerShell testingtest_echo_mcp.sh
- Bash testing
Common Issues and Solutions
"Failed to validate request: Received request before initialization was complete"
Solution: Always send the initialization sequence first:
initialize
requestnotifications/initialized
Then your actual requests
"Tool not found" errors
Solution: Check that your tool is properly decorated with @mcp.tool()
and the name matches exactly.
Performance issues
Solution:
Use async functions for I/O operations
Implement proper error handling
Consider caching for expensive operations
Next Steps
Explore the MCP Specification: Official MCP Documentation
Check out FastMCP: FastMCP GitHub
Build Real Tools: Create tools that interact with APIs, databases, or file systems
Add Authentication: Implement security for production use
Deploy: Consider containerization with Docker
Contributing
This is a template project. Feel free to:
Fork and modify for your needs
Add more examples
Improve the test scripts
Share your MCP server implementations
License
This project is provided as-is for educational and development purposes.
Happy MCP Development! 🚀
For questions or issues, refer to the MCP Community or create an issue in your fork of this project.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
A simple demonstration MCP server that provides an echo tool and resource for learning how to build MCP servers. Serves as a starting point and template for creating custom MCP server implementations.