Quick Start: MCP Server Testing on Ubuntu¶
Since Claude Desktop is not available for Ubuntu, here's how to test your MCP servers locally.
✅ What You Have¶
All files are in /mnt/user-data/outputs/:
- simple_mcp_server.py - Example MCP server with 4 tools
- simple_mcp_test.py - Direct testing script (EASIEST ⭐)
- mcp_test_client.py - Full-featured test client
- test_server.py - Basic functionality test
- MCP_TESTING_UBUNTU.md - Complete testing guide
🚀 Quickest Way to Test (30 seconds)¶
That's it! You'll see: - ✓ List of available tools - ✓ Test results for each tool - ✓ Summary of successes/failures
📋 Available Testing Methods¶
Method 1: Direct Testing (Easiest) ⭐¶
Pros: - No dependencies - Fast - Clear output
Cons: - Not a full client - Tests by importing the module
Method 2: MCP Inspector (Most Professional)¶
The official tool from Anthropic:
# Install Node.js first (if not installed)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Run the inspector
npx @modelcontextprotocol/inspector python simple_mcp_server.py
Then open http://localhost:6274 in your browser
Pros: - Official tool - Web interface - Full MCP protocol testing
Cons: - Requires Node.js - More setup
Method 3: Your Own Client¶
Use the provided mcp_test_client.py (requires MCP client library):
# Install dependencies
pip install mcp --break-system-packages
# Run tests
python3 mcp_test_client.py simple_mcp_server.py
# Or interactive mode
python3 mcp_test_client.py simple_mcp_server.py --interactive
Pros: - Full MCP client - Interactive mode available - Colorful output
Cons: - Requires MCP client library - More dependencies
🎯 Recommended Workflow¶
- Start with simple_mcp_test.py - Quick validation
- Use MCP Inspector for thorough testing
- Create custom tests as your server grows
📝 Creating Your Own MCP Server¶
Step 1: Copy the Template¶
Step 2: Add Your Tools¶
@app.list_tools()
async def list_tools() -> list[Tool]:
return [
Tool(
name="my_new_tool",
description="What your tool does",
inputSchema={
"type": "object",
"properties": {
"param1": {
"type": "string",
"description": "Description of parameter",
}
},
"required": ["param1"]
}
)
]
@app.call_tool()
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
if name == "my_new_tool":
result = f"You called with: {arguments['param1']}"
return [TextContent(type="text", text=result)]
Step 3: Test It¶
🔧 Common Issues & Solutions¶
Issue: "Module not found: mcp"¶
Issue: "Server file not found"¶
# Make sure you're in the right directory:
cd /mnt/user-data/outputs
# Or use full path:
python3 simple_mcp_test.py /full/path/to/server.py
Issue: "Port already in use"¶
💡 Tips¶
-
Use virtual environments for each project:
-
Add logging to debug:
-
Test incrementally - add one tool at a time
-
Check the examples in the project knowledge
📚 Next Steps¶
- ✅ Test the example server
- ✅ Create your own server
- ✅ Add custom tools
- ✅ Test with different methods
- ✅ Integrate with your applications
🌐 Using MCP Servers in Applications¶
With LangChain¶
With Your Own Code¶
import subprocess
import json
# Start MCP server process
process = subprocess.Popen(
["python3", "simple_mcp_server.py"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE
)
# Send JSON-RPC requests
# ... handle responses
📖 More Resources¶
- MCP Specification: https://spec.modelcontextprotocol.io
- Python SDK: https://github.com/modelcontextprotocol/python-sdk
- MCP Docs: https://modelcontextprotocol.io
✨ Summary¶
For Ubuntu users:
- Quick test:
python3 simple_mcp_test.py simple_mcp_server.py✅ - Professional testing: Install Node.js + use MCP Inspector
- Development: Use the template and iterate
No Claude Desktop needed! You have everything you need to develop and test MCP servers on Ubuntu.
Happy coding! 🚀