Skip to main content
Glama
mcp-server-example

mcp-server-example

by nirojsapkota

MCP Server Example

A minimal example Model Context Protocol (MCP) server built with the official TypeScript SDK (@modelcontextprotocol/sdk). It communicates over stdio and demonstrates the three core MCP primitives:

  • Tools — callable functions:

    • add(a, b) — adds two numbers.

    • get-weather(city) — returns a mock weather report.

    • save-note(key, text) — saves a note in memory.

  • Resources — readable data:

    • notes://list — lists all saved notes as JSON.

  • Prompts — reusable prompt templates:

    • summarize-notes — asks the model to summarize all saved notes.

Setup

npm install
npm run build

Related MCP server: mcp-demo

Run

npm start

The server communicates over stdio, so it's meant to be launched by an MCP client (e.g. Claude Desktop, VS Code, or the GitHub Copilot CLI), not run interactively.

Configure with an MCP client

Example client config (e.g. claude_desktop_config.json or similar):

{
  "mcpServers": {
    "example": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-server-example/build/index.js"]
    }
  }
}

Debugging

Use the official MCP Inspector to test the server interactively without a full client:

npx @modelcontextprotocol/inspector node build/index.js

Project structure

mcp-server-example/
├── src/
│   └── index.ts      # Server implementation (tools, resources, prompts)
├── package.json
├── tsconfig.json
└── README.md

Available Tools

4 tools
addAdd two numbersA

Adds two numbers together and returns the result.

Inputs: a (required), b (required).

get-weatherGet weather (mock)A

Returns a mock weather report for a given city.

Inputs: city (required).

multiplyMultiply two numbersC

Multiplies two numbers together you jackass

Inputs: a (required), b (required).

save-noteSave a noteA

Saves a text note under a given key for later retrieval.

Inputs: key (required), text (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 4 tools

    Disambiguation4/5

    The tools are mostly easy to tell apart: multiply and add share an arithmetic context but perform clearly distinct operations, while get-weather and save-note are completely unrelated. The only minor ambiguity is that multiply and add could be grouped together by an agent looking for generic math tools.

    Naming Consistency2/5

    Naming is inconsistent: multiply and add are bare verbs, while get-weather and save-note use hyphenated verb-noun compounds. A uniform verb_noun convention would make the toolset more predictable.

    Tool Count4/5

    Four tools is a reasonable size for an example MCP server, and each tool has a distinct function. However, the tools serve unrelated domains, making the set feel like a demo grab-bag rather than a focused toolkit.

    Completeness2/5

    The set is incomplete for any single domain: arithmetic lacks subtract/divide, notes lack retrieval/deletion, and weather is just one mock endpoint. Agents would hit dead ends when trying to do basic related workflows.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      A minimal MCP server example demonstrating Tools, Resources, and Prompts. It enables calculations, time queries, note management, and code review prompts via stdio transport.
      3
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables arithmetic addition, personalized greetings, version lookup, and text summarization through MCP tools, a resource, and a prompt.
      -
    • A
      license
      A
      quality
      C
      maintenance
      Provides AI clients with real-time tools for math evaluation, timezone-aware time lookup, live weather retrieval, and persistent note management, all accessible over the Model Context Protocol via stdio.
      6
      2
      MIT