mcp-server-ddd-template

alexandresanlim/mcp-server-ddd-template

3.3

If you are the rightful owner of mcp-server-ddd-template and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This repository is a sample implementation of a Model Context Protocol (MCP) server in Node.js/TypeScript, designed to demonstrate a clean, layered architecture using Domain-Driven Design (DDD) principles.

Tools
1
Resources
0
Prompts
0

šŸš€ MCP Server DDD Template

This repository is a template implementation of a Model Context Protocol (MCP) server in Node.js/TypeScript, designed to demonstrate a clean, layered architecture using Domain-Driven Design (DDD) principles. It provides tools to obtain Bitcoin-related information via external APIs.

✨ Key Features

  • šŸ—ļø Template Project: This codebase serves as a reference template for structuring MCP servers with DDD, ready for customization and production use.
  • šŸ”Œ MCP Protocol: Communicates via stdio using the MCP protocol (@modelcontextprotocol/sdk).
  • šŸ›ļø Layered DDD Architecture: Clear separation of domain, application, infrastructure, and interface layers.
  • ⚔ TypeScript: Fully typed with modern TypeScript for better development experience.

šŸ“ Project Structure

src/
ā”œā”€ā”€ domain/                  # šŸ›ļø Domain models and response interfaces
│   └── models/
│       └── responses/
│           ā”œā”€ā”€ ** interfaces responses **
ā”œā”€ā”€ infrastructure/          # šŸ”Œ External API clients and request services
│   ā”œā”€ā”€ interfaces/
│   │   └── IApiClient.ts
│   └── services/
│       ā”œā”€ā”€ clients/
│       │   └── ** client api
│       └── requests/
│           ā”œā”€ā”€ ** requests services **
ā”œā”€ā”€ application/             # āš™ļø Business logic and helpers
│   ā”œā”€ā”€ services/
│   │   ā”œā”€ā”€ ** services implementation **
│   └── helpers/
│       └── ** helpers **
ā”œā”€ā”€ interface/               # šŸŽ® Controllers (MCP tool registration)
│   └── controllers/
│       ā”œā”€ā”€ base/
│       │   └── BaseToolsController.ts
│       ā”œā”€ā”€ **controllers to inteface**
│       └── index.ts
ā”œā”€ā”€ shared/                  # šŸ”— Shared types/parameters
│   └── parameters/
│       └── **interfaces parameters**
└── main.ts                  # šŸš€ Application entry point

šŸš€ Getting Started

git clone https://github.com/alexandresanlim/mcp-server-ddd-template.git
cd mcp-server-ddd-template
npm install
npm run build

šŸŽÆ Usage

After building, you can run the server directly:

node build/main.js

Or, if registered as a binary (for example, mcp-server-ddd-template):

npm link
mcp-server-ddd-template

The server will start on standard output (stdio) and wait for MCP requests.

šŸ› ļø Available Tools in this sample

  • šŸ’° get-recommended-fees: Get recommended Bitcoin transaction fees from Mempool.space
  • šŸ”— ping: Simple health check endpoint

šŸ”— Integration Example

To use this MCP server as a tool provider in a client (e.g., Claude client), you can either reference a local build or use the published npm package.

šŸ“‚ Using Local Build Path

"btc-server": {
    "command": "node",
    "args": [
        "{your project path}/mcp-server-ddd-template/build/main.js"
    ]
}

šŸ› ļø Development

Build Commands

# Build for Unix/Linux/macOS
npm run build

# Build for Windows
npm run build:windows

# Run the server
npm run server

Dependencies

  • @modelcontextprotocol/sdk: MCP protocol implementation
  • zod: Runtime type validation
  • typescript: Type safety and compilation

šŸ¤ Contributing

Pull requests are welcome! Feel free to open issues or suggest improvements for this template repository.

⭐ Star this repository if you find it helpful!