spinov001-art/mcp-server-tutorial
Build your own MCP server for AI agents. Step-by-step tutorial with Python examples. Connect Claude, GPT, and other LLMs to real-time data.
Platform-specific configuration:
{
"mcpServers": {
"mcp-server-tutorial": {
"command": "npx",
"args": [
"-y",
"mcp-server-tutorial"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
Step-by-step tutorial: create an MCP (Model Context Protocol) server that connects AI agents (Claude, GPT, etc.) to real-time data sources.
MCP (Model Context Protocol) lets AI agents call external tools and data sources. Instead of the AI guessing, it can query live APIs, databases, and services.
Example: Ask Claude "What's trending on Hacker News?" → Claude calls your MCP server → server queries HN API → returns real data.
pip install mcp
python server.pyBuild an MCP server that researches any company — domain info, tech stack, WHOIS data.
from mcp.server import Server
from mcp.types import Tool, TextContent
import requests
server = Server("company-researcher")
@server.tool()
async def research_company(domain: str) -> list[TextContent]:
"""Research a company by its domain name."""
results = {}
# WHOIS data
whois_url = f"https://rdap.org/domain/{domain}"
try:
resp = requests.get(whois_url, timeout=10)
if resp.ok:
data = resp.json()
results["registrar"] = data.get("entities", [{}])[0].get("vcardArray", [None, []])[1][1][3] if data.get("entities") else "unknown"
results["created"] = data.get("events", [{}])[0].get("eventDate", "unknown")
except Exception:
results["whois"] = "unavailable"
# DNS records
dns_url = f"https://dns.google/resolve?name={domain}&type=A"
try:
resp = requests.get(dns_url, timeout=5)
if resp.ok:
answers = resp.json().get("Answer", [])
results["ip_addresses"] = [a["data"] for a in answers]
except Exception:
results["dns"] = "unavailable"
# Tech detection via headers
try:
resp = requests.head(f"https://{domain}", timeout=5, allow_redirects=True)
headers = dict(resp.headers)
results["serLoading reviews...