Model Context Protocol (MCP) Giriş
James Chapman
AI Curriculum Manager, DataCamp


from mcp.server.fastmcp import FastMCP
import requests
# Bir MCP sunucu örneği oluşturun
mcp = FastMCP("Timezone Converter")
from mcp.server.fastmcp import FastMCP import requests # Bir MCP sunucu örneği oluşturun mcp = FastMCP("Timezone Converter")@mcp.tool()def convert_timezone(date_time, from_timezone, to_timezone):
@mcp.tool() def convert_timezone(date_time, from_timezone, to_timezone): # API uç noktasını tanımlayın ve girdi verisini biçimlendirinurl = "https://api.opentimezone.com/convert" payload = {"dateTime": date_time, "fromTimezone": from_timezone, "toTimezone": to_timezone}response = requests.post(url, json=payload)data = response.json() converted_time = data.get('dateTime', 'N/A')return f"Time in {to_timezone}: {converted_time}"
@mcp.tool()
def convert_timezone(date_time: str, from_timezone: str, to_timezone: str) -> str:
"""
Bir tarih-saat bilgisini bir saat diliminden diğerine dönüştürür.
Args:
date_time: ISO biçiminde tarih-saat dizesi (örn. '2025-01-20T14:30:00')
from_timezone: Kaynak saat dilimi (örn. 'America/New_York')
to_timezone: Hedef saat dilimi (örn. 'Europe/London')
Returns:
Dönüştürülen tarih-saat ve saat dilimi bilgisini içeren bir dize
"""

Model Context Protocol (MCP) Giriş