latitude-mcp-server 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,8 +18,9 @@
18
18
  </p>
19
19
 
20
20
  <p align="center">
21
- <img alt="tools" src="https://img.shields.io/badge/🛠️_16_MCP_tools-full_CRUD_operations-2ED573.svg?style=for-the-badge">
22
- <img alt="resources" src="https://img.shields.io/badge/📚_4_resources-read_only_access-2ED573.svg?style=for-the-badge">
21
+ <img alt="tools" src="https://img.shields.io/badge/🛠️_19_MCP_tools-full_CRUD_+_docs-2ED573.svg?style=for-the-badge">
22
+ <img alt="resources" src="https://img.shields.io/badge/📚_6_resources-read_only_access-2ED573.svg?style=for-the-badge">
23
+ <img alt="docs" src="https://img.shields.io/badge/📖_38_doc_topics-self_learning-4D87E6.svg?style=for-the-badge">
23
24
  </p>
24
25
 
25
26
  <div align="center">
@@ -217,7 +218,7 @@ Add to `.cursor/mcp.json` or MCP settings:
217
218
 
218
219
  ## 🛠️ Tool Reference
219
220
 
220
- This server provides **16 MCP tools** covering the complete Latitude API.
221
+ This server provides **19 MCP tools** covering the complete Latitude API plus built-in documentation with **38 topics**.
221
222
 
222
223
  <div align="center">
223
224
  <table>
@@ -227,6 +228,7 @@ This server provides **16 MCP tools** covering the complete Latitude API.
227
228
  <td align="center">📝<br/><b>Prompts</b></td>
228
229
  <td align="center">🤖<br/><b>Execution</b></td>
229
230
  <td align="center">📊<br/><b>Operations</b></td>
231
+ <td align="center">📚<br/><b>Docs</b></td>
230
232
  </tr>
231
233
  <tr>
232
234
  <td valign="top">
@@ -255,12 +257,124 @@ This server provides **16 MCP tools** covering the complete Latitude API.
255
257
  <code>create_log</code><br/>
256
258
  <code>trigger_evaluation</code>
257
259
  </td>
260
+ <td valign="top">
261
+ <code>help</code><br/>
262
+ <code>get_docs</code><br/>
263
+ <code>find_docs</code>
264
+ </td>
258
265
  </tr>
259
266
  </table>
260
267
  </div>
261
268
 
262
269
  ---
263
270
 
271
+ ### 📚 Documentation Tools (AI Self-Learning)
272
+
273
+ The server includes **38 documentation topics** organized by category, enabling AI agents to learn PromptL syntax on-demand. Topics include enhanced metadata (`useWhen` triggers, `difficulty`, `prerequisites`) for intelligent discovery.
274
+
275
+ #### `latitude_help`
276
+
277
+ Get complete server overview — all tools, documentation topics, and quick start workflow.
278
+
279
+ ```json
280
+ {}
281
+ ```
282
+
283
+ **Returns:** Server overview with 19 tools, 38 doc topics by category, and suggested next actions.
284
+
285
+ ---
286
+
287
+ #### `latitude_find_docs` ⭐ NEW
288
+
289
+ **Semantic search for documentation.** Describe what you're trying to do, get matched topics. Uses `useWhen` triggers from topic metadata for intelligent matching.
290
+
291
+ | Parameter | Type | Required | Description |
292
+ |-----------|------|----------|-------------|
293
+ | `query` | `string` | Yes | What are you trying to do? |
294
+ | `maxResults` | `number` | No | Max topics to return (default: 5) |
295
+
296
+ ```json
297
+ {
298
+ "query": "extract structured data from text"
299
+ }
300
+ ```
301
+
302
+ **How it works:** Scores topics based on:
303
+ - Title/description match
304
+ - `useWhen` trigger phrases (e.g., "json output", "extract", "chatbot")
305
+ - Topic name relevance
306
+
307
+ **Returns:** Ranked topics with relevance scores and `getDocsCommand` for each.
308
+
309
+ ---
310
+
311
+ #### `latitude_get_docs`
312
+
313
+ Get comprehensive PromptL documentation for a specific topic.
314
+
315
+ | Parameter | Type | Required | Description |
316
+ |-----------|------|----------|-------------|
317
+ | `topic` | `enum` | Yes | One of 38 topics (see below) |
318
+
319
+ **Available Topics (38 total):**
320
+
321
+ | Category | Topics |
322
+ |----------|--------|
323
+ | **Core Syntax** (11) | `overview`, `structure`, `variables`, `conditionals`, `loops`, `references`, `tools`, `chains`, `agents`, `techniques`, `agent-patterns` |
324
+ | **Configuration** (7) | `config-basics`, `config-generation`, `config-json-output`, `config-advanced`, `providers-openai`, `providers-anthropic`, `providers-google` |
325
+ | **Messages** (2) | `messages-roles`, `messages-multimodal` |
326
+ | **Tools** (4) | `tools-builtin`, `tools-custom`, `tools-schema` |
327
+ | **Techniques** (4) | `technique-role`, `technique-few-shot`, `technique-cot`, `technique-tot` |
328
+ | **Recipes** (5) | `recipe-classification`, `recipe-extraction`, `recipe-generation`, `recipe-chatbot`, `recipe-rag` |
329
+ | **Guides** (6) | `conversation-history`, `guide-debugging`, `guide-safety`, `guide-performance`, `guide-testing`, `guide-versioning` |
330
+
331
+ ```json
332
+ {
333
+ "topic": "recipe-rag"
334
+ }
335
+ ```
336
+
337
+ **Returns:** Comprehensive documentation with syntax, examples, best practices, related topics, and suggested tools.
338
+
339
+ ---
340
+
341
+ #### Writing PromptL-Compliant Prompts
342
+
343
+ AI agents can use these tools to write valid PromptL prompts:
344
+
345
+ ```
346
+ 1. latitude_find_docs({ query: "build a chatbot" }) → Discover relevant topics
347
+ 2. latitude_get_docs({ topic: "recipe-chatbot" }) → Learn chatbot patterns
348
+ 3. latitude_get_docs({ topic: "conversation-history" }) → Learn context management
349
+ 4. latitude_push_prompt → Push your prompt
350
+ 5. latitude_run_prompt → Test execution
351
+ ```
352
+
353
+ **Example: AI discovers how to extract structured data:**
354
+
355
+ ```
356
+ AI: latitude_find_docs({ query: "extract JSON from text" })
357
+ → Returns: config-json-output (score: 24), recipe-extraction (score: 18)
358
+
359
+ AI: latitude_get_docs({ topic: "config-json-output" })
360
+ → Learns: schema config, JSON Schema types, constraints
361
+
362
+ AI: Now writes valid PromptL:
363
+ ---
364
+ provider: OpenAI
365
+ model: gpt-4o
366
+ schema:
367
+ type: object
368
+ properties:
369
+ name: { type: string }
370
+ email: { type: string }
371
+ required: [name, email]
372
+ ---
373
+ Extract contact info from: {{ text }}
374
+ ```
375
+
376
+ ---
377
+
264
378
  ### Project Tools
265
379
 
266
380
  #### `latitude_list_projects`
@@ -530,6 +644,8 @@ Access Latitude data via MCP resources (read-only):
530
644
  | `latitude://projects/{projectId}/versions` | List versions for project |
531
645
  | `latitude://projects/{projectId}/versions/{versionUuid}/prompts` | List prompts in version |
532
646
  | `latitude://projects/{projectId}/versions/{versionUuid}/prompts/{path}` | Get specific prompt |
647
+ | `docs://latitude/help` | Server overview & quick start |
648
+ | `docs://latitude/{topic}` | PromptL documentation by topic |
533
649
 
534
650
  ---
535
651
 
@@ -635,8 +751,30 @@ latitude-mcp chat <conversationUuid> -m "Follow up question"
635
751
  | Variable | Required | Default | Description |
636
752
  |----------|----------|---------|-------------|
637
753
  | `LATITUDE_API_KEY` | Yes | — | Your Latitude API key |
754
+ | `LATITUDE_PROJECT_ID` | No | — | Default project ID (skip `projectId` in all tools) |
638
755
  | `LATITUDE_BASE_URL` | No | `https://gateway.latitude.so` | API base URL |
639
756
 
757
+ ### Skip `projectId` with Default Project
758
+
759
+ Set `LATITUDE_PROJECT_ID` to avoid specifying `projectId` in every tool call:
760
+
761
+ ```json
762
+ {
763
+ "mcpServers": {
764
+ "latitude": {
765
+ "command": "npx",
766
+ "args": ["latitude-mcp-server"],
767
+ "env": {
768
+ "LATITUDE_API_KEY": "your-api-key",
769
+ "LATITUDE_PROJECT_ID": "27756"
770
+ }
771
+ }
772
+ }
773
+ }
774
+ ```
775
+
776
+ When set, all tools that require `projectId` will use this default. You can still override per-call.
777
+
640
778
  ---
641
779
 
642
780
  ## 🔥 Common Issues & Quick Fixes
@@ -191,7 +191,10 @@ async function runPrompt(args) {
191
191
  userMessage: args.userMessage,
192
192
  });
193
193
  // Handle streaming response
194
- if (args.stream && result && typeof result === 'object' && Symbol.asyncIterator in result) {
194
+ if (args.stream &&
195
+ result &&
196
+ typeof result === 'object' &&
197
+ Symbol.asyncIterator in result) {
195
198
  const chunks = [];
196
199
  for await (const chunk of result) {
197
200
  chunks.push(chunk);
@@ -236,7 +239,10 @@ async function chat(args) {
236
239
  const messages = [{ role: 'user', content: args.message }];
237
240
  const result = await vendor_latitude_service_js_1.default.chatConversation(args.conversationUuid, messages, args.stream);
238
241
  // Handle streaming response
239
- if (args.stream && result && typeof result === 'object' && Symbol.asyncIterator in result) {
242
+ if (args.stream &&
243
+ result &&
244
+ typeof result === 'object' &&
245
+ Symbol.asyncIterator in result) {
240
246
  const chunks = [];
241
247
  for await (const chunk of result) {
242
248
  chunks.push(chunk);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Phase 1 - Tier 1 Documentation Topics
3
+ *
4
+ * New granular documentation for:
5
+ * - config-json-output
6
+ * - config-generation
7
+ * - tools-builtin
8
+ * - technique-role
9
+ * - recipe-classification
10
+ * - recipe-extraction
11
+ * - conversation-history
12
+ * - guide-debugging
13
+ */
14
+ export declare const DOCS_CONFIG_JSON_OUTPUT = "# Enforcing JSON Output\n\n> Guarantee structured responses with JSON Schema\n\n## Overview\n\nUse the \\`schema\\` config to force the model to return valid JSON.\n\n\\`\\`\\`yaml\n---\nprovider: OpenAI\nmodel: gpt-4o\nschema:\n type: object\n properties:\n sentiment:\n type: string\n enum: [positive, negative, neutral]\n confidence:\n type: number\n required: [sentiment, confidence]\n---\nAnalyze: {{ text }}\n\\`\\`\\`\n\n## Data Types\n\n| Type | Example | Use Case |\n|------|---------|----------|\n| \\`string\\` | \\`\"hello\"\\` | Text |\n| \\`number\\` | \\`0.95\\` | Scores |\n| \\`integer\\` | \\`42\\` | Counts |\n| \\`boolean\\` | \\`true\\` | Flags |\n| \\`array\\` | \\`[\"a\"]\\` | Lists |\n| \\`object\\` | \\`{...}\\` | Nested |\n\n## Constraints\n\n| Constraint | Description |\n|------------|-------------|\n| \\`enum\\` | Limit to values |\n| \\`minimum/maximum\\` | Number range |\n| \\`minLength/maxLength\\` | String length |\n| \\`minItems/maxItems\\` | Array size |\n\n## Tips\n\n- Always add \\`required\\` - prevents missing fields\n- Use \\`enum\\` for categories\n- Keep schemas focused - smaller = reliable\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"recipe-extraction\" })\\`\n- \\`latitude_get_docs({ topic: \"tools-builtin\" })\\`\n";
15
+ export declare const DOCS_CONFIG_GENERATION = "# Generation Parameters\n\n> Control randomness, length, and quality\n\n## temperature\n\nControls randomness. Lower = focused, higher = creative.\n\n| Value | Use Case |\n|-------|----------|\n| \\`0\\` | Factual (enables caching) |\n| \\`0.2-0.4\\` | Code, analysis |\n| \\`0.5-0.7\\` | Balanced |\n| \\`0.8-1.0\\` | Creative |\n\n## maxTokens\n\nMaximum response length (~4 chars/token).\n\n## topP\n\nNucleus sampling. Use temperature OR topP, not both.\n\n## Penalties\n\n- \\`presencePenalty\\`: Avoid repeating topics\n- \\`frequencyPenalty\\`: Avoid repeating words\n\n## Common Configs\n\n- **Factual:** temperature: 0, maxTokens: 500\n- **Creative:** temperature: 0.9, maxTokens: 2000\n- **Code:** temperature: 0.2, maxTokens: 1000\n\n## Troubleshooting\n\n| Problem | Solution |\n|---------|----------|\n| Too random | Lower temperature |\n| Too boring | Raise temperature |\n| Too long | Set maxTokens |\n| Repetitive | Add frequencyPenalty |\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"guide-debugging\" })\\`\n";
16
+ export declare const DOCS_TOOLS_BUILTIN = "# Built-in Latitude Tools\n\n> Pre-built: search, code, extract\n\n## Overview\n\n| Tool | Capability |\n|------|------------|\n| \\`latitude/search\\` | Web search |\n| \\`latitude/code\\` | Execute code |\n| \\`latitude/extract\\` | Extract data |\n\n## latitude/search\n\n\\`\\`\\`yaml\ntools:\n - latitude/search\n\\`\\`\\`\n\n**Use for:** Real-time info, fact verification, research.\n\n## latitude/code\n\n\\`\\`\\`yaml\ntools:\n - latitude/code\n\\`\\`\\`\n\n**Use for:** Math, data transformations, algorithms.\n\n## latitude/extract\n\n\\`\\`\\`yaml\ntools:\n - latitude/extract\n\\`\\`\\`\n\n**Use for:** Entity extraction, data parsing.\n\n## Combining Tools\n\n\\`\\`\\`yaml\ntools:\n - latitude/search\n - latitude/code\n - latitude/extract\n\\`\\`\\`\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"tools\" })\\`\n- \\`latitude_get_docs({ topic: \"recipe-extraction\" })\\`\n";
17
+ export declare const DOCS_TECHNIQUE_ROLE = "# Role Prompting\n\n> Assign personas for specialized responses\n\n## Overview\n\nRole prompting assigns a persona to improve response quality.\n\n\\`\\`\\`\nYou are a senior financial advisor with 20 years of experience.\nSpecialization: retirement planning.\nStyle: professional yet approachable.\n\\`\\`\\`\n\n## Role Template\n\n\\`\\`\\`\nYou are a [ROLE] with [EXPERIENCE].\n\n**Expertise:** [skills]\n**Style:** [tone]\n**Constraints:** [limitations]\n\\`\\`\\`\n\n## Dynamic Roles\n\n\\`\\`\\`\n{{ if domain == \"legal\" }}\nYou are a senior attorney in {{ specialty }}.\n{{ else if domain == \"medical\" }}\nYou are a physician in {{ specialty }}.\n{{ endif }}\n\\`\\`\\`\n\n## Constrained Roles\n\n\\`\\`\\`\nYou are a customer service rep.\n\n**You MUST:** Be polite, reference policies.\n**You MUST NOT:** Make promises, share internal info.\n\\`\\`\\`\n\n## Best Practices\n\n| Do | Don't |\n|----|-------|\n| Define specific expertise | Generic \"expert\" |\n| Set communication style | Let tone vary |\n| Add constraints | Allow unrestricted |\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"agents\" })\\`\n- \\`latitude_get_docs({ topic: \"techniques\" })\\`\n";
18
+ export declare const DOCS_RECIPE_CLASSIFICATION = "# Classification Patterns\n\n> Sentiment, intent, category classification\n\n## Few-Shot Classification\n\n\\`\\`\\`yaml\nschema:\n type: object\n properties:\n label:\n type: string\n enum: [positive, negative, neutral]\n required: [label]\n\\`\\`\\`\n\n\\`\\`\\`\nText: \"I love this!\" \u2192 positive\nText: \"Terrible.\" \u2192 negative\nText: \"{{ input }}\" \u2192\n\\`\\`\\`\n\n## Dynamic Examples\n\n\\`\\`\\`\n{{ for ex in examples }}\nText: {{ ex.text }}\nLabel: {{ ex.label }}\n{{ endfor }}\nText: {{ input }}\nLabel:\n\\`\\`\\`\n\n## Intent Classification\n\n\\`\\`\\`yaml\nschema:\n type: object\n properties:\n intent:\n type: string\n enum: [order_status, return, complaint, other]\n urgency:\n type: string\n enum: [low, medium, high]\n\\`\\`\\`\n\n## Tips\n\n- Use 3-5 examples per class\n- Balance examples across categories\n- Use JSON schema for reliable output\n- Include \"other\" for edge cases\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"config-json-output\" })\\`\n- \\`latitude_get_docs({ topic: \"loops\" })\\`\n";
19
+ export declare const DOCS_RECIPE_EXTRACTION = "# Data Extraction Patterns\n\n> Entity extraction, structured data parsing\n\n## Basic Extraction\n\n\\`\\`\\`yaml\nschema:\n type: object\n properties:\n name: { type: string }\n email: { type: string }\n phone: { type: string }\n\\`\\`\\`\n\n## Named Entity Recognition\n\n\\`\\`\\`yaml\nschema:\n type: object\n properties:\n people:\n type: array\n items: { type: string }\n organizations:\n type: array\n items: { type: string }\n locations:\n type: array\n items: { type: string }\n\\`\\`\\`\n\n## Financial Extraction\n\n\\`\\`\\`yaml\nschema:\n type: object\n properties:\n company: { type: string }\n revenue: { type: string }\n profit: { type: string }\n\\`\\`\\`\n\n## Tips\n\n- Use specific schemas for accuracy\n- Handle missing fields gracefully\n- Test with varied inputs\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"config-json-output\" })\\`\n- \\`latitude_get_docs({ topic: \"tools-builtin\" })\\`\n";
20
+ export declare const DOCS_CONVERSATION_HISTORY = "# Conversation History\n\n> Multi-turn conversations, context management\n\n## Basic History Injection\n\n\\`\\`\\`\n{{ for msg in history }}\n<{{ msg.role }}>\n{{ msg.content }}\n</{{ msg.role }}>\n{{ endfor }}\n\n<user>{{ new_message }}</user>\n\\`\\`\\`\n\n## With System Context\n\n\\`\\`\\`\n<system>\nYou are a helpful assistant for {{ company }}.\n</system>\n\n{{ for msg in history }}\n<{{ msg.role }}>{{ msg.content }}</{{ msg.role }}>\n{{ endfor }}\n\n<user>{{ input }}</user>\n\\`\\`\\`\n\n## Summarized History\n\nFor long conversations:\n\n\\`\\`\\`\n<system>\nSummary: {{ summary }}\n</system>\n\n{{ for msg in recent_messages }}\n<{{ msg.role }}>{{ msg.content }}</{{ msg.role }}>\n{{ endfor }}\n\\`\\`\\`\n\n## Using latitude_chat\n\n1. \\`latitude_run_prompt\\` \u2192 get conversationUuid\n2. \\`latitude_chat({ conversationUuid, message })\\` \u2192 continue\n3. \\`latitude_get_conversation\\` \u2192 retrieve history\n\n## Token Management\n\n| Length | Strategy |\n|--------|----------|\n| < 10 msgs | Include all |\n| 10-30 msgs | Last 10 + summary |\n| 30+ msgs | Summary + last 5 |\n\n## Next Steps\n\n- \\`latitude_chat\\`\n- \\`latitude_get_docs({ topic: \"loops\" })\\`\n";
21
+ export declare const DOCS_GUIDE_DEBUGGING = "# Debugging & Troubleshooting\n\n> Common errors and fixes\n\n## Variables Not Rendering\n\n**Symptom:** {{ variable }} appears literally\n\n| Cause | Fix |\n|-------|-----|\n| Typo | Check spelling |\n| Not passed | Provide parameter |\n| Wrong syntax | Use {{ }} |\n\n**Debug:** {{ variable || \"NOT_PROVIDED\" }}\n\n## Conditionals Not Working\n\nWrong - Missing endif:\n\\`\\`\\`\n{{ if condition }}\n content\n\\`\\`\\`\n\nCorrect:\n\\`\\`\\`\n{{ if condition }}\n content\n{{ endif }}\n\\`\\`\\`\n\nWrong - Missing quotes:\n\\`\\`\\`\n{{ if role == admin }}\n\\`\\`\\`\n\nCorrect:\n\\`\\`\\`\n{{ if role == \"admin\" }}\n\\`\\`\\`\n\n## Loops Not Iterating\n\n| Cause | Fix |\n|-------|-----|\n| Empty array | Check array has items |\n| Wrong name | Verify spelling |\n\n## Model Behavior Issues\n\n| Problem | Solution |\n|---------|----------|\n| Ignores instructions | Move to beginning |\n| Wrong format | Use JSON schema |\n| Too verbose | Add length instruction |\n| Too creative | Lower temperature |\n| Repetitive | Add frequencyPenalty |\n\n## Debugging Checklist\n\n- Variables spelled correctly?\n- All if have endif?\n- All for have endfor?\n- Strings quoted in comparisons?\n- YAML indentation correct?\n- Parameters provided?\n\n## Next Steps\n\n- \\`latitude_get_docs({ topic: \"variables\" })\\`\n- \\`latitude_get_docs({ topic: \"conditionals\" })\\`\n";