Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

An MCP server makes capabilities—such as tools, resources, and prompts—available to an MCP host. The official TypeScript tutorial provides a concrete first build: create a Node.js project, register a weather-alert tool, and serve it locally over standard input and output (stdio). You can then connect to it with the MCP Inspector. This route creates a local process integration, not a hosted web service.

What an MCP server does

The Model Context Protocol (MCP) is an open standard connecting AI applications to systems that contain data and tools. An MCP server exposes capabilities for an MCP host to use:

  • Tools are callable actions. A server can define an input schema and a handler that runs when the host calls the tool.
  • Resources make data available to the host.
  • Prompts provide prompt templates or related instructions.

In the TypeScript tutorial, the tool’s schema validates its arguments before the asynchronous handler runs, and the handler returns typed content blocks. The protocol and server concepts are described in the official TypeScript SDK overview.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create an MCP server with the official TypeScript SDK

This walkthrough follows the official TypeScript v2 first-server tutorial. It requires Node.js 20 or later and uses the tutorial’s package set: @modelcontextprotocol/server, zod, and tsx. The SDK ships as ES modules, so the project must use module mode. tsx runs TypeScript directly, without a separate build step.

  1. Set up the project

    Create a project directory, initialize it as an npm project, and install the documented dependencies:

    mkdir weather-mcp-server
    cd weather-mcp-server
    npm init -y
    npm install @modelcontextprotocol/server zod
    npm install --save-dev tsx

    In package.json, set "type": "module" and add a script such as "start": "tsx index.ts". The module setting is important because the SDK is published as ES modules.

    Rank #2
    TypeScript Programming Language - Software Engineer & Coder T-Shirt
    • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
    • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
    • Lightweight, Classic fit, Double-needle sleeve and bottom hem
  2. Register a tool and start the stdio server

    Create index.ts. The tutorial’s example creates an McpServer, registers a weather-alert tool with an input schema and asynchronous handler, and starts it using serveStdio(createServer). Use the complete implementation from the official first-server tutorial; it includes the tool definition and result format.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

    The stdio transport is for a host that starts the server as a local process and manages its lifetime. The process waits for the host or client to communicate over stdin, while stdout carries protocol traffic. Do not use console.log for diagnostics: send logs to stderr so they cannot corrupt the JSON-RPC stream.

  3. Launch it with the MCP Inspector

    The documented check uses the MCP Inspector to start the stdio command and connect to the server. Open the Tools view and invoke the sample weather-alert tool. The Inspector lets you check the connection and exercise the tool locally; it does not turn the example into a deployed remote service.

Should you use stdio or HTTP?

Need Transport direction What it means
A host launches the server on the same machine and controls its lifetime stdio The server runs as a local process and exchanges protocol messages through stdin and stdout. This is the first-server tutorial’s deployment shape.
One remote endpoint should serve multiple clients Streamable HTTP The TypeScript SDK v2 overview recommends HTTP for remote servers and says to use HTTP when one endpoint should serve multiple clients. Hosting and deployment are then part of the design.

The TypeScript SDK v1 server reference describes Streamable HTTP as its modern, fully featured transport and HTTP+SSE as a backwards-compatibility option. That is v1-specific guidance; do not assume it applies unchanged to the separate stable v2 documentation. Check the docs for the SDK version and framework you choose.

For localhost HTTP, the v1 reference also warns about DNS rebinding and documents createMcpExpressApp(), with protection enabled by default in supported localhost configurations. Treat this as version- and framework-specific guidance, not a universal setting: verify the selected SDK version and deployment framework before copying it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Which SDK should you use?

Choose based on the language and runtime you intend to maintain, then follow that SDK’s own getting-started path rather than translating TypeScript-specific commands.

  • TypeScript: The v2 first-server guide gives a concrete Node.js 20+ local stdio example, including tool registration and an Inspector workflow.
  • Python: The official Python SDK guide requires Python 3.10 or later and shows a server that can be exercised with the MCP Inspector or an in-memory client. See the official Python SDK guide.
  • Go: The official Go quick start creates a server, adds features, and runs it over a transport, including stdin/stdout. See the official Go quick start.

The TypeScript commands above are not a language-neutral recipe. Python and Go projects have their own setup and server APIs; use their official documentation for a runnable implementation.

What to decide before making the server remote

The local tutorial is a starting point for learning server capabilities and testing tool behavior. A shared HTTP endpoint changes the deployment shape: you need to host the process and choose an appropriate transport and framework. The cited SDK guidance establishes the local-versus-remote distinction, but does not prescribe a production architecture or hosting provider. Make those decisions for the clients and operating environment your server must support, and consult documentation matching the SDK version you deploy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.