@xano/developer-mcp 1.0.20 → 1.0.22

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 (57) hide show
  1. package/README.md +100 -19
  2. package/dist/index.js +4 -227
  3. package/dist/meta_api_docs/format.d.ts +16 -1
  4. package/dist/meta_api_docs/format.js +24 -6
  5. package/dist/meta_api_docs/format.test.d.ts +1 -0
  6. package/dist/meta_api_docs/format.test.js +274 -0
  7. package/dist/meta_api_docs/index.test.d.ts +1 -0
  8. package/dist/meta_api_docs/index.test.js +128 -0
  9. package/dist/meta_api_docs/types.test.d.ts +1 -0
  10. package/dist/meta_api_docs/types.test.js +132 -0
  11. package/dist/run_api_docs/format.d.ts +1 -0
  12. package/dist/run_api_docs/format.js +3 -170
  13. package/dist/run_api_docs/format.test.d.ts +1 -0
  14. package/dist/run_api_docs/format.test.js +86 -0
  15. package/dist/run_api_docs/index.test.d.ts +1 -0
  16. package/dist/run_api_docs/index.test.js +127 -0
  17. package/dist/templates/init-workspace.js +4 -4
  18. package/dist/templates/xanoscript-index.d.ts +3 -1
  19. package/dist/templates/xanoscript-index.js +54 -51
  20. package/dist/xanoscript.d.ts +41 -0
  21. package/dist/xanoscript.js +261 -0
  22. package/dist/xanoscript.test.d.ts +1 -0
  23. package/dist/xanoscript.test.js +303 -0
  24. package/dist/xanoscript_docs/README.md +53 -37
  25. package/dist/xanoscript_docs/agents.md +1 -1
  26. package/dist/xanoscript_docs/apis.md +6 -3
  27. package/dist/xanoscript_docs/branch.md +239 -0
  28. package/dist/xanoscript_docs/functions.md +6 -6
  29. package/dist/xanoscript_docs/integrations.md +43 -1
  30. package/dist/xanoscript_docs/middleware.md +321 -0
  31. package/dist/xanoscript_docs/performance.md +1 -1
  32. package/dist/xanoscript_docs/realtime.md +113 -1
  33. package/dist/xanoscript_docs/tasks.md +2 -2
  34. package/dist/xanoscript_docs/tools.md +3 -3
  35. package/dist/xanoscript_docs/types.md +25 -8
  36. package/dist/xanoscript_docs/workspace.md +209 -0
  37. package/dist/xanoscript_docs_auto/README.md +119 -0
  38. package/dist/xanoscript_docs_auto/agents.md +446 -0
  39. package/dist/xanoscript_docs_auto/apis.md +517 -0
  40. package/dist/xanoscript_docs_auto/control-flow.md +543 -0
  41. package/dist/xanoscript_docs_auto/database.md +551 -0
  42. package/dist/xanoscript_docs_auto/debugging.md +527 -0
  43. package/dist/xanoscript_docs_auto/filters.md +464 -0
  44. package/dist/xanoscript_docs_auto/functions.md +431 -0
  45. package/dist/xanoscript_docs_auto/integrations.md +657 -0
  46. package/dist/xanoscript_docs_auto/mcp-servers.md +408 -0
  47. package/dist/xanoscript_docs_auto/operators.md +368 -0
  48. package/dist/xanoscript_docs_auto/syntax.md +287 -0
  49. package/dist/xanoscript_docs_auto/tables.md +447 -0
  50. package/dist/xanoscript_docs_auto/tasks.md +479 -0
  51. package/dist/xanoscript_docs_auto/testing.md +574 -0
  52. package/dist/xanoscript_docs_auto/tools.md +485 -0
  53. package/dist/xanoscript_docs_auto/triggers.md +595 -0
  54. package/dist/xanoscript_docs_auto/types.md +323 -0
  55. package/dist/xanoscript_docs_auto/variables.md +462 -0
  56. package/dist/xanoscript_docs_auto/version.json +5 -0
  57. package/package.json +6 -2
@@ -0,0 +1,446 @@
1
+ ---
2
+ applyTo: "agents/**/*.xs"
3
+ ---
4
+
5
+ # AI Agents
6
+
7
+ AI agent configuration with LLM providers, tools, and conversation management.
8
+
9
+ ## Quick Reference
10
+
11
+ ```xs
12
+ agent "<name>" {
13
+ model = "openai:gpt-4"
14
+ system_prompt = "You are a helpful assistant."
15
+ tools = [search, calculator]
16
+ max_tokens = 1000
17
+ temperature = 0.7
18
+ }
19
+ ```
20
+
21
+ ---
22
+
23
+ ## Agent Definition
24
+
25
+ ### Basic Agent
26
+
27
+ ```xs
28
+ agent "customer_support" {
29
+ model = "openai:gpt-4"
30
+ system_prompt = "You are a customer support agent. Help users with their questions about our products and services."
31
+ max_tokens = 500
32
+ temperature = 0.7
33
+ }
34
+ ```
35
+
36
+ ### Agent with Tools
37
+
38
+ ```xs
39
+ agent "data_analyst" {
40
+ model = "openai:gpt-4"
41
+ system_prompt = "You are a data analyst. Use the available tools to query data and provide insights."
42
+ tools = [query_database, generate_chart, export_data]
43
+ max_tokens = 1000
44
+ temperature = 0.5
45
+ }
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Model Configuration
51
+
52
+ ### OpenAI Models
53
+
54
+ ```xs
55
+ model = "openai:gpt-4"
56
+ model = "openai:gpt-4-turbo"
57
+ model = "openai:gpt-3.5-turbo"
58
+ ```
59
+
60
+ ### Anthropic Models
61
+
62
+ ```xs
63
+ model = "anthropic:claude-3-opus"
64
+ model = "anthropic:claude-3-sonnet"
65
+ model = "anthropic:claude-3-haiku"
66
+ ```
67
+
68
+ ### Custom Provider
69
+
70
+ ```xs
71
+ model = "custom:my-model"
72
+ api_base = "https://my-llm-api.com/v1"
73
+ api_key = $env.CUSTOM_API_KEY
74
+ ```
75
+
76
+ ---
77
+
78
+ ## Agent Parameters
79
+
80
+ | Parameter | Description | Default |
81
+ |-----------|-------------|---------|
82
+ | `model` | LLM model identifier | Required |
83
+ | `system_prompt` | Instructions for the agent | Required |
84
+ | `tools` | Available tools | `[]` |
85
+ | `max_tokens` | Maximum response tokens | `500` |
86
+ | `temperature` | Creativity (0-1) | `0.7` |
87
+ | `top_p` | Nucleus sampling | `1` |
88
+ | `stop` | Stop sequences | `[]` |
89
+
90
+ ---
91
+
92
+ ## System Prompts
93
+
94
+ ### Simple Prompt
95
+
96
+ ```xs
97
+ agent "assistant" {
98
+ model = "openai:gpt-4"
99
+ system_prompt = "You are a helpful assistant."
100
+ }
101
+ ```
102
+
103
+ ### Detailed Prompt
104
+
105
+ ```xs
106
+ agent "product_expert" {
107
+ model = "openai:gpt-4"
108
+ system_prompt = """
109
+ You are a product expert for our e-commerce platform.
110
+
111
+ Your responsibilities:
112
+ - Answer questions about products
113
+ - Provide recommendations based on user needs
114
+ - Help with order-related queries
115
+
116
+ Guidelines:
117
+ - Be friendly and professional
118
+ - If you don't know something, say so
119
+ - Always verify information using available tools
120
+ """
121
+ }
122
+ ```
123
+
124
+ ### Dynamic Prompt
125
+
126
+ ```xs
127
+ agent "personalized_assistant" {
128
+ model = "openai:gpt-4"
129
+ system_prompt = "You are a personal assistant for " ~ $user.name ~ ". Their preferences are: " ~ $user.preferences|json_encode
130
+ }
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Running Agents
136
+
137
+ ### Basic Execution
138
+
139
+ ```xs
140
+ ai.agent.run {
141
+ agent = "customer_support"
142
+ message = $input.user_message
143
+ } as $response
144
+ ```
145
+
146
+ ### With Conversation History
147
+
148
+ ```xs
149
+ ai.agent.run {
150
+ agent = "customer_support"
151
+ message = $input.user_message
152
+ history = $conversation.messages
153
+ } as $response
154
+ ```
155
+
156
+ ### With Context
157
+
158
+ ```xs
159
+ ai.agent.run {
160
+ agent = "product_expert"
161
+ message = $input.question
162
+ context = {
163
+ user_id: $auth.id,
164
+ cart_items: $cart.items,
165
+ recent_orders: $recent_orders
166
+ }
167
+ } as $response
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Conversation Management
173
+
174
+ ### Store Conversation
175
+
176
+ ```xs
177
+ // Add user message
178
+ db.add message {
179
+ data = {
180
+ conversation_id: $input.conversation_id,
181
+ role: "user",
182
+ content: $input.message,
183
+ created_at: now
184
+ }
185
+ }
186
+
187
+ // Get agent response
188
+ ai.agent.run {
189
+ agent = "assistant"
190
+ message = $input.message
191
+ history = $previous_messages
192
+ } as $response
193
+
194
+ // Store agent response
195
+ db.add message {
196
+ data = {
197
+ conversation_id: $input.conversation_id,
198
+ role: "assistant",
199
+ content: $response.content,
200
+ created_at: now
201
+ }
202
+ }
203
+ ```
204
+
205
+ ### Load History
206
+
207
+ ```xs
208
+ db.query message {
209
+ where = $db.message.conversation_id == $input.conversation_id
210
+ order_by = {field: "created_at", direction: "asc"}
211
+ return = {type: "list", paging: {per_page: 50}}
212
+ } as $history
213
+
214
+ var $formatted_history {
215
+ value = $history|map:{role: $$.role, content: $$.content}
216
+ }
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Tools Integration
222
+
223
+ ### Linking Tools to Agents
224
+
225
+ ```xs
226
+ agent "smart_assistant" {
227
+ model = "openai:gpt-4"
228
+ system_prompt = "Use tools to help users."
229
+ tools = [
230
+ search_products,
231
+ check_inventory,
232
+ create_order,
233
+ get_order_status
234
+ ]
235
+ }
236
+ ```
237
+
238
+ ### Tool Execution
239
+
240
+ When the agent calls a tool, the response includes tool calls that Xano automatically executes:
241
+
242
+ ```xs
243
+ ai.agent.run {
244
+ agent = "smart_assistant"
245
+ message = "Check if iPhone 15 is in stock"
246
+ } as $response
247
+
248
+ // $response.content contains the agent's response
249
+ // Tool calls are automatically executed
250
+ ```
251
+
252
+ ---
253
+
254
+ ## Agent Triggers
255
+
256
+ Handle events from agent interactions:
257
+
258
+ ```xs
259
+ agent_trigger "on_tool_call" {
260
+ agent = "smart_assistant"
261
+ event = "tool_call"
262
+
263
+ stack {
264
+ // Log tool usage
265
+ db.add agent_log {
266
+ data = {
267
+ agent: $trigger.agent,
268
+ tool: $trigger.tool_name,
269
+ input: $trigger.tool_input,
270
+ created_at: now
271
+ }
272
+ }
273
+ }
274
+ }
275
+ ```
276
+
277
+ ---
278
+
279
+ ## Error Handling
280
+
281
+ ```xs
282
+ try_catch {
283
+ try {
284
+ ai.agent.run {
285
+ agent = "assistant"
286
+ message = $input.message
287
+ timeout = 30000
288
+ } as $response
289
+ }
290
+ catch {
291
+ var $response {
292
+ value = {
293
+ content: "I'm sorry, I encountered an error. Please try again.",
294
+ error: true
295
+ }
296
+ }
297
+ }
298
+ }
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Streaming Responses
304
+
305
+ For real-time responses:
306
+
307
+ ```xs
308
+ query "chat" verb=POST {
309
+ stack {
310
+ api.stream {
311
+ content_type = "text/event-stream"
312
+ run {
313
+ ai.agent.run {
314
+ agent = "assistant"
315
+ message = $input.message
316
+ stream = true
317
+ on_token {
318
+ api.stream.write {
319
+ data = "data: " ~ $this.token ~ "\n\n"
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+ }
326
+ }
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Example: Customer Service Agent
332
+
333
+ ```xs
334
+ agent "customer_service" {
335
+ model = "openai:gpt-4"
336
+ system_prompt = """
337
+ You are a customer service agent for TechStore.
338
+
339
+ Available actions:
340
+ - Look up orders by order number or email
341
+ - Check product availability
342
+ - Process returns and refunds
343
+ - Answer questions about products
344
+
345
+ Guidelines:
346
+ - Always verify customer identity before sharing order details
347
+ - Be polite and professional
348
+ - Escalate complex issues to human support
349
+
350
+ Use the provided tools to assist customers.
351
+ """
352
+ tools = [
353
+ lookup_order,
354
+ check_inventory,
355
+ process_return,
356
+ search_products,
357
+ create_ticket
358
+ ]
359
+ max_tokens = 1000
360
+ temperature = 0.5
361
+ }
362
+
363
+ // Tool definitions
364
+ tool "lookup_order" {
365
+ description = "Look up an order by order number or customer email"
366
+ input {
367
+ text? order_number
368
+ email? customer_email
369
+ }
370
+ stack {
371
+ db.query order {
372
+ where = $db.order.order_number ==? $input.order_number
373
+ || $db.order.customer_email ==? $input.customer_email
374
+ } as $orders
375
+ }
376
+ response = $orders
377
+ }
378
+
379
+ tool "check_inventory" {
380
+ description = "Check if a product is in stock"
381
+ input {
382
+ text product_name
383
+ }
384
+ stack {
385
+ db.query product {
386
+ where = $db.product.name ilike ("%" ~ $input.product_name ~ "%")
387
+ } as $products
388
+ }
389
+ response = $products|map:{name: $$.name, stock: $$.stock, available: $$.stock > 0}
390
+ }
391
+ ```
392
+
393
+ ---
394
+
395
+ ## Example: Data Analysis Agent
396
+
397
+ ```xs
398
+ agent "data_analyst" {
399
+ model = "openai:gpt-4"
400
+ system_prompt = """
401
+ You are a data analyst. Help users understand their data by:
402
+ - Running queries to find insights
403
+ - Generating summary statistics
404
+ - Creating visualizations
405
+ - Explaining trends and patterns
406
+
407
+ Always explain your analysis in plain language.
408
+ """
409
+ tools = [
410
+ run_query,
411
+ calculate_stats,
412
+ generate_chart
413
+ ]
414
+ max_tokens = 2000
415
+ temperature = 0.3
416
+ }
417
+ ```
418
+
419
+ ---
420
+
421
+ ## Best Practices
422
+
423
+ ### Clear System Prompts
424
+
425
+ - Define the agent's role clearly
426
+ - List available capabilities
427
+ - Specify guidelines and constraints
428
+ - Provide examples if helpful
429
+
430
+ ### Appropriate Tool Selection
431
+
432
+ - Only include relevant tools
433
+ - Use descriptive tool names
434
+ - Document tool parameters well
435
+
436
+ ### Handle Edge Cases
437
+
438
+ - Set reasonable timeouts
439
+ - Catch and handle errors
440
+ - Provide fallback responses
441
+
442
+ ### Security
443
+
444
+ - Validate tool inputs
445
+ - Limit agent capabilities
446
+ - Log agent actions for auditing