MCP Server

MCP Server

A robust server implementing the Model Context Protocol with SSE and STDIO transport, enabling real-time communication and extensible tooling for AI models.

Category
Visit Server

README

MCP Server

License: MIT Node.js: β‰₯18

A robust server implementation of the Model Context Protocol (MCP) that supports multiple transport methods (SSE and STDIO) for real-time communication with AI models.

πŸš€ Features

  • Full MCP Implementation: Complete and standard-compliant implementation of the Model Context Protocol
  • Multiple Transports: Seamless communication via SSE (Server-Sent Events) and STDIO
  • Robust Architecture: Built on Clean Architecture and SOLID principles for maintainability and extensibility
  • Powerful Tooling: Easily extensible tools, resources, and prompts
  • Developer-Friendly: Comprehensive logging, error handling, and testing support

πŸ—οΈ Architecture

The project follows a clean, layered architecture adhering to SOLID principles:

Layer Responsibility Components
Domain Core business logic Interfaces, Models, Entities
Application Use cases, application flow Services, Use Cases, DTOs
Infrastructure Technical concerns Implementations, Adapters, External services
Presentation User interface API Controllers, HTTP endpoints

Architectural Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Presentation       β”‚      β”‚  Application        β”‚
β”‚  Layer              β”‚      β”‚  Layer              β”‚
β”‚  - Express API      │─────▢│  - Use Cases        β”‚
β”‚  - Controllers      β”‚      β”‚  - Services         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                        β”‚
                                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Infrastructure     β”‚      β”‚  Domain             β”‚
β”‚  Layer              │◀─────│  Layer              β”‚
β”‚  - Implementations  β”‚      β”‚  - Interfaces       β”‚
β”‚  - Adapters         β”‚      β”‚  - Models           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’» Requirements

  • Node.js 18 or higher
  • Yarn or npm package manager

πŸ“¦ Installation

# Clone the repository
git clone https://github.com/your-username/mcp-server.git
cd mcp-server

# Install dependencies
yarn install

# Build the project
yarn build

πŸš€ Running the Server

# Start the server
yarn start

# Build and start in one command (for development)
yarn rebuild

By default, the server runs on port 3001. You can configure this using the PORT environment variable.

πŸ”Œ Transport Options

The MCP server supports two transport methods:

Transport Description Use Case
SSE Server-Sent Events over HTTP Web applications, browser clients
STDIO Standard input/output streams CLI tools, local applications

πŸ›£οΈ API Endpoints

  • SSE: /sse - Establish SSE connections for real-time communication
  • Messages: /messages - Send JSON-RPC messages to the server

πŸ§ͺ Testing

Use the official MCP Inspector tool to test your server implementation:

  1. Build and start your MCP Server
yarn build
yarn rebuild  # if using SSE transport (builds & starts)
# OR
yarn start    # manual start
  1. Run the inspector against your server
npx @modelcontextprotocol/inspector node build/index.js
  1. Access to Inspecto UI http://127.0.0.1:6274 πŸš€

🧩 Extending Functionality

Adding a New Tool

// tools/custom/my-tool.ts
import { z } from "zod";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { ITool } from "../core/domain/interfaces/tool.interface.js";
import { ILogger } from "../core/domain/interfaces/logger.interface.js";

export class MyTool implements ITool {
    private readonly logger: ILogger;

    constructor(logger: ILogger) {
        this.logger = logger;
    }

    public register(server: McpServer): void {
        server.tool(
            "my-tool",
            "Description of my tool",
            {
                param1: z.string().describe("Parameter description"),
            },
            async ({ param1 }) => {
                this.logger.info(`MyTool called with param1: ${param1}`);
                
                return {
                    content: [
                        {
                            type: "text",
                            text: `Result: ${param1}`,
                        },
                    ],
                };
            },
        );

        this.logger.info("MyTool registered");
    }
}

Adding a New Resource

// resources/custom/my-resource.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { IResource } from "../core/domain/interfaces/resource.interface.js";
import { ILogger } from "../core/domain/interfaces/logger.interface.js";

export class MyResource implements IResource {
    private readonly logger: ILogger;

    constructor(logger: ILogger) {
        this.logger = logger;
    }

    public register(server: McpServer): void {
        server.resource('my-resource', 'my-data.json', async () => {
            this.logger.info('My resource accessed');

            return {
                contents: [
                    {
                        uri: 'my-data.json',
                        text: JSON.stringify({ key: "value" }, null, 2),
                        mimeType: 'application/json',
                    },
                ],
            };
        });

        this.logger.info('My resource registered');
    }
}

Adding a New Prompt

// prompts/custom/my-prompt.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { IPrompt } from "../core/domain/interfaces/prompt.interface.js";
import { ILogger } from "../core/domain/interfaces/logger.interface.js";

export class MyPrompt implements IPrompt {
    private readonly logger: ILogger;

    constructor(logger: ILogger) {
        this.logger = logger;
    }

    public register(server: McpServer): void {
        server.prompt(
            'my-prompt',
            'Description of my prompt',
            () => {
                this.logger.info('My prompt accessed');

                return {
                    messages: [
                        {
                            role: 'user',
                            content: {
                                type: 'text',
                                text: 'Initial user message',
                            },
                        },
                        {
                            role: 'assistant',
                            content: {
                                type: 'text',
                                text: 'Initial assistant response',
                            },
                        },
                    ],
                };
            },
        );

        this.logger.info('My prompt registered');
    }
}

πŸ“ SOLID Principles Applied

Principle Implementation
Single Responsibility Each class has one clear responsibility
Open/Closed System can be extended without modifying existing code
Liskov Substitution Derived types can be substituted for their base types
Interface Segregation Specific interfaces for specific clients
Dependency Inversion High-level modules depend on abstractions

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

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