FastAPI MCP Server (Single Tool)
A minimal, production-ready MCP server implemented with FastAPI and deployable to Google Cloud Run. It exposes a single tool get_time
via the OpenAI Model Context Protocol (MCP) using JSON‑RPC 2.0 over HTTP.
Features
tools/list
andtools/call
implemented exactly to specReturns content (text for humans) and structuredContent (JSON for machines)
Proper JSON‑RPC error codes and input validation with
jsonschema
CORS enabled (dev) + optional API key auth via
x-api-key
Health check (
/healthz
) and simple request loggingDockerfile and one‑command Cloud Run deploy
Endpoints
POST /
— JSON‑RPC 2.0 endpoint fortools/list
andtools/call
GET /healthz
— returns{ "ok": true }
Tool
get_time
Description: Returns the current UTC timestamp, optionally formatted.
Input schema:
Output structuredContent:
Local Dev
Test:
If you set API_KEY=secret
, include a header: -H 'x-api-key: secret'
Deploy to Google Cloud Run
Option 1 — from source (simplest):
Option 2 — via Cloud Build pipeline:
Wire into OpenAI Agent Builder
Add a new MCP Server to your agent
Server URL: your Cloud Run URL (e.g.
https://mcp-clock-xxxx-uc.a.run.app
)Label:
clock
Allowed tools:
get_time
(or leave empty to allow all)
License
MIT
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A minimal MCP server that provides current time functionality with optional formatting. Designed for production deployment on Google Cloud Run with proper JSON-RPC 2.0 implementation.