latitude-mcp-server 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/.releaserc.json +34 -0
- package/README.md +687 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +43 -0
- package/dist/cli/latitude.cli.d.ts +10 -0
- package/dist/cli/latitude.cli.js +286 -0
- package/dist/controllers/latitude.controller.d.ts +115 -0
- package/dist/controllers/latitude.controller.js +287 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +166 -0
- package/dist/resources/latitude.resource.d.ts +12 -0
- package/dist/resources/latitude.resource.js +145 -0
- package/dist/services/vendor.latitude.service.d.ts +49 -0
- package/dist/services/vendor.latitude.service.js +294 -0
- package/dist/tools/latitude.tool.d.ts +6 -0
- package/dist/tools/latitude.tool.js +517 -0
- package/dist/types/common.types.d.ts +20 -0
- package/dist/types/common.types.js +7 -0
- package/dist/types/latitude.types.d.ts +487 -0
- package/dist/types/latitude.types.js +311 -0
- package/dist/utils/cli.test.util.d.ts +34 -0
- package/dist/utils/cli.test.util.js +143 -0
- package/dist/utils/config.util.d.ts +43 -0
- package/dist/utils/config.util.js +145 -0
- package/dist/utils/config.util.test.d.ts +1 -0
- package/dist/utils/constants.util.d.ts +26 -0
- package/dist/utils/constants.util.js +29 -0
- package/dist/utils/error-handler.util.d.ts +54 -0
- package/dist/utils/error-handler.util.js +202 -0
- package/dist/utils/error-handler.util.test.d.ts +1 -0
- package/dist/utils/error.util.d.ts +73 -0
- package/dist/utils/error.util.js +174 -0
- package/dist/utils/error.util.test.d.ts +1 -0
- package/dist/utils/formatter.util.d.ts +36 -0
- package/dist/utils/formatter.util.js +116 -0
- package/dist/utils/jest.setup.d.ts +5 -0
- package/dist/utils/jest.setup.js +36 -0
- package/dist/utils/jq.util.d.ts +34 -0
- package/dist/utils/jq.util.js +87 -0
- package/dist/utils/logger.util.d.ts +78 -0
- package/dist/utils/logger.util.js +344 -0
- package/dist/utils/toon.util.d.ts +15 -0
- package/dist/utils/toon.util.js +65 -0
- package/dist/utils/transport.util.d.ts +49 -0
- package/dist/utils/transport.util.js +162 -0
- package/eslint.config.mjs +46 -0
- package/openapi.json +12592 -0
- package/package.json +118 -0
- package/scripts/ensure-executable.js +38 -0
- package/scripts/package.json +3 -0
- package/scripts/update-version.js +204 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Standardized formatting utilities for consistent output across all CLI and Tool interfaces.
|
|
4
|
+
* These functions should be used by all formatters to ensure consistent formatting.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.formatDate = formatDate;
|
|
8
|
+
exports.formatUrl = formatUrl;
|
|
9
|
+
exports.formatHeading = formatHeading;
|
|
10
|
+
exports.formatBulletList = formatBulletList;
|
|
11
|
+
exports.formatSeparator = formatSeparator;
|
|
12
|
+
/**
|
|
13
|
+
* Format a date in a standardized way: YYYY-MM-DD HH:MM:SS UTC
|
|
14
|
+
* @param dateString - ISO date string or Date object
|
|
15
|
+
* @returns Formatted date string
|
|
16
|
+
*/
|
|
17
|
+
function formatDate(dateString) {
|
|
18
|
+
if (!dateString) {
|
|
19
|
+
return 'Not available';
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const date = typeof dateString === 'string' ? new Date(dateString) : dateString;
|
|
23
|
+
// Format: YYYY-MM-DD HH:MM:SS UTC
|
|
24
|
+
return date
|
|
25
|
+
.toISOString()
|
|
26
|
+
.replace('T', ' ')
|
|
27
|
+
.replace(/\.\d+Z$/, ' UTC');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return 'Invalid date';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Format a URL as a markdown link
|
|
35
|
+
* @param url - URL to format
|
|
36
|
+
* @param title - Link title
|
|
37
|
+
* @returns Formatted markdown link
|
|
38
|
+
*/
|
|
39
|
+
function formatUrl(url, title) {
|
|
40
|
+
if (!url) {
|
|
41
|
+
return 'Not available';
|
|
42
|
+
}
|
|
43
|
+
const linkTitle = title || url;
|
|
44
|
+
return `[${linkTitle}](${url})`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format a heading with consistent style
|
|
48
|
+
* @param text - Heading text
|
|
49
|
+
* @param level - Heading level (1-6)
|
|
50
|
+
* @returns Formatted heading
|
|
51
|
+
*/
|
|
52
|
+
function formatHeading(text, level = 1) {
|
|
53
|
+
const validLevel = Math.min(Math.max(level, 1), 6);
|
|
54
|
+
const prefix = '#'.repeat(validLevel);
|
|
55
|
+
return `${prefix} ${text}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Format a list of key-value pairs as a bullet list
|
|
59
|
+
* @param items - Object with key-value pairs
|
|
60
|
+
* @param keyFormatter - Optional function to format keys
|
|
61
|
+
* @returns Formatted bullet list
|
|
62
|
+
*/
|
|
63
|
+
function formatBulletList(items, keyFormatter) {
|
|
64
|
+
const lines = [];
|
|
65
|
+
for (const [key, value] of Object.entries(items)) {
|
|
66
|
+
if (value === undefined || value === null) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const formattedKey = keyFormatter ? keyFormatter(key) : key;
|
|
70
|
+
const formattedValue = formatValue(value);
|
|
71
|
+
lines.push(`- **${formattedKey}**: ${formattedValue}`);
|
|
72
|
+
}
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Format a value based on its type
|
|
77
|
+
* @param value - Value to format
|
|
78
|
+
* @returns Formatted value
|
|
79
|
+
*/
|
|
80
|
+
function formatValue(value) {
|
|
81
|
+
if (value === undefined || value === null) {
|
|
82
|
+
return 'Not available';
|
|
83
|
+
}
|
|
84
|
+
if (value instanceof Date) {
|
|
85
|
+
return formatDate(value);
|
|
86
|
+
}
|
|
87
|
+
// Handle URL objects with url and title properties
|
|
88
|
+
if (typeof value === 'object' && value !== null && 'url' in value) {
|
|
89
|
+
const urlObj = value;
|
|
90
|
+
if (typeof urlObj.url === 'string') {
|
|
91
|
+
return formatUrl(urlObj.url, urlObj.title);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (typeof value === 'string') {
|
|
95
|
+
// Check if it's a URL
|
|
96
|
+
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
97
|
+
return formatUrl(value);
|
|
98
|
+
}
|
|
99
|
+
// Check if it might be a date
|
|
100
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value)) {
|
|
101
|
+
return formatDate(value);
|
|
102
|
+
}
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
if (typeof value === 'boolean') {
|
|
106
|
+
return value ? 'Yes' : 'No';
|
|
107
|
+
}
|
|
108
|
+
return String(value);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Format a separator line
|
|
112
|
+
* @returns Separator line
|
|
113
|
+
*/
|
|
114
|
+
function formatSeparator() {
|
|
115
|
+
return '---';
|
|
116
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Jest global setup for suppressing console output during tests
|
|
4
|
+
* This file is used to mock console methods to reduce noise in test output
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const globals_1 = require("@jest/globals");
|
|
8
|
+
// Store original console methods
|
|
9
|
+
const originalConsole = {
|
|
10
|
+
log: console.log,
|
|
11
|
+
info: console.info,
|
|
12
|
+
warn: console.warn,
|
|
13
|
+
error: console.error,
|
|
14
|
+
debug: console.debug,
|
|
15
|
+
};
|
|
16
|
+
// Global setup to suppress console output during tests
|
|
17
|
+
(0, globals_1.beforeEach)(() => {
|
|
18
|
+
// Mock console methods to suppress output
|
|
19
|
+
console.log = globals_1.jest.fn();
|
|
20
|
+
console.info = globals_1.jest.fn();
|
|
21
|
+
console.warn = globals_1.jest.fn();
|
|
22
|
+
console.error = globals_1.jest.fn();
|
|
23
|
+
console.debug = globals_1.jest.fn();
|
|
24
|
+
});
|
|
25
|
+
(0, globals_1.afterEach)(() => {
|
|
26
|
+
// Clear mock calls after each test
|
|
27
|
+
globals_1.jest.clearAllMocks();
|
|
28
|
+
});
|
|
29
|
+
(0, globals_1.afterAll)(() => {
|
|
30
|
+
// Restore original console methods after all tests
|
|
31
|
+
console.log = originalConsole.log;
|
|
32
|
+
console.info = originalConsole.info;
|
|
33
|
+
console.warn = originalConsole.warn;
|
|
34
|
+
console.error = originalConsole.error;
|
|
35
|
+
console.debug = originalConsole.debug;
|
|
36
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apply a JMESPath filter to JSON data
|
|
3
|
+
*
|
|
4
|
+
* @param data - The data to filter (any JSON-serializable value)
|
|
5
|
+
* @param filter - JMESPath expression to apply
|
|
6
|
+
* @returns Filtered data or original data if filter is empty/invalid
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Get single field
|
|
10
|
+
* applyJqFilter(data, "name")
|
|
11
|
+
*
|
|
12
|
+
* // Get nested field
|
|
13
|
+
* applyJqFilter(data, "body.storage.value")
|
|
14
|
+
*
|
|
15
|
+
* // Get multiple fields as object
|
|
16
|
+
* applyJqFilter(data, "{id: id, title: title}")
|
|
17
|
+
*
|
|
18
|
+
* // Array operations
|
|
19
|
+
* applyJqFilter(data, "results[*].title")
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyJqFilter(data: unknown, filter?: string): unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Convert data to output string for MCP response
|
|
24
|
+
*
|
|
25
|
+
* By default, converts to TOON format (Token-Oriented Object Notation)
|
|
26
|
+
* for improved LLM token efficiency (30-60% fewer tokens).
|
|
27
|
+
* Falls back to JSON if TOON conversion fails or if useToon is false.
|
|
28
|
+
*
|
|
29
|
+
* @param data - The data to convert
|
|
30
|
+
* @param useToon - Whether to use TOON format (default: true)
|
|
31
|
+
* @param pretty - Whether to pretty-print JSON (default: true)
|
|
32
|
+
* @returns TOON formatted string (default), or JSON string
|
|
33
|
+
*/
|
|
34
|
+
export declare function toOutputString(data: unknown, useToon?: boolean, pretty?: boolean): Promise<string>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.applyJqFilter = applyJqFilter;
|
|
7
|
+
exports.toOutputString = toOutputString;
|
|
8
|
+
const jmespath_1 = __importDefault(require("jmespath"));
|
|
9
|
+
const logger_util_js_1 = require("./logger.util.js");
|
|
10
|
+
const toon_util_js_1 = require("./toon.util.js");
|
|
11
|
+
const logger = logger_util_js_1.Logger.forContext('utils/jq.util.ts');
|
|
12
|
+
/**
|
|
13
|
+
* Apply a JMESPath filter to JSON data
|
|
14
|
+
*
|
|
15
|
+
* @param data - The data to filter (any JSON-serializable value)
|
|
16
|
+
* @param filter - JMESPath expression to apply
|
|
17
|
+
* @returns Filtered data or original data if filter is empty/invalid
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Get single field
|
|
21
|
+
* applyJqFilter(data, "name")
|
|
22
|
+
*
|
|
23
|
+
* // Get nested field
|
|
24
|
+
* applyJqFilter(data, "body.storage.value")
|
|
25
|
+
*
|
|
26
|
+
* // Get multiple fields as object
|
|
27
|
+
* applyJqFilter(data, "{id: id, title: title}")
|
|
28
|
+
*
|
|
29
|
+
* // Array operations
|
|
30
|
+
* applyJqFilter(data, "results[*].title")
|
|
31
|
+
*/
|
|
32
|
+
function applyJqFilter(data, filter) {
|
|
33
|
+
const methodLogger = logger.forMethod('applyJqFilter');
|
|
34
|
+
// Return original data if no filter provided
|
|
35
|
+
if (!filter || filter.trim() === '') {
|
|
36
|
+
methodLogger.debug('No filter provided, returning original data');
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
methodLogger.debug(`Applying JMESPath filter: ${filter}`);
|
|
41
|
+
const result = jmespath_1.default.search(data, filter);
|
|
42
|
+
methodLogger.debug('Filter applied successfully');
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
methodLogger.error(`Invalid JMESPath expression: ${filter}`, error);
|
|
47
|
+
// Return original data with error info if filter is invalid
|
|
48
|
+
return {
|
|
49
|
+
_jqError: `Invalid JMESPath expression: ${filter}`,
|
|
50
|
+
_originalData: data,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Convert data to JSON string for MCP response
|
|
56
|
+
*
|
|
57
|
+
* @param data - The data to stringify
|
|
58
|
+
* @param pretty - Whether to pretty-print the JSON (default: true)
|
|
59
|
+
* @returns JSON string
|
|
60
|
+
*/
|
|
61
|
+
function toJsonString(data, pretty = true) {
|
|
62
|
+
if (pretty) {
|
|
63
|
+
return JSON.stringify(data, null, 2);
|
|
64
|
+
}
|
|
65
|
+
return JSON.stringify(data);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert data to output string for MCP response
|
|
69
|
+
*
|
|
70
|
+
* By default, converts to TOON format (Token-Oriented Object Notation)
|
|
71
|
+
* for improved LLM token efficiency (30-60% fewer tokens).
|
|
72
|
+
* Falls back to JSON if TOON conversion fails or if useToon is false.
|
|
73
|
+
*
|
|
74
|
+
* @param data - The data to convert
|
|
75
|
+
* @param useToon - Whether to use TOON format (default: true)
|
|
76
|
+
* @param pretty - Whether to pretty-print JSON (default: true)
|
|
77
|
+
* @returns TOON formatted string (default), or JSON string
|
|
78
|
+
*/
|
|
79
|
+
async function toOutputString(data, useToon = true, pretty = true) {
|
|
80
|
+
const jsonString = toJsonString(data, pretty);
|
|
81
|
+
// Return JSON directly if TOON is not requested
|
|
82
|
+
if (!useToon) {
|
|
83
|
+
return jsonString;
|
|
84
|
+
}
|
|
85
|
+
// Try TOON conversion with JSON fallback
|
|
86
|
+
return (0, toon_util_js_1.toToonOrJson)(data, jsonString);
|
|
87
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger class for consistent logging across the application.
|
|
3
|
+
*
|
|
4
|
+
* RECOMMENDED USAGE:
|
|
5
|
+
*
|
|
6
|
+
* 1. Create a file-level logger using the static forContext method:
|
|
7
|
+
* ```
|
|
8
|
+
* const logger = Logger.forContext('controllers/myController.ts');
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* 2. For method-specific logging, create a method logger:
|
|
12
|
+
* ```
|
|
13
|
+
* const methodLogger = Logger.forContext('controllers/myController.ts', 'myMethod');
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* 3. Avoid using raw string prefixes in log messages. Instead, use contextualized loggers.
|
|
17
|
+
*
|
|
18
|
+
* 4. For debugging objects, use the debugResponse method to log only essential properties.
|
|
19
|
+
*
|
|
20
|
+
* 5. Set DEBUG environment variable to control which modules show debug logs:
|
|
21
|
+
* - DEBUG=true (enable all debug logs)
|
|
22
|
+
* - DEBUG=controllers/*,services/* (enable for specific module groups)
|
|
23
|
+
* - DEBUG=transport,utils/formatter* (enable specific modules, supports wildcards)
|
|
24
|
+
*/
|
|
25
|
+
declare class Logger {
|
|
26
|
+
private context?;
|
|
27
|
+
private modulePath;
|
|
28
|
+
private static sessionId;
|
|
29
|
+
private static logFilePath;
|
|
30
|
+
constructor(context?: string, modulePath?: string);
|
|
31
|
+
/**
|
|
32
|
+
* Create a contextualized logger for a specific file or component.
|
|
33
|
+
* This is the preferred method for creating loggers.
|
|
34
|
+
*
|
|
35
|
+
* @param filePath The file path (e.g., 'controllers/aws.sso.auth.controller.ts')
|
|
36
|
+
* @param functionName Optional function name for more specific context
|
|
37
|
+
* @returns A new Logger instance with the specified context
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // File-level logger
|
|
41
|
+
* const logger = Logger.forContext('controllers/myController.ts');
|
|
42
|
+
*
|
|
43
|
+
* // Method-level logger
|
|
44
|
+
* const methodLogger = Logger.forContext('controllers/myController.ts', 'myMethod');
|
|
45
|
+
*/
|
|
46
|
+
static forContext(filePath: string, functionName?: string): Logger;
|
|
47
|
+
/**
|
|
48
|
+
* Create a method level logger from a context logger
|
|
49
|
+
* @param method Method name
|
|
50
|
+
* @returns A new logger with the method context
|
|
51
|
+
*/
|
|
52
|
+
forMethod(method: string): Logger;
|
|
53
|
+
private _formatMessage;
|
|
54
|
+
private _formatArgs;
|
|
55
|
+
_log(level: 'info' | 'warn' | 'error' | 'debug', message: string, ...args: unknown[]): void;
|
|
56
|
+
info(message: string, ...args: unknown[]): void;
|
|
57
|
+
warn(message: string, ...args: unknown[]): void;
|
|
58
|
+
error(message: string, ...args: unknown[]): void;
|
|
59
|
+
debug(message: string, ...args: unknown[]): void;
|
|
60
|
+
/**
|
|
61
|
+
* Log essential information about an API response
|
|
62
|
+
* @param message Log message
|
|
63
|
+
* @param response API response object
|
|
64
|
+
* @param essentialKeys Keys to extract from the response
|
|
65
|
+
*/
|
|
66
|
+
debugResponse(message: string, response: Record<string, unknown>, essentialKeys: string[]): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get the current session ID
|
|
69
|
+
* @returns The UUID for the current logging session
|
|
70
|
+
*/
|
|
71
|
+
static getSessionId(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get the current log file path
|
|
74
|
+
* @returns The path to the current log file
|
|
75
|
+
*/
|
|
76
|
+
static getLogFilePath(): string;
|
|
77
|
+
}
|
|
78
|
+
export { Logger };
|