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,517 @@
|
|
|
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 logger_util_js_1 = require("../utils/logger.util.js");
|
|
7
|
+
const error_util_js_1 = require("../utils/error.util.js");
|
|
8
|
+
// Zod schemas imported from types
|
|
9
|
+
const latitude_controller_js_1 = __importDefault(require("../controllers/latitude.controller.js"));
|
|
10
|
+
const latitude_types_js_1 = require("../types/latitude.types.js");
|
|
11
|
+
const toolLogger = logger_util_js_1.Logger.forContext('tools/latitude.tool.ts');
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Tool Descriptions
|
|
14
|
+
// ============================================================================
|
|
15
|
+
const LIST_PROJECTS_DESC = `List all projects in your Latitude workspace.
|
|
16
|
+
|
|
17
|
+
**Use when:** You need to see available projects or find a project ID.
|
|
18
|
+
|
|
19
|
+
**Returns:** Array of projects with id, name, createdAt, updatedAt.
|
|
20
|
+
|
|
21
|
+
**Example:** Call without parameters to get all projects.`;
|
|
22
|
+
const CREATE_PROJECT_DESC = `Create a new project in Latitude.
|
|
23
|
+
|
|
24
|
+
**Use when:** Starting a new prompt collection or AI workflow.
|
|
25
|
+
|
|
26
|
+
**Parameters:**
|
|
27
|
+
- \`name\` (required) - Project name
|
|
28
|
+
|
|
29
|
+
**Returns:** Created project with id and details.`;
|
|
30
|
+
const LIST_VERSIONS_DESC = `List all versions (commits) for a Latitude project.
|
|
31
|
+
|
|
32
|
+
**Use when:** You need to see version history or find a version UUID.
|
|
33
|
+
|
|
34
|
+
**Parameters:**
|
|
35
|
+
- \`projectId\` (required) - Project ID
|
|
36
|
+
|
|
37
|
+
**Returns:** Array of versions with uuid, title, status, mergedAt.`;
|
|
38
|
+
const GET_VERSION_DESC = `Get details for a specific version.
|
|
39
|
+
|
|
40
|
+
**Use when:** You need version metadata before operations.
|
|
41
|
+
|
|
42
|
+
**Parameters:**
|
|
43
|
+
- \`projectId\` (required) - Project ID
|
|
44
|
+
- \`versionUuid\` (required) - Version UUID
|
|
45
|
+
|
|
46
|
+
**Returns:** Version details including status and metadata.`;
|
|
47
|
+
const CREATE_VERSION_DESC = `Create a new draft version (branch) for a project.
|
|
48
|
+
|
|
49
|
+
**Use when:** You want to make changes without affecting the live version.
|
|
50
|
+
|
|
51
|
+
**Parameters:**
|
|
52
|
+
- \`projectId\` (required) - Project ID
|
|
53
|
+
- \`name\` (required) - Version/commit name
|
|
54
|
+
|
|
55
|
+
**Returns:** Created draft version with UUID.`;
|
|
56
|
+
const PUBLISH_VERSION_DESC = `Publish a draft version to make it live.
|
|
57
|
+
|
|
58
|
+
**Use when:** Your draft changes are ready for production.
|
|
59
|
+
|
|
60
|
+
**Parameters:**
|
|
61
|
+
- \`projectId\` (required) - Project ID
|
|
62
|
+
- \`versionUuid\` (required) - Draft version UUID to publish
|
|
63
|
+
- \`title\` (optional) - Publication title
|
|
64
|
+
- \`description\` (optional) - Publication description
|
|
65
|
+
|
|
66
|
+
**Returns:** Published version details.`;
|
|
67
|
+
const LIST_PROMPTS_DESC = `List all prompts/documents in a project version.
|
|
68
|
+
|
|
69
|
+
**Use when:** You need to see available prompts or find a prompt path.
|
|
70
|
+
|
|
71
|
+
**Parameters:**
|
|
72
|
+
- \`projectId\` (required) - Project ID
|
|
73
|
+
- \`versionUuid\` (optional, default: "live") - Version UUID or "live"
|
|
74
|
+
|
|
75
|
+
**Returns:** Array of documents with path, content, config, parameters.`;
|
|
76
|
+
const GET_PROMPT_DESC = `Get a specific prompt by path.
|
|
77
|
+
|
|
78
|
+
**Use when:** You need prompt content, config, or parameters.
|
|
79
|
+
|
|
80
|
+
**Parameters:**
|
|
81
|
+
- \`projectId\` (required) - Project ID
|
|
82
|
+
- \`versionUuid\` (optional, default: "live") - Version UUID or "live"
|
|
83
|
+
- \`path\` (required) - Prompt path (e.g., "/my-prompt" or "folder/prompt")
|
|
84
|
+
|
|
85
|
+
**Returns:** Document with content, config, and parameters.`;
|
|
86
|
+
const PUSH_PROMPT_DESC = `Create or update a prompt in a draft version.
|
|
87
|
+
|
|
88
|
+
**Use when:** You want to save a new or modified prompt.
|
|
89
|
+
|
|
90
|
+
**Important:** Can only push to draft versions, not "live".
|
|
91
|
+
|
|
92
|
+
**Parameters:**
|
|
93
|
+
- \`projectId\` (required) - Project ID
|
|
94
|
+
- \`versionUuid\` (required) - Draft version UUID
|
|
95
|
+
- \`path\` (required) - Prompt path
|
|
96
|
+
- \`content\` (required) - Prompt content in PromptL format
|
|
97
|
+
- \`force\` (optional) - Force overwrite if exists
|
|
98
|
+
|
|
99
|
+
**Example content:**
|
|
100
|
+
\`\`\`
|
|
101
|
+
---
|
|
102
|
+
model: gpt-4
|
|
103
|
+
temperature: 0.7
|
|
104
|
+
---
|
|
105
|
+
<system>You are a helpful assistant.</system>
|
|
106
|
+
<user>{{user_input}}</user>
|
|
107
|
+
\`\`\``;
|
|
108
|
+
const PUSH_PROMPT_FROM_FILE_DESC = `Push a prompt from a local file to a draft version.
|
|
109
|
+
|
|
110
|
+
**Use when:** You have a prompt file (e.g., .md, .promptl) and want to push it to Latitude.
|
|
111
|
+
|
|
112
|
+
**Important:**
|
|
113
|
+
- Can only push to draft versions, not "live"
|
|
114
|
+
- Reads file content automatically
|
|
115
|
+
- Derives prompt path from filename if not specified
|
|
116
|
+
|
|
117
|
+
**Parameters:**
|
|
118
|
+
- \`projectId\` (required) - Project ID
|
|
119
|
+
- \`versionUuid\` (required) - Draft version UUID
|
|
120
|
+
- \`filePath\` (required) - Absolute path to the prompt file
|
|
121
|
+
- \`promptPath\` (optional) - Latitude prompt path. If omitted, derived from filename:
|
|
122
|
+
- "/path/to/my-prompt.md" → "my-prompt"
|
|
123
|
+
- "/path/to/folder/assistant.promptl" → "assistant"
|
|
124
|
+
- \`force\` (optional) - Force overwrite if exists
|
|
125
|
+
|
|
126
|
+
**Example:**
|
|
127
|
+
\`\`\`
|
|
128
|
+
filePath: "/Users/dev/prompts/customer-support.md"
|
|
129
|
+
promptPath: "support/customer" (optional, defaults to "customer-support")
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
**Returns:** Pushed document info with source file metadata.`;
|
|
133
|
+
const RUN_PROMPT_DESC = `Execute a prompt with parameters and get AI response.
|
|
134
|
+
|
|
135
|
+
**Use when:** You want to run a prompt and get results.
|
|
136
|
+
|
|
137
|
+
**Parameters:**
|
|
138
|
+
- \`projectId\` (required) - Project ID
|
|
139
|
+
- \`versionUuid\` (optional, default: "live") - Version UUID or "live"
|
|
140
|
+
- \`path\` (required) - Prompt path to run
|
|
141
|
+
- \`parameters\` (optional) - Key-value pairs for prompt variables
|
|
142
|
+
- \`stream\` (optional) - Enable streaming response
|
|
143
|
+
- \`tools\` (optional) - Tool names to enable
|
|
144
|
+
- \`userMessage\` (optional) - Additional user message
|
|
145
|
+
|
|
146
|
+
**Returns:** AI response with conversation UUID for follow-up.`;
|
|
147
|
+
const PUSH_CHANGES_DESC = `Push multiple document changes to a version at once.
|
|
148
|
+
|
|
149
|
+
**Use when:** You have multiple prompts to update in a single operation.
|
|
150
|
+
|
|
151
|
+
**Parameters:**
|
|
152
|
+
- \`projectId\` (required) - Project ID
|
|
153
|
+
- \`versionUuid\` (required) - Target version UUID
|
|
154
|
+
- \`changes\` (required) - Array of {path, content, status}
|
|
155
|
+
- status: "added" | "modified" | "deleted"
|
|
156
|
+
|
|
157
|
+
**Returns:** Push result with applied changes.`;
|
|
158
|
+
const CHAT_DESC = `Continue a conversation with additional messages.
|
|
159
|
+
|
|
160
|
+
**Use when:** You have a conversation UUID from a previous run and want to continue.
|
|
161
|
+
|
|
162
|
+
**Parameters:**
|
|
163
|
+
- \`conversationUuid\` (required) - Conversation UUID from previous run
|
|
164
|
+
- \`message\` (required) - User message to send
|
|
165
|
+
- \`stream\` (optional) - Enable streaming response
|
|
166
|
+
|
|
167
|
+
**Returns:** AI response continuing the conversation.`;
|
|
168
|
+
const GET_CONVERSATION_DESC = `Get details and history of a conversation.
|
|
169
|
+
|
|
170
|
+
**Use when:** You need to review conversation messages or metadata.
|
|
171
|
+
|
|
172
|
+
**Parameters:**
|
|
173
|
+
- \`conversationUuid\` (required) - Conversation UUID
|
|
174
|
+
|
|
175
|
+
**Returns:** Conversation with message history.`;
|
|
176
|
+
const STOP_CONVERSATION_DESC = `Stop an ongoing conversation/generation.
|
|
177
|
+
|
|
178
|
+
**Use when:** You need to cancel a running AI generation.
|
|
179
|
+
|
|
180
|
+
**Parameters:**
|
|
181
|
+
- \`conversationUuid\` (required) - Conversation UUID to stop
|
|
182
|
+
|
|
183
|
+
**Returns:** Stop confirmation.`;
|
|
184
|
+
const CREATE_LOG_DESC = `Create a prompt execution log for analytics.
|
|
185
|
+
|
|
186
|
+
**Use when:** You want to log a conversation for evaluation or monitoring.
|
|
187
|
+
|
|
188
|
+
**Parameters:**
|
|
189
|
+
- \`projectId\` (required) - Project ID
|
|
190
|
+
- \`versionUuid\` (required) - Version UUID
|
|
191
|
+
- \`path\` (required) - Prompt path
|
|
192
|
+
- \`messages\` (required) - Array of {role, content} messages
|
|
193
|
+
|
|
194
|
+
**Returns:** Created log confirmation.`;
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Tool Handlers
|
|
197
|
+
// ============================================================================
|
|
198
|
+
async function handleListProjects(args) {
|
|
199
|
+
const methodLogger = toolLogger.forMethod('handleListProjects');
|
|
200
|
+
methodLogger.debug('Listing projects');
|
|
201
|
+
try {
|
|
202
|
+
const result = await latitude_controller_js_1.default.listProjects(args);
|
|
203
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
methodLogger.error('Error listing projects', error);
|
|
207
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function handleCreateProject(args) {
|
|
211
|
+
const methodLogger = toolLogger.forMethod('handleCreateProject');
|
|
212
|
+
methodLogger.debug('Creating project', args);
|
|
213
|
+
try {
|
|
214
|
+
const result = await latitude_controller_js_1.default.createProject(args);
|
|
215
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
methodLogger.error('Error creating project', error);
|
|
219
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function handleListVersions(args) {
|
|
223
|
+
const methodLogger = toolLogger.forMethod('handleListVersions');
|
|
224
|
+
methodLogger.debug('Listing versions', args);
|
|
225
|
+
try {
|
|
226
|
+
const result = await latitude_controller_js_1.default.listVersions(args);
|
|
227
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
methodLogger.error('Error listing versions', error);
|
|
231
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async function handleGetVersion(args) {
|
|
235
|
+
const methodLogger = toolLogger.forMethod('handleGetVersion');
|
|
236
|
+
methodLogger.debug('Getting version', args);
|
|
237
|
+
try {
|
|
238
|
+
const result = await latitude_controller_js_1.default.getVersion(args);
|
|
239
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
methodLogger.error('Error getting version', error);
|
|
243
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async function handleCreateVersion(args) {
|
|
247
|
+
const methodLogger = toolLogger.forMethod('handleCreateVersion');
|
|
248
|
+
methodLogger.debug('Creating version', args);
|
|
249
|
+
try {
|
|
250
|
+
const result = await latitude_controller_js_1.default.createVersion(args);
|
|
251
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
methodLogger.error('Error creating version', error);
|
|
255
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function handlePublishVersion(args) {
|
|
259
|
+
const methodLogger = toolLogger.forMethod('handlePublishVersion');
|
|
260
|
+
methodLogger.debug('Publishing version', args);
|
|
261
|
+
try {
|
|
262
|
+
const result = await latitude_controller_js_1.default.publishVersion(args);
|
|
263
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
methodLogger.error('Error publishing version', error);
|
|
267
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function handleListPrompts(args) {
|
|
271
|
+
const methodLogger = toolLogger.forMethod('handleListPrompts');
|
|
272
|
+
methodLogger.debug('Listing prompts', args);
|
|
273
|
+
try {
|
|
274
|
+
const typedArgs = {
|
|
275
|
+
projectId: args.projectId,
|
|
276
|
+
versionUuid: args.versionUuid || 'live',
|
|
277
|
+
};
|
|
278
|
+
const result = await latitude_controller_js_1.default.listPrompts(typedArgs);
|
|
279
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
methodLogger.error('Error listing prompts', error);
|
|
283
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
async function handleGetPrompt(args) {
|
|
287
|
+
const methodLogger = toolLogger.forMethod('handleGetPrompt');
|
|
288
|
+
methodLogger.debug('Getting prompt', args);
|
|
289
|
+
try {
|
|
290
|
+
const typedArgs = {
|
|
291
|
+
projectId: args.projectId,
|
|
292
|
+
versionUuid: args.versionUuid || 'live',
|
|
293
|
+
path: args.path,
|
|
294
|
+
};
|
|
295
|
+
const result = await latitude_controller_js_1.default.getPrompt(typedArgs);
|
|
296
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
methodLogger.error('Error getting prompt', error);
|
|
300
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async function handlePushPrompt(args) {
|
|
304
|
+
const methodLogger = toolLogger.forMethod('handlePushPrompt');
|
|
305
|
+
methodLogger.debug('Pushing prompt', args);
|
|
306
|
+
try {
|
|
307
|
+
const result = await latitude_controller_js_1.default.pushPrompt(args);
|
|
308
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
methodLogger.error('Error pushing prompt', error);
|
|
312
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async function handlePushPromptFromFile(args) {
|
|
316
|
+
const methodLogger = toolLogger.forMethod('handlePushPromptFromFile');
|
|
317
|
+
methodLogger.debug('Pushing prompt from file', args);
|
|
318
|
+
try {
|
|
319
|
+
const result = await latitude_controller_js_1.default.pushPromptFromFile({
|
|
320
|
+
projectId: args.projectId,
|
|
321
|
+
versionUuid: args.versionUuid,
|
|
322
|
+
filePath: args.filePath,
|
|
323
|
+
promptPath: args.promptPath,
|
|
324
|
+
force: args.force,
|
|
325
|
+
});
|
|
326
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
methodLogger.error('Error pushing prompt from file', error);
|
|
330
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
async function handleRunPrompt(args) {
|
|
334
|
+
const methodLogger = toolLogger.forMethod('handleRunPrompt');
|
|
335
|
+
methodLogger.debug('Running prompt', args);
|
|
336
|
+
try {
|
|
337
|
+
const typedArgs = {
|
|
338
|
+
projectId: args.projectId,
|
|
339
|
+
versionUuid: args.versionUuid || 'live',
|
|
340
|
+
path: args.path,
|
|
341
|
+
parameters: args.parameters,
|
|
342
|
+
stream: args.stream,
|
|
343
|
+
tools: args.tools,
|
|
344
|
+
userMessage: args.userMessage,
|
|
345
|
+
};
|
|
346
|
+
const result = await latitude_controller_js_1.default.runPrompt(typedArgs);
|
|
347
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
348
|
+
}
|
|
349
|
+
catch (error) {
|
|
350
|
+
methodLogger.error('Error running prompt', error);
|
|
351
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
async function handlePushChanges(args) {
|
|
355
|
+
const methodLogger = toolLogger.forMethod('handlePushChanges');
|
|
356
|
+
methodLogger.debug('Pushing changes', args);
|
|
357
|
+
try {
|
|
358
|
+
const rawChanges = args.changes;
|
|
359
|
+
const changes = rawChanges.map((c) => ({
|
|
360
|
+
path: c.path,
|
|
361
|
+
content: c.content,
|
|
362
|
+
status: (c.status || 'modified'),
|
|
363
|
+
}));
|
|
364
|
+
const result = await latitude_controller_js_1.default.pushChanges({
|
|
365
|
+
projectId: args.projectId,
|
|
366
|
+
versionUuid: args.versionUuid,
|
|
367
|
+
changes,
|
|
368
|
+
});
|
|
369
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
methodLogger.error('Error pushing changes', error);
|
|
373
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
async function handleChat(args) {
|
|
377
|
+
const methodLogger = toolLogger.forMethod('handleChat');
|
|
378
|
+
methodLogger.debug('Chatting', args);
|
|
379
|
+
try {
|
|
380
|
+
const result = await latitude_controller_js_1.default.chat(args);
|
|
381
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
382
|
+
}
|
|
383
|
+
catch (error) {
|
|
384
|
+
methodLogger.error('Error in chat', error);
|
|
385
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
async function handleGetConversation(args) {
|
|
389
|
+
const methodLogger = toolLogger.forMethod('handleGetConversation');
|
|
390
|
+
methodLogger.debug('Getting conversation', args);
|
|
391
|
+
try {
|
|
392
|
+
const result = await latitude_controller_js_1.default.getConversation(args);
|
|
393
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
methodLogger.error('Error getting conversation', error);
|
|
397
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
async function handleStopConversation(args) {
|
|
401
|
+
const methodLogger = toolLogger.forMethod('handleStopConversation');
|
|
402
|
+
methodLogger.debug('Stopping conversation', args);
|
|
403
|
+
try {
|
|
404
|
+
const result = await latitude_controller_js_1.default.stopConversation(args);
|
|
405
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
406
|
+
}
|
|
407
|
+
catch (error) {
|
|
408
|
+
methodLogger.error('Error stopping conversation', error);
|
|
409
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async function handleCreateLog(args) {
|
|
413
|
+
const methodLogger = toolLogger.forMethod('handleCreateLog');
|
|
414
|
+
methodLogger.debug('Creating log', args);
|
|
415
|
+
try {
|
|
416
|
+
const result = await latitude_controller_js_1.default.createLog(args);
|
|
417
|
+
return { content: [{ type: 'text', text: result.content }] };
|
|
418
|
+
}
|
|
419
|
+
catch (error) {
|
|
420
|
+
methodLogger.error('Error creating log', error);
|
|
421
|
+
return (0, error_util_js_1.formatErrorForMcpTool)(error);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// ============================================================================
|
|
425
|
+
// Tool Registration
|
|
426
|
+
// ============================================================================
|
|
427
|
+
function registerTools(server) {
|
|
428
|
+
const methodLogger = toolLogger.forMethod('registerTools');
|
|
429
|
+
methodLogger.debug('Registering Latitude tools...');
|
|
430
|
+
// Projects
|
|
431
|
+
server.registerTool('latitude_list_projects', {
|
|
432
|
+
title: 'List Latitude Projects',
|
|
433
|
+
description: LIST_PROJECTS_DESC,
|
|
434
|
+
inputSchema: latitude_types_js_1.ListProjectsInputSchema,
|
|
435
|
+
}, handleListProjects);
|
|
436
|
+
server.registerTool('latitude_create_project', {
|
|
437
|
+
title: 'Create Latitude Project',
|
|
438
|
+
description: CREATE_PROJECT_DESC,
|
|
439
|
+
inputSchema: latitude_types_js_1.CreateProjectInputSchema,
|
|
440
|
+
}, handleCreateProject);
|
|
441
|
+
// Versions
|
|
442
|
+
server.registerTool('latitude_list_versions', {
|
|
443
|
+
title: 'List Project Versions',
|
|
444
|
+
description: LIST_VERSIONS_DESC,
|
|
445
|
+
inputSchema: latitude_types_js_1.ListVersionsInputSchema,
|
|
446
|
+
}, handleListVersions);
|
|
447
|
+
server.registerTool('latitude_get_version', {
|
|
448
|
+
title: 'Get Version Details',
|
|
449
|
+
description: GET_VERSION_DESC,
|
|
450
|
+
inputSchema: latitude_types_js_1.GetVersionInputSchema,
|
|
451
|
+
}, handleGetVersion);
|
|
452
|
+
server.registerTool('latitude_create_version', {
|
|
453
|
+
title: 'Create Draft Version',
|
|
454
|
+
description: CREATE_VERSION_DESC,
|
|
455
|
+
inputSchema: latitude_types_js_1.CreateVersionInputSchema,
|
|
456
|
+
}, handleCreateVersion);
|
|
457
|
+
server.registerTool('latitude_publish_version', {
|
|
458
|
+
title: 'Publish Version',
|
|
459
|
+
description: PUBLISH_VERSION_DESC,
|
|
460
|
+
inputSchema: latitude_types_js_1.PublishVersionInputSchema,
|
|
461
|
+
}, handlePublishVersion);
|
|
462
|
+
// Prompts/Documents
|
|
463
|
+
server.registerTool('latitude_list_prompts', {
|
|
464
|
+
title: 'List Prompts',
|
|
465
|
+
description: LIST_PROMPTS_DESC,
|
|
466
|
+
inputSchema: latitude_types_js_1.ListPromptsInputSchema,
|
|
467
|
+
}, handleListPrompts);
|
|
468
|
+
server.registerTool('latitude_get_prompt', {
|
|
469
|
+
title: 'Get Prompt',
|
|
470
|
+
description: GET_PROMPT_DESC,
|
|
471
|
+
inputSchema: latitude_types_js_1.GetPromptInputSchema,
|
|
472
|
+
}, handleGetPrompt);
|
|
473
|
+
server.registerTool('latitude_push_prompt', {
|
|
474
|
+
title: 'Push Prompt',
|
|
475
|
+
description: PUSH_PROMPT_DESC,
|
|
476
|
+
inputSchema: latitude_types_js_1.PushPromptInputSchema,
|
|
477
|
+
}, handlePushPrompt);
|
|
478
|
+
server.registerTool('latitude_push_prompt_from_file', {
|
|
479
|
+
title: 'Push Prompt from File',
|
|
480
|
+
description: PUSH_PROMPT_FROM_FILE_DESC,
|
|
481
|
+
inputSchema: latitude_types_js_1.PushPromptFromFileInputSchema,
|
|
482
|
+
}, handlePushPromptFromFile);
|
|
483
|
+
server.registerTool('latitude_run_prompt', {
|
|
484
|
+
title: 'Run Prompt',
|
|
485
|
+
description: RUN_PROMPT_DESC,
|
|
486
|
+
inputSchema: latitude_types_js_1.RunPromptInputSchema,
|
|
487
|
+
}, handleRunPrompt);
|
|
488
|
+
server.registerTool('latitude_push_changes', {
|
|
489
|
+
title: 'Push Multiple Changes',
|
|
490
|
+
description: PUSH_CHANGES_DESC,
|
|
491
|
+
inputSchema: latitude_types_js_1.PushChangesInputSchema,
|
|
492
|
+
}, handlePushChanges);
|
|
493
|
+
// Conversations
|
|
494
|
+
server.registerTool('latitude_chat', {
|
|
495
|
+
title: 'Chat in Conversation',
|
|
496
|
+
description: CHAT_DESC,
|
|
497
|
+
inputSchema: latitude_types_js_1.ChatInputSchema,
|
|
498
|
+
}, handleChat);
|
|
499
|
+
server.registerTool('latitude_get_conversation', {
|
|
500
|
+
title: 'Get Conversation',
|
|
501
|
+
description: GET_CONVERSATION_DESC,
|
|
502
|
+
inputSchema: latitude_types_js_1.GetConversationInputSchema,
|
|
503
|
+
}, handleGetConversation);
|
|
504
|
+
server.registerTool('latitude_stop_conversation', {
|
|
505
|
+
title: 'Stop Conversation',
|
|
506
|
+
description: STOP_CONVERSATION_DESC,
|
|
507
|
+
inputSchema: latitude_types_js_1.StopConversationInputSchema,
|
|
508
|
+
}, handleStopConversation);
|
|
509
|
+
// Logs
|
|
510
|
+
server.registerTool('latitude_create_log', {
|
|
511
|
+
title: 'Create Prompt Log',
|
|
512
|
+
description: CREATE_LOG_DESC,
|
|
513
|
+
inputSchema: latitude_types_js_1.CreateLogInputSchema,
|
|
514
|
+
}, handleCreateLog);
|
|
515
|
+
methodLogger.debug('Successfully registered 16 Latitude tools');
|
|
516
|
+
}
|
|
517
|
+
exports.default = { registerTools };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common type definitions shared across controllers.
|
|
3
|
+
* These types provide a standard interface for controller interactions.
|
|
4
|
+
* Centralized here to ensure consistency across the codebase.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Common response structure for controller operations.
|
|
8
|
+
* All controller methods should return this structure.
|
|
9
|
+
*
|
|
10
|
+
* All output, including pagination information and any additional metadata,
|
|
11
|
+
* is now consolidated into the content field as a single Markdown-formatted string.
|
|
12
|
+
*/
|
|
13
|
+
export interface ControllerResponse {
|
|
14
|
+
/**
|
|
15
|
+
* Formatted content to be displayed to the user.
|
|
16
|
+
* A comprehensive Markdown-formatted string that includes all necessary information,
|
|
17
|
+
* including pagination details and any additional metadata.
|
|
18
|
+
*/
|
|
19
|
+
content: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Common type definitions shared across controllers.
|
|
4
|
+
* These types provide a standard interface for controller interactions.
|
|
5
|
+
* Centralized here to ensure consistency across the codebase.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|