A FastMCP-based Model Context Protocol server providing timezone conversion tools with OAuth2 PKCE authentication support.
- OAuth2 PKCE Authentication: Secure OAuth flow implementation
- SSE Transport: Server-Sent Events for real-time communication
- Timezone Tools: Get current time and convert between timezones
- IANA Timezone Support: All standard timezone conversions
- Mock OAuth Server: Built-in testing OAuth server
# Create and activate virtual environment
python -m venv venv
.\venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txtOption A: Simple Server (No Auth)
python simplified_server.pyOption B: OAuth-Ready Server (SSE Mode)
# Terminal 1 - Mock OAuth Server
python mock_oauth_server.py
# Terminal 2 - MCP Server
python time_mcp_server.pyOption C: Clean Server (Reduced Logging)
python time_mcp_server_clean.pyGet the current time in any timezone.
{
"timezone": "America/New_York",
"datetime": "2025-11-05T09:30:00-05:00",
"is_dst": false
}Convert time between timezones.
{
"source": {
"timezone": "America/New_York",
"datetime": "2025-11-05T16:30:00-05:00",
"is_dst": false
},
"target": {
"timezone": "Asia/Tokyo",
"datetime": "2025-11-06T06:30:00+09:00",
"is_dst": false
},
"time_difference": "+14.0h"
}time://current- Current UTC timetime://timezones- List of available IANA timezones
GET /.well-known/oauth-authorization-server- OAuth 2.0 Authorization Server Metadata (RFC 8414)GET /.well-known/openid-configuration- OpenID Connect Discovery
GET /.well-known/oauth-protected-resource- OAuth 2.0 Protected Resource Metadata (RFC 9728)
# Test MCP tools
python test_server.py
# Test OAuth flow
python test_oauth_flow.py
# Test integration (requires both servers running)
python test_integration.py
# Test .well-known endpoints
python test_wellknown_endpoints.pyEdit .env for OAuth settings:
CLIENT_ID=time-mcp-client
AUTH_URL=http://localhost:8000/oauth/authorize
TOKEN_URL=http://localhost:8000/oauth/token
SCOPES=time:read,time:convert┌─────────────────────────────────────────┐
│ Mock OAuth Server │
│ (http://localhost:8000) │
│ • /oauth/authorize │
│ • /oauth/token │
│ • PKCE validation │
└───────────┬─────────────────────────────┘
│ OAuth2 PKCE Flow
▼
┌─────────────────────────────────────────┐
│ Time MCP Server (SSE) │
│ (http://localhost:3000/sse) │
│ Tools: │
│ • get_current_time(timezone) │
│ • convert_time(source, time, target) │
│ Resources: │
│ • time://current │
│ • time://timezones │
└─────────────────────────────────────────┘
├── time_mcp_server.py # Main OAuth-ready server (SSE)
├── time_mcp_server_clean.py # Version with reduced logging
├── simplified_server.py # No-auth version for testing
├── mock_oauth_server.py # OAuth2 PKCE mock server
├── server.py # Working server file
├── test_server.py # Unit tests (24 tests)
├── test_oauth_flow.py # OAuth flow tests
├── test_integration.py # Integration tests
├── requirements.txt # Python dependencies
├── .env # OAuth configuration
├── .gitignore # Git ignore rules
├── run_server.ps1 # Quick start script (no auth)
└── run_sse_server.ps1 # Quick start script (SSE)
| Feature | simplified_server.py | time_mcp_server.py | time_mcp_server_clean.py |
|---|---|---|---|
| OAuth Support | ❌ | ✅ | ✅ |
| SSE Transport | ❌ | ✅ | ✅ |
| Reduced Logging | ✅ | ❌ | ✅ |
| Best For | Testing/Development | Production | Production (clean logs) |
When running the SSE server, you may see:
ERROR: TypeError: 'NoneType' object is not callable
This is expected behavior when testing with simple HTTP clients (curl, browser). Real MCP clients maintain long-lived connections and won't trigger this error.
Solutions:
- Ignore the errors (they're harmless)
- Use
time_mcp_server_clean.pyfor reduced logging - Use
simplified_server.pyfor testing without SSE
- OAuth Tests: ✅ 100% passing
- Unit Tests: ✅ 95.8% passing (23/24)
- Integration Tests: ✅ Passing
-
Test with Real OAuth Provider
- Replace mock server with actual OAuth gateway
- Update URLs in
.env
-
Connect MCP Client
- Claude Desktop
- Custom MCP client
- Test authenticated requests
-
Deploy to Production
- Configure SSL/TLS
- Set up proper OAuth credentials
- Deploy to cloud platform
MIT
Pull requests welcome! Please ensure tests pass before submitting.