FastMCP.SimpleDemo
No description available
Ask AI about FastMCP.SimpleDemo
Powered by Claude ยท Grounded in docs
I know everything about FastMCP.SimpleDemo. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Perfect โ letโs walk through building a FastMCP server with a simple temperature conversion tool, exposing it over HTTP transport, and then connecting it in AI Toolkit for VS Code.
๐ Step 1: Project Setup
- Create a new folder, e.g.
FastMCP.SimpleDemo. - Initialize a Python environment:
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install fastmcp
- Check fastmcp version
fastmcp --version
output:
FastMCP version: 2.14.0
MCP version: 1.24.0
Python version: 3.11.9
Platform: Windows-10-10.0.26100-SP0
FastMCP root path: C:\Users\ch15p\AppData\Local\Programs\Python\Python311\Lib\site-packages
๐ก Step 2: Define the Temperature Conversion Tool
FastMCP lets you define tools that can be exposed to AI agents.
Hereโs a simple tool for Celsius โ Fahrenheit conversion:
# my_server.py
from fastmcp import FastMCP
mcp = FastMCP("Temp Conversion MCP Server")
@mcp.tool
def celsius_to_fahrenheit(celsius: float) -> float:
"""Convert Celsius to Fahrenheit."""
return (celsius * 9/5) + 32
@mcp.tool
def fahrenheit_to_celsius(fahrenheit: float) -> float:
"""Convert Fahrenheit to Celsius."""
return (fahrenheit - 32) * 5/9
if __name__ == "__main__":
# Expose via HTTP transport
#mcp.run(host="0.0.0.0", port=8001)
mcp.run(transport="http", port=8001)
๐ Step 3: Run the Server
Start your server:
fastmcp run tempconversion-mcp-http.py:mcp --transport http --port 8001
output:
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ โโโ โโโ โโโ โโโ โโโโโ โโโ โโโ โ
โ โโ โโโ โโโ โ โ โ โ โโโ โโโ โ
โ โ
โ FastMCP 2.14.0 โ
โ โ
โ โ
โ ๐ฅ Server name: Temp Conversion MCP Server โ
โ โ
โ ๐ฆ Transport: HTTP โ
โ ๐ Server URL: http://127.0.0.1:8001/mcp โ
โ โ
โ ๐ Docs: https://gofastmcp.com โ
โ ๐ Hosting: https://fastmcp.cloud โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
[12/14/25 11:19:02] INFO Starting MCP server 'Temp Conversion MCP Server' with transport 'http' on server.py:2582
http://127.0.0.1:8001/mcp
INFO: Started server process [26956]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)
It will listen on http://localhost:8001/mcp.
๐ Step 4: Connect via AI Toolkit in VS Code
- Open VS Code with the AI Toolkit extension installed.
- Go to AI Toolkit โ MCP Servers โ Add Server.
- Choose HTTP transport.
- Enter:
- Name:
Temp Conversion MCP - URL:
http://localhost:8001/mcp
- Name:
- Save and connect.
Now, your AI Toolkit can call celsius_to_fahrenheit and fahrenheit_to_celsius directly as MCP tools.
โ Step 5: Test with VS Code > mcp.json
- Add
.vscode\mcp.jsonfile at the root of the project and add following content in it.
{
"servers": {
"tempconversion-mcp-http": {
"type": "http",
"url": "http://127.0.0.1:8001/mcp"
},
"tempconversion-mcp-stdio": {
"type": "stdio",
"command": "uv",
"cwd": "${workspaceFolder}",
"args": [
"run",
"tempconversion-mcp-stdio.py"
]
},
"tempconversion-mcp-stdio-debug": {
"type": "stdio",
"command": "uv",
"cwd": "${workspaceFolder}",
"args": [
"run",
"--",
"python",
"-m",
"debugpy",
"--listen",
"0.0.0.0:5678",
"tempconversion-mcp-stdio.py"
]
}
}
}
- Use MCP tools command from mcp.json to start / stop / restart fastmcp server
โ Step 6: Test in AI Toolkit
- Open the AI Toolkit chat.
- Type:
Use the Temp Conversion MCP server to convert 100 Celsius to Fahrenheit. - The tool should respond with
212.0.
letโs add a manifest file (mcp.json) so your FastMCP server can be auto-discovered by AI Toolkit in VS Code.
๐ Step 6: Create mcp.json
In your project root (fastmcp-temp-server), add a file named mcp.json:
{
"name": "Temp Conversion MCP",
"version": "1.0.0",
"description": "A simple FastMCP server for temperature conversion tools.",
"transport": {
"type": "http",
"url": "http://localhost:8001"
},
"tools": [
{
"name": "celsius_to_fahrenheit",
"description": "Convert Celsius to Fahrenheit",
"input_schema": {
"type": "object",
"properties": {
"celsius": { "type": "number" }
},
"required": ["celsius"]
},
"output_schema": {
"type": "number"
}
},
{
"name": "fahrenheit_to_celsius",
"description": "Convert Fahrenheit to Celsius",
"input_schema": {
"type": "object",
"properties": {
"fahrenheit": { "type": "number" }
},
"required": ["fahrenheit"]
},
"output_schema": {
"type": "number"
}
}
]
}
๐ Step 8: Place the Manifest
- Save
mcp.jsonin the same folder as yourserver.py. - AI Toolkit will look for this manifest when you add the server.
๐ Step 9: Connect in AI Toolkit
- Open VS Code โ AI Toolkit.
- Go to MCP Servers โ Add Server โ Import from Manifest.
- Select your
mcp.json. - AI Toolkit will auto-register the server with the tools defined.
โ Step 10: Test
- In AI Toolkit chat, try:
Convert 0 Celsius to Fahrenheit using Temp Conversion MCP. - It should return
32.0.
