home / mcp / hello world mcp server
A minimal Python FastAPI MCP server exposing a hello resource and hello tool for end-to-end MCP client validation.
Configuration
View docs{
"mcpServers": {
"bankszach-mcp-date-and-time": {
"url": "http://127.0.0.1:8080/mcp"
}
}
}You run a minimal Model Context Protocol (MCP) server backed by FastAPI. It exposes a resource and a tool that respond with a simple Hello World message so you can validate your MCP client integration end-to-end. You can run locally with FastAPI via Uvicorn, verify health, and connect your MCP client to exercise a basic workflow before wiring up richer resources and tools.
Connect your MCP client to the HTTP MCP streamable endpoint to start validating resource and tool interactions. Point your MCP client at the endpoint you run locally, or at a hosted instance if you deploy it. When connected, you should see a resource://hello response with a Hello World message and a say_hello tool that returns a greeting. Use this setup as a baseline to wire up more complex resources and tools in your MCP server.
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment (bash/zsh)
source .venv/bin/activate
# Install requirements
pip install -r requirements.txtRun the server locally using FastAPI with Uvicorn. The server exposes a readiness probe at the root URL, a health check at /healthz, and the MCP streamable HTTP endpoint mounted at /mcp. You can also run the server via Docker Compose to simplify local development and testing.
uvicorn app:app --reload --port 8080If you prefer a containerized setup, you can build and run the server with a single command. After the build completes, the server is reachable at the root URL and at /healthz.
docker compose up --buildThe MCP streamable HTTP endpoint is available at the /mcp path. It supports a small set of tools that you can invoke after establishing a session. The following tools are available for quick validation and time-related operations.
- ping β returns pong to verify connectivity.
- server_time(fmt?: string) β returns the current UTC time, optionally formatted.
- echo(text: string) β echoes back the provided text.
- date_math(expr: string) β computes a date-time in UTC using expressions like +2h, -15m, or +1d 30m.
When you connect with an MCP client, the node URL is https://<service>/mcp. After a successful handshake, tools ping, server_time, echo, and date_math should be selectable. Use these tools to validate end-to-end tool invocation and basic time calculations.
Checks connectivity by returning a simple 'pong' response to confirm the MCP streamable HTTP path is reachable.
Returns the current UTC time, optionally formatted with a given pattern.
Echoes back the provided text, useful for validating payload transmission.
Calculates a UTC timestamp based on expressions like +2h, -15m, or +1d 30m for quick timing calculations.