Skip to main content
Glama
nirojsapkota

mcp-server-example

by nirojsapkota
README.md
# MCP Server Example

A minimal example [Model Context Protocol](https://modelcontextprotocol.io) (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

```bash
npm install
npm run build
```

## Run

```bash
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):

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

## Debugging

Use the official [MCP Inspector](https://github.com/modelcontextprotocol/inspector) to
test the server interactively without a full client:

```bash
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
```

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

ActivityMaintained
ResponsivenessNo issues