Skip to main content
Glama

Example MCP Server

by Mtar786

Example MCP Server

This repository contains a minimal Model Context Protocol (MCP) server written in Node.js. The server exposes two simple tools that can be called from AI assistants (such as Claude Desktop or Cursor) via the MCP standard.

Tools provided

Tool nameDescriptionParametersReturn value
addAdds two numbers togethera (number), b (number)Text containing the sum
getTimeReturns the current server time in ISO formatnoneText with an ISO timestamp

These tools are defined in the index.js file using the McpServer class from the official SDK. You can extend this server by registering your own tools with custom parameters and logic.

Installation

  1. Install Node.js (version 20 or later is recommended).
  2. Clone this repository and install dependencies:
    npm install

    The @modelcontextprotocol/sdk package is published on npm. This example uses version 1.17.0 as referenced in package.json. MCP requires Node.js 18.x or higher to run properly【364465667226308†L72-L78】.

Running the server

Run the server with Node:

npm start

By default the server uses the StdioServerTransport to communicate. This means it will read JSON‑RPC 2.0 messages from stdin and write responses to stdout. Tools like Claude Desktop or Cursor will manage this communication for you.

Connecting with Claude Desktop

To connect this server to Claude Desktop, add an entry in your mcp.json configuration file (usually located in your ~/.claude/ or ~/.cursor/ directory depending on the client). An example configuration looks like this:

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

Replace the command path with the absolute path to your Node binary (e.g. the output of which node) and update the args path to point to this project's index.js file.

After saving the config, restart your Claude Desktop app, grant permission to the tools when prompted, and you can invoke them by writing natural language instructions like:

“Add 3 and 5.” — Claude will call the add tool and return the sum.

“What’s the current time?” — Claude will call the getTime tool and return the timestamp.

References

  • The concept of MCP servers is described in Anthropic’s announcement【714031847317279†L20-L36】 and documented in several tutorials【67709559959600†L144-L178】.
  • For an example of defining tools with the official SDK, see the minimal server from the mcp-server-node project【966057210205090†L0-L18】.

License

This example is provided for educational purposes. Modify and adapt it to suit your own MCP workflows.

Install Server
A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

A minimal Node.js Model Context Protocol server that exposes two simple tools ('add' and 'getTime') that can be called from AI assistants like Claude Desktop or Cursor.

  1. Tools provided
    1. Installation
      1. Running the server
        1. Connecting with Claude Desktop
      2. References
        1. License

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            A comprehensive Model Context Protocol server that provides advanced Node.js development tooling for automating project creation, component generation, package management, and documentation with AI-powered assistance.
            Last updated -
            7
            4
            JavaScript
            MIT License
          • A
            security
            F
            license
            A
            quality
            A simple Model Context Protocol server that provides standardized tool functionality, currently implementing a basic calculator for adding two numbers together.
            Last updated -
            2
            738
            JavaScript
          • A
            security
            A
            license
            A
            quality
            A Model Context Protocol server for time manipulation tasks, enabling AI models to get the current date/time and calculate duration between timestamps.
            Last updated -
            2
            TypeScript
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            quality
            A minimal Model Context Protocol server that provides a simple add(a, b) tool for computing the sum of two numbers.
            Last updated -
            1
            5
            JavaScript
            MIT License

          View all related MCP servers

          MCP directory API

          We provide all the information about MCP servers via our MCP API.

          curl -X GET 'https://glama.ai/api/mcp/v1/servers/Mtar786/mcpServer'

          If you have feedback or need assistance with the MCP directory API, please join our Discord server