Skip to main content
Glama
alexandresanlim

mcp-server-ddd-template

README.md
# šŸš€ 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

```bash
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:

```bash
node build/main.js
```

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

```bash
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

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

## šŸ› ļø Development

### Build Commands

```bash
# 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!**

TDQS

A3.8/5.0

Scored across 3 tools

Disambiguation5/5

Each tool targets a distinct purpose: block details, health check, and fee recommendations. There is no overlap or ambiguity.

Naming Consistency5/5

All tools follow a consistent 'get-' prefix with hyphenated lowercase naming, forming a clear pattern.

Tool Count4/5

Three tools is a reasonable count for a minimal Bitcoin service, though the server's purpose as a template might justify even fewer.

Completeness3/5

The set covers block retrieval, health checking, and fee recommendations, but lacks common Bitcoin operations like transaction handling, making it somewhat incomplete for a full service.

Maintenance

ActivityInactive
ResponsivenessNo issues