@aashari/boilerplate-mcp-server 1.10.2 → 1.10.3
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 +8 -0
- package/dist/cli/ipaddress.cli.js +4 -3
- package/dist/controllers/ipaddress.controller.d.ts +9 -4
- package/dist/controllers/ipaddress.controller.js +24 -22
- package/dist/resources/ipaddress.resource.js +2 -1
- package/dist/tools/ipaddress.tool.js +2 -4
- package/dist/utils/constants.util.d.ts +1 -1
- package/dist/utils/constants.util.js +1 -1
- package/package.json +2 -2
- package/package.json.bak +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.10.3](https://github.com/aashari/boilerplate-mcp-server/compare/v1.10.2...v1.10.3) (2025-05-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* Refactor IP address controller to accept args as a single object ([acb7ea2](https://github.com/aashari/boilerplate-mcp-server/commit/acb7ea2a148e9673a4bf2aa703f8ca988dc05c93))
|
|
7
|
+
* update dependencies ([02c42fa](https://github.com/aashari/boilerplate-mcp-server/commit/02c42fa6ef66be461444d1780b013860b455cbff))
|
|
8
|
+
|
|
1
9
|
## [1.10.2](https://github.com/aashari/boilerplate-mcp-server/compare/v1.10.1...v1.10.2) (2025-05-21)
|
|
2
10
|
|
|
3
11
|
|
|
@@ -28,12 +28,13 @@ function register(program) {
|
|
|
28
28
|
ipAddress,
|
|
29
29
|
options,
|
|
30
30
|
});
|
|
31
|
-
//
|
|
32
|
-
const
|
|
31
|
+
// Create a single args object to pass to the controller
|
|
32
|
+
const args = {
|
|
33
|
+
ipAddress,
|
|
33
34
|
includeExtendedData: options.includeExtendedData || false,
|
|
34
35
|
useHttps: options.useHttps, // commander handles the default via --no-use-https
|
|
35
36
|
};
|
|
36
|
-
const result = await ipaddress_controller_js_1.default.get(
|
|
37
|
+
const result = await ipaddress_controller_js_1.default.get(args);
|
|
37
38
|
console.log(result.content);
|
|
38
39
|
}
|
|
39
40
|
catch (error) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ControllerResponse } from '../types/common.types.js';
|
|
2
|
-
import { IpAddressToolArgsType } from '../tools/ipaddress.types.js';
|
|
3
2
|
/**
|
|
4
3
|
* @namespace IpAddressController
|
|
5
4
|
* @description Controller responsible for handling IP address lookup logic.
|
|
@@ -11,12 +10,18 @@ import { IpAddressToolArgsType } from '../tools/ipaddress.types.js';
|
|
|
11
10
|
* @description Fetches details for a specific IP address or the current device's IP.
|
|
12
11
|
* Handles mapping controller options (like includeExtendedData) to service parameters (fields).
|
|
13
12
|
* @memberof IpAddressController
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {
|
|
13
|
+
* @param {Object} args - Arguments containing ipAddress and options
|
|
14
|
+
* @param {string} [args.ipAddress] - Optional IP address to look up. If omitted, the service will fetch the current device's public IP.
|
|
15
|
+
* @param {boolean} [args.includeExtendedData=false] - Whether to include extended data fields requiring an API token
|
|
16
|
+
* @param {boolean} [args.useHttps=true] - Whether to use HTTPS for the API request
|
|
16
17
|
* @returns {Promise<ControllerResponse>} A promise that resolves to the standard controller response containing the formatted IP details in Markdown.
|
|
17
18
|
* @throws {McpError} Throws an McpError (handled by `handleControllerError`) if the service call fails or returns an error.
|
|
18
19
|
*/
|
|
19
|
-
declare function get(
|
|
20
|
+
declare function get(args?: {
|
|
21
|
+
ipAddress?: string;
|
|
22
|
+
includeExtendedData?: boolean;
|
|
23
|
+
useHttps?: boolean;
|
|
24
|
+
}): Promise<ControllerResponse>;
|
|
20
25
|
declare const _default: {
|
|
21
26
|
get: typeof get;
|
|
22
27
|
};
|
|
@@ -21,57 +21,59 @@ const error_handler_util_js_2 = require("../utils/error-handler.util.js");
|
|
|
21
21
|
* @description Fetches details for a specific IP address or the current device's IP.
|
|
22
22
|
* Handles mapping controller options (like includeExtendedData) to service parameters (fields).
|
|
23
23
|
* @memberof IpAddressController
|
|
24
|
-
* @param {
|
|
25
|
-
* @param {
|
|
24
|
+
* @param {Object} args - Arguments containing ipAddress and options
|
|
25
|
+
* @param {string} [args.ipAddress] - Optional IP address to look up. If omitted, the service will fetch the current device's public IP.
|
|
26
|
+
* @param {boolean} [args.includeExtendedData=false] - Whether to include extended data fields requiring an API token
|
|
27
|
+
* @param {boolean} [args.useHttps=true] - Whether to use HTTPS for the API request
|
|
26
28
|
* @returns {Promise<ControllerResponse>} A promise that resolves to the standard controller response containing the formatted IP details in Markdown.
|
|
27
29
|
* @throws {McpError} Throws an McpError (handled by `handleControllerError`) if the service call fails or returns an error.
|
|
28
30
|
*/
|
|
29
|
-
async function get(
|
|
30
|
-
includeExtendedData: false,
|
|
31
|
-
useHttps: true,
|
|
32
|
-
}) {
|
|
31
|
+
async function get(args = {}) {
|
|
33
32
|
const methodLogger = logger_util_js_1.Logger.forContext('controllers/ipaddress.controller.ts', 'get');
|
|
34
|
-
methodLogger.debug(`Getting IP address details for ${ipAddress || 'current device'}...`);
|
|
33
|
+
methodLogger.debug(`Getting IP address details for ${args.ipAddress || 'current device'}...`);
|
|
35
34
|
try {
|
|
36
35
|
// Detect if we're running in a test environment
|
|
37
36
|
const isTestEnvironment = process.env.NODE_ENV === 'test' ||
|
|
38
37
|
process.env.JEST_WORKER_ID !== undefined;
|
|
39
|
-
//
|
|
40
|
-
const
|
|
38
|
+
// Apply defaults
|
|
39
|
+
const options = {
|
|
40
|
+
includeExtendedData: args.includeExtendedData ?? false,
|
|
41
|
+
useHttps: args.useHttps ?? true,
|
|
42
|
+
};
|
|
41
43
|
// Special handling for test environments
|
|
42
44
|
if (isTestEnvironment) {
|
|
43
45
|
methodLogger.debug('Running in test environment');
|
|
44
46
|
// Force these settings for consistent test behavior
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
options.includeExtendedData = false;
|
|
48
|
+
options.useHttps = false;
|
|
47
49
|
}
|
|
48
50
|
// For non-test environments, check API token
|
|
49
51
|
else {
|
|
50
52
|
const hasApiToken = Boolean(config_util_js_1.config.get('IPAPI_API_TOKEN'));
|
|
51
|
-
if (
|
|
53
|
+
if (options.includeExtendedData && !hasApiToken) {
|
|
52
54
|
methodLogger.warn('Extended data requested but no API token found. Falling back to basic data.');
|
|
53
|
-
|
|
55
|
+
options.includeExtendedData = false;
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
// Service options
|
|
57
59
|
const serviceOptions = {
|
|
58
|
-
useHttps:
|
|
60
|
+
useHttps: options.useHttps,
|
|
59
61
|
// Map includeExtendedData to the 'fields' expected by the service
|
|
60
62
|
// Only send fields parameter if explicitly requesting extended data
|
|
61
|
-
fields:
|
|
63
|
+
fields: options.includeExtendedData
|
|
62
64
|
? getAllIpApiFields()
|
|
63
65
|
: undefined,
|
|
64
66
|
};
|
|
65
|
-
methodLogger.debug(`Getting IP details for ${ipAddress || 'current IP'}`, {
|
|
66
|
-
ipAddress,
|
|
67
|
-
originalOptions:
|
|
68
|
-
|
|
67
|
+
methodLogger.debug(`Getting IP details for ${args.ipAddress || 'current IP'}`, {
|
|
68
|
+
ipAddress: args.ipAddress,
|
|
69
|
+
originalOptions: args,
|
|
70
|
+
options,
|
|
69
71
|
serviceOptions,
|
|
70
72
|
isTestEnvironment,
|
|
71
73
|
});
|
|
72
74
|
try {
|
|
73
75
|
// Call the service with ipAddress and the mapped serviceOptions
|
|
74
|
-
const data = await vendor_ip_api_com_service_js_1.default.get(ipAddress, serviceOptions);
|
|
76
|
+
const data = await vendor_ip_api_com_service_js_1.default.get(args.ipAddress, serviceOptions);
|
|
75
77
|
methodLogger.debug(`Got the response from the service`, data);
|
|
76
78
|
const formattedContent = (0, ipaddress_formatter_js_1.formatIpDetails)(data);
|
|
77
79
|
return { content: formattedContent };
|
|
@@ -85,7 +87,7 @@ async function get(ipAddress, options = {
|
|
|
85
87
|
error.message.includes('Access denied'))) {
|
|
86
88
|
methodLogger.warn('HTTPS request failed, falling back to HTTP');
|
|
87
89
|
// Try again with HTTP
|
|
88
|
-
const httpData = await vendor_ip_api_com_service_js_1.default.get(ipAddress, {
|
|
90
|
+
const httpData = await vendor_ip_api_com_service_js_1.default.get(args.ipAddress, {
|
|
89
91
|
...serviceOptions,
|
|
90
92
|
useHttps: false,
|
|
91
93
|
});
|
|
@@ -98,7 +100,7 @@ async function get(ipAddress, options = {
|
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
catch (error) {
|
|
101
|
-
throw (0, error_handler_util_js_1.handleControllerError)(error, (0, error_handler_util_js_2.buildErrorContext)('IP Address', 'get', 'controllers/ipaddress.controller.ts@get', ipAddress || 'current device', {
|
|
103
|
+
throw (0, error_handler_util_js_1.handleControllerError)(error, (0, error_handler_util_js_2.buildErrorContext)('IP Address', 'get', 'controllers/ipaddress.controller.ts@get', args.ipAddress || 'current device', { args }));
|
|
102
104
|
}
|
|
103
105
|
}
|
|
104
106
|
/** Helper to define all fields for extended data */
|
|
@@ -27,7 +27,8 @@ function registerResources(server) {
|
|
|
27
27
|
// Get everything after the ip:// protocol
|
|
28
28
|
const ipAddress = uri.toString().replace(/^ip:\/\//, '');
|
|
29
29
|
// Call the controller to get the IP details
|
|
30
|
-
const result = await ipaddress_controller_js_1.default.get(
|
|
30
|
+
const result = await ipaddress_controller_js_1.default.get({
|
|
31
|
+
ipAddress: ipAddress || undefined,
|
|
31
32
|
includeExtendedData: false,
|
|
32
33
|
useHttps: true,
|
|
33
34
|
});
|
|
@@ -32,10 +32,8 @@ async function handleGetIpDetails(args) {
|
|
|
32
32
|
const methodLogger = logger_util_js_1.Logger.forContext('tools/ipaddress.tool.ts', 'handleGetIpDetails');
|
|
33
33
|
methodLogger.debug(`Getting IP address details for ${args.ipAddress || 'current IP'}...`, args);
|
|
34
34
|
try {
|
|
35
|
-
//
|
|
36
|
-
const
|
|
37
|
-
// Call the controller with the ipAddress and the options object
|
|
38
|
-
const result = await ipaddress_controller_js_1.default.get(ipAddress, controllerOptions);
|
|
35
|
+
// Pass args directly to the controller
|
|
36
|
+
const result = await ipaddress_controller_js_1.default.get(args);
|
|
39
37
|
methodLogger.debug(`Got the response from the controller`, result);
|
|
40
38
|
// Format the response for the MCP tool
|
|
41
39
|
return {
|
|
@@ -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.3';
|
|
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.3",
|
|
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",
|
|
@@ -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.25.
|
|
87
|
+
"zod": "^3.25.17"
|
|
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.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",
|
|
@@ -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.25.
|
|
87
|
+
"zod": "^3.25.17"
|
|
88
88
|
},
|
|
89
89
|
"directories": {
|
|
90
90
|
"example": "examples"
|