Skip to main content

Building an MCP Server

4.1 Development Environment Setup

Python

4.2 Complete TypeScript Example

An MCP Server providing a weather query tool:

Multi-Tool Server (with outputSchema and structuredContent)

Protocol version 2025-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:
The Inspector opens a web interface where you can:
  • 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
Restart Claude Desktop and try using your tools in a conversation.

4.7 Common Errors

stdio Servers must never use console.log. stdout is the protocol channel; any non-JSON-RPC output will break communication. Use console.error or write to a log file instead.

Next Chapter: Commerce MCP Server — MCP Server design patterns for e-commerce scenarios