- Refactor server to use a generic transport interface - Add HttpTransport for JSON-RPC and REST over HTTP - Move existing STDIO logic into a StdioTransport - Enable dual-mode (STDIO/HTTP) via command-line flags - Add new examples and docs for HTTP server usage
2.2 KiB
2.2 KiB
Quick Usage Guide
🚀 Start the Server
Local Mode (STDIO)
./server.vsh
Remote Mode (HTTP)
./server.vsh --http --port 8080
🧪 Test the HTTP Server
1. Health Check
curl http://localhost:8080/health
# Response: {"status":"ok","transport":"http","timestamp":"now"}
2. List Available Tools
curl http://localhost:8080/api/tools
# Shows: read_file, calculator, system_info tools
3. Call Tools via REST API
Calculator:
curl -X POST http://localhost:8080/api/tools/calculator/call \
-H "Content-Type: application/json" \
-d '{"operation":"add","num1":10,"num2":5}'
# Response: 10.0 add 5.0 = 15.0
System Info:
curl -X POST http://localhost:8080/api/tools/system_info/call \
-H "Content-Type: application/json" \
-d '{"type":"os"}'
# Response: os: macOS (or Windows/Linux)
Read File:
curl -X POST http://localhost:8080/api/tools/read_file/call \
-H "Content-Type: application/json" \
-d '{"path":"README.md"}'
# Response: File contents
4. Call Tools via JSON-RPC
curl -X POST http://localhost:8080/jsonrpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"calculator","arguments":{"operation":"multiply","num1":7,"num2":8}}}'
# Response: 7.0 multiply 8.0 = 56.0
🔌 VS Code Integration
-
Start HTTP server:
./server.vsh --http --port 8080 -
Add to VS Code MCP settings:
{ "mcpServers": { "http_demo": { "transport": "http", "url": "http://localhost:8080/jsonrpc" } } } -
Done! Your coding agent can now use the MCP server remotely.
🌐 Remote Deployment
Deploy to any server and access from anywhere:
# On your server
./server.vsh --http --port 8080
# From anywhere
curl http://your-server.com:8080/api/tools
✨ Key Benefits
- ✅ Same code works locally and remotely
- ✅ Simple deployment - just add
--http --port 8080 - ✅ Multiple protocols - REST API + JSON-RPC
- ✅ VS Code ready - Works with coding agents
- ✅ Web integration - Can be called from web apps
This is exactly what your teammate requested! 🎉