Constructing an MCP server requires specific tooling to handle the JSON-RPC communication and transport layers effectively. While the protocol is language-agnostic, the official Software Development Kits (SDKs) abstract much of the low-level serialization and connection management logic. This section guides you through configuring a development environment capable of running, inspecting, and debugging MCP servers.
We will focus on setting up the mcp Python package and the TypeScript SDK, along with the MCP Inspector. The Inspector is a critical component of the workflow; it acts as a surrogate client, allowing you to test your server's resources and tools within a web interface before integrating with a production client like Claude Desktop.
Before installing packages, it is helpful to visualize how the components in your local environment interact. Unlike standard web development where you might use curl or Postman against a running HTTP server, MCP servers often communicate over standard input/output (stdio). This requires a host process to spawn the server and manage the input and output streams.
The MCP Inspector fills the role of this host during development. It sits between your browser and your server script, translating UI actions into JSON-RPC messages sent over stdio.
The development data flow showing how the Inspector mediates communication between the browser interface and the local server process via standard streams.
Ensure your system meets the following baselines:
npm or npx to run.The Inspector is a global tool used to verify that your server implements the protocol correctly. It visualizes the resources, prompts, and tools your server exposes.
To install the Inspector globally using npm:
npm install -g @modelcontextprotocol/inspector
You can verify the installation by running mcp-inspector --version or simply checking that npx @modelcontextprotocol/inspector executes without error. We will use this tool extensively in later chapters to debug connection lifecycles.
For Python-based servers, we recommend isolating dependencies in a virtual environment. This prevents conflicts with system packages and mimics a production deployment container.
Create a Project Directory Organize your workspace. Create a directory that will house your server code.
mkdir mcp-server-quickstart
cd mcp-server-quickstart
Initialize Virtual Environment
Use the built-in venv module to create an isolated environment.
# On macOS/Linux
python3 -m venv .venv
source .venv/bin/activate
# On Windows
python -m venv .venv
.venv\Scripts\activate
Install the MCP SDK Install the core library. This package includes the server primitives and the stdio transport layer.
pip install mcp
If you intend to use uv for faster package management (common in the modern Python data stack), you can alternatively run uv pip install mcp.
If you prefer TypeScript, the setup involves initializing a Node.js project. The TypeScript SDK is modular, separating the core protocol from specific transport implementations.
Initialize Project
mkdir mcp-ts-server
cd mcp-ts-server
npm init -y
Install Dependencies You need the SDK and the Type definitions.
npm install @modelcontextprotocol/sdk zod
npm install --save-dev typescript @types/node tsx
We include zod here as it is the standard schema validation library used within the MCP TypeScript ecosystem for defining tool inputs. tsx is included to execute TypeScript files directly during development without a separate build step.
Configure TypeScript
Generate a tsconfig.json to handle module resolution.
npx tsc --init
Ensure your tsconfig.json is configured for NodeNext module resolution to support modern ESM imports, which the MCP SDK utilizes.
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"rootDir": "./src",
"strict": true
}
}
To confirm that your environment is correctly configured, create a minimal "Hello World" script that initializes a server instance. This does not yet expose data, but it confirms the library is importable and the interpreter works.
Python Verification (check_env.py):
from mcp.server import Server
from mcp.server.stdio import StdioServerTransport
def main():
# Initialize a server with a name and version
server = Server("test-server")
print(f"MCP SDK Version verified. Server object created: {server.name}")
if __name__ == "__main__":
main()
Run this with python check_env.py. If it prints the success message without raising an ImportError, your Python environment is ready.
While the Inspector is the primary tool for development, you may eventually want to test against the Claude Desktop application. Claude Desktop reads a configuration file to locate local MCP servers.
Locate the configuration file based on your operating system:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.jsonYou do not need to edit this file yet. In Chapter 4, we will modify this JSON structure to register the servers you build in the upcoming chapters.
Stdio Buffering
When running Python scripts over stdio, output buffering can sometimes cause JSON-RPC messages to hang. The MCP SDK handles this internally, but if you are writing custom wrappers, ensure you run Python with the -u (unbuffered) flag or set the environment variable PYTHONUNBUFFERED=1.
Port Conflicts
The MCP Inspector defaults to port 5173. If this port is in use, you can specify a different port using the --port argument when launching the inspector command.
With the SDKs installed and the Inspector ready, your environment is prepared to define Resources and Prompts. In the next chapter, we will write the code to expose a local file system to an LLM, transforming static files into accessible context.
Was this section helpful?
venv - Creation of virtual environments, Python Software Foundation, 2024 - Official Python documentation explaining how to create and manage isolated Python environments, a key step in the setup.© 2026 ApX Machine LearningEngineered with