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.
Files changed (51) hide show
  1. package/.releaserc.json +34 -0
  2. package/README.md +687 -0
  3. package/dist/cli/index.d.ts +7 -0
  4. package/dist/cli/index.js +43 -0
  5. package/dist/cli/latitude.cli.d.ts +10 -0
  6. package/dist/cli/latitude.cli.js +286 -0
  7. package/dist/controllers/latitude.controller.d.ts +115 -0
  8. package/dist/controllers/latitude.controller.js +287 -0
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.js +166 -0
  11. package/dist/resources/latitude.resource.d.ts +12 -0
  12. package/dist/resources/latitude.resource.js +145 -0
  13. package/dist/services/vendor.latitude.service.d.ts +49 -0
  14. package/dist/services/vendor.latitude.service.js +294 -0
  15. package/dist/tools/latitude.tool.d.ts +6 -0
  16. package/dist/tools/latitude.tool.js +517 -0
  17. package/dist/types/common.types.d.ts +20 -0
  18. package/dist/types/common.types.js +7 -0
  19. package/dist/types/latitude.types.d.ts +487 -0
  20. package/dist/types/latitude.types.js +311 -0
  21. package/dist/utils/cli.test.util.d.ts +34 -0
  22. package/dist/utils/cli.test.util.js +143 -0
  23. package/dist/utils/config.util.d.ts +43 -0
  24. package/dist/utils/config.util.js +145 -0
  25. package/dist/utils/config.util.test.d.ts +1 -0
  26. package/dist/utils/constants.util.d.ts +26 -0
  27. package/dist/utils/constants.util.js +29 -0
  28. package/dist/utils/error-handler.util.d.ts +54 -0
  29. package/dist/utils/error-handler.util.js +202 -0
  30. package/dist/utils/error-handler.util.test.d.ts +1 -0
  31. package/dist/utils/error.util.d.ts +73 -0
  32. package/dist/utils/error.util.js +174 -0
  33. package/dist/utils/error.util.test.d.ts +1 -0
  34. package/dist/utils/formatter.util.d.ts +36 -0
  35. package/dist/utils/formatter.util.js +116 -0
  36. package/dist/utils/jest.setup.d.ts +5 -0
  37. package/dist/utils/jest.setup.js +36 -0
  38. package/dist/utils/jq.util.d.ts +34 -0
  39. package/dist/utils/jq.util.js +87 -0
  40. package/dist/utils/logger.util.d.ts +78 -0
  41. package/dist/utils/logger.util.js +344 -0
  42. package/dist/utils/toon.util.d.ts +15 -0
  43. package/dist/utils/toon.util.js +65 -0
  44. package/dist/utils/transport.util.d.ts +49 -0
  45. package/dist/utils/transport.util.js +162 -0
  46. package/eslint.config.mjs +46 -0
  47. package/openapi.json +12592 -0
  48. package/package.json +118 -0
  49. package/scripts/ensure-executable.js +38 -0
  50. package/scripts/package.json +3 -0
  51. package/scripts/update-version.js +204 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Run the CLI with the provided arguments
3
+ *
4
+ * @param args Command line arguments to process
5
+ * @returns Promise that resolves when CLI command execution completes
6
+ */
7
+ export declare function runCli(args: string[]): Promise<void>;
@@ -0,0 +1,43 @@
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.runCli = runCli;
7
+ const commander_1 = require("commander");
8
+ const logger_util_js_1 = require("../utils/logger.util.js");
9
+ const constants_util_js_1 = require("../utils/constants.util.js");
10
+ const latitude_cli_js_1 = __importDefault(require("./latitude.cli.js"));
11
+ /**
12
+ * CLI entry point for the Latitude MCP Server
13
+ * Handles command registration, parsing, and execution
14
+ */
15
+ // Package description
16
+ const DESCRIPTION = 'MCP server for Latitude prompt management - manage prompts, versions, and run AI conversations';
17
+ /**
18
+ * Run the CLI with the provided arguments
19
+ *
20
+ * @param args Command line arguments to process
21
+ * @returns Promise that resolves when CLI command execution completes
22
+ */
23
+ async function runCli(args) {
24
+ const cliLogger = logger_util_js_1.Logger.forContext('cli/index.ts', 'runCli');
25
+ cliLogger.debug('Initializing CLI with arguments', args);
26
+ const program = new commander_1.Command();
27
+ program.name(constants_util_js_1.CLI_NAME).description(DESCRIPTION).version(constants_util_js_1.VERSION);
28
+ // Register CLI commands
29
+ cliLogger.debug('Registering CLI commands...');
30
+ latitude_cli_js_1.default.register(program);
31
+ cliLogger.debug('CLI commands registered successfully');
32
+ // Handle unknown commands
33
+ program.on('command:*', (operands) => {
34
+ cliLogger.error(`Unknown command: ${operands[0]}`);
35
+ console.log('');
36
+ program.help();
37
+ process.exit(1);
38
+ });
39
+ // Parse arguments; default to help if no command provided
40
+ cliLogger.debug('Parsing CLI arguments');
41
+ await program.parseAsync(args.length ? args : ['--help'], { from: 'user' });
42
+ cliLogger.debug('CLI command execution completed');
43
+ }
@@ -0,0 +1,10 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * Register Latitude CLI commands
4
+ * @param program The Commander program instance
5
+ */
6
+ declare function register(program: Command): void;
7
+ declare const _default: {
8
+ register: typeof register;
9
+ };
10
+ export default _default;
@@ -0,0 +1,286 @@
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
+ const fs_1 = require("fs");
7
+ const path_1 = require("path");
8
+ const logger_util_js_1 = require("../utils/logger.util.js");
9
+ const error_util_js_1 = require("../utils/error.util.js");
10
+ const latitude_controller_js_1 = __importDefault(require("../controllers/latitude.controller.js"));
11
+ /**
12
+ * Read content from file path or stdin
13
+ */
14
+ function readContentFromFile(filePath) {
15
+ const absolutePath = (0, path_1.resolve)(filePath);
16
+ if (!(0, fs_1.existsSync)(absolutePath)) {
17
+ throw new Error(`File not found: ${absolutePath}`);
18
+ }
19
+ return (0, fs_1.readFileSync)(absolutePath, 'utf-8');
20
+ }
21
+ /**
22
+ * Derive prompt path from filename if not provided
23
+ * e.g., "/path/to/my-prompt.md" → "my-prompt"
24
+ */
25
+ function derivePromptPath(filePath) {
26
+ const base = (0, path_1.basename)(filePath);
27
+ const ext = (0, path_1.extname)(base);
28
+ // Remove .md, .promptl, .txt extensions
29
+ if (['.md', '.promptl', '.txt'].includes(ext)) {
30
+ return base.slice(0, -ext.length);
31
+ }
32
+ return base;
33
+ }
34
+ const logger = logger_util_js_1.Logger.forContext('cli/latitude.cli.ts');
35
+ /**
36
+ * Register Latitude CLI commands
37
+ * @param program The Commander program instance
38
+ */
39
+ function register(program) {
40
+ const methodLogger = logger.forMethod('register');
41
+ methodLogger.debug('Registering Latitude CLI commands...');
42
+ // Projects command group
43
+ const projects = program
44
+ .command('projects')
45
+ .description('Manage Latitude projects');
46
+ projects
47
+ .command('list')
48
+ .description('List all projects in your workspace')
49
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
50
+ .action(async (options) => {
51
+ try {
52
+ const result = await latitude_controller_js_1.default.listProjects({
53
+ outputFormat: options.outputFormat,
54
+ });
55
+ console.log(result.content);
56
+ }
57
+ catch (error) {
58
+ (0, error_util_js_1.handleCliError)(error);
59
+ }
60
+ });
61
+ projects
62
+ .command('create <name>')
63
+ .description('Create a new project')
64
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
65
+ .action(async (name, options) => {
66
+ try {
67
+ const result = await latitude_controller_js_1.default.createProject({
68
+ name,
69
+ outputFormat: options.outputFormat,
70
+ });
71
+ console.log(result.content);
72
+ }
73
+ catch (error) {
74
+ (0, error_util_js_1.handleCliError)(error);
75
+ }
76
+ });
77
+ // Versions command group
78
+ const versions = program
79
+ .command('versions')
80
+ .description('Manage project versions');
81
+ versions
82
+ .command('list <projectId>')
83
+ .description('List all versions for a project')
84
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
85
+ .action(async (projectId, options) => {
86
+ try {
87
+ const result = await latitude_controller_js_1.default.listVersions({
88
+ projectId,
89
+ outputFormat: options.outputFormat,
90
+ });
91
+ console.log(result.content);
92
+ }
93
+ catch (error) {
94
+ (0, error_util_js_1.handleCliError)(error);
95
+ }
96
+ });
97
+ versions
98
+ .command('create <projectId> <name>')
99
+ .description('Create a new draft version')
100
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
101
+ .action(async (projectId, name, options) => {
102
+ try {
103
+ const result = await latitude_controller_js_1.default.createVersion({
104
+ projectId,
105
+ name,
106
+ outputFormat: options.outputFormat,
107
+ });
108
+ console.log(result.content);
109
+ }
110
+ catch (error) {
111
+ (0, error_util_js_1.handleCliError)(error);
112
+ }
113
+ });
114
+ versions
115
+ .command('publish <projectId> <versionUuid>')
116
+ .description('Publish a draft version to make it live')
117
+ .option('-t, --title <title>', 'Publication title')
118
+ .option('-d, --description <description>', 'Publication description')
119
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
120
+ .action(async (projectId, versionUuid, options) => {
121
+ try {
122
+ const result = await latitude_controller_js_1.default.publishVersion({
123
+ projectId,
124
+ versionUuid,
125
+ title: options.title,
126
+ description: options.description,
127
+ outputFormat: options.outputFormat,
128
+ });
129
+ console.log(result.content);
130
+ }
131
+ catch (error) {
132
+ (0, error_util_js_1.handleCliError)(error);
133
+ }
134
+ });
135
+ // Prompts command group
136
+ const prompts = program
137
+ .command('prompts')
138
+ .description('Manage prompts/documents');
139
+ prompts
140
+ .command('list <projectId>')
141
+ .description('List all prompts in a version')
142
+ .option('-v, --version-uuid <versionUuid>', 'Version UUID (default: "live")', 'live')
143
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
144
+ .action(async (projectId, options) => {
145
+ try {
146
+ const result = await latitude_controller_js_1.default.listPrompts({
147
+ projectId,
148
+ versionUuid: options.versionUuid,
149
+ outputFormat: options.outputFormat,
150
+ });
151
+ console.log(result.content);
152
+ }
153
+ catch (error) {
154
+ (0, error_util_js_1.handleCliError)(error);
155
+ }
156
+ });
157
+ prompts
158
+ .command('get <projectId> <path>')
159
+ .description('Get a specific prompt by path')
160
+ .option('-v, --version-uuid <versionUuid>', 'Version UUID (default: "live")', 'live')
161
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
162
+ .action(async (projectId, path, options) => {
163
+ try {
164
+ const result = await latitude_controller_js_1.default.getPrompt({
165
+ projectId,
166
+ versionUuid: options.versionUuid,
167
+ path,
168
+ outputFormat: options.outputFormat,
169
+ });
170
+ console.log(result.content);
171
+ }
172
+ catch (error) {
173
+ (0, error_util_js_1.handleCliError)(error);
174
+ }
175
+ });
176
+ // Push command (standalone like git push)
177
+ // Supports: --file path/to/prompt.md OR --content "inline content"
178
+ program
179
+ .command('push <projectId> <versionUuid> [promptPath]')
180
+ .description('Push a prompt to a draft version. Use --file to read from a file, or --content for inline.')
181
+ .option('-i, --file <filePath>', 'Read prompt content from file (supports .md, .promptl)')
182
+ .option('-c, --content <content>', 'Prompt content in PromptL format (inline)')
183
+ .option('-f, --force', 'Force overwrite if exists', false)
184
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
185
+ .action(async (projectId, versionUuid, promptPath, options) => {
186
+ try {
187
+ let content;
188
+ let finalPath;
189
+ // Determine content source
190
+ if (options.file) {
191
+ // Read from file
192
+ const filePath = options.file;
193
+ content = readContentFromFile(filePath);
194
+ // Use provided promptPath or derive from filename
195
+ finalPath = promptPath || derivePromptPath(filePath);
196
+ console.log(`Reading from: ${(0, path_1.resolve)(filePath)}`);
197
+ }
198
+ else if (options.content) {
199
+ // Use inline content
200
+ content = options.content;
201
+ if (!promptPath) {
202
+ console.error('Error: promptPath is required when using --content');
203
+ process.exit(1);
204
+ }
205
+ finalPath = promptPath;
206
+ }
207
+ else {
208
+ console.error('Error: Either --file or --content is required');
209
+ console.error(' Example with file: latitude-mcp push proj123 draft456 --file ./my-prompt.md');
210
+ console.error(' Example with content: latitude-mcp push proj123 draft456 my-prompt --content "..."');
211
+ process.exit(1);
212
+ }
213
+ const result = await latitude_controller_js_1.default.pushPrompt({
214
+ projectId,
215
+ versionUuid,
216
+ path: finalPath,
217
+ content,
218
+ force: options.force,
219
+ outputFormat: options.outputFormat,
220
+ });
221
+ console.log(result.content);
222
+ }
223
+ catch (error) {
224
+ (0, error_util_js_1.handleCliError)(error);
225
+ }
226
+ });
227
+ // Run command (execute a prompt)
228
+ program
229
+ .command('run <projectId> <path>')
230
+ .description('Execute a prompt and get AI response')
231
+ .option('-v, --version-uuid <versionUuid>', 'Version UUID (default: "live")', 'live')
232
+ .option('-p, --parameters <json>', 'Parameters as JSON object')
233
+ .option('-m, --message <message>', 'Additional user message')
234
+ .option('-s, --stream', 'Enable streaming response', false)
235
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
236
+ .action(async (projectId, path, options) => {
237
+ try {
238
+ let parameters;
239
+ if (options.parameters) {
240
+ try {
241
+ parameters = JSON.parse(options.parameters);
242
+ }
243
+ catch {
244
+ console.error('Error: Invalid JSON in --parameters');
245
+ process.exit(1);
246
+ }
247
+ }
248
+ const result = await latitude_controller_js_1.default.runPrompt({
249
+ projectId,
250
+ versionUuid: options.versionUuid,
251
+ path,
252
+ parameters,
253
+ userMessage: options.message,
254
+ stream: options.stream,
255
+ outputFormat: options.outputFormat,
256
+ });
257
+ console.log(result.content);
258
+ }
259
+ catch (error) {
260
+ (0, error_util_js_1.handleCliError)(error);
261
+ }
262
+ });
263
+ // Chat command (continue conversation)
264
+ program
265
+ .command('chat <conversationUuid>')
266
+ .description('Continue a conversation')
267
+ .requiredOption('-m, --message <message>', 'User message to send')
268
+ .option('-s, --stream', 'Enable streaming response', false)
269
+ .option('-o, --output-format <format>', 'Output format: "toon" or "json"', 'toon')
270
+ .action(async (conversationUuid, options) => {
271
+ try {
272
+ const result = await latitude_controller_js_1.default.chat({
273
+ conversationUuid,
274
+ message: options.message,
275
+ stream: options.stream,
276
+ outputFormat: options.outputFormat,
277
+ });
278
+ console.log(result.content);
279
+ }
280
+ catch (error) {
281
+ (0, error_util_js_1.handleCliError)(error);
282
+ }
283
+ });
284
+ methodLogger.debug('Latitude CLI commands registered successfully');
285
+ }
286
+ exports.default = { register };
@@ -0,0 +1,115 @@
1
+ import { DocumentChange } from '../types/latitude.types.js';
2
+ /**
3
+ * Output format type
4
+ */
5
+ type OutputFormat = 'toon' | 'json';
6
+ /**
7
+ * Controller response type
8
+ */
9
+ interface ControllerResponse {
10
+ content: string;
11
+ }
12
+ /**
13
+ * Common controller options
14
+ */
15
+ interface ControllerOptions {
16
+ jq?: string;
17
+ outputFormat?: OutputFormat;
18
+ }
19
+ declare function listProjects(options?: ControllerOptions): Promise<ControllerResponse>;
20
+ declare function createProject(args: {
21
+ name: string;
22
+ } & ControllerOptions): Promise<ControllerResponse>;
23
+ declare function listVersions(args: {
24
+ projectId: string;
25
+ } & ControllerOptions): Promise<ControllerResponse>;
26
+ declare function getVersion(args: {
27
+ projectId: string;
28
+ versionUuid: string;
29
+ } & ControllerOptions): Promise<ControllerResponse>;
30
+ declare function createVersion(args: {
31
+ projectId: string;
32
+ name: string;
33
+ } & ControllerOptions): Promise<ControllerResponse>;
34
+ declare function publishVersion(args: {
35
+ projectId: string;
36
+ versionUuid: string;
37
+ title?: string;
38
+ description?: string;
39
+ } & ControllerOptions): Promise<ControllerResponse>;
40
+ declare function pushChanges(args: {
41
+ projectId: string;
42
+ versionUuid: string;
43
+ changes: DocumentChange[];
44
+ } & ControllerOptions): Promise<ControllerResponse>;
45
+ declare function listPrompts(args: {
46
+ projectId: string;
47
+ versionUuid: string;
48
+ } & ControllerOptions): Promise<ControllerResponse>;
49
+ declare function getPrompt(args: {
50
+ projectId: string;
51
+ versionUuid: string;
52
+ path: string;
53
+ } & ControllerOptions): Promise<ControllerResponse>;
54
+ declare function pushPrompt(args: {
55
+ projectId: string;
56
+ versionUuid: string;
57
+ path: string;
58
+ content: string;
59
+ force?: boolean;
60
+ } & ControllerOptions): Promise<ControllerResponse>;
61
+ declare function pushPromptFromFile(args: {
62
+ projectId: string;
63
+ versionUuid: string;
64
+ filePath: string;
65
+ promptPath?: string;
66
+ force?: boolean;
67
+ } & ControllerOptions): Promise<ControllerResponse>;
68
+ declare function runPrompt(args: {
69
+ projectId: string;
70
+ versionUuid: string;
71
+ path: string;
72
+ parameters?: Record<string, unknown>;
73
+ stream?: boolean;
74
+ tools?: string[];
75
+ userMessage?: string;
76
+ } & ControllerOptions): Promise<ControllerResponse>;
77
+ declare function createLog(args: {
78
+ projectId: string;
79
+ versionUuid: string;
80
+ path: string;
81
+ messages: Array<{
82
+ role: string;
83
+ content: string;
84
+ }>;
85
+ } & ControllerOptions): Promise<ControllerResponse>;
86
+ declare function getConversation(args: {
87
+ conversationUuid: string;
88
+ } & ControllerOptions): Promise<ControllerResponse>;
89
+ declare function chat(args: {
90
+ conversationUuid: string;
91
+ message: string;
92
+ stream?: boolean;
93
+ } & ControllerOptions): Promise<ControllerResponse>;
94
+ declare function stopConversation(args: {
95
+ conversationUuid: string;
96
+ } & ControllerOptions): Promise<ControllerResponse>;
97
+ declare const _default: {
98
+ listProjects: typeof listProjects;
99
+ createProject: typeof createProject;
100
+ listVersions: typeof listVersions;
101
+ getVersion: typeof getVersion;
102
+ createVersion: typeof createVersion;
103
+ publishVersion: typeof publishVersion;
104
+ pushChanges: typeof pushChanges;
105
+ listPrompts: typeof listPrompts;
106
+ getPrompt: typeof getPrompt;
107
+ pushPrompt: typeof pushPrompt;
108
+ pushPromptFromFile: typeof pushPromptFromFile;
109
+ runPrompt: typeof runPrompt;
110
+ createLog: typeof createLog;
111
+ getConversation: typeof getConversation;
112
+ chat: typeof chat;
113
+ stopConversation: typeof stopConversation;
114
+ };
115
+ export default _default;