MCPmatic

MCP server examples

Published · Updated · Written against MCP spec 2026-07-28

The fastest way to understand an MCP server is to run one. This page collects the official reference servers, the smallest working servers from the official quickstart in TypeScript and Python, and real tool definitions you can copy.

Official reference servers#

The MCP project maintains a small set of reference servers that show protocol features. The examples page lists these:

ServerWhat it shows
EverythingA test server with prompts, resources and tools
FetchFetching web content and converting it for LLMs
FilesystemFile operations with configurable access controls
GitReading, searching and changing Git repositories
MemoryA knowledge-graph-based persistent memory
Sequential ThinkingStep-by-step problem solving
TimeTime and time zone conversion

TypeScript servers run with npx, Python ones with uvx:

npx -y @modelcontextprotocol/server-memory
uvx mcp-server-git

To use one in a desktop app, add it to the host's config file. See add an MCP server to Claude Desktop and Cursor.

These are reference implementations for learning, not hardened products. Read the code before giving any server access to real data.

A minimal server in TypeScript#

Install the SDK and Zod (npm install @modelcontextprotocol/server zod), then register tools on a server created by a factory function. Adapted from the official quickstart:

import { McpServer } from "@modelcontextprotocol/server";
import { serveStdio } from "@modelcontextprotocol/server/stdio";
import { z } from "zod";

// serveStdio calls this whenever it needs an instance,
// so it must return a fresh server every time.
function createServer() {
  const server = new McpServer({ name: "weather", version: "1.0.0" });
  server.registerTool(
    "get_alerts",
    {
      description: "Get weather alerts for a state",
      inputSchema: z.object({
        state: z.string().length(2).describe("Two-letter state code (e.g. CA, NY)"),
      }),
    },
    async ({ state }) => ({
      content: [{ type: "text", text: `No active alerts for ${state}` }],
    }),
  );
  return server;
}

serveStdio(createServer, { onerror: (err) => console.error(err) });

The quickstart explains why the factory matters: serveStdio negotiates the protocol revision with each client, so the same server answers 2026-07-28 clients and older clients that still send initialize. A server wired by hand with server.connect(new StdioServerTransport()) only serves 2025-era clients.

A minimal server in Python#

The quickstart requires Python SDK 2.0.0 or higher (uv add "mcp[cli]"). MCPServer builds the tool definition from type hints and the docstring:

from mcp.server import MCPServer

mcp = MCPServer("weather")

@mcp.tool()
async def get_forecast(latitude: float, longitude: float) -> str:
    """Get weather forecast for a location.

    Args:
        latitude: Latitude of the location
        longitude: Longitude of the location
    """
    ...  # call your API here

if __name__ == "__main__":
    mcp.run(transport="stdio")

Never write to stdout in a stdio server. Stdout carries the JSON-RPC messages, so a stray print() or console.log() corrupts them. Log to stderr instead.

Tool definition examples#

Whatever the language, the client sees JSON like this in the tools/list result. Paste any of them into the linter to see how they score.

A read-only lookup#

{
  "name": "get_weather",
  "title": "Weather lookup",
  "description": "Get current weather for a city. Returns temperature in Celsius and conditions.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "city": { "type": "string", "description": "City name, e.g. Sydney" }
    },
    "required": ["city"]
  },
  "annotations": { "readOnlyHint": true, "openWorldHint": true }
}

A tool with no parameters#

The spec recommends this form for tools that take no arguments:

{
  "name": "get_server_time",
  "description": "Return the server's current time in ISO 8601 format.",
  "inputSchema": { "type": "object", "additionalProperties": false }
}

A tool with structured output#

{
  "name": "get_order_total",
  "description": "Get the total for an order, in cents, with its currency.",
  "inputSchema": {
    "type": "object",
    "properties": { "order_id": { "type": "string", "description": "Order number" } },
    "required": ["order_id"]
  },
  "outputSchema": {
    "type": "object",
    "properties": {
      "total_cents": { "type": "integer" },
      "currency": { "type": "string" }
    },
    "required": ["total_cents", "currency"]
  }
}

With an outputSchema, the server MUST return structuredContent that conforms to it, and SHOULD also return the same JSON as text for older clients. The tool schema reference covers every field.

Next steps#

Frequently asked questions#

Where can I find more MCP servers?

The official examples page lists the reference servers, and the MCP Registry (in preview at registry.modelcontextprotocol.io) lists published servers. Review any third-party server's source before installing it.

Which language should I write my server in?

Use whichever official SDK matches your stack. The MCP blog lists TypeScript, Python, Go and C# as the Tier 1 SDKs for 2026-07-28. The official quickstart also has Java, Kotlin, Ruby and Rust versions.

Sources#