Skip to main content
Glama
first-mcp-server

first-mcp-server

by kuldeeepy

first-mcp-server

The smallest MCP server that actually does something — one tool, stdio transport, no build step. About 35 lines in server.ts.

I wrote this while figuring out how MCP works. If you've read Understanding MCP Servers, this is that post's weather example as code you can actually run.

What it does

Exposes a single tool, getCityWeather, over stdio. Ask Claude "what's the weather in Delhi?" and it discovers the tool, calls it, and answers from the result.

The weather itself is a hardcoded map of three cities. That's on purpose — the point here is the protocol, not the data. Swap the lookup for a real API call and nothing else about the server changes.

Related MCP server: Minimal MCP Demo

Run it

npm install
npm start

That starts the server on stdio. On its own it does nothing visible — it's waiting for a client to talk to it, which is the whole idea.

Connect it to Claude

Add it to your MCP config (claude_desktop_config.json for Claude Desktop, or .mcp.json for Claude Code):

{
  "mcpServers": {
    "first-server": {
      "command": "npx",
      "args": ["tsx", "/absolute/path/to/first-mcp-server/server.ts"]
    }
  }
}

Use an absolute path — the host spawns this as a subprocess and won't be in your project directory. Restart the host, then ask it about the weather in Delhi, Mumbai or Bangalore.

The three pieces

Everything in server.ts is one of these:

Piece

What it is

McpServer

the server itself, with a name and version the client sees

registerTool

one tool — a name, a description, and an input schema

StdioServerTransport

how bytes move; JSON-RPC over stdin/stdout

The description and schema matter more than they look. They're the only thing the model reads when deciding whether this tool is relevant to your question, so vague descriptions produce a tool that never gets called.

License

MIT

Available Tools

1 tool
getCityWeatherB

Fetch the current weather for a city

Inputs: name (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 1 tool

    Disambiguation5/5

    Only one tool exists, so there is no possibility of confusion or overlap. The single tool's purpose is immediately clear from its name and description.

    Naming Consistency5/5

    The single tool name follows a clear verb-noun camelCase pattern (getCityWeather), and there are no other names to create inconsistency.

    Tool Count3/5

    One tool feels thin for a weather server, which often supports forecasts, alerts, and other query types. It is not necessarily wrong, but it is on the low end of acceptable.

    Completeness3/5

    The tool covers the specific task of fetching current city weather, but leaves obvious gaps like forecasts, historical data, or unit selection unexplained. It is adequate for a narrow demo, but not a full weather service.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables users to get weather forecasts for any city using the Open-Meteo API through natural language in Claude Desktop or VS Code.
      ISC
    • A
      license
      B
      quality
      D
      maintenance
      This MCP server demonstrates basic Model Context Protocol architecture by exposing a get_weather tool that returns fake weather data, communicating over stdio.
      1
      ISC
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables querying current weather information for cities through natural language, with support for both stdio and streamable HTTP transports.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to retrieve current weather conditions and 3-day forecasts for cities through standardized MCP tools over stdio.
      -