Skip to main content
Glama

Example MCP Server

by jherr

Example MCP Server

A simple Model Context Protocol (MCP) server built with TypeScript and Node.js. This server demonstrates how to create an MCP server that exposes tools for use in Claude Desktop and other MCP clients.

Features

  • Simple say_hello tool that greets a person by name

  • Built with TypeScript for type safety

  • Uses the official MCP SDK for Node.js

  • STDIO transport for communication with MCP clients

Prerequisites

  • Node.js (v16 or higher)

  • npm

Installation

Install the project dependencies:

npm install

Building

Build the TypeScript source code:

npm run build

This will compile the TypeScript files from src/ to build/ and make the output executable.

Running the Inspector

After building, you can test your server using the MCP Inspector:

npm run inspector

Or run it directly:

npx @modelcontextprotocol/inspector@latest node build/index.js

The inspector provides a web-based interface where you can test your MCP tools interactively.

Development

For development with auto-reload, use:

npm run dev

Important: When developing MCP servers that use STDIO transport, always use console.error() for logging, never console.log(). Writing to stdout will corrupt the JSON-RPC messages and break your server.

Project Structure

example-mcp-server/ ├── src/ │ └── index.ts # Main server implementation ├── build/ # Compiled output (generated) ├── package.json ├── tsconfig.json └── README.md

Additional Resources

  • MCP Server Setup Gist - Additional information and walkthrough for setting up MCP STDIO servers, including project setup, configuration, and Claude Desktop integration

  • Official MCP Documentation - The official documentation for building MCP servers (Note: this documentation may not be up to date)

Claude Desktop Integration

To use this server with Claude Desktop, add it to your claude_desktop_config.json:

{ "mcpServers": { "example_server": { "command": "node", "args": ["/ABSOLUTE/PATH/TO/THIS/PROJECT/build/index.js"] } } }

Note: Use the absolute path to the built index.js file. After making changes, fully quit and restart Claude Desktop for the configuration to take effect.

-
security - not tested
F
license - not found
-
quality - not tested

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/jherr/saw-mcp-intro'

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