@aashari/boilerplate-mcp-server 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +120 -152
- package/dist/utils/constants.util.d.ts +1 -1
- package/dist/utils/constants.util.js +1 -1
- package/package.json +3 -3
- package/package.json.bak +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.10.2](https://github.com/aashari/boilerplate-mcp-server/compare/v1.10.1...v1.10.2) (2025-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update dependencies ([1340085](https://github.com/aashari/boilerplate-mcp-server/commit/1340085d8476f92e72e7afe248a86f50e0b4ff84))
|
|
7
|
+
|
|
8
|
+
## [1.10.1](https://github.com/aashari/boilerplate-mcp-server/compare/v1.10.0...v1.10.1) (2025-05-20)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update dependencies ([88fa27c](https://github.com/aashari/boilerplate-mcp-server/commit/88fa27c0e67d97a83d780f0aa99255979e139bb7))
|
|
14
|
+
|
|
1
15
|
# [1.10.0](https://github.com/aashari/boilerplate-mcp-server/compare/v1.9.0...v1.10.0) (2025-05-19)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -1,41 +1,30 @@
|
|
|
1
1
|
# Boilerplate MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A foundation for developing custom Model Context Protocol (MCP) servers in TypeScript. Provides a complete layered architecture pattern, working example tools, and developer infrastructure to connect AI assistants with external APIs and data sources.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## What is MCP?
|
|
10
|
-
|
|
11
|
-
Model Context Protocol (MCP) is an open standard that allows AI systems to securely and contextually connect with external tools and data sources.
|
|
12
|
-
|
|
13
|
-
This boilerplate implements the MCP specification with a clean, layered architecture that can be extended to build custom MCP servers for any API or data source.
|
|
5
|
+
[](https://www.npmjs.com/package/@aashari/boilerplate-mcp-server)
|
|
6
|
+
[](https://github.com/aashari/boilerplate-mcp-server/actions)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://opensource.org/licenses/ISC)
|
|
14
9
|
|
|
15
10
|
## Why Use This Boilerplate?
|
|
16
11
|
|
|
17
|
-
- **Production-Ready Architecture**: Follows the same pattern used in published MCP servers, with
|
|
18
|
-
|
|
19
|
-
- **
|
|
20
|
-
|
|
21
|
-
- **
|
|
12
|
+
- **Production-Ready Architecture**: Follows the same pattern used in published MCP servers, with clean separation between CLI, tools, controllers, and services
|
|
13
|
+
- **Type Safety**: Built with TypeScript for improved developer experience, code quality, and maintainability
|
|
14
|
+
- **Working Example**: Includes fully implemented tools demonstrating the complete pattern from CLI to API integration
|
|
15
|
+
- **Testing Framework**: Ready-to-use testing infrastructure for unit and CLI integration tests, with coverage reporting
|
|
16
|
+
- **Complete Developer Tooling**: Pre-configured ESLint, Prettier, TypeScript, and CI/CD workflows
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **Development Tooling**: Includes ESLint, Prettier, TypeScript, and other quality tools preconfigured for MCP server development.
|
|
26
|
-
|
|
27
|
-
---
|
|
18
|
+
## What is MCP?
|
|
28
19
|
|
|
29
|
-
|
|
20
|
+
Model Context Protocol (MCP) is an open standard for securely connecting AI systems to external tools and data sources. This boilerplate implements the MCP specification with a clean, layered architecture that can be extended to build custom MCP servers for any API or data source.
|
|
30
21
|
|
|
31
22
|
## Prerequisites
|
|
32
23
|
|
|
33
24
|
- **Node.js** (>=18.x): [Download](https://nodejs.org/)
|
|
34
25
|
- **Git**: For version control
|
|
35
26
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## Step 1: Clone and Install
|
|
27
|
+
## Quick Start
|
|
39
28
|
|
|
40
29
|
```bash
|
|
41
30
|
# Clone the repository
|
|
@@ -44,143 +33,139 @@ cd boilerplate-mcp-server
|
|
|
44
33
|
|
|
45
34
|
# Install dependencies
|
|
46
35
|
npm install
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
---
|
|
50
36
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
Start the server in development mode:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
37
|
+
# Start development server
|
|
56
38
|
npm run dev:server
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
This starts the MCP server with hot-reloading and enables the MCP Inspector at http://localhost:5173.
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Step 3: Test the Example Tool
|
|
64
39
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
# Using CLI in development mode
|
|
69
|
-
npm run dev:cli -- get-ip-details
|
|
70
|
-
|
|
71
|
-
# Or with a specific IP
|
|
40
|
+
# Try the example tool
|
|
72
41
|
npm run dev:cli -- get-ip-details 8.8.8.8
|
|
73
42
|
```
|
|
74
43
|
|
|
75
|
-
|
|
44
|
+
## Architecture Overview
|
|
76
45
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
This boilerplate follows a clean, layered architecture pattern that separates concerns and promotes maintainability.
|
|
80
|
-
|
|
81
|
-
## Project Structure
|
|
46
|
+
<details>
|
|
47
|
+
<summary><b>Project Structure (Click to expand)</b></summary>
|
|
82
48
|
|
|
83
49
|
```
|
|
84
50
|
src/
|
|
85
51
|
├── cli/ # Command-line interfaces
|
|
52
|
+
│ ├── index.ts # CLI entry point
|
|
53
|
+
│ └── *.cli.ts # Feature-specific CLI modules
|
|
86
54
|
├── controllers/ # Business logic
|
|
55
|
+
│ └── *.controller.ts # Feature controllers
|
|
87
56
|
├── services/ # External API interactions
|
|
57
|
+
│ └── *.service.ts # Service modules
|
|
88
58
|
├── tools/ # MCP tool definitions
|
|
59
|
+
│ ├── *.tool.ts # Tool implementations
|
|
60
|
+
│ └── *.types.ts # Tool argument schemas
|
|
89
61
|
├── types/ # Type definitions
|
|
62
|
+
│ └── common.types.ts # Shared type definitions
|
|
90
63
|
├── utils/ # Shared utilities
|
|
91
|
-
|
|
64
|
+
│ ├── logger.util.ts # Structured logging
|
|
65
|
+
│ ├── error.util.ts # Error handling
|
|
66
|
+
│ └── ... # Other utility modules
|
|
67
|
+
└── index.ts # Server entry point
|
|
92
68
|
```
|
|
93
69
|
|
|
94
|
-
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
## Layered Architecture
|
|
95
73
|
|
|
96
|
-
|
|
74
|
+
The boilerplate follows a clean, layered architecture that promotes maintainability and clear separation of concerns:
|
|
97
75
|
|
|
98
|
-
|
|
99
|
-
- **Naming**: Files should be named `<feature>.cli.ts`
|
|
100
|
-
- **Testing**: CLI integration tests in `<feature>.cli.test.ts`
|
|
76
|
+
### 1. CLI Layer (`src/cli/*.cli.ts`)
|
|
101
77
|
|
|
102
|
-
|
|
78
|
+
- **Purpose**: Command-line interfaces that parse arguments and call controllers
|
|
79
|
+
- **Pattern**: Use `commander` for argument parsing, call controllers, handle errors with `handleCliError`
|
|
80
|
+
- **Naming**: `<feature>.cli.ts`
|
|
103
81
|
|
|
104
|
-
|
|
105
|
-
- **Naming**: Files should be named `<feature>.tool.ts` with types in `<feature>.types.ts`
|
|
106
|
-
- **Pattern**: Each tool should use zod for argument validation
|
|
82
|
+
### 2. Tools Layer (`src/tools/*.tool.ts`)
|
|
107
83
|
|
|
108
|
-
|
|
84
|
+
- **Purpose**: MCP tool definitions exposed to AI assistants
|
|
85
|
+
- **Pattern**: Use `zod` for schema validation, call controllers, format responses for MCP
|
|
86
|
+
- **Naming**: `<feature>.tool.ts` with types in `<feature>.types.ts`
|
|
109
87
|
|
|
110
|
-
|
|
111
|
-
- **Naming**: Files should be named `<feature>.controller.ts`
|
|
112
|
-
- **Pattern**: Should return standardized `ControllerResponse` objects
|
|
88
|
+
### 3. Controllers Layer (`src/controllers/*.controller.ts`)
|
|
113
89
|
|
|
114
|
-
|
|
90
|
+
- **Purpose**: Business logic orchestration, error handling, response formatting
|
|
91
|
+
- **Pattern**: Return standardized `ControllerResponse` objects, throw errors with context
|
|
92
|
+
- **Naming**: `<feature>.controller.ts` with optional `<feature>.formatter.ts`
|
|
115
93
|
|
|
116
|
-
|
|
117
|
-
- **Naming**: Files should be named `<feature>.service.ts`
|
|
118
|
-
- **Pattern**: Pure API interactions with minimal logic
|
|
94
|
+
### 4. Services Layer (`src/services/*.service.ts`)
|
|
119
95
|
|
|
120
|
-
|
|
96
|
+
- **Purpose**: External API interactions and data handling
|
|
97
|
+
- **Pattern**: Pure API calls with minimal logic, return raw data
|
|
98
|
+
- **Naming**: `<feature>.service.ts` or `vendor.<vendor>.<feature>.service.ts`
|
|
121
99
|
|
|
122
|
-
|
|
123
|
-
- **Key Utils**:
|
|
124
|
-
- `logger.util.ts`: Structured logging
|
|
125
|
-
- `error.util.ts`: Error handling and standardization
|
|
126
|
-
- `formatter.util.ts`: Markdown formatting helpers
|
|
100
|
+
### 5. Utils Layer (`src/utils/*.util.ts`)
|
|
127
101
|
|
|
128
|
-
|
|
102
|
+
- **Purpose**: Shared functionality across the application
|
|
103
|
+
- **Key Utils**: Logging, error handling, formatting, configuration
|
|
129
104
|
|
|
130
|
-
|
|
105
|
+
## Developer Guide
|
|
131
106
|
|
|
132
|
-
|
|
107
|
+
### Development Scripts
|
|
133
108
|
|
|
134
109
|
```bash
|
|
135
|
-
# Start server in
|
|
110
|
+
# Start server in dev mode with hot-reload & inspector
|
|
136
111
|
npm run dev:server
|
|
137
112
|
|
|
138
|
-
# Run CLI in development
|
|
113
|
+
# Run CLI commands in development
|
|
139
114
|
npm run dev:cli -- [command] [args]
|
|
140
115
|
|
|
141
116
|
# Build the project
|
|
142
117
|
npm run build
|
|
143
118
|
|
|
144
|
-
#
|
|
119
|
+
# Production server
|
|
120
|
+
npm start
|
|
145
121
|
npm run start:server
|
|
146
122
|
|
|
147
|
-
#
|
|
123
|
+
# Production CLI
|
|
148
124
|
npm run start:cli -- [command] [args]
|
|
149
|
-
```
|
|
150
125
|
|
|
151
|
-
|
|
126
|
+
# Testing
|
|
127
|
+
npm test # Run all tests
|
|
128
|
+
npm test -- src/path/to/test.ts # Run specific tests
|
|
129
|
+
npm run test:coverage # Generate coverage report
|
|
152
130
|
|
|
153
|
-
|
|
154
|
-
# Run
|
|
155
|
-
npm
|
|
131
|
+
# Code Quality
|
|
132
|
+
npm run lint # Run ESLint
|
|
133
|
+
npm run format # Format with Prettier
|
|
134
|
+
npm run typecheck # Check TypeScript types
|
|
135
|
+
```
|
|
156
136
|
|
|
157
|
-
|
|
158
|
-
npm test -- src/path/to/test.ts
|
|
137
|
+
### Debugging Tools
|
|
159
138
|
|
|
160
|
-
|
|
161
|
-
npm run
|
|
162
|
-
|
|
139
|
+
- **MCP Inspector**: Visual tool for testing your MCP tools
|
|
140
|
+
- Run server with `npm run dev:server`
|
|
141
|
+
- Open http://localhost:5173 in your browser
|
|
163
142
|
|
|
164
|
-
|
|
143
|
+
- **Server Logs**: Enable with `DEBUG=true npm run dev:server` or in config
|
|
165
144
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
npm run lint
|
|
145
|
+
<details>
|
|
146
|
+
<summary><b>Configuration (Click to expand)</b></summary>
|
|
169
147
|
|
|
170
|
-
|
|
171
|
-
npm run format
|
|
148
|
+
Create `~/.mcp/configs.json`:
|
|
172
149
|
|
|
173
|
-
|
|
174
|
-
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"boilerplate": {
|
|
153
|
+
"environments": {
|
|
154
|
+
"DEBUG": "true",
|
|
155
|
+
"ANY_OTHER_CONFIG": "value"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
175
159
|
```
|
|
176
160
|
|
|
177
|
-
|
|
161
|
+
</details>
|
|
178
162
|
|
|
179
|
-
|
|
163
|
+
## Building Custom Tools
|
|
180
164
|
|
|
181
|
-
|
|
165
|
+
<details>
|
|
166
|
+
<summary><b>Step-by-Step Tool Implementation Guide (Click to expand)</b></summary>
|
|
182
167
|
|
|
183
|
-
|
|
168
|
+
### 1. Define Service Layer
|
|
184
169
|
|
|
185
170
|
Create a new service in `src/services/` to interact with your external API:
|
|
186
171
|
|
|
@@ -197,7 +182,7 @@ export async function getData(param: string): Promise<any> {
|
|
|
197
182
|
}
|
|
198
183
|
```
|
|
199
184
|
|
|
200
|
-
|
|
185
|
+
### 2. Create Controller
|
|
201
186
|
|
|
202
187
|
Add a controller in `src/controllers/` to handle business logic:
|
|
203
188
|
|
|
@@ -236,7 +221,7 @@ export async function getData(
|
|
|
236
221
|
}
|
|
237
222
|
```
|
|
238
223
|
|
|
239
|
-
|
|
224
|
+
### 3. Implement MCP Tool
|
|
240
225
|
|
|
241
226
|
Create a tool definition in `src/tools/`:
|
|
242
227
|
|
|
@@ -284,7 +269,7 @@ Use this to fetch example data. Returns formatted data as Markdown.`,
|
|
|
284
269
|
}
|
|
285
270
|
```
|
|
286
271
|
|
|
287
|
-
|
|
272
|
+
### 4. Add CLI Support
|
|
288
273
|
|
|
289
274
|
Create a CLI command in `src/cli/`:
|
|
290
275
|
|
|
@@ -316,7 +301,7 @@ program
|
|
|
316
301
|
});
|
|
317
302
|
```
|
|
318
303
|
|
|
319
|
-
|
|
304
|
+
### 5. Register Components
|
|
320
305
|
|
|
321
306
|
Update the entry points to register your new components:
|
|
322
307
|
|
|
@@ -330,56 +315,39 @@ import exampleTool from './tools/example.tool.js';
|
|
|
330
315
|
exampleTool.register(server);
|
|
331
316
|
```
|
|
332
317
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
# Debugging Tools
|
|
336
|
-
|
|
337
|
-
## MCP Inspector
|
|
338
|
-
|
|
339
|
-
Access the visual MCP Inspector to test your tools and view request/response details:
|
|
340
|
-
|
|
341
|
-
1. Run `npm run dev:server`
|
|
342
|
-
2. Open http://localhost:5173 in your browser
|
|
343
|
-
3. Test your tools and view logs directly in the UI
|
|
344
|
-
|
|
345
|
-
## Server Logs
|
|
346
|
-
|
|
347
|
-
Enable debug logs for development:
|
|
348
|
-
|
|
349
|
-
```bash
|
|
350
|
-
# Set environment variable
|
|
351
|
-
DEBUG=true npm run dev:server
|
|
352
|
-
|
|
353
|
-
# Or configure in ~/.mcp/configs.json
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
---
|
|
318
|
+
</details>
|
|
357
319
|
|
|
358
|
-
|
|
320
|
+
## Publishing Your MCP Server
|
|
359
321
|
|
|
360
|
-
|
|
322
|
+
1. Update package.json with your details:
|
|
323
|
+
```json
|
|
324
|
+
{
|
|
325
|
+
"name": "your-mcp-server-name",
|
|
326
|
+
"version": "1.0.0",
|
|
327
|
+
"description": "Your custom MCP server",
|
|
328
|
+
"author": "Your Name",
|
|
329
|
+
// Other fields...
|
|
330
|
+
}
|
|
331
|
+
```
|
|
361
332
|
|
|
362
|
-
1. Update package.json with your details
|
|
363
333
|
2. Update README.md with your tool documentation
|
|
364
|
-
3. Build
|
|
365
|
-
4. Test
|
|
366
|
-
5. Publish
|
|
334
|
+
3. Build: `npm run build`
|
|
335
|
+
4. Test: `npm run start:server`
|
|
336
|
+
5. Publish: `npm publish`
|
|
337
|
+
|
|
338
|
+
## Testing Best Practices
|
|
367
339
|
|
|
368
|
-
|
|
340
|
+
- **Unit Tests**: Test utils and pure functions in isolation
|
|
341
|
+
- **Controller Tests**: Test business logic with mocked service calls
|
|
342
|
+
- **Integration Tests**: Test CLI with real dependencies
|
|
343
|
+
- **Coverage Goal**: Aim for >80% test coverage
|
|
369
344
|
|
|
370
|
-
|
|
345
|
+
## License
|
|
371
346
|
|
|
372
347
|
[ISC License](https://opensource.org/licenses/ISC)
|
|
373
348
|
|
|
374
|
-
|
|
375
|
-
{
|
|
376
|
-
"boilerplate": {
|
|
377
|
-
"environments": {
|
|
378
|
-
"DEBUG": "true",
|
|
379
|
-
"ANY_OTHER_CONFIG": "value"
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
```
|
|
349
|
+
## Resources
|
|
384
350
|
|
|
385
|
-
|
|
351
|
+
- [MCP Specification](https://github.com/modelcontextprotocol/mcp-spec)
|
|
352
|
+
- [Official MCP Documentation](https://www.modelcontextprotocol.ai/)
|
|
353
|
+
- [TypeScript Documentation](https://www.typescriptlang.org/docs/)
|
|
@@ -11,7 +11,7 @@ exports.CLI_NAME = exports.PACKAGE_NAME = exports.VERSION = void 0;
|
|
|
11
11
|
* Current application version
|
|
12
12
|
* This should match the version in package.json
|
|
13
13
|
*/
|
|
14
|
-
exports.VERSION = '1.10.
|
|
14
|
+
exports.VERSION = '1.10.2';
|
|
15
15
|
/**
|
|
16
16
|
* Package name with scope
|
|
17
17
|
* Used for initialization and identification
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aashari/boilerplate-mcp-server",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "TypeScript Model Context Protocol (MCP) server boilerplate providing IP lookup tools/resources. Includes CLI support and extensible structure for connecting AI systems (LLMs) to external data sources like ip-api.com. Ideal template for creating new MCP integrations via Node.js.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@semantic-release/github": "^11.0.2",
|
|
61
61
|
"@semantic-release/npm": "^12.0.1",
|
|
62
62
|
"@types/jest": "^29.5.14",
|
|
63
|
-
"@types/node": "^22.15.
|
|
63
|
+
"@types/node": "^22.15.21",
|
|
64
64
|
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
65
65
|
"@typescript-eslint/parser": "^8.32.1",
|
|
66
66
|
"eslint": "^9.27.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@modelcontextprotocol/sdk": "^1.11.4",
|
|
85
85
|
"commander": "^14.0.0",
|
|
86
86
|
"dotenv": "^16.5.0",
|
|
87
|
-
"zod": "^3.
|
|
87
|
+
"zod": "^3.25.13"
|
|
88
88
|
},
|
|
89
89
|
"directories": {
|
|
90
90
|
"example": "examples"
|
package/package.json.bak
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aashari/boilerplate-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "TypeScript Model Context Protocol (MCP) server boilerplate providing IP lookup tools/resources. Includes CLI support and extensible structure for connecting AI systems (LLMs) to external data sources like ip-api.com. Ideal template for creating new MCP integrations via Node.js.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@semantic-release/github": "^11.0.2",
|
|
61
61
|
"@semantic-release/npm": "^12.0.1",
|
|
62
62
|
"@types/jest": "^29.5.14",
|
|
63
|
-
"@types/node": "^22.15.
|
|
63
|
+
"@types/node": "^22.15.21",
|
|
64
64
|
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
65
65
|
"@typescript-eslint/parser": "^8.32.1",
|
|
66
66
|
"eslint": "^9.27.0",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@modelcontextprotocol/sdk": "^1.11.4",
|
|
85
85
|
"commander": "^14.0.0",
|
|
86
86
|
"dotenv": "^16.5.0",
|
|
87
|
-
"zod": "^3.
|
|
87
|
+
"zod": "^3.25.13"
|
|
88
88
|
},
|
|
89
89
|
"directories": {
|
|
90
90
|
"example": "examples"
|