@aashari/boilerplate-mcp-server 1.1.0 → 1.1.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/.releaserc.json +6 -1
- package/CHANGELOG.md +17 -0
- package/README.md +167 -162
- package/dist/cli/index.js +5 -2
- package/dist/cli/index.js.bak +5 -2
- package/dist/cli/ipaddress.cli.js +27 -7
- package/dist/cli/ipaddress.cli.test.d.ts +1 -0
- package/dist/controllers/ipaddress.controller.d.ts +9 -3
- package/dist/controllers/ipaddress.controller.js +62 -19
- package/dist/controllers/ipaddress.formatter.d.ts +7 -0
- package/dist/controllers/ipaddress.formatter.js +50 -0
- package/dist/controllers/ipaddress.types.d.ts +22 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +26 -28
- package/dist/index.js.bak +26 -28
- package/dist/resources/ipaddress.resource.js +42 -5
- package/dist/services/vendor.ip-api.com.service.d.ts +9 -2
- package/dist/services/vendor.ip-api.com.service.js +29 -27
- package/dist/services/vendor.ip-api.com.types.d.ts +58 -0
- package/dist/services/vendor.ip-api.com.types.js +2 -0
- package/dist/tools/ipaddress.tool.d.ts +3 -0
- package/dist/tools/ipaddress.tool.js +64 -7
- package/dist/tools/{ipaddress.type.d.ts → ipaddress.types.d.ts} +6 -0
- package/dist/tools/ipaddress.types.js +19 -0
- package/dist/types/common.types.d.ts +71 -0
- package/dist/types/common.types.js +7 -0
- package/dist/utils/cli.test.util.d.ts +28 -0
- package/dist/utils/cli.test.util.js +122 -0
- package/dist/utils/config.util.js +13 -10
- package/dist/utils/defaults.util.d.ts +26 -0
- package/dist/utils/defaults.util.js +38 -0
- package/dist/utils/error-handler.util.d.ts +60 -0
- package/dist/utils/error-handler.util.js +162 -0
- package/dist/utils/error.util.js +6 -3
- package/dist/utils/formatter.util.d.ts +57 -0
- package/dist/utils/formatter.util.js +188 -0
- package/dist/utils/logger.util.d.ts +44 -2
- package/dist/utils/logger.util.js +159 -7
- package/dist/utils/pagination.util.d.ts +69 -0
- package/dist/utils/pagination.util.js +140 -0
- package/dist/utils/transport.util.d.ts +40 -0
- package/dist/utils/transport.util.js +143 -0
- package/package.json +9 -8
- package/package.json.bak +9 -8
- package/.eslintrc.json +0 -19
- package/dist/services/vendor.ip-api.com.type.d.ts +0 -16
- package/dist/tools/ipaddress.type.js +0 -8
- /package/dist/{services/vendor.ip-api.com.type.js → controllers/ipaddress.types.js} +0 -0
package/.releaserc.json
CHANGED
|
@@ -20,7 +20,12 @@
|
|
|
20
20
|
[
|
|
21
21
|
"@semantic-release/git",
|
|
22
22
|
{
|
|
23
|
-
"assets": [
|
|
23
|
+
"assets": [
|
|
24
|
+
"package.json",
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"src/index.ts",
|
|
27
|
+
"src/cli/index.ts"
|
|
28
|
+
],
|
|
24
29
|
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
25
30
|
}
|
|
26
31
|
],
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [1.1.2](https://github.com/aashari/boilerplate-mcp-server/compare/v1.1.1...v1.1.2) (2025-03-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Performance Improvements
|
|
5
|
+
|
|
6
|
+
* **ipaddress:** enhance formatter output and optimize service implementation ([f1ccdbf](https://github.com/aashari/boilerplate-mcp-server/commit/f1ccdbf58cb2518ca979363369904255e5de275b))
|
|
7
|
+
|
|
8
|
+
## [1.1.1](https://github.com/aashari/boilerplate-mcp-server/compare/v1.1.0...v1.1.1) (2025-03-27)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Performance Improvements
|
|
12
|
+
|
|
13
|
+
* **core:** refactor code structure to align with Atlassian MCP patterns ([090fd56](https://github.com/aashari/boilerplate-mcp-server/commit/090fd5653ab62d70eb75c49828a9876f54cee6fc))
|
|
14
|
+
* **standards:** align codebase with Atlassian MCP server patterns ([8b8eb13](https://github.com/aashari/boilerplate-mcp-server/commit/8b8eb13fd4ce18158e83c4f8c7044ce06287f23e))
|
|
15
|
+
* **tests:** add CLI test infrastructure and ipaddress tests ([ccee308](https://github.com/aashari/boilerplate-mcp-server/commit/ccee308a86e076a67756e9113b481aa3848f40b7))
|
|
16
|
+
* **utils:** implement standardized core utilities and error handling ([6c14a2f](https://github.com/aashari/boilerplate-mcp-server/commit/6c14a2f83397f79cc39f0b7ec70b40e9d9755b9c))
|
|
17
|
+
|
|
1
18
|
# [1.1.0](https://github.com/aashari/boilerplate-mcp-server/compare/v1.0.3...v1.1.0) (2025-03-23)
|
|
2
19
|
|
|
3
20
|
|
package/README.md
CHANGED
|
@@ -1,215 +1,199 @@
|
|
|
1
1
|
# Boilerplate MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This project provides a Model Context Protocol (MCP) server template that serves as a starting point for building your own connections between AI assistants (like Anthropic's Claude, Cursor AI, or other MCP-compatible clients) and external data sources or APIs. It includes a working IP lookup tool example to demonstrate the pattern.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What is MCP and Why Use This Template?
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Model Context Protocol (MCP) is an open standard enabling AI models to connect securely to external tools and data sources. This server implements the MCP standard with a flexible architecture for building custom tools.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **IP Address Lookup**: Includes an example tool (`get-ip-details`) for fetching IP details, configurable with [ipapi.co](https://ipapi.co).
|
|
11
|
-
- **CLI Support**: Run tools directly from the command line without an AI client.
|
|
12
|
-
- **Flexible Configuration**: Supports direct environment variables for quick use or a global config file at `$HOME/.mcp/configs.json` for managing multiple servers.
|
|
13
|
-
- **Development Tools**: Built-in MCP Inspector for debugging, plus testing and linting utilities.
|
|
9
|
+
**Benefits:**
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
- **Quick Start:** Begin with a fully-functional MCP server structure including CLI support.
|
|
12
|
+
- **Proven Patterns:** Follow established architecture patterns used in production MCP servers.
|
|
13
|
+
- **Complete Example:** Includes a working IP lookup tool demonstrating the full pattern from CLI to API.
|
|
14
|
+
- **Modern TypeScript:** Built with TypeScript and modern Node.js practices for type safety and maintainability.
|
|
15
|
+
- **Testing Support:** Includes test infrastructure for both unit and CLI integration tests.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Available Tools
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
This MCP server provides the following example tool for your AI assistant:
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
- **Get IP Address Details (`get-ip-details`)**
|
|
22
22
|
|
|
23
|
-
- **
|
|
24
|
-
- **
|
|
23
|
+
- **Purpose:** Retrieves geolocation information (country, city, region, coordinates), ISP, and organization details associated with an IP address.
|
|
24
|
+
- **Use When:** You need to find the geographical location of a given IP address, identify the ISP/organization owning an IP, or get your own public IP details.
|
|
25
|
+
- **Conversational Example:** "What's my public IP and where is it located?" or "Look up the location of IP 8.8.8.8"
|
|
26
|
+
- **Parameter Example:** `{}` (no parameters for current device IP) or `{ ipAddress: "8.8.8.8" }` (specific IP)
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
## Interface Philosophy: Simple Input, Rich Output
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
This server follows a "Minimal Interface, Maximal Detail" approach:
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```
|
|
32
|
+
1. **Simple Tools:** Ask for only essential identifiers or parameters (like `ipAddress`).
|
|
33
|
+
2. **Rich Details:** Provides comprehensive information in a well-formatted Markdown response.
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
## Prerequisites
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
- **Node.js and npm:** Ensure you have Node.js (which includes npm) installed. Download from [nodejs.org](https://nodejs.org/).
|
|
38
|
+
- **IP API Token (Optional):** For enhanced IP lookup capabilities, you can obtain a token from [ip-api.com](https://ip-api.com/) (basic lookups work without a token).
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
"@aashari/boilerplate-mcp-server": {
|
|
41
|
-
"environments": {
|
|
42
|
-
"DEBUG": "true",
|
|
43
|
-
"IPAPI_API_TOKEN": "your_token"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
40
|
+
## Quick Start Guide
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"environments": {
|
|
55
|
-
"DEBUG": "true",
|
|
56
|
-
"IPAPI_API_TOKEN": "your_token"
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
"@aashari/mcp-server-atlassian-confluence": {
|
|
60
|
-
"environments": {
|
|
61
|
-
"DEBUG": "true",
|
|
62
|
-
"ATLASSIAN_SITE_NAME": "your-instance",
|
|
63
|
-
"ATLASSIAN_USER_EMAIL": "your-email@example.com",
|
|
64
|
-
"ATLASSIAN_API_TOKEN": "your_api_token"
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"@aashari/mcp-server-atlassian-jira": {
|
|
68
|
-
"environments": {
|
|
69
|
-
"DEBUG": "true",
|
|
70
|
-
"ATLASSIAN_SITE_NAME": "your-instance",
|
|
71
|
-
"ATLASSIAN_USER_EMAIL": "your-email@example.com",
|
|
72
|
-
"ATLASSIAN_API_TOKEN": "your_api_token"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
```
|
|
42
|
+
Follow these steps to connect your AI assistant to this boilerplate server:
|
|
43
|
+
|
|
44
|
+
### Step 1: Configure the Server (Optional)
|
|
45
|
+
|
|
46
|
+
The server works without configuration, but for enhanced options:
|
|
77
47
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
3. **Add
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"command": "npx",
|
|
102
|
-
"args": [
|
|
103
|
-
"-y",
|
|
104
|
-
"DEBUG=true",
|
|
105
|
-
"IPAPI_API_TOKEN=your_token",
|
|
106
|
-
"@aashari/boilerplate-mcp-server"
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
4. **Restart**: Close and reopen Claude Desktop.
|
|
113
|
-
5. **Test**: Click the hammer icon, verify `get-ip-details` is listed, then ask: "What's my public IP?" or "Get details for IP 8.8.8.8".
|
|
114
|
-
|
|
115
|
-
### Using with Cursor AI
|
|
116
|
-
|
|
117
|
-
1. **Open Settings**:
|
|
118
|
-
- Launch Cursor, press `CMD + SHIFT + P` (or `CTRL + SHIFT + P`), select "Cursor Settings" > "MCP".
|
|
119
|
-
2. **Add Server**:
|
|
120
|
-
- Click "+ Add new MCP server".
|
|
121
|
-
- **Name**: `aashari/boilerplate-mcp-server`.
|
|
122
|
-
- **Type**: `command`.
|
|
123
|
-
- **Command**:
|
|
124
|
-
- Global config: `npx -y @aashari/boilerplate-mcp-server`.
|
|
125
|
-
- Direct: `DEBUG=true IPAPI_API_TOKEN=your_token npx -y @aashari/boilerplate-mcp-server`.
|
|
126
|
-
- Click "Add".
|
|
127
|
-
3. **Verify**: Check for a green indicator and `get-ip-details` tool listed.
|
|
128
|
-
4. **Test**: In Agent mode, ask: "What's my public IP?" or "Get information about IP 8.8.8.8".
|
|
129
|
-
|
|
130
|
-
### Using as a CLI Tool
|
|
131
|
-
|
|
132
|
-
Run without installation:
|
|
48
|
+
#### Method A: Global MCP Config File (Recommended)
|
|
49
|
+
|
|
50
|
+
This keeps configurations separate and organized.
|
|
51
|
+
|
|
52
|
+
1. **Create the directory** (if needed): `~/.mcp/`
|
|
53
|
+
2. **Create/Edit the file:** `~/.mcp/configs.json`
|
|
54
|
+
3. **Add the configuration:** Paste the following JSON structure, replacing the placeholders:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"@aashari/boilerplate-mcp-server": {
|
|
59
|
+
"environments": {
|
|
60
|
+
"DEBUG": "true",
|
|
61
|
+
"IPAPI_API_TOKEN": "<YOUR_OPTIONAL_IP_API_TOKEN>"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Add other servers here if needed
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Method B: Environment Variables (Alternative)
|
|
69
|
+
|
|
70
|
+
Set environment variables when running the server.
|
|
133
71
|
|
|
134
72
|
```bash
|
|
135
|
-
|
|
136
|
-
npx -y @aashari/boilerplate-mcp-server -- --help
|
|
137
|
-
# Current IP
|
|
138
|
-
npx -y @aashari/boilerplate-mcp-server -- get-ip-details
|
|
139
|
-
# Specific IP
|
|
140
|
-
npx -y @aashari/boilerplate-mcp-server -- get-ip-details 8.8.8.8
|
|
73
|
+
DEBUG=true IPAPI_API_TOKEN="<YOUR_OPTIONAL_TOKEN>" npx -y @aashari/boilerplate-mcp-server
|
|
141
74
|
```
|
|
142
75
|
|
|
143
|
-
|
|
76
|
+
### Step 2: Connect Your AI Assistant
|
|
77
|
+
|
|
78
|
+
Configure your MCP client (Claude Desktop, Cursor, etc.) to run this server.
|
|
79
|
+
|
|
80
|
+
#### Claude Desktop
|
|
81
|
+
|
|
82
|
+
1. Open Settings (gear icon) > Edit Config.
|
|
83
|
+
2. Add or merge into `mcpServers`:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"aashari/boilerplate-mcp-server": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["-y", "@aashari/boilerplate-mcp-server"]
|
|
91
|
+
}
|
|
92
|
+
// ... other servers
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
3. Save and **Restart Claude Desktop**.
|
|
98
|
+
4. **Verify:** Click the "Tools" (hammer) icon; the IP lookup tool should be listed.
|
|
99
|
+
|
|
100
|
+
#### Cursor AI
|
|
101
|
+
|
|
102
|
+
1. Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`) > **Cursor Settings > MCP**.
|
|
103
|
+
2. Click **+ Add new MCP server**.
|
|
104
|
+
3. Enter:
|
|
105
|
+
- Name: `aashari/boilerplate-mcp-server`
|
|
106
|
+
- Type: `command`
|
|
107
|
+
- Command: `npx -y @aashari/boilerplate-mcp-server`
|
|
108
|
+
4. Click **Add**.
|
|
109
|
+
5. **Verify:** Wait for the indicator next to the server name to turn green.
|
|
110
|
+
|
|
111
|
+
### Step 3: Using the Tools
|
|
112
|
+
|
|
113
|
+
You can now ask your AI assistant IP-related questions:
|
|
114
|
+
|
|
115
|
+
- "What's my public IP address and where is it located?"
|
|
116
|
+
- "Can you get details for IP 8.8.8.8?"
|
|
117
|
+
- "Look up the geolocation of 1.1.1.1"
|
|
118
|
+
|
|
119
|
+
## Using as a Command-Line Tool (CLI)
|
|
120
|
+
|
|
121
|
+
You can also use this package directly from your terminal:
|
|
122
|
+
|
|
123
|
+
#### Quick Use with `npx`
|
|
144
124
|
|
|
145
125
|
```bash
|
|
146
|
-
|
|
126
|
+
npx -y @aashari/boilerplate-mcp-server get-ip-details
|
|
127
|
+
npx -y @aashari/boilerplate-mcp-server get-ip-details 8.8.8.8
|
|
128
|
+
npx -y @aashari/boilerplate-mcp-server --help
|
|
147
129
|
```
|
|
148
130
|
|
|
149
|
-
|
|
131
|
+
#### Global Installation (Optional)
|
|
132
|
+
|
|
133
|
+
1. `npm install -g @aashari/boilerplate-mcp-server`
|
|
134
|
+
2. Use the `mcp-server` command:
|
|
150
135
|
|
|
151
136
|
```bash
|
|
152
|
-
# Help
|
|
153
|
-
mcp-server --help
|
|
154
|
-
# Current IP
|
|
155
137
|
mcp-server get-ip-details
|
|
156
|
-
# Specific IP
|
|
157
138
|
mcp-server get-ip-details 8.8.8.8
|
|
139
|
+
mcp-server --help # See all commands
|
|
158
140
|
```
|
|
159
141
|
|
|
160
|
-
|
|
142
|
+
## Extending the Project
|
|
161
143
|
|
|
162
|
-
|
|
163
|
-
DEBUG=true IPAPI_API_TOKEN=your_token mcp-server get-ip-details
|
|
164
|
-
```
|
|
144
|
+
This boilerplate is designed to be extended with your own custom tools:
|
|
165
145
|
|
|
166
|
-
|
|
146
|
+
### Architecture Overview
|
|
167
147
|
|
|
168
|
-
|
|
148
|
+
The project follows a clean layered architecture:
|
|
169
149
|
|
|
170
|
-
|
|
150
|
+
- **CLI / Tool Layer** (`src/cli/*.cli.ts`, `src/tools/*.tool.ts`): User interfaces
|
|
151
|
+
- **Controller Layer** (`src/controllers/*.controller.ts`): Business logic
|
|
152
|
+
- **Service Layer** (`src/services/*.service.ts`): External API interactions
|
|
153
|
+
- **Utils** (`src/utils/*.util.ts`): Shared functionality
|
|
171
154
|
|
|
172
|
-
|
|
173
|
-
- **`npm run dev:cli`**: Run CLI commands in development mode with debug logging.
|
|
174
|
-
- **`npm run start:server`**: Run the server in production mode with MCP Inspector.
|
|
175
|
-
- **`npm run start:cli`**: Run CLI commands in production mode.
|
|
155
|
+
### Adding Your Own Tools
|
|
176
156
|
|
|
177
|
-
|
|
157
|
+
1. **Create a Service** in `src/services/` to interact with your API or data source.
|
|
158
|
+
2. **Add a Controller** in `src/controllers/` with business logic and type definitions.
|
|
159
|
+
3. **Implement a Tool** in `src/tools/` that defines the MCP tool interface.
|
|
160
|
+
4. **Add CLI Support** in `src/cli/` to enable command-line use.
|
|
161
|
+
5. **Register** your new tool in `src/index.ts`.
|
|
162
|
+
|
|
163
|
+
## Developer Guide
|
|
164
|
+
|
|
165
|
+
### Development Scripts
|
|
178
166
|
|
|
179
167
|
```bash
|
|
180
|
-
# Start
|
|
168
|
+
# Start server in development mode (with Inspector & debug logs)
|
|
181
169
|
npm run dev:server
|
|
182
170
|
|
|
183
|
-
# Run
|
|
171
|
+
# Run CLI in development mode
|
|
184
172
|
npm run dev:cli -- get-ip-details 8.8.8.8
|
|
185
173
|
|
|
186
|
-
#
|
|
174
|
+
# Production mode (server with Inspector)
|
|
187
175
|
npm run start:server
|
|
188
176
|
|
|
189
|
-
#
|
|
190
|
-
npm run start:cli -- get-ip-details
|
|
177
|
+
# Production mode (CLI command)
|
|
178
|
+
npm run start:cli -- get-ip-details
|
|
191
179
|
```
|
|
192
180
|
|
|
193
|
-
###
|
|
194
|
-
|
|
195
|
-
To add custom tools or resources:
|
|
196
|
-
|
|
197
|
-
1. **Services**: Add API/data logic in `src/services`.
|
|
198
|
-
2. **Controllers**: Implement business logic in `src/controllers`.
|
|
199
|
-
3. **Tools**: Define new tools in `src/tools`.
|
|
200
|
-
4. **Resources**: Add data sources in `src/resources`.
|
|
201
|
-
5. **Register**: Update `src/index.ts` with your tools/resources.
|
|
202
|
-
|
|
203
|
-
### Additional Development Tools
|
|
181
|
+
### Testing and Quality Tools
|
|
204
182
|
|
|
205
183
|
```bash
|
|
206
|
-
# Run tests
|
|
184
|
+
# Run all tests
|
|
207
185
|
npm test
|
|
208
|
-
|
|
186
|
+
|
|
187
|
+
# Run specific CLI tests
|
|
188
|
+
npm test -- src/cli/ipaddress.cli.test.ts
|
|
189
|
+
|
|
190
|
+
# Generate test coverage report
|
|
209
191
|
npm run test:coverage
|
|
210
|
-
|
|
192
|
+
|
|
193
|
+
# Lint code
|
|
211
194
|
npm run lint
|
|
212
|
-
|
|
195
|
+
|
|
196
|
+
# Format code
|
|
213
197
|
npm run format
|
|
214
198
|
```
|
|
215
199
|
|
|
@@ -217,9 +201,30 @@ npm run format
|
|
|
217
201
|
|
|
218
202
|
The MCP Inspector provides a visual interface for debugging and testing your MCP server:
|
|
219
203
|
|
|
220
|
-
1.
|
|
221
|
-
2.
|
|
222
|
-
3. Use the UI to test tools, view requests/responses, and check errors
|
|
204
|
+
1. Run `npm run dev:server` or `npm run start:server`
|
|
205
|
+
2. The Inspector launches a web UI (typically at `http://localhost:5173`)
|
|
206
|
+
3. Use the UI to test tools, view requests/responses, and check errors
|
|
207
|
+
|
|
208
|
+
## Troubleshooting
|
|
209
|
+
|
|
210
|
+
- **Server Not Connecting (in AI Client):**
|
|
211
|
+
- Confirm the command (`npx ...`) in your client's config is correct
|
|
212
|
+
- Check Node.js/npm installation and PATH
|
|
213
|
+
- Run the `npx` command directly in your terminal for errors
|
|
214
|
+
- **IP API Errors:**
|
|
215
|
+
- Basic lookups should work without configuration
|
|
216
|
+
- If using a token, verify `IPAPI_API_TOKEN` is set correctly
|
|
217
|
+
- Some IP ranges (private IPs like 192.168.x.x) may not return results
|
|
218
|
+
- **Enable Debug Logs:** Set `DEBUG=true` environment variable for verbose logging
|
|
219
|
+
|
|
220
|
+
## For Developers: Contributing
|
|
221
|
+
|
|
222
|
+
Contributions are welcome! If you'd like to contribute:
|
|
223
|
+
|
|
224
|
+
- **Setup:** Clone repo, `npm install`. Use `npm run dev:server` or `npm run dev:cli -- <command>`.
|
|
225
|
+
- **Code Style:** Use `npm run lint` and `npm run format`.
|
|
226
|
+
- **Tests:** Add tests via `npm test`.
|
|
227
|
+
- **Consistency:** Follow existing patterns and the "Minimal Interface, Maximal Detail" philosophy.
|
|
223
228
|
|
|
224
229
|
## License
|
|
225
230
|
|
package/dist/cli/index.js
CHANGED
|
@@ -8,21 +8,24 @@ const commander_1 = require("commander");
|
|
|
8
8
|
const logger_util_js_1 = require("../utils/logger.util.js");
|
|
9
9
|
const ipaddress_cli_js_1 = __importDefault(require("./ipaddress.cli.js"));
|
|
10
10
|
// Get the version from package.json
|
|
11
|
-
const VERSION = '1.1.
|
|
11
|
+
const VERSION = '1.1.2'; // This should match the version in src/index.ts
|
|
12
12
|
const NAME = '@aashari/boilerplate-mcp-server';
|
|
13
13
|
const DESCRIPTION = 'A boilerplate Model Context Protocol (MCP) server implementation using TypeScript';
|
|
14
14
|
async function runCli(args) {
|
|
15
|
+
const methodLogger = logger_util_js_1.Logger.forContext('cli/index.ts', 'runCli');
|
|
16
|
+
methodLogger.debug('Processing CLI arguments', args);
|
|
15
17
|
const program = new commander_1.Command();
|
|
16
18
|
program.name(NAME).description(DESCRIPTION).version(VERSION);
|
|
17
19
|
// Register CLI commands
|
|
18
20
|
ipaddress_cli_js_1.default.register(program);
|
|
19
21
|
// Handle unknown commands
|
|
20
22
|
program.on('command:*', (operands) => {
|
|
21
|
-
|
|
23
|
+
methodLogger.error(`Unknown command: ${operands[0]}`);
|
|
22
24
|
console.log('');
|
|
23
25
|
program.help();
|
|
24
26
|
process.exit(1);
|
|
25
27
|
});
|
|
26
28
|
// Parse arguments; default to help if no command provided
|
|
27
29
|
await program.parseAsync(args.length ? args : ['--help'], { from: 'user' });
|
|
30
|
+
methodLogger.debug('CLI command execution completed');
|
|
28
31
|
}
|
package/dist/cli/index.js.bak
CHANGED
|
@@ -8,21 +8,24 @@ const commander_1 = require("commander");
|
|
|
8
8
|
const logger_util_js_1 = require("../utils/logger.util.js");
|
|
9
9
|
const ipaddress_cli_js_1 = __importDefault(require("./ipaddress.cli.js"));
|
|
10
10
|
// Get the version from package.json
|
|
11
|
-
const VERSION = '1.
|
|
11
|
+
const VERSION = '1.1.1'; // This should match the version in src/index.ts
|
|
12
12
|
const NAME = '@aashari/boilerplate-mcp-server';
|
|
13
13
|
const DESCRIPTION = 'A boilerplate Model Context Protocol (MCP) server implementation using TypeScript';
|
|
14
14
|
async function runCli(args) {
|
|
15
|
+
const methodLogger = logger_util_js_1.Logger.forContext('cli/index.ts', 'runCli');
|
|
16
|
+
methodLogger.debug('Processing CLI arguments', args);
|
|
15
17
|
const program = new commander_1.Command();
|
|
16
18
|
program.name(NAME).description(DESCRIPTION).version(VERSION);
|
|
17
19
|
// Register CLI commands
|
|
18
20
|
ipaddress_cli_js_1.default.register(program);
|
|
19
21
|
// Handle unknown commands
|
|
20
22
|
program.on('command:*', (operands) => {
|
|
21
|
-
|
|
23
|
+
methodLogger.error(`Unknown command: ${operands[0]}`);
|
|
22
24
|
console.log('');
|
|
23
25
|
program.help();
|
|
24
26
|
process.exit(1);
|
|
25
27
|
});
|
|
26
28
|
// Parse arguments; default to help if no command provided
|
|
27
29
|
await program.parseAsync(args.length ? args : ['--help'], { from: 'user' });
|
|
30
|
+
methodLogger.debug('CLI command execution completed');
|
|
28
31
|
}
|
|
@@ -11,16 +11,36 @@ const ipaddress_controller_js_1 = __importDefault(require("../controllers/ipaddr
|
|
|
11
11
|
* @param program The Commander program instance
|
|
12
12
|
*/
|
|
13
13
|
function register(program) {
|
|
14
|
-
logger_util_js_1.
|
|
14
|
+
const methodLogger = logger_util_js_1.Logger.forContext('cli/ipaddress.cli.ts', 'register');
|
|
15
|
+
methodLogger.debug(`Registering IP address CLI commands...`);
|
|
15
16
|
program
|
|
16
17
|
.command('get-ip-details')
|
|
17
|
-
.description(
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
.description(`Get geolocation and network details about an IP address or the current device.
|
|
19
|
+
|
|
20
|
+
PURPOSE: Retrieve comprehensive information about an IP address including geographical location, ISP, organization, and network details.
|
|
21
|
+
|
|
22
|
+
Use Case: Useful for identifying the location of an IP address, determining network ownership, or checking your own public IP information.
|
|
23
|
+
|
|
24
|
+
Output: Formatted Markdown containing location data (country, region, city), network information (ISP, organization, AS number), coordinates, and a link to view the location on a map.
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
$ mcp-ipaddress get-ip-details
|
|
28
|
+
$ mcp-ipaddress get-ip-details 8.8.8.8
|
|
29
|
+
$ mcp-ipaddress get-ip-details 1.1.1.1`)
|
|
30
|
+
.argument('[ipAddress]', 'IP address to lookup (optional, omit for current device)')
|
|
31
|
+
.option('--extended', 'Include extended data like ASN, mobile and proxy detection')
|
|
32
|
+
.option('--https', 'Use HTTPS for API requests (may require paid API key)')
|
|
33
|
+
.action(async (ipAddress, cmdOptions) => {
|
|
34
|
+
const actionLogger = logger_util_js_1.Logger.forContext('cli/ipaddress.cli.ts', 'get-ip-details');
|
|
20
35
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
actionLogger.debug(`Fetching IP details for ${ipAddress || 'current device'}...`, cmdOptions);
|
|
37
|
+
// Map CLI options to controller options
|
|
38
|
+
const controllerOptions = {
|
|
39
|
+
includeExtendedData: cmdOptions?.extended || false,
|
|
40
|
+
useHttps: cmdOptions?.https || false,
|
|
41
|
+
};
|
|
42
|
+
const result = await ipaddress_controller_js_1.default.get(ipAddress, controllerOptions);
|
|
43
|
+
actionLogger.debug(`IP details fetched successfully`, result);
|
|
24
44
|
console.log(result.content);
|
|
25
45
|
}
|
|
26
46
|
catch (error) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ControllerResponse } from '../types/common.types.js';
|
|
2
|
+
import { GetIpOptions } from './ipaddress.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Get IP address details from the IP API.
|
|
5
|
+
* @param ipAddress Optional IP address to lookup (omit for current IP)
|
|
6
|
+
* @param options Optional configuration for the request
|
|
7
|
+
* @returns Controller response with formatted content
|
|
8
|
+
*/
|
|
9
|
+
declare function get(ipAddress?: string, options?: GetIpOptions): Promise<ControllerResponse>;
|
|
4
10
|
declare const _default: {
|
|
5
11
|
get: typeof get;
|
|
6
12
|
};
|
|
@@ -5,29 +5,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const vendor_ip_api_com_service_js_1 = __importDefault(require("../services/vendor.ip-api.com.service.js"));
|
|
7
7
|
const logger_util_js_1 = require("../utils/logger.util.js");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const ipaddress_formatter_js_1 = require("./ipaddress.formatter.js");
|
|
9
|
+
const error_handler_util_js_1 = require("../utils/error-handler.util.js");
|
|
10
|
+
const defaults_util_js_1 = require("../utils/defaults.util.js");
|
|
11
|
+
/**
|
|
12
|
+
* Get IP address details from the IP API.
|
|
13
|
+
* @param ipAddress Optional IP address to lookup (omit for current IP)
|
|
14
|
+
* @param options Optional configuration for the request
|
|
15
|
+
* @returns Controller response with formatted content
|
|
16
|
+
*/
|
|
17
|
+
async function get(ipAddress, options = {}) {
|
|
18
|
+
const methodLogger = logger_util_js_1.Logger.forContext('controllers/ipaddress.controller.ts', 'get');
|
|
19
|
+
methodLogger.debug(`Getting IP address details for ${ipAddress || 'current device'}...`);
|
|
11
20
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
// Define controller defaults
|
|
22
|
+
const defaults = {
|
|
23
|
+
includeExtendedData: false,
|
|
24
|
+
useHttps: false,
|
|
25
|
+
};
|
|
26
|
+
// Apply defaults to provided options
|
|
27
|
+
const mergedOptions = (0, defaults_util_js_1.applyDefaults)(options, defaults);
|
|
28
|
+
methodLogger.debug('Using options after defaults:', mergedOptions);
|
|
29
|
+
// Map controller options to service options
|
|
30
|
+
const serviceOptions = {
|
|
31
|
+
useHttps: mergedOptions.useHttps,
|
|
20
32
|
};
|
|
33
|
+
// If extended data is requested, include additional fields
|
|
34
|
+
if (mergedOptions.includeExtendedData) {
|
|
35
|
+
serviceOptions.fields = [
|
|
36
|
+
'status',
|
|
37
|
+
'message',
|
|
38
|
+
'country',
|
|
39
|
+
'countryCode',
|
|
40
|
+
'region',
|
|
41
|
+
'regionName',
|
|
42
|
+
'city',
|
|
43
|
+
'zip',
|
|
44
|
+
'lat',
|
|
45
|
+
'lon',
|
|
46
|
+
'timezone',
|
|
47
|
+
'isp',
|
|
48
|
+
'org',
|
|
49
|
+
'as',
|
|
50
|
+
'asname',
|
|
51
|
+
'reverse',
|
|
52
|
+
'mobile',
|
|
53
|
+
'proxy',
|
|
54
|
+
'hosting',
|
|
55
|
+
'query',
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
// Call the service with the mapped options
|
|
59
|
+
const ipData = await vendor_ip_api_com_service_js_1.default.get(ipAddress, serviceOptions);
|
|
60
|
+
methodLogger.debug(`Got the response from the service`, ipData);
|
|
61
|
+
// Format the data using the formatter
|
|
62
|
+
const formattedContent = (0, ipaddress_formatter_js_1.formatIpDetails)(ipData);
|
|
63
|
+
// Return the standard ControllerResponse structure
|
|
64
|
+
return { content: formattedContent };
|
|
21
65
|
}
|
|
22
66
|
catch (error) {
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
throw (0, error_util_js_1.createUnexpectedError)('Failed to get IP address details', error);
|
|
67
|
+
// Use the standardized error handler with return
|
|
68
|
+
return (0, error_handler_util_js_1.handleControllerError)(error, {
|
|
69
|
+
entityType: 'IP Address Details',
|
|
70
|
+
operation: 'retrieving',
|
|
71
|
+
source: 'controllers/ipaddress.controller.ts@get',
|
|
72
|
+
additionalInfo: { ipAddress },
|
|
73
|
+
});
|
|
31
74
|
}
|
|
32
75
|
}
|
|
33
76
|
exports.default = { get };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IPDetail } from '../services/vendor.ip-api.com.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Format IP address details into Markdown.
|
|
4
|
+
* @param ipData - Raw IP details from the ip-api.com service.
|
|
5
|
+
* @returns Formatted Markdown string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatIpDetails(ipData: IPDetail): string;
|