Build an MCP Server: Complete Tutorial (Python & TypeScript)
Learn how to build MCP servers from scratch using FastMCP for Python or the TypeScript SDK. Deploy with one command and start earning on the MCPize marketplace.
Why Build MCP Servers in 2025?
Model Context Protocol (MCP) has become the standard for connecting AI applications to external data and tools. In 2025, the ecosystem has exploded with adoption from major players. When you build an MCP server, you tap into a rapidly growing market of AI developers looking for integrations.
Industry Adoption
- OpenAI adopted MCP (March 2025)
- Google DeepMind integration (April 2025)
- Claude, Cursor, VS Code native support
Monetization Opportunity
- 85% revenue share on MCPize
- Flexible pricing tiers (Free/Pro/Enterprise)
- Monthly payouts via Stripe Connect
Developer Experience
- FastMCP 2.0 for rapid Python development
- TypeScript SDK with full type safety
- One-command deploy with MCPize CLI
Building an MCP server today positions you at the forefront of the AI tools ecosystem. Whether you want to create internal tools for your organization or build a public server to monetize on the marketplace, now is the perfect time to build MCP servers.
Prerequisites
Before you start building your MCP server, make sure you have the following tools installed on your system. The MCP server tutorial below assumes you have these prerequisites ready.
For Python Development
- Python 3.10+
FastMCP requires Python 3.10 or higher
- uv or pip
Package manager for dependencies (uv recommended)
- FastMCP 2.0
pip install fastmcp
For TypeScript Development
- Node.js 18+
LTS version recommended for stability
- TypeScript 5+
For type safety and better DX
- @modelcontextprotocol/sdk
Official TypeScript SDK
MCPize Account & CLI
To deploy and monetize your MCP server, you will need a free MCPize account and the CLI tools installed.
Initialize Your Project with MCPize CLI
The fastest way to create an MCP server is using the MCPize CLI. It scaffolds a complete project with best practices, configuration files, and example code. You can build MCP servers in Python or TypeScript.
Step 1: Create a New Project
Run the init command and follow the interactive prompts
Step 2: Project Structure
The CLI generates a complete project with all necessary files
my-mcp-server/
├── src/server.py # Main server code
├── mcpize.yaml # MCPize config
├── pyproject.toml # Dependencies
└── README.mdmcpize.yaml Configuration
Server metadata, pricing, and deployment settings
name: my-mcp-server
runtime: python3.11
entrypoint: src/server.py
plans:
- name: Free
price: 0
limits: { requests_per_month: 1000 }
- name: Pro
price: 9
limits: { requests_per_month: 50000 }Build MCP Server in Python (FastMCP)
FastMCP is the recommended way to build MCP servers in Python. It provides a simple decorator-based API that lets you focus on your tool logic rather than protocol details. This MCP server Python tutorial shows you how to create a server with tools, resources, and prompts.
Python MCP Server (FastMCP)
Clean, minimal MCP server with tools and resources
# server.py - FastMCP MCP Server
from fastmcp import FastMCP
mcp = FastMCP("my-server")
@mcp.tool()
def get_weather(city: str) -> dict:
"""Get current weather for a city."""
# Your API call here
return {"city": city, "temp": 22, "condition": "sunny"}
@mcp.tool()
def calculate(a: float, b: float, op: str = "add") -> float:
"""Perform calculation: add, sub, mul, div."""
ops = {"add": a + b, "sub": a - b, "mul": a * b, "div": a / b}
return ops.get(op, a + b)
@mcp.resource("config://settings")
def get_settings() -> str:
"""Server configuration."""
return "max_requests: 100\nversion: 1.0.0"
if __name__ == "__main__":
mcp.run()Key Concepts
@mcp.tool()
Tools are functions the AI can call to perform actions. FastMCP automatically generates the JSON schema from your type hints and docstrings.
@mcp.resource()
Resources expose data the AI can read. Use URI patterns like "config://settings" or "file://path/to/data" to organize your resources.
@mcp.prompt()
Prompts are reusable templates that help users interact with your server. They can include parameters for customization.
Important: stdio Transport
When building an MCP server for stdio transport (local development with Claude Desktop):
- !Never log to stdout - it breaks JSON-RPC communication
- !Use stderr for debugging:
print(..., file=sys.stderr) - !Or use Python logging configured to write to stderr
Build MCP Server in TypeScript
The TypeScript SDK provides full control over your MCP server implementation with complete type safety. This MCP server TypeScript tutorial covers creating a server using the official @modelcontextprotocol/sdk package.
TypeScript MCP Server
Clean MCP server with type-safe tools
// server.ts - TypeScript MCP Server
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
const server = new Server(
{ name: "my-server", version: "1.0.0" },
{ capabilities: { tools: {} } }
);
// Define tools
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [{
name: "get_weather",
description: "Get weather for a city",
inputSchema: {
type: "object",
properties: { city: { type: "string" } },
required: ["city"]
}
}]
}));
// Handle tool calls
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
if (name === "get_weather") {
return {
content: [{ type: "text", text: `Weather in ${args?.city}: 22°C, sunny` }]
};
}
throw new Error(`Unknown tool: ${name}`);
});
// Start server
const transport = new StdioServerTransport();
await server.connect(transport);TypeScript vs Python: When to Choose
Choose Python (FastMCP) when:
- - You want rapid prototyping and development
- - Your team is more familiar with Python
- - You are integrating with Python libraries (ML, data science)
- - You prefer decorator-based, concise syntax
Choose TypeScript when:
- - You need full type safety and IDE support
- - Your team works primarily in JavaScript/TypeScript
- - You are building complex enterprise applications
- - You want maximum control over the protocol
Test with Claude Desktop
Before deploying your MCP server, test it locally with Claude Desktop. This lets you verify your tools work correctly and iterate quickly on your implementation. Claude Desktop connects to local MCP servers via stdio transport.
Step 1: Configure Claude Desktop
Add your server to the Claude Desktop configuration file
Edit the Claude Desktop config file at:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
- Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"my-mcp-server": {
"command": "python",
"args": ["/path/to/server.py"]
}
}
}Step 2: Use mcpize dev for Hot Reload
The MCPize CLI provides a development server with automatic reloading
Step 3: Test Your Tools
Open Claude Desktop and interact with your server
After restarting Claude Desktop, your server tools will be available. Try prompts like:
"What time is it in Tokyo?"
"Calculate the price for 5 items at $29.99 each with 15% discount"
"Show me the server settings"
Claude will automatically detect and use the appropriate tools from your MCP server.
Deploy to MCPize (One Command)
Once your MCP server is tested locally, deploy it to MCPize with a single command. MCPize handles hosting, scaling, SSL, monitoring, and provides a production-ready HTTP endpoint. The deploy MCP server process takes less than a minute.
Deploy Your Server
Streamable HTTP
Global Edge Network
Built-in Monitoring
Ready to Deploy?
Sign up for a free MCPize account and deploy your first MCP server in minutes. No credit card required.
Deploy Your First ServerPublish to Marketplace
After deploying your MCP server, publish it to the MCPize marketplace to make it discoverable by thousands of developers. Publishing adds your server to the directory with searchable metadata, documentation, and pricing.
Publish Command
What Gets Published
- Server name, description, and category from mcpize.yaml
- Auto-generated API documentation from tool schemas
- Pricing tiers and usage limits
- README.md content for detailed documentation
- Example prompts and use cases
Marketplace Visibility Tips
- Write clear, descriptive tool names and descriptions
- Include relevant tags for better search discovery
- Provide example prompts showing real use cases
- Offer a free tier to attract initial users
- Keep documentation up-to-date with new features
Monetize Your MCP Server
MCPize makes it easy to earn money from your MCP server. Set up pricing tiers, track revenue, and receive monthly payouts. With 85% revenue share, your earnings scale with your user base.
Revenue Share Model
You keep 85% of all subscription revenue. MCPize takes 15% to cover hosting, billing infrastructure, and platform maintenance.
- Monthly payouts via Stripe Connect
- $100 minimum payout threshold
- Real-time earnings dashboard
Recommended Pricing Tiers
1,000 requests/month - great for discovery
50,000 requests/month - individual developers
Unlimited requests - teams and businesses
Earnings Example
| Subscribers | Plan | Monthly Revenue | Your Earnings (85%) |
|---|---|---|---|
| 50 | Pro ($19/mo) | $950 | $665 |
| 100 | Pro ($19/mo) | $1,900 | $1,330 |
| 200 | Mixed tiers | $4,500 | $3,150 |
| 500 | Mixed tiers | $12,000 | $8,400 |
* Actual earnings depend on your pricing and subscriber mix. Popular servers with quality tools can grow to 500+ subscribers within 6-12 months.
Best Practices for Building MCP Servers
Follow these best practices to build reliable, secure, and user-friendly MCP servers that provide great experiences and attract subscribers.
Tool Design
Error Handling
Performance
Security
Frequently Asked Questions
Get answers to common questions about building MCP servers, deployment, and monetization.
Ready to Build Your MCP Server?
Join thousands of developers building and monetizing MCP servers on MCPize. Create your free account and deploy your first server in 15 minutes.
No credit card required. Free tier available.