Build Your Own MCP Server in 30 Minutes: Python & TypeScript Tutorial

An MCP server is just a program that exposes functions AI can call. If you can write an API endpoint, you can build an MCP server. Here’s both Python and TypeScript, from zero to working in 30 minutes.

What We’re Building

A simple MCP server with two tools:

  1. search_hackathons – searches a list of hackathons by keyword
  2. get_hackathon_details – returns details for a specific hackathon

After building this, your AI can say: “Find AI hackathons happening this month” and get real results.

TypeScript Version

Step 1: Setup

mkdir my-mcp-server && cd my-mcp-server
npm init -y
npm install @modelcontextprotocol/sdk zod

Step 2: Create server (index.ts)

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({ name: "hackathon-search", version: "1.0.0" });

// Sample data (replace with your database)
const hackathons = [
  { name: "Build with AI", theme: "ai", date: "2026-08-30", url: "https://buildwithai.reskilll.com" },
  { name: "Health-a-thon", theme: "healthcare", date: "2026-09-28", url: "https://healthathon.reskilll.com" },
  { name: "TechQuest", theme: "mobile", date: "2026-08-16", url: "https://techquest.reskilll.com" },
];

// Tool 1: Search
server.tool("search_hackathons", { query: z.string() }, async ({ query }) => {
  const results = hackathons.filter(h =>
    h.name.toLowerCase().includes(query.toLowerCase()) ||
    h.theme.toLowerCase().includes(query.toLowerCase())
  );
  return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] };
});

// Tool 2: Get details
server.tool("get_hackathon_details", { name: z.string() }, async ({ name }) => {
  const hack = hackathons.find(h => h.name.toLowerCase() === name.toLowerCase());
  if (!hack) return { content: [{ type: "text", text: "Hackathon not found" }] };
  return { content: [{ type: "text", text: JSON.stringify(hack, null, 2) }] };
});

// Start
const transport = new StdioServerTransport();
await server.connect(transport);

Step 3: Connect to Claude

// In claude_desktop_config.json
{
  "mcpServers": {
    "hackathons": {
      "command": "npx",
      "args": ["tsx", "/path/to/my-mcp-server/index.ts"]
    }
  }
}

Python Version

# server.py
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("hackathon-search")

hackathons = [
    {"name": "Build with AI", "theme": "ai", "date": "2026-08-30"},
    {"name": "Health-a-thon", "theme": "healthcare", "date": "2026-09-28"},
    {"name": "TechQuest", "theme": "mobile", "date": "2026-08-16"},
]

@mcp.tool()
def search_hackathons(query: str) -> str:
    """Search hackathons by keyword"""
    results = [h for h in hackathons if query.lower() in h["name"].lower() or query.lower() in h["theme"]]
    return str(results)

@mcp.tool()
def get_hackathon_details(name: str) -> str:
    """Get details of a specific hackathon"""
    hack = next((h for h in hackathons if h["name"].lower() == name.lower()), None)
    return str(hack) if hack else "Not found"

mcp.run()

Test It

Restart Claude Desktop. Ask: “Search for AI hackathons”. Claude calls your search_hackathons tool and returns the results from your data.

Next Steps

  • Replace sample data with a real database query
  • Add authentication (API keys, OAuth)
  • Add more tools (create, update, delete)
  • Publish to npm/PyPI for others to use

Build something cool with MCP? Show it at a hackathon

Scroll to Top