Documentation Index
Fetch the complete documentation index at: https://mintlify.com/alexyslozada/mcp-course/llms.txt
Use this file to discover all available pages before exploring further.
What is an MCP Server?
An MCP server is a program that exposes capabilities (tools, resources, and prompts) to AI applications through the Model Context Protocol. Servers run as separate processes and communicate with clients via the MCP protocol.Creating an MCP Server
TypeScript Server
The MCP SDK for TypeScript provides theMcpServer class for creating servers.
Python Server
The FastMCP library provides a simpler API for creating Python servers.Real-World Server Examples
Game of Thrones Quotes Server
This server demonstrates all three capability types (tools, resources, and prompts). Location:source/servers/basic/src/server.ts
- Fetches quotes from external API
- Provides tools for getting random quotes and calculating LCM
- Exposes static and dynamic resources
- Offers analysis prompts
Calculator Server (Python)
A simple calculator demonstrating Python server implementation. Location:source/servers/calculator-py/server.py:1-34
TODO List Server
A CRUD server for managing TODO items. Location:source/servers/todo-ts/src/index.ts:1-13
- Create, read, update, delete TODO items
- Complete and clear completed TODOs
- Demonstrates stateful server pattern
Server Lifecycle
1. Initialization
When a client connects, the server goes through an initialization handshake:2. Request Handling
Once initialized, the server processes incoming requests:- List requests: Return available capabilities
- Call requests: Execute tools, read resources, get prompts
- Notification requests: Handle updates and changes
3. Shutdown
When the client disconnects, the server cleans up and exits:Server Configuration
Declaring Capabilities
Servers must declare which capabilities they support:Server Metadata
Error Handling
TypeScript Error Handling
Fromsource/servers/basic/src/server.ts:92-96:
Python Error Handling
Fromsource/servers/calculator-py/server.py:14-16:
Transport Options
Stdio Transport (Most Common)
- Simple to implement
- No network configuration
- Process isolation
- Works across languages
Other Transports
MCP also supports:- SSE (Server-Sent Events): For web-based servers
- HTTP: For REST-like interactions
Best Practices
Use Descriptive Names
Use Descriptive Names
Give your server and capabilities clear, descriptive names:
Validate Input
Validate Input
Always validate input parameters using schemas (Zod for TypeScript):
Return Structured Errors
Return Structured Errors
Use the
isError flag and provide helpful error messages:Log to stderr
Log to stderr
Use stderr for logging, not stdout (which is used for MCP messages):
Testing Your Server
You can test your server using the MCP Inspector or by creating a simple client:Next Steps
Tools
Learn how to add tools to your server
Resources
Discover how to expose data through resources
Prompts
Create reusable prompt templates
Clients
Build clients to connect to your server