loading…
Search for a command to run...
loading…
Provides unit conversion tools (celsius/fahrenheit, kilometers/miles) via MCP, along with resources and prompts for conversion explanations and API usage.
Provides unit conversion tools (celsius/fahrenheit, kilometers/miles) via MCP, along with resources and prompts for conversion explanations and API usage.
⸻
python -m venv .venv
# Mac or Gitbash
source .venv/bin/activate
# Windows powershell:
.venv\Scripts\activate
python -m pip install -r requirements.txt
⸻
# start the server
python converter_streamable_http_server.py
# or
python -m converter_streamable_http_server
You’ll see:
MCP endpoints served by FastMCP:
⸻
curl -X POST "http://localhost:8003/miles-to-kilometers?miles=3.1" \
-H "Authorization: Bearer 143f4a46d74fee0d7918b2857577868cb3daf9e6e50ee91c2f7975ba26fdb8f7"
# If we use pydantic models
curl -X POST "http://localhost:8003/miles-to-kilometers" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer Y658139cf61948208ed76a4b36122b9552ec5c3f6da5e02f7c5d85d995dede17dE" \
-d "3.1"
# Celsius → Fahrenheit
curl -X POST "http://localhost:8003/celsius-to-fahrenheit" \
-H "Content-Type: application/json" \
-d "25"
# Fahrenheit → Celsius
curl -X POST "http://localhost:8003/fahrenheit-to-celsius" \
-H "Content-Type: application/json" \
-d "86"
# Kilometers → Miles
curl -X POST "http://localhost:8003/kilometers-to-miles" \
-H "Content-Type: application/json" \
-d "5"
# Miles → Kilometers (rejects negative values)
curl -X POST "http://localhost:8003/miles-to-kilometers" \
-H "Content-Type: application/json" \
-d "3.1"
Each endpoint returns JSON like:
-H "Content-Type: application/json"
-H "Authorization: Bearer
Our server doesn’t require auth yet, we can omit the Authorization header.
// Example VS Code .vscode/mcp.json entry:
{
"servers": {
"UnitConverter": {
"command": "python",
"args": ["converter_api_tutorial.py"]
}
}
}
⸻
# If env error appears
npx @modelcontextprotocol/inspector@latest -e DUMMY=1 --url http://localhost:8003/mcp --transport streamable-http
# If you want to test the older HTTP:
npx @modelcontextprotocol/inspector@latest -e DUMMY=1 --url http://localhost:8003/mcp --transport http
# If you want to test the deprecated SSE:
npx @modelcontextprotocol/inspector@latest -e DUMMY=1 --url http://localhost:8003/sse --transport sse
# If venv is ".venv", change to .\.venv\Scripts\python.exe
npx @modelcontextprotocol/inspector python converter_stdio_server.py
curl -s -X POST <SERVER_URL> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"prompts/list","params":{},"id":1}'
⸻
curl -s -X POST <SERVER_URL> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"prompts/get","params":{"name":"summarize"},"id":2}'
⸻
curl -s -X POST <SERVER_URL> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"prompts/render","params":{"name":"summarize","variables":{"text":"This is the content to summarize","tone":"neutral"}},"id":3}'
curl -s -X POST <SERVER_URL> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"resources/list","params":{},"id":4}'
curl -s -X POST <SERVER_URL> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"resources/read","params":{"uri":"file:///data/report.pdf"},"id":5}'
curl -s -X POST <SERVER_URL> \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"resources/search","params":{"query":"error OR exception","limit":50},"id":6}'
⸻
macOS/Linux (bash/zsh) • The examples above will work as-is.
# Windows PowerShell
curl -Method POST <SERVER_URL> ` -Headers @{ "Content-Type"="application/json" }`
-Body '{"jsonrpc":"2.0","method":"prompts/list","params":{},"id":1}'
Windows CMD
curl -s -X POST <SERVER_URL> -H "Content-Type: application/json" -d "{\"jsonrpc\":\"2.0\",\"method\":\"prompts/list\",\"params\":{},\"id\":1}"
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"unit-converter-mcp-server": {
"command": "npx",
"args": []
}
}
}