creating-your-first-mcp-server

creating-your-first-mcp-server

Enables to perform mathematical calculations, retrieve weather information, and manage files through a standardized MCP interface, showcasing best practices for building MCP servers.

Category
Visit Server

README

Creating Your First MCP Server

<p align="center"> <img src="hero.svg" alt="Creating Your First MCP Server" width="100%"> </p>

A production-ready TypeScript implementation of a Model Context Protocol (MCP) server with example tools demonstrating best practices for building MCP servers.

Quick Start

Installation

npm install

Build

npm run build

Run the Server

npm start

Run Example Client

npm run example

What is MCP?

The Model Context Protocol (MCP) is an open protocol that standardizes how applications provide context to Large Language Models (LLMs). It enables:

  • Standardized Communication: A unified way for LLMs to interact with external tools and data sources
  • Tool Integration: Expose custom functionality that AI models can discover and use
  • Resource Management: Provide structured access to files, databases, and APIs
  • Prompt Templates: Define reusable prompts for common tasks

Key MCP Concepts

  1. Server: Exposes tools, resources, and prompts that clients can use
  2. Client: Connects to MCP servers to access their capabilities
  3. Tools: Executable functions that perform specific tasks
  4. Resources: Data sources like files, database records, or API endpoints
  5. Prompts: Reusable prompt templates with parameters

Project Structure

creating-your-first-mcp-server/
├── src/
│   ├── index.ts              # Main MCP server implementation
│   └── tools/
│       ├── calculator.ts      # Mathematical operations tool
│       ├── weather.ts         # Weather information tool
│       └── file-ops.ts        # File operations tool
├── examples/
│   └── client.ts             # Example MCP client usage
├── documentation/
│   ├── MCP-CONCEPTS.md       # In-depth MCP concepts
│   ├── TOOL-DEVELOPMENT.md   # Guide to creating tools
│   └── INTEGRATION.md        # Integration guide
├── package.json
├── tsconfig.json
└── LICENSE

Available Tools

Calculator Tool

Performs mathematical operations (add, subtract, multiply, divide, power, sqrt).

// Example usage
{
  "operation": "add",
  "a": 5,
  "b": 3
}
// Returns: { "result": 8 }

Weather Tool

Retrieves weather information for a location (simulated data for demonstration).

// Example usage
{
  "location": "San Francisco"
}
// Returns weather data including temperature, conditions, humidity

File Operations Tool

Performs file system operations (read, write, list, delete).

// Example usage
{
  "operation": "read",
  "path": "/path/to/file.txt"
}
// Returns file contents or operation result

Development

Building

npm run build

Watch Mode

npm run dev

Clean Build Artifacts

npm run clean

Documentation

For more detailed information, see:

Error Handling

This server implements comprehensive error handling:

  • Input validation for all tool parameters
  • Graceful error messages for clients
  • Type-safe error responses
  • Logging for debugging

Security Considerations

  • File operations are restricted to safe directories
  • Input validation prevents injection attacks
  • Error messages don't expose sensitive system information
  • Rate limiting can be added for production use

License

MIT License - Copyright (c) 2026 ry-ops

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Resources

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
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

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