Building an MCP Server
4.1 Development Environment Setup
TypeScript (Recommended)
Python
4.2 Complete TypeScript Example
An MCP Server providing a weather query tool:Multi-Tool Server (with outputSchema and structuredContent)
Protocol version2025-11-25 supports outputSchema for defining structured output format, with structuredContent for returning structured data:
4.3 Complete Python Example
4.4 Exposing Resources
In addition to tools, Servers can also expose data resources:4.5 Streamable HTTP Server
Use Streamable HTTP transport for remote deployment:4.6 Testing and Debugging
MCP Inspector
The official interactive debugging tool:- View all tools, resources, and prompts exposed by the Server
- Manually enter parameters and execute tools
- Inspect the raw JSON-RPC requests and responses
- Validate inputSchema and outputSchema
Testing in Claude Desktop
Edit the Claude Desktop configuration file: macOS:~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
4.7 Common Errors
Next Chapter: Commerce MCP Server — MCP Server design patterns for e-commerce scenarios