Example MCP Server

Example MCP Server

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.

Category
Visit Server

Tools

add

Add two numbers together

getTime

Get the current server time

README

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 name Description Parameters Return value
add Adds two numbers together a (number), b (number) Text containing the sum
getTime Returns the current server time in ISO format none Text 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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured