Ch 9 — Building an MCP Server
From zero to a working server in Python and TypeScript
High Level
-
Click play or press Space to begin...
AThe Official SDKsTwo first-class SDKs for building MCP servers
1code
Python SDKFastMCP class
decorator pattern
or
javascript
TypeScript SDKMcpServer class
method pattern
both
2auto_fix_high
Auto SchemaTypes → JSON Schema
automatically
3arrow_downward Step 1: Create a server and add tools
BDefine ToolsWrite functions, get tools — the SDK does the rest
edit_note
Write FunctionNormal function
with type hints
decorate
auto_awesome
@mcp.tool()SDK registers it
as an MCP tool
generates
schema
inputSchemaJSON Schema from
your type hints
4arrow_downward Step 2: Add resources and prompts
CAdd Resources & PromptsSame pattern: decorate a function, get a primitive
description
@mcp.resource()URI-addressed
read-only data
+
chat
@mcp.prompt()Reusable message
templates
all
5hub
One ServerTools + resources +
prompts together
6arrow_downward Step 3: Choose a transport and run
DTransport & RunChoose stdio or HTTP, then start the server
terminal
stdiomcp.run(transport="stdio")
for local use
or
cloud
HTTPmcp.run(transport="sse")
for remote use
7arrow_downward Step 4: Configure the host to use your server
EHost ConfigurationTell the host how to find and run your server
settings
mcp.jsonConfig file with
server definitions
defines
terminal
CommandHow to start
the server process
+
tune
Args & EnvArguments and
environment vars
8arrow_downward Testing and debugging your server
FTesting & DebuggingTools for developing and testing MCP servers
bug_report
MCP InspectorInteractive testing
UI for servers
+
terminal
CLI Testingmcp dev for
quick iteration
+
science
Unit TestsTest tools in
isolation