itglue-mcp 1.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/LICENSE +21 -0
- package/README.md +382 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +513 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-client.d.ts +76 -0
- package/dist/lib/api-client.d.ts.map +1 -0
- package/dist/lib/api-client.js +189 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/audit-logger.d.ts +51 -0
- package/dist/lib/audit-logger.d.ts.map +1 -0
- package/dist/lib/audit-logger.js +119 -0
- package/dist/lib/audit-logger.js.map +1 -0
- package/dist/lib/cache.d.ts +52 -0
- package/dist/lib/cache.d.ts.map +1 -0
- package/dist/lib/cache.js +115 -0
- package/dist/lib/cache.js.map +1 -0
- package/dist/lib/error-handler.d.ts +25 -0
- package/dist/lib/error-handler.d.ts.map +1 -0
- package/dist/lib/error-handler.js +99 -0
- package/dist/lib/error-handler.js.map +1 -0
- package/dist/lib/rate-limiter.d.ts +45 -0
- package/dist/lib/rate-limiter.d.ts.map +1 -0
- package/dist/lib/rate-limiter.js +124 -0
- package/dist/lib/rate-limiter.js.map +1 -0
- package/dist/tools/auxiliary/audit/compliance-check.d.ts +54 -0
- package/dist/tools/auxiliary/audit/compliance-check.d.ts.map +1 -0
- package/dist/tools/auxiliary/audit/compliance-check.js +303 -0
- package/dist/tools/auxiliary/audit/compliance-check.js.map +1 -0
- package/dist/tools/auxiliary/health/health-check.d.ts +36 -0
- package/dist/tools/auxiliary/health/health-check.d.ts.map +1 -0
- package/dist/tools/auxiliary/health/health-check.js +287 -0
- package/dist/tools/auxiliary/health/health-check.js.map +1 -0
- package/dist/tools/auxiliary/reporting/organization-report.d.ts +41 -0
- package/dist/tools/auxiliary/reporting/organization-report.d.ts.map +1 -0
- package/dist/tools/auxiliary/reporting/organization-report.js +297 -0
- package/dist/tools/auxiliary/reporting/organization-report.js.map +1 -0
- package/dist/tools/auxiliary/staleness/staleness-detector.d.ts +82 -0
- package/dist/tools/auxiliary/staleness/staleness-detector.d.ts.map +1 -0
- package/dist/tools/auxiliary/staleness/staleness-detector.js +238 -0
- package/dist/tools/auxiliary/staleness/staleness-detector.js.map +1 -0
- package/dist/tools/auxiliary/validation/data-validator.d.ts +46 -0
- package/dist/tools/auxiliary/validation/data-validator.d.ts.map +1 -0
- package/dist/tools/auxiliary/validation/data-validator.js +296 -0
- package/dist/tools/auxiliary/validation/data-validator.js.map +1 -0
- package/dist/tools/configurations.d.ts +48 -0
- package/dist/tools/configurations.d.ts.map +1 -0
- package/dist/tools/configurations.js +89 -0
- package/dist/tools/configurations.js.map +1 -0
- package/dist/tools/documents.d.ts +42 -0
- package/dist/tools/documents.d.ts.map +1 -0
- package/dist/tools/documents.js +79 -0
- package/dist/tools/documents.js.map +1 -0
- package/dist/tools/flexible-assets.d.ts +79 -0
- package/dist/tools/flexible-assets.d.ts.map +1 -0
- package/dist/tools/flexible-assets.js +136 -0
- package/dist/tools/flexible-assets.js.map +1 -0
- package/dist/tools/organizations.d.ts +68 -0
- package/dist/tools/organizations.d.ts.map +1 -0
- package/dist/tools/organizations.js +123 -0
- package/dist/tools/organizations.js.map +1 -0
- package/dist/tools/passwords.d.ts +86 -0
- package/dist/tools/passwords.d.ts.map +1 -0
- package/dist/tools/passwords.js +165 -0
- package/dist/tools/passwords.js.map +1 -0
- package/dist/tools/search.d.ts +34 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +79 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types/itglue.d.ts +129 -0
- package/dist/types/itglue.d.ts.map +1 -0
- package/dist/types/itglue.js +10 -0
- package/dist/types/itglue.js.map +1 -0
- package/dist/types/mcp.d.ts +33 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +11 -0
- package/dist/types/mcp.js.map +1 -0
- package/package.json +64 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ITGlue MCP Server
|
|
4
|
+
* Model Context Protocol server for ITGlue API access
|
|
5
|
+
*/
|
|
6
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
7
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
8
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import { APIClient } from './lib/api-client.js';
|
|
10
|
+
import { AuditLogger } from './lib/audit-logger.js';
|
|
11
|
+
// Import tool schemas and handlers
|
|
12
|
+
import { SearchOrganizationsSchema, ListOrganizationTypesSchema, searchOrganizations, listOrganizationTypes, } from './tools/organizations.js';
|
|
13
|
+
import { GlobalSearchSchema, globalSearch } from './tools/search.js';
|
|
14
|
+
import { ListConfigurationsSchema, listConfigurations } from './tools/configurations.js';
|
|
15
|
+
import { ListPasswordsSchema, GetPasswordSchema, listPasswords, getPassword, } from './tools/passwords.js';
|
|
16
|
+
import { ListFlexibleAssetsSchema, GetFlexibleAssetSchema, listFlexibleAssets, getFlexibleAsset, } from './tools/flexible-assets.js';
|
|
17
|
+
import { ListDocumentsSchema, listDocuments } from './tools/documents.js';
|
|
18
|
+
// Import auxiliary tool schemas and handlers
|
|
19
|
+
import { ComplianceCheckSchema, performComplianceCheck, } from './tools/auxiliary/audit/compliance-check.js';
|
|
20
|
+
import { StalenessCheckSchema, detectStaleness, } from './tools/auxiliary/staleness/staleness-detector.js';
|
|
21
|
+
import { DataValidationSchema, validateData, } from './tools/auxiliary/validation/data-validator.js';
|
|
22
|
+
import { OrganizationReportSchema, generateOrganizationReport, } from './tools/auxiliary/reporting/organization-report.js';
|
|
23
|
+
import { HealthCheckSchema, performHealthCheck, } from './tools/auxiliary/health/health-check.js';
|
|
24
|
+
// Global logger for server-level events
|
|
25
|
+
const logger = new AuditLogger();
|
|
26
|
+
/**
|
|
27
|
+
* Initialize API client from environment variables
|
|
28
|
+
*/
|
|
29
|
+
function initializeClient() {
|
|
30
|
+
const apiKey = process.env.ITGLUE_API_KEY;
|
|
31
|
+
if (!apiKey) {
|
|
32
|
+
throw new Error('ITGLUE_API_KEY environment variable is required. Get your API key from ITGlue Settings → API Keys');
|
|
33
|
+
}
|
|
34
|
+
const baseURL = process.env.ITGLUE_BASE_URL; // Custom base URL for on-prem
|
|
35
|
+
const region = (process.env.ITGLUE_REGION || 'US');
|
|
36
|
+
const cacheTTL = parseInt(process.env.ITGLUE_CACHE_TTL || '300');
|
|
37
|
+
const rateLimit = parseInt(process.env.ITGLUE_RATE_LIMIT || '8');
|
|
38
|
+
const debug = process.env.ITGLUE_DEBUG === 'true';
|
|
39
|
+
logger.debug('Initializing ITGlue API client', {
|
|
40
|
+
baseURL: baseURL || `Region: ${region}`,
|
|
41
|
+
cacheTTL,
|
|
42
|
+
rateLimit,
|
|
43
|
+
debug,
|
|
44
|
+
});
|
|
45
|
+
return new APIClient({
|
|
46
|
+
apiKey,
|
|
47
|
+
baseURL,
|
|
48
|
+
region,
|
|
49
|
+
cacheTTL,
|
|
50
|
+
rateLimit,
|
|
51
|
+
debug,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Main server setup
|
|
56
|
+
*/
|
|
57
|
+
async function main() {
|
|
58
|
+
try {
|
|
59
|
+
// Initialize API client
|
|
60
|
+
const client = initializeClient();
|
|
61
|
+
// Create MCP server
|
|
62
|
+
const server = new Server({
|
|
63
|
+
name: 'itglue-mcp',
|
|
64
|
+
version: '1.0.0',
|
|
65
|
+
}, {
|
|
66
|
+
capabilities: {
|
|
67
|
+
tools: {},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* Register tools/list handler
|
|
72
|
+
*/
|
|
73
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
74
|
+
return {
|
|
75
|
+
tools: [
|
|
76
|
+
// Tier 1: Discovery
|
|
77
|
+
{
|
|
78
|
+
name: 'itglue_search_organizations',
|
|
79
|
+
description: 'Search for organizations by name or filter by type/status. Returns lightweight summaries with ID, name, type, and status.',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
name: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
description: 'Organization name to search for (partial match)',
|
|
86
|
+
},
|
|
87
|
+
organization_type_id: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
description: 'Filter by organization type ID',
|
|
90
|
+
},
|
|
91
|
+
organization_status_id: {
|
|
92
|
+
type: 'number',
|
|
93
|
+
description: 'Filter by organization status ID',
|
|
94
|
+
},
|
|
95
|
+
limit: {
|
|
96
|
+
type: 'number',
|
|
97
|
+
description: 'Maximum number of results (1-100, default: 50)',
|
|
98
|
+
default: 50,
|
|
99
|
+
minimum: 1,
|
|
100
|
+
maximum: 100,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'itglue_list_organization_types',
|
|
107
|
+
description: 'List all available organization types (e.g., Client, Internal, Vendor). Useful for filtering organization searches.',
|
|
108
|
+
inputSchema: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'itglue_search_global',
|
|
115
|
+
description: 'Search across all ITGlue entities (organizations, configurations, passwords, documents, etc.) using a query string. Returns grouped results by entity type.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
query: {
|
|
120
|
+
type: 'string',
|
|
121
|
+
description: 'Search query',
|
|
122
|
+
},
|
|
123
|
+
limit: {
|
|
124
|
+
type: 'number',
|
|
125
|
+
description: 'Maximum number of results (1-100, default: 20)',
|
|
126
|
+
default: 20,
|
|
127
|
+
minimum: 1,
|
|
128
|
+
maximum: 100,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
required: ['query'],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
// Tier 2: Entity Navigation
|
|
135
|
+
{
|
|
136
|
+
name: 'itglue_list_configurations',
|
|
137
|
+
description: 'List configurations (servers, workstations, network devices) for a specific organization. Returns summaries with type, serial number, manufacturer, and model.',
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {
|
|
141
|
+
organization_id: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
description: 'Organization ID (from search_organizations)',
|
|
144
|
+
},
|
|
145
|
+
configuration_type_id: {
|
|
146
|
+
type: 'number',
|
|
147
|
+
description: 'Filter by configuration type ID',
|
|
148
|
+
},
|
|
149
|
+
configuration_status_id: {
|
|
150
|
+
type: 'number',
|
|
151
|
+
description: 'Filter by configuration status ID',
|
|
152
|
+
},
|
|
153
|
+
limit: {
|
|
154
|
+
type: 'number',
|
|
155
|
+
description: 'Maximum number of results (1-100, default: 50)',
|
|
156
|
+
default: 50,
|
|
157
|
+
minimum: 1,
|
|
158
|
+
maximum: 100,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
required: ['organization_id'],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'itglue_list_passwords',
|
|
166
|
+
description: 'List passwords for a specific organization (NO password values returned, just metadata). Use itglue_get_password to retrieve actual password values.',
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
organization_id: {
|
|
171
|
+
type: 'string',
|
|
172
|
+
description: 'Organization ID',
|
|
173
|
+
},
|
|
174
|
+
password_category_id: {
|
|
175
|
+
type: 'number',
|
|
176
|
+
description: 'Filter by password category ID',
|
|
177
|
+
},
|
|
178
|
+
limit: {
|
|
179
|
+
type: 'number',
|
|
180
|
+
description: 'Maximum number of results (1-100, default: 50)',
|
|
181
|
+
default: 50,
|
|
182
|
+
minimum: 1,
|
|
183
|
+
maximum: 100,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
required: ['organization_id'],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: 'itglue_list_flexible_assets',
|
|
191
|
+
description: 'List flexible assets (custom documentation types) for an organization. Requires flexible_asset_type_id.',
|
|
192
|
+
inputSchema: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
organization_id: {
|
|
196
|
+
type: 'string',
|
|
197
|
+
description: 'Organization ID',
|
|
198
|
+
},
|
|
199
|
+
flexible_asset_type_id: {
|
|
200
|
+
type: 'number',
|
|
201
|
+
description: 'Flexible asset type ID (required)',
|
|
202
|
+
},
|
|
203
|
+
limit: {
|
|
204
|
+
type: 'number',
|
|
205
|
+
description: 'Maximum number of results (1-100, default: 50)',
|
|
206
|
+
default: 50,
|
|
207
|
+
minimum: 1,
|
|
208
|
+
maximum: 100,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
required: ['organization_id', 'flexible_asset_type_id'],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: 'itglue_list_documents',
|
|
216
|
+
description: 'List documents for a specific organization. Returns document names, file names, and content types.',
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: 'object',
|
|
219
|
+
properties: {
|
|
220
|
+
organization_id: {
|
|
221
|
+
type: 'string',
|
|
222
|
+
description: 'Organization ID',
|
|
223
|
+
},
|
|
224
|
+
limit: {
|
|
225
|
+
type: 'number',
|
|
226
|
+
description: 'Maximum number of results (1-100, default: 50)',
|
|
227
|
+
default: 50,
|
|
228
|
+
minimum: 1,
|
|
229
|
+
maximum: 100,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
required: ['organization_id'],
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
// Tier 3: Detail Retrieval
|
|
236
|
+
{
|
|
237
|
+
name: 'itglue_get_password',
|
|
238
|
+
description: '⚠️ Retrieve full password details including the password value. THIS ACCESS IS AUDIT LOGGED. Use responsibly and only when necessary.',
|
|
239
|
+
inputSchema: {
|
|
240
|
+
type: 'object',
|
|
241
|
+
properties: {
|
|
242
|
+
password_id: {
|
|
243
|
+
type: 'string',
|
|
244
|
+
description: 'Password ID (from list_passwords)',
|
|
245
|
+
},
|
|
246
|
+
organization_id: {
|
|
247
|
+
type: 'string',
|
|
248
|
+
description: 'Organization ID (for audit logging)',
|
|
249
|
+
},
|
|
250
|
+
show_password: {
|
|
251
|
+
type: 'boolean',
|
|
252
|
+
description: 'Whether to include the password value (default: true)',
|
|
253
|
+
default: true,
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
required: ['password_id'],
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'itglue_get_flexible_asset',
|
|
261
|
+
description: 'Retrieve full details for a flexible asset including all custom fields (traits).',
|
|
262
|
+
inputSchema: {
|
|
263
|
+
type: 'object',
|
|
264
|
+
properties: {
|
|
265
|
+
flexible_asset_id: {
|
|
266
|
+
type: 'string',
|
|
267
|
+
description: 'Flexible asset ID',
|
|
268
|
+
},
|
|
269
|
+
organization_id: {
|
|
270
|
+
type: 'string',
|
|
271
|
+
description: 'Organization ID (for context)',
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
required: ['flexible_asset_id'],
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
// Auxiliary Tools: Audit & Compliance
|
|
278
|
+
{
|
|
279
|
+
name: 'itglue_compliance_check',
|
|
280
|
+
description: '🔍 Perform comprehensive compliance checks on ITGlue data. Identifies issues with passwords, configurations, documentation, and warranties. Essential for MSP audits and security reviews.',
|
|
281
|
+
inputSchema: {
|
|
282
|
+
type: 'object',
|
|
283
|
+
properties: {
|
|
284
|
+
organization_id: {
|
|
285
|
+
type: 'string',
|
|
286
|
+
description: 'Organization ID to check compliance for',
|
|
287
|
+
},
|
|
288
|
+
checks: {
|
|
289
|
+
type: 'array',
|
|
290
|
+
items: {
|
|
291
|
+
type: 'string',
|
|
292
|
+
enum: ['passwords', 'configurations', 'documentation', 'warranties'],
|
|
293
|
+
},
|
|
294
|
+
default: ['passwords', 'configurations', 'documentation'],
|
|
295
|
+
description: 'Compliance checks to perform',
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
required: ['organization_id'],
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
// Auxiliary Tools: Staleness Detection
|
|
302
|
+
{
|
|
303
|
+
name: 'itglue_detect_staleness',
|
|
304
|
+
description: '⏰ Detect stale or outdated data in ITGlue. Identifies passwords, configurations, and documents that haven\'t been updated within threshold periods. Helps maintain current documentation.',
|
|
305
|
+
inputSchema: {
|
|
306
|
+
type: 'object',
|
|
307
|
+
properties: {
|
|
308
|
+
organization_id: {
|
|
309
|
+
type: 'string',
|
|
310
|
+
description: 'Organization ID to check for stale data',
|
|
311
|
+
},
|
|
312
|
+
thresholds: {
|
|
313
|
+
type: 'object',
|
|
314
|
+
properties: {
|
|
315
|
+
passwords_days: {
|
|
316
|
+
type: 'number',
|
|
317
|
+
default: 180,
|
|
318
|
+
description: 'Days since password update to consider stale',
|
|
319
|
+
},
|
|
320
|
+
configurations_days: {
|
|
321
|
+
type: 'number',
|
|
322
|
+
default: 90,
|
|
323
|
+
description: 'Days since config update to consider stale',
|
|
324
|
+
},
|
|
325
|
+
documents_days: {
|
|
326
|
+
type: 'number',
|
|
327
|
+
default: 365,
|
|
328
|
+
description: 'Days since document update to consider stale',
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
description: 'Staleness thresholds in days',
|
|
332
|
+
},
|
|
333
|
+
},
|
|
334
|
+
required: ['organization_id'],
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
// Auxiliary Tools: Data Validation
|
|
338
|
+
{
|
|
339
|
+
name: 'itglue_validate_data',
|
|
340
|
+
description: '✓ Validate ITGlue data quality and completeness. Checks for missing information, duplicates, broken relationships, and data quality issues. Generates quality score and recommendations.',
|
|
341
|
+
inputSchema: {
|
|
342
|
+
type: 'object',
|
|
343
|
+
properties: {
|
|
344
|
+
organization_id: {
|
|
345
|
+
type: 'string',
|
|
346
|
+
description: 'Organization ID to validate',
|
|
347
|
+
},
|
|
348
|
+
validation_types: {
|
|
349
|
+
type: 'array',
|
|
350
|
+
items: {
|
|
351
|
+
type: 'string',
|
|
352
|
+
enum: ['completeness', 'duplicates', 'relationships', 'quality'],
|
|
353
|
+
},
|
|
354
|
+
default: ['completeness', 'quality'],
|
|
355
|
+
description: 'Types of validation to perform',
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
required: ['organization_id'],
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
// Auxiliary Tools: Reporting
|
|
362
|
+
{
|
|
363
|
+
name: 'itglue_generate_report',
|
|
364
|
+
description: '📊 Generate comprehensive reports for ITGlue organizations. Available report types: full (complete overview), summary (quick stats), security (compliance & vulnerabilities), asset-inventory (detailed asset list).',
|
|
365
|
+
inputSchema: {
|
|
366
|
+
type: 'object',
|
|
367
|
+
properties: {
|
|
368
|
+
organization_id: {
|
|
369
|
+
type: 'string',
|
|
370
|
+
description: 'Organization ID to generate report for',
|
|
371
|
+
},
|
|
372
|
+
report_type: {
|
|
373
|
+
type: 'string',
|
|
374
|
+
enum: ['full', 'summary', 'security', 'asset-inventory'],
|
|
375
|
+
default: 'summary',
|
|
376
|
+
description: 'Type of report to generate',
|
|
377
|
+
},
|
|
378
|
+
include_sensitive: {
|
|
379
|
+
type: 'boolean',
|
|
380
|
+
default: false,
|
|
381
|
+
description: 'Include sensitive data like password counts (not values)',
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
required: ['organization_id'],
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
// Auxiliary Tools: Health Check
|
|
388
|
+
{
|
|
389
|
+
name: 'itglue_health_check',
|
|
390
|
+
description: '💚 Check ITGlue MCP Server health status. Monitors API connectivity, rate limits, cache performance, and authentication. Essential for troubleshooting and performance monitoring.',
|
|
391
|
+
inputSchema: {
|
|
392
|
+
type: 'object',
|
|
393
|
+
properties: {
|
|
394
|
+
checks: {
|
|
395
|
+
type: 'array',
|
|
396
|
+
items: {
|
|
397
|
+
type: 'string',
|
|
398
|
+
enum: ['connectivity', 'rate-limits', 'cache', 'authentication'],
|
|
399
|
+
},
|
|
400
|
+
default: ['connectivity', 'rate-limits', 'cache'],
|
|
401
|
+
description: 'Health checks to perform',
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
/**
|
|
410
|
+
* Register tools/call handler
|
|
411
|
+
*/
|
|
412
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
413
|
+
const { name, arguments: args } = request.params;
|
|
414
|
+
try {
|
|
415
|
+
logger.debug('Tool called', { name, args });
|
|
416
|
+
switch (name) {
|
|
417
|
+
// Tier 1: Discovery
|
|
418
|
+
case 'itglue_search_organizations': {
|
|
419
|
+
const parsed = SearchOrganizationsSchema.parse(args);
|
|
420
|
+
return await searchOrganizations(client, parsed);
|
|
421
|
+
}
|
|
422
|
+
case 'itglue_list_organization_types': {
|
|
423
|
+
const parsed = ListOrganizationTypesSchema.parse(args);
|
|
424
|
+
return await listOrganizationTypes(client, parsed);
|
|
425
|
+
}
|
|
426
|
+
case 'itglue_search_global': {
|
|
427
|
+
const parsed = GlobalSearchSchema.parse(args);
|
|
428
|
+
return await globalSearch(client, parsed);
|
|
429
|
+
}
|
|
430
|
+
// Tier 2: Entity Navigation
|
|
431
|
+
case 'itglue_list_configurations': {
|
|
432
|
+
const parsed = ListConfigurationsSchema.parse(args);
|
|
433
|
+
return await listConfigurations(client, parsed);
|
|
434
|
+
}
|
|
435
|
+
case 'itglue_list_passwords': {
|
|
436
|
+
const parsed = ListPasswordsSchema.parse(args);
|
|
437
|
+
return await listPasswords(client, parsed);
|
|
438
|
+
}
|
|
439
|
+
case 'itglue_list_flexible_assets': {
|
|
440
|
+
const parsed = ListFlexibleAssetsSchema.parse(args);
|
|
441
|
+
return await listFlexibleAssets(client, parsed);
|
|
442
|
+
}
|
|
443
|
+
case 'itglue_list_documents': {
|
|
444
|
+
const parsed = ListDocumentsSchema.parse(args);
|
|
445
|
+
return await listDocuments(client, parsed);
|
|
446
|
+
}
|
|
447
|
+
// Tier 3: Detail Retrieval
|
|
448
|
+
case 'itglue_get_password': {
|
|
449
|
+
const parsed = GetPasswordSchema.parse(args);
|
|
450
|
+
return await getPassword(client, parsed);
|
|
451
|
+
}
|
|
452
|
+
case 'itglue_get_flexible_asset': {
|
|
453
|
+
const parsed = GetFlexibleAssetSchema.parse(args);
|
|
454
|
+
return await getFlexibleAsset(client, parsed);
|
|
455
|
+
}
|
|
456
|
+
// Auxiliary Tools
|
|
457
|
+
case 'itglue_compliance_check': {
|
|
458
|
+
const parsed = ComplianceCheckSchema.parse(args);
|
|
459
|
+
return await performComplianceCheck(client, parsed);
|
|
460
|
+
}
|
|
461
|
+
case 'itglue_detect_staleness': {
|
|
462
|
+
const parsed = StalenessCheckSchema.parse(args);
|
|
463
|
+
return await detectStaleness(client, parsed);
|
|
464
|
+
}
|
|
465
|
+
case 'itglue_validate_data': {
|
|
466
|
+
const parsed = DataValidationSchema.parse(args);
|
|
467
|
+
return await validateData(client, parsed);
|
|
468
|
+
}
|
|
469
|
+
case 'itglue_generate_report': {
|
|
470
|
+
const parsed = OrganizationReportSchema.parse(args);
|
|
471
|
+
return await generateOrganizationReport(client, parsed);
|
|
472
|
+
}
|
|
473
|
+
case 'itglue_health_check': {
|
|
474
|
+
const parsed = HealthCheckSchema.parse(args);
|
|
475
|
+
return await performHealthCheck(client, parsed);
|
|
476
|
+
}
|
|
477
|
+
default:
|
|
478
|
+
return {
|
|
479
|
+
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
|
480
|
+
isError: true,
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
catch (error) {
|
|
485
|
+
logger.logError(error, { tool: name, args });
|
|
486
|
+
return {
|
|
487
|
+
content: [
|
|
488
|
+
{
|
|
489
|
+
type: 'text',
|
|
490
|
+
text: `Error executing ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
491
|
+
},
|
|
492
|
+
],
|
|
493
|
+
isError: true,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
// Connect to STDIO transport
|
|
498
|
+
const transport = new StdioServerTransport();
|
|
499
|
+
await server.connect(transport);
|
|
500
|
+
logger.debug('ITGlue MCP Server running on STDIO transport');
|
|
501
|
+
}
|
|
502
|
+
catch (error) {
|
|
503
|
+
logger.logError(error);
|
|
504
|
+
console.error('Fatal error:', error);
|
|
505
|
+
process.exit(1);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
// Start the server
|
|
509
|
+
main().catch((error) => {
|
|
510
|
+
console.error('Fatal error:', error);
|
|
511
|
+
process.exit(1);
|
|
512
|
+
});
|
|
513
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,mCAAmC;AACnC,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE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,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEhC,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,QAAQ,CAAC,KAAc,CAAC,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,mBAAmB;AACnB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ITGlue API Client
|
|
3
|
+
* Integrates rate limiting, caching, retry logic, and error handling
|
|
4
|
+
*/
|
|
5
|
+
import type { JsonApiResponse, ApiParams, ITGlueRegion } from '../types/itglue.js';
|
|
6
|
+
export interface APIClientConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
region?: ITGlueRegion;
|
|
9
|
+
baseURL?: string;
|
|
10
|
+
cacheTTL?: number;
|
|
11
|
+
rateLimit?: number;
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class APIClient {
|
|
15
|
+
private readonly axios;
|
|
16
|
+
private readonly cache;
|
|
17
|
+
private readonly rateLimiter;
|
|
18
|
+
private readonly logger;
|
|
19
|
+
private readonly maxRetries;
|
|
20
|
+
private readonly retryDelays;
|
|
21
|
+
constructor(config: APIClientConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Validate configuration
|
|
24
|
+
*/
|
|
25
|
+
private validateConfig;
|
|
26
|
+
/**
|
|
27
|
+
* GET request with caching and rate limiting
|
|
28
|
+
*/
|
|
29
|
+
get<T>(endpoint: string, params?: ApiParams, options?: {
|
|
30
|
+
skipCache?: boolean;
|
|
31
|
+
cacheTTL?: number;
|
|
32
|
+
organizationId?: string;
|
|
33
|
+
}): Promise<JsonApiResponse<T>>;
|
|
34
|
+
/**
|
|
35
|
+
* Execute request with retry logic
|
|
36
|
+
*/
|
|
37
|
+
private requestWithRetry;
|
|
38
|
+
/**
|
|
39
|
+
* Get all pages of a paginated endpoint
|
|
40
|
+
* Follows JSON:API links.next pattern
|
|
41
|
+
*/
|
|
42
|
+
getAllPages<T>(endpoint: string, params?: ApiParams, options?: {
|
|
43
|
+
maxPages?: number;
|
|
44
|
+
cacheTTL?: number;
|
|
45
|
+
organizationId?: string;
|
|
46
|
+
}): Promise<JsonApiResponse<T>[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Log rate limit headers from response
|
|
49
|
+
*/
|
|
50
|
+
private logRateLimitHeaders;
|
|
51
|
+
/**
|
|
52
|
+
* Sleep for specified milliseconds
|
|
53
|
+
*/
|
|
54
|
+
private sleep;
|
|
55
|
+
/**
|
|
56
|
+
* Invalidate cache entries matching pattern
|
|
57
|
+
*/
|
|
58
|
+
invalidateCache(pattern: RegExp): number;
|
|
59
|
+
/**
|
|
60
|
+
* Get client statistics
|
|
61
|
+
*/
|
|
62
|
+
getStats(): {
|
|
63
|
+
cache: {
|
|
64
|
+
size: number;
|
|
65
|
+
maxSize: number;
|
|
66
|
+
utilization: number;
|
|
67
|
+
};
|
|
68
|
+
rateLimiter: {
|
|
69
|
+
queueSize: number;
|
|
70
|
+
requestsInLastSecond: number;
|
|
71
|
+
maxRequestsPerSecond: number;
|
|
72
|
+
utilization: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../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