@aashari/boilerplate-mcp-server 1.17.0 → 3.0.0

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 CHANGED
@@ -1,3 +1,166 @@
1
+ # [3.0.0](https://github.com/aashari/boilerplate-mcp-server/compare/v2.0.0...v3.0.0) (2026-02-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * migrate to OIDC trusted publishing for npm (long-term solution) ([b7c36e3](https://github.com/aashari/boilerplate-mcp-server/commit/b7c36e31688e68a38cfd21977c938dc48d1bb380))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * Requires one-time OIDC configuration on npmjs.com
12
+ See docs/OIDC-TRUSTED-PUBLISHING-SETUP.md for complete migration guide
13
+
14
+ # [2.0.0](https://github.com/aashari/boilerplate-mcp-server/compare/v1.17.0...v2.0.0) (2026-02-04)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * disable npm publishing in semantic-release ([7bef842](https://github.com/aashari/boilerplate-mcp-server/commit/7bef84256a953919a711a1ee132be3b2397d8aa4))
20
+
21
+
22
+ ### Features
23
+
24
+ * add security hardening, prompts support, and ResourceLink pattern ([02a89c2](https://github.com/aashari/boilerplate-mcp-server/commit/02a89c2aa55db3ce52fbcb5ccb693b833f1e5e9d))
25
+
26
+
27
+ ### BREAKING CHANGES
28
+
29
+ * none
30
+ Security: DNS rebinding protection, localhost binding
31
+ Testing: 47 unit tests + 15 integration tests passing (100%)
32
+
33
+ # [1.19.0](https://github.com/aashari/boilerplate-mcp-server/compare/v1.18.0...v1.19.0) (2026-02-04)
34
+
35
+ ### Security 🔒
36
+
37
+ * **security:** implement DNS rebinding protection with Origin header validation ([src/index.ts](src/index.ts))
38
+ - Validates Origin header on all HTTP requests
39
+ - Prevents malicious websites from accessing localhost MCP server
40
+ - Allows localhost/127.0.0.1 origins only
41
+ - Returns 403 Forbidden for invalid origins
42
+
43
+ * **security:** add explicit localhost-only binding ([src/index.ts](src/index.ts))
44
+ - Server explicitly binds to 127.0.0.1 (not 0.0.0.0)
45
+ - Prevents network exposure and remote attacks
46
+ - Ensures server only accepts local connections
47
+
48
+ * **security:** add comprehensive security documentation ([SECURITY.md](SECURITY.md))
49
+ - Complete threat model and mitigation strategies
50
+ - Authentication implementation guides (Bearer, API Key, OAuth, mTLS)
51
+ - Security checklists for dev/staging/production
52
+ - Best practices for input validation, rate limiting, logging
53
+
54
+ * **security:** publish security audit report ([docs/AUDIT-2025-01-13.md](docs/AUDIT-2025-01-13.md))
55
+ - Independent audit against MCP best practices
56
+ - 70% compliance rating with clear improvement roadmap
57
+ - All critical security gaps addressed in this release
58
+
59
+ ### Features ✨
60
+
61
+ * **mcp:** add `isError: true` field to tool error responses ([src/utils/error.util.ts](src/utils/error.util.ts))
62
+ - Follows MCP best practices for error signaling
63
+ - Enables clients to reliably detect error states
64
+ - Maintains backward compatibility with metadata
65
+
66
+ * **mcp:** add ResourceLink pattern example ([src/tools/ipaddress-link.tool.ts](src/tools/ipaddress-link.tool.ts))
67
+ - New `ip_get_details_link` tool demonstrates ResourceLink pattern
68
+ - Returns resource references instead of inline content
69
+ - Reduces token usage for large responses
70
+ - Shows pattern for cacheable, reusable data
71
+
72
+ * **mcp:** add prompt registration support ([src/prompts/analysis.prompt.ts](src/prompts/analysis.prompt.ts))
73
+ - New `ip-analysis` prompt generates structured IP analysis requests
74
+ - Supports multiple focus modes (security, geolocation, network, comprehensive)
75
+ - Demonstrates all three MCP primitives (tools, resources, prompts)
76
+ - Provides template for AI-driven analysis workflows
77
+
78
+ * **architecture:** add prompts layer to 7-layer architecture
79
+ - Clean separation of prompt templates from tools/resources
80
+ - Type-safe prompt argument schemas with Zod
81
+ - Registered in index.ts alongside tools and resources
82
+
83
+ ### Documentation 📖
84
+
85
+ * **readme:** update README with security section and new features
86
+ - Add security badges and protection summary
87
+ - Document ResourceLink pattern and prompt examples
88
+ - Update architecture overview to 7 layers
89
+ - Add references to SECURITY.md and audit report
90
+
91
+ * **docs:** update project structure in README
92
+ - Add prompts/ directory
93
+ - Add ipaddress-link.tool.ts
94
+ - Update layer descriptions
95
+
96
+ ### Testing ✅
97
+
98
+ All tests passing after security and feature additions:
99
+ - ✅ 6 test suites, 47 tests passed
100
+ - ✅ Build successful with TypeScript compilation
101
+ - ✅ DNS rebinding protection tested
102
+ - ✅ Localhost binding verified
103
+ - ✅ New tools and prompts functional
104
+
105
+ ### Breaking Changes
106
+
107
+ **None** - All changes are backward compatible additions.
108
+
109
+ ---
110
+
111
+ # [1.18.0](https://github.com/aashari/boilerplate-mcp-server/compare/v1.17.0...v1.18.0) (2026-02-04)
112
+
113
+ ### Features
114
+
115
+ * **deps:** modernize all dependencies to latest stable versions ([#TBD](https://github.com/aashari/boilerplate-mcp-server/issues/TBD))
116
+ - Update MCP SDK from 1.23.0 to 1.25.3 (stability improvements)
117
+ - Update Zod from 4.1.13 to 4.3.6 (major feature release)
118
+ - Update @toon-format/toon from 2.0.1 to 2.1.0
119
+ - Update Express from 5.1.0 to 5.2.1
120
+ - Update Commander from 14.0.2 to 14.0.3
121
+ - Update CORS from 2.8.5 to 2.8.6
122
+ - Update @types/node from 24.10.1 to 24.10.10
123
+
124
+ ### Documentation
125
+
126
+ * **modernization:** add comprehensive modernization guide ([MODERNIZATION.md](MODERNIZATION.md))
127
+ - Document new Zod 4.3 features (z.fromJSONSchema, z.xor, z.looseRecord, .exactOptional)
128
+ - Add MCP SDK v2 preparation guide
129
+ - Include migration timeline and recommendations
130
+ - Provide code examples for new features
131
+
132
+ * **readme:** update README with latest versions and v2 preparation notes
133
+
134
+ ### Zod 4.3 New Features Available
135
+
136
+ While maintaining backward compatibility, the following new Zod features are now available:
137
+
138
+ - `z.fromJSONSchema()` - Convert JSON Schema to Zod schemas
139
+ - `z.xor()` - Exclusive union validation (exactly one must match)
140
+ - `z.looseRecord()` - Partial record validation
141
+ - `.exactOptional()` - Strict optional properties
142
+ - `.apply()` - Schema composition helper
143
+ - `.with()` - Readable alias for `.check()`
144
+ - Type predicates on `.refine()`
145
+ - `z.slugify()` - URL-friendly slug transformation
146
+
147
+ ### MCP SDK v2 Preparation
148
+
149
+ - Confirmed compatibility with v2 patterns (no code changes needed)
150
+ - Added v2 migration guide and timeline
151
+ - Project already uses modern v1.x APIs (registerTool, ResourceTemplate, etc.)
152
+
153
+ ### Testing
154
+
155
+ All tests pass with updated dependencies:
156
+ - ✅ 6 test suites, 47 tests passed
157
+ - ✅ CLI functionality verified
158
+ - ✅ HTTPS to HTTP fallback working correctly
159
+
160
+ ### Breaking Changes
161
+
162
+ **None** - This is a drop-in update maintaining full backward compatibility.
163
+
1
164
  # [1.17.0](https://github.com/aashari/boilerplate-mcp-server/compare/v1.16.1...v1.17.0) (2025-12-03)
2
165
 
3
166
 
package/README.md CHANGED
@@ -5,18 +5,25 @@ A production-ready foundation for developing custom Model Context Protocol (MCP)
5
5
  [![NPM Version](https://img.shields.io/npm/v/@aashari/boilerplate-mcp-server)](https://www.npmjs.com/package/@aashari/boilerplate-mcp-server)
6
6
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC)
7
7
 
8
+ > **Latest Update (Feb 2026)**: Updated to MCP SDK 1.25.3 and Zod 4.3.6 with new features like `z.fromJSONSchema()`, `z.xor()`, and improved validation. See [docs/MODERNIZATION.md](docs/MODERNIZATION.md) for details.
9
+
8
10
  ## Features
9
11
 
12
+ - **Security First**: DNS rebinding protection, localhost-only binding, secure error handling
10
13
  - **Dual Transport Support**: STDIO and Streamable HTTP transports with automatic fallback
11
- - **5-Layer Architecture**: Clean separation between CLI, tools, controllers, services, and utilities
12
- - **Type Safety**: Full TypeScript implementation with Zod v4 schema validation
14
+ - **Layered Architecture**: Clean separation between CLI, tools, resources, prompts, controllers, services, and utilities
15
+ - **Type Safety**: Full TypeScript implementation with Zod v4.3.6 schema validation
16
+ - **All MCP Primitives**: Tools, resources, and prompts (with examples)
17
+ - **ResourceLink Pattern**: Token-efficient resource references for large responses
13
18
  - **TOON Output Format**: Token-Oriented Object Notation for 30-60% fewer tokens than JSON
14
19
  - **JMESPath Filtering**: Extract only needed fields from responses to reduce token costs
15
- - **Modern SDK**: Uses MCP SDK v1.23.0 with `registerTool` API pattern
16
- - **Complete IP Address Example**: Tools, resources, and CLI commands for IP geolocation
17
- - **Comprehensive Testing**: Unit and integration tests with coverage reporting
20
+ - **Raw Response Logging**: Automatic logging of large API responses to `/tmp/mcp/<project>/` with truncation guidance
21
+ - **Modern SDK**: Uses MCP SDK v1.25.3 with `registerTool` API pattern (ready for v2 migration)
22
+ - **Complete IP Address Example**: Tools, resources, prompts, and CLI commands for IP geolocation
23
+ - **Comprehensive Testing**: Unit and integration tests with coverage reporting (47 tests passing)
18
24
  - **Production Tooling**: ESLint, Prettier, semantic-release, and MCP Inspector integration
19
- - **Error Handling**: Structured error handling with contextual logging
25
+ - **Error Handling**: Structured error handling with `isError` field and contextual logging
26
+ - **Security Documentation**: Complete [SECURITY.md](SECURITY.md) with authentication implementation guides
20
27
 
21
28
  ## What is MCP?
22
29
 
@@ -44,10 +51,10 @@ npm run build
44
51
 
45
52
  # 1. CLI Mode - Execute commands directly
46
53
  npm run cli -- get-ip-details 8.8.8.8
47
- npm run cli -- get-ip-details # Get your current IP
48
- npm run cli -- get-ip-details 1.1.1.1 --include-extended-data
49
- npm run cli -- get-ip-details 8.8.8.8 --jq "{ip: query, country: country}" # JQ filter
50
- npm run cli -- get-ip-details 8.8.8.8 --output-format json # JSON output
54
+ npm run cli -- get-ip-details # Get your current IP
55
+ npm run cli -- get-ip-details 1.1.1.1 -e # With extended data
56
+ npm run cli -- get-ip-details 8.8.8.8 --jq "{ip: query, country: country}" # JMESPath filter
57
+ npm run cli -- get-ip-details 8.8.8.8 -o json # JSON output
51
58
 
52
59
  # 2. STDIO Transport - For AI assistant integration (Claude Desktop, Cursor)
53
60
  npm run mcp:stdio
@@ -74,6 +81,26 @@ npm run mcp:inspect # Auto-opens browser with debugging
74
81
  - Health Check: `http://localhost:3000/` → Returns server version
75
82
  - Run with: `TRANSPORT_MODE=http node dist/index.js`
76
83
 
84
+ ## Security 🔒
85
+
86
+ **This boilerplate implements production-ready security measures:**
87
+
88
+ ### ✅ Built-In Protection
89
+
90
+ 1. **DNS Rebinding Protection**: Origin header validation prevents malicious websites from accessing your localhost server
91
+ 2. **Localhost-Only Binding**: Server explicitly binds to `127.0.0.1` (not accessible from network)
92
+ 3. **Secure Error Handling**: Error responses include `isError: true` flag and don't leak sensitive information
93
+
94
+ ### 🔐 Security Best Practices
95
+
96
+ - **Local Development**: No authentication required (localhost-only + DNS rebinding protection)
97
+ - **Network Deployment**: Authentication REQUIRED - see [SECURITY.md](SECURITY.md) for implementation guides
98
+ - **Production**: Use mTLS, OAuth 2.0, or bearer tokens (detailed in [SECURITY.md](SECURITY.md))
99
+
100
+ **📖 Complete security documentation:** [SECURITY.md](SECURITY.md)
101
+
102
+ **🔍 Security audit report:** [docs/AUDIT-2025-01-13.md](docs/AUDIT-2025-01-13.md)
103
+
77
104
  ## Output Formats
78
105
 
79
106
  ### TOON Format (Default)
@@ -137,10 +164,13 @@ src/
137
164
  │ ├── vendor.ip-api.com.service.ts # ip-api.com service
138
165
  │ └── vendor.ip-api.com.types.ts # Service type definitions
139
166
  ├── tools/ # MCP tool definitions (AI interface)
140
- │ ├── ipaddress.tool.ts # IP lookup tool for AI assistants
167
+ │ ├── ipaddress.tool.ts # IP lookup tool (inline content)
168
+ │ ├── ipaddress-link.tool.ts # IP lookup with ResourceLink pattern
141
169
  │ └── ipaddress.types.ts # Tool argument schemas
142
170
  ├── resources/ # MCP resource definitions
143
171
  │ └── ipaddress.resource.ts # IP lookup resource (URI: ip://address)
172
+ ├── prompts/ # MCP prompt definitions
173
+ │ └── analysis.prompt.ts # IP analysis prompt templates
144
174
  ├── types/ # Global type definitions
145
175
  │ └── common.types.ts # Shared interfaces (ControllerResponse, etc.)
146
176
  ├── utils/ # Shared utilities
@@ -149,18 +179,19 @@ src/
149
179
  │ ├── error-handler.util.ts # Error handling utilities
150
180
  │ ├── config.util.ts # Environment configuration
151
181
  │ ├── constants.util.ts # Version and package constants
152
- │ ├── formatter.util.ts # Markdown formatting
182
+ │ ├── formatter.util.ts # Markdown formatting and response truncation
153
183
  │ ├── toon.util.ts # TOON format encoding
154
184
  │ ├── jq.util.ts # JMESPath filtering
185
+ │ ├── response.util.ts # Raw API response logging
155
186
  │ └── transport.util.ts # HTTP transport utilities
156
187
  └── index.ts # Server entry point (dual transport)
157
188
  ```
158
189
 
159
190
  </details>
160
191
 
161
- ## 5-Layer Architecture
192
+ ## Layered Architecture
162
193
 
163
- The boilerplate follows a clean, layered architecture that promotes maintainability and clear separation of concerns:
194
+ The boilerplate follows a clean, layered architecture with 6 distinct layers that promotes maintainability and clear separation of concerns:
164
195
 
165
196
  ### 1. CLI Layer (`src/cli/`)
166
197
 
@@ -203,10 +234,14 @@ The boilerplate follows a clean, layered architecture that promotes maintainabil
203
234
  - **Key Components**:
204
235
  - `logger.util.ts`: Contextual logging (file:method context)
205
236
  - `error.util.ts`: MCP-specific error formatting
237
+ - `error-handler.util.ts`: Error handling and context building
206
238
  - `transport.util.ts`: HTTP/API utilities with retry logic
207
239
  - `config.util.ts`: Environment configuration management
240
+ - `constants.util.ts`: Version and package constants
241
+ - `formatter.util.ts`: Markdown formatting and response truncation
208
242
  - `toon.util.ts`: TOON format encoding (token-efficient output)
209
243
  - `jq.util.ts`: JMESPath filtering for response transformation
244
+ - `response.util.ts`: Raw API response logging to `/tmp/mcp/<project>/`
210
245
 
211
246
  ## Developer Guide
212
247
 
@@ -246,21 +281,23 @@ npm run update:deps # Update dependencies
246
281
  ### Environment Variables
247
282
 
248
283
  #### Core Configuration
249
- - `TRANSPORT_MODE`: Transport mode (`stdio` | `http`, default: `stdio`)
284
+ - `TRANSPORT_MODE`: Transport mode (`stdio` | `http`, default: `stdio`)
250
285
  - `PORT`: HTTP server port (default: `3000`)
251
286
  - `DEBUG`: Enable debug logging (`true` | `false`, default: `false`)
287
+ - `NODE_ENV`: Node environment (`development` | `production`, default: `development`)
252
288
 
253
- #### IP API Configuration
289
+ #### IP API Configuration
254
290
  - `IPAPI_API_TOKEN`: API token for ip-api.com extended data (optional, free tier available)
255
291
 
256
292
  #### Example `.env` File
257
293
  ```bash
258
- # Basic configuration
294
+ # Core configuration
259
295
  TRANSPORT_MODE=http
260
- PORT=3001
296
+ PORT=3000
261
297
  DEBUG=true
298
+ NODE_ENV=development
262
299
 
263
- # Extended data (requires ip-api.com account)
300
+ # External API Keys
264
301
  IPAPI_API_TOKEN=your_token_here
265
302
  ```
266
303
 
@@ -273,6 +310,12 @@ IPAPI_API_TOKEN=your_token_here
273
310
 
274
311
  - **Debug Logging**: Enable with `DEBUG=true` environment variable
275
312
 
313
+ - **Raw Response Logging**: Large API responses (>40,000 characters) are automatically logged
314
+ - Responses saved to `/tmp/mcp/<project-name>/` directory
315
+ - Filename format: `<timestamp>-<random>.txt`
316
+ - Includes request details, response data, and performance metrics
317
+ - Truncated responses include guidance on accessing the full raw file
318
+
276
319
  <details>
277
320
  <summary><b>Configuration (Click to expand)</b></summary>
278
321
 
@@ -451,7 +494,7 @@ async function handleGetData(args: Record<string, unknown>) {
451
494
  }
452
495
  }
453
496
 
454
- // Registration function using the modern registerTool API (SDK v1.22.0+)
497
+ // Registration function using the modern registerTool API (SDK v1.23.0)
455
498
  function registerTools(server: McpServer) {
456
499
  const registerLogger = logger.forMethod('registerTools');
457
500
  registerLogger.debug('Registering example tools...');
@@ -560,7 +603,7 @@ function registerResources(server: McpServer) {
560
603
  const registerLogger = logger.forMethod('registerResources');
561
604
  registerLogger.debug('Registering example resources...');
562
605
 
563
- // Use registerResource with ResourceTemplate for parameterized URIs (SDK v1.22.0+)
606
+ // Use registerResource with ResourceTemplate for parameterized URIs (SDK v1.23.0)
564
607
  server.registerResource(
565
608
  'example-data',
566
609
  new ResourceTemplate('example://{param}', { list: undefined }),
@@ -610,21 +653,29 @@ The boilerplate includes a complete IP address geolocation example demonstrating
610
653
 
611
654
  **CLI Commands:**
612
655
  ```bash
613
- npm run cli -- get-ip-details # Get current public IP (TOON format)
614
- npm run cli -- get-ip-details 8.8.8.8 # Get details for specific IP
615
- npm run cli -- get-ip-details 1.1.1.1 --include-extended-data # With extended data
616
- npm run cli -- get-ip-details 8.8.8.8 --no-use-https # Force HTTP (for free tier)
617
- npm run cli -- get-ip-details 8.8.8.8 --output-format json # JSON output
618
- npm run cli -- get-ip-details 8.8.8.8 --jq "{ip: query, country: country}" # Filtered output
656
+ npm run cli -- get-ip-details # Get current public IP (TOON format)
657
+ npm run cli -- get-ip-details 8.8.8.8 # Get details for specific IP
658
+ npm run cli -- get-ip-details 1.1.1.1 -e # Short form with extended data
659
+ npm run cli -- get-ip-details 1.1.1.1 --include-extended-data # Long form with extended data
660
+ npm run cli -- get-ip-details 8.8.8.8 --no-use-https # Force HTTP (for free tier)
661
+ npm run cli -- get-ip-details 8.8.8.8 -o json # JSON output (short form)
662
+ npm run cli -- get-ip-details 8.8.8.8 --output-format json # JSON output (long form)
663
+ npm run cli -- get-ip-details 8.8.8.8 --jq "{ip: query, country: country}" # JMESPath filtered output
619
664
  ```
620
665
 
621
666
  **MCP Tools:**
622
667
  - `ip_get_details` - IP geolocation lookup for AI assistants
623
- - Supports `outputFormat`: "toon" (default) or "json"
624
- - Supports `jq`: JMESPath expression for filtering
668
+ - Parameters:
669
+ - `ipAddress` (optional): IP address to lookup (omit for current device's public IP)
670
+ - `includeExtendedData` (optional, default: `false`): Include ASN, host, organization data (requires API token)
671
+ - `useHttps` (optional, default: `true`): Use HTTPS for API calls
672
+ - `jq` (optional): JMESPath expression to filter/transform response
673
+ - `outputFormat` (optional, default: `"toon"`): Output format - "toon" or "json"
625
674
 
626
675
  **MCP Resources:**
627
- - `ip://{ipAddress}` - IP details resource template (e.g., `ip://8.8.8.8`)
676
+ - `ip://{ipAddress}` - IP details resource template (e.g., `ip://8.8.8.8`, `ip://1.1.1.1`)
677
+ - Returns IP geolocation data in Markdown format
678
+ - Uses TOON format by default for token efficiency
628
679
 
629
680
  ### Features Demonstrated
630
681
 
@@ -709,11 +760,22 @@ npm run test:cli # CLI-specific tests only
709
760
 
710
761
  [ISC License](https://opensource.org/licenses/ISC)
711
762
 
763
+ ## MCP SDK v2 Preparation
764
+
765
+ ⚠️ **Note**: MCP SDK v2 is in development (expected stable Q1 2026). This boilerplate is ready for migration with minimal changes needed.
766
+
767
+ **Key v2 Changes**:
768
+ - Package split: `@modelcontextprotocol/server` and `@modelcontextprotocol/client`
769
+ - Optional middleware packages for Express, Hono, Node.js HTTP
770
+ - Same core API patterns (this boilerplate already uses modern APIs)
771
+
772
+ See [MODERNIZATION.md](MODERNIZATION.md) for detailed migration guide and timeline.
773
+
712
774
  ## Resources & Documentation
713
775
 
714
776
  ### MCP Protocol Resources
715
777
  - [MCP Specification](https://modelcontextprotocol.io/specification) - Latest protocol specification
716
- - [MCP SDK Documentation](https://github.com/modelcontextprotocol/typescript-sdk) - TypeScript SDK v1.23.0+
778
+ - [MCP SDK Documentation](https://github.com/modelcontextprotocol/typescript-sdk) - TypeScript SDK v1.23.0
717
779
  - [MCP Inspector](https://github.com/modelcontextprotocol/inspector) - Visual debugging tool
718
780
  - [MCP Concepts](https://modelcontextprotocol.io/docs/concepts) - Tools, resources, transports
719
781