@xano/developer-mcp 2.2.6-beta.0 → 2.3.0-beta.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.
@@ -19,6 +19,8 @@ import { taskDoc } from "./topics/task.js";
19
19
  import { agentDoc } from "./topics/agent.js";
20
20
  import { toolDoc } from "./topics/tool.js";
21
21
  import { mcpServerDoc } from "./topics/mcp_server.js";
22
+ import { promptDoc } from "./topics/prompt.js";
23
+ import { resourceDoc } from "./topics/resource.js";
22
24
  import { middlewareDoc } from "./topics/middleware.js";
23
25
  import { branchDoc } from "./topics/branch.js";
24
26
  import { realtimeDoc } from "./topics/realtime.js";
@@ -40,6 +42,8 @@ export const topics = {
40
42
  agent: agentDoc,
41
43
  tool: toolDoc,
42
44
  mcp_server: mcpServerDoc,
45
+ prompt: promptDoc,
46
+ resource: resourceDoc,
43
47
  middleware: middlewareDoc,
44
48
  branch: branchDoc,
45
49
  realtime: realtimeDoc,
@@ -0,0 +1,13 @@
1
+ import type { EndpointDoc } from "../types.js";
2
+ /** The debug-route description shared by the tool, prompt and resource topics. */
3
+ export declare function debugDescription(kind: "tool" | "prompt" | "resource"): string;
4
+ /**
5
+ * Shared route set for the MCP `prompt` and `resource` objects. Both expose the
6
+ * same CRUD + debug surface in cloud-client (`app/meta/{prompt,resource}.yaml`).
7
+ */
8
+ export declare function mcpPrimitiveEndpoints(opts: {
9
+ kind: "prompt" | "resource";
10
+ plural: string;
11
+ debugInputDescription: string;
12
+ createExample: string;
13
+ }): EndpointDoc[];
@@ -0,0 +1,105 @@
1
+ /** The debug-route description shared by the tool, prompt and resource topics. */
2
+ export function debugDescription(kind) {
3
+ return `Run the ${kind}'s stack outside MCP and return its result. Requires \`workspace:tool\` read and \`workspace:action:rundebug\` enabled. \`elicit\` simulates mcp.elicit answers keyed by elicit key, e.g. {"confirm":{"action":"accept","content":{"proceed":true}}}; an elicit with no simulated answer gets {"action":"cancel"}. The response's \`mcp\` object lists every elicit asked (with its answer) and every mcp.progress call. The stack runs for real, so its writes happen.`;
4
+ }
5
+ /**
6
+ * Shared route set for the MCP `prompt` and `resource` objects. Both expose the
7
+ * same CRUD + debug surface in cloud-client (`app/meta/{prompt,resource}.yaml`).
8
+ */
9
+ export function mcpPrimitiveEndpoints(opts) {
10
+ const { kind, plural, debugInputDescription, createExample } = opts;
11
+ const idParam = `${kind}_id`;
12
+ const PascalPlural = plural.charAt(0).toUpperCase() + plural.slice(1);
13
+ const PascalKind = kind.charAt(0).toUpperCase() + kind.slice(1);
14
+ const workspace = { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" };
15
+ const id = { name: idParam, type: "integer", required: true, in: "path", description: `${PascalKind} ID` };
16
+ return [
17
+ {
18
+ method: "GET",
19
+ path: `/workspace/{workspace_id}/${kind}`,
20
+ tool_name: `list${PascalPlural}`,
21
+ description: `List MCP ${plural} in a workspace.`,
22
+ parameters: [
23
+ workspace,
24
+ { name: "branch", type: "string", description: "Filter by branch name" },
25
+ { name: "page", type: "integer", default: 1, description: "Page number" },
26
+ { name: "per_page", type: "integer", default: 50, description: "Items per page" },
27
+ { name: "search", type: "string", description: `Search ${plural}` },
28
+ { name: "sort", type: "string", default: "created_at", enum: ["created_at", "updated_at", "name"], description: "Sort field" },
29
+ { name: "order", type: "string", default: "desc", enum: ["asc", "desc"], description: "Sort order" },
30
+ { name: "include_xanoscript", type: "boolean", default: false, description: "Include XanoScript" },
31
+ { name: "include_draft", type: "boolean", default: false, description: "Include draft versions" }
32
+ ]
33
+ },
34
+ {
35
+ method: "GET",
36
+ path: `/workspace/{workspace_id}/${kind}/{${idParam}}`,
37
+ tool_name: `get${PascalKind}`,
38
+ description: `Get one MCP ${kind}.`,
39
+ parameters: [
40
+ workspace,
41
+ id,
42
+ { name: "include_xanoscript", type: "boolean", default: false, description: "Include XanoScript" },
43
+ { name: "include_draft", type: "boolean", default: false, description: "Include the draft version" }
44
+ ]
45
+ },
46
+ {
47
+ method: "POST",
48
+ path: `/workspace/{workspace_id}/${kind}`,
49
+ tool_name: `create${PascalKind}`,
50
+ description: `Create an MCP ${kind} from XanoScript. The body is the raw XanoScript (Content-Type: text/x-xanoscript).`,
51
+ parameters: [
52
+ workspace,
53
+ { name: "branch", type: "string", description: "Target branch name" },
54
+ { name: "include_xanoscript", type: "boolean", default: false, description: "Include XanoScript in the response" }
55
+ ],
56
+ request_body: {
57
+ type: "text/x-xanoscript",
58
+ description: `The ${kind} definition in XanoScript.`
59
+ },
60
+ example: {
61
+ method: "POST",
62
+ path: `/workspace/1/${kind}`,
63
+ headers: { "Content-Type": "text/x-xanoscript" },
64
+ body: createExample
65
+ }
66
+ },
67
+ {
68
+ method: "PUT",
69
+ path: `/workspace/{workspace_id}/${kind}/{${idParam}}`,
70
+ tool_name: `update${PascalKind}`,
71
+ description: `Replace an MCP ${kind}'s definition with new XanoScript (Content-Type: text/x-xanoscript).`,
72
+ parameters: [
73
+ workspace,
74
+ id,
75
+ { name: "publish", type: "boolean", default: true, description: "Publish the change immediately" },
76
+ { name: "include_xanoscript", type: "boolean", default: false, description: "Include XanoScript in the response" }
77
+ ],
78
+ request_body: {
79
+ type: "text/x-xanoscript",
80
+ description: `The full ${kind} definition in XanoScript.`
81
+ }
82
+ },
83
+ {
84
+ method: "DELETE",
85
+ path: `/workspace/{workspace_id}/${kind}/{${idParam}}`,
86
+ tool_name: `delete${PascalKind}`,
87
+ description: `Delete an MCP ${kind} permanently. MCP servers that list it stop offering it.`,
88
+ parameters: [workspace, id]
89
+ },
90
+ {
91
+ method: "POST",
92
+ path: `/workspace/{workspace_id}/${kind}/{${idParam}}/debug`,
93
+ tool_name: `debug${PascalKind}`,
94
+ description: debugDescription(kind),
95
+ parameters: [workspace, id],
96
+ request_body: {
97
+ type: "application/json",
98
+ properties: {
99
+ input: { type: "object", description: debugInputDescription },
100
+ elicit: { type: "object", description: "Simulated mcp.elicit answers, keyed by elicit key: {action: accept|decline|cancel, content?}" }
101
+ }
102
+ }
103
+ }
104
+ ];
105
+ }
@@ -1,7 +1,7 @@
1
1
  export const mcpServerDoc = {
2
2
  topic: "mcp_server",
3
3
  title: "MCP Server Management",
4
- description: `MCP (Model Context Protocol) Servers expose tools to external AI clients like Claude Desktop, Cursor, or other MCP-compatible applications.
4
+ description: `MCP (Model Context Protocol) Servers expose tools, prompts and resources to external AI clients like Claude Desktop, Cursor, or other MCP-compatible applications.
5
5
 
6
6
  ## Key Concepts
7
7
  - MCP Servers expose Xano tools via the MCP protocol
@@ -9,6 +9,8 @@ export const mcpServerDoc = {
9
9
  - Supports authentication for secure access
10
10
  - Can have triggers for event-driven invocation
11
11
  - Standardized interface for AI tool discovery
12
+ - First-class prompts and resources are attached with \`prompts = [...]\` and \`resources = [...]\` blocks (\`name\`, \`active\`, \`auth\`); agents cannot have these blocks
13
+ - Serves MCP 2026-07-28 and older clients (2024-11-05 through 2025-11-25) on one URL; elicitation input is only collected from 2026-07-28 clients, and list-changed notifications need a Swoole instance
12
14
 
13
15
  ## Use Cases
14
16
  - Expose Xano functionality to Claude Desktop
@@ -19,7 +21,9 @@ export const mcpServerDoc = {
19
21
  - Create tools first, then create MCP server to expose them
20
22
  - Authentication settings control who can access the server
21
23
  - Use triggers to invoke actions when MCP events occur
22
- - Check documentation endpoint for client setup instructions`,
24
+ - Check documentation endpoint for client setup instructions
25
+ - Create prompts (createPrompt) and resources (createResource) before listing them on a server
26
+ - The \`type: "resource"\` tool reference is legacy; use a resource object for new work`,
23
27
  endpoints: [
24
28
  {
25
29
  method: "GET",
@@ -0,0 +1,2 @@
1
+ import type { TopicDoc } from "../types.js";
2
+ export declare const promptDoc: TopicDoc;
@@ -0,0 +1,54 @@
1
+ import { mcpPrimitiveEndpoints } from "./mcp_primitive.js";
2
+ export const promptDoc = {
3
+ topic: "prompt",
4
+ title: "MCP Prompt Management",
5
+ description: `MCP prompts are reusable prompt templates an MCP server offers to clients (\`prompts/list\`, \`prompts/get\`). A prompt has an \`input\` block (its arguments), a \`stack\` that builds the messages, and a \`response\`.
6
+
7
+ ## Key Concepts
8
+ - A prompt is attached to an MCP server through the server's \`prompts\` block: \`prompts = [{ name: "code_review", auth: "user" }]\`
9
+ - Prompts cannot be attached to agents
10
+ - \`response\` may be a string (one user message), a list of \`{role, content}\` messages, or one message object
11
+ - An \`enum\` input field gives clients argument completions
12
+ - The stack may use \`mcp.elicit\` and \`mcp.progress\`
13
+ - RBAC uses the same scope as tools (\`workspace:tool\`); the debug route also requires \`workspace:action:rundebug\` enabled`,
14
+ ai_hints: `- Create the prompt, then add it to an MCP server's \`prompts\` block (updateMcpServer)
15
+ - Write and validate the XanoScript first; see the \`prompts\` XanoScript docs topic
16
+ - Use debugPrompt to test, including simulated elicitation answers
17
+ - Every eliciting prompt needs a cancel branch: clients older than MCP 2026-07-28 always answer cancel`,
18
+ endpoints: mcpPrimitiveEndpoints({
19
+ kind: "prompt",
20
+ plural: "prompts",
21
+ debugInputDescription: "The prompt's input (its arguments)",
22
+ createExample: `prompt summarize {
23
+ description = "Summarize a document"
24
+ input {
25
+ text doc {
26
+ description = "The text to summarize"
27
+ }
28
+ }
29
+
30
+ stack {
31
+ var $msg {
32
+ value = "Summarize: " ~ $input.doc
33
+ }
34
+ }
35
+
36
+ response = $msg
37
+ }`
38
+ }),
39
+ schemas: {
40
+ Prompt: {
41
+ type: "object",
42
+ properties: {
43
+ id: { type: "integer" },
44
+ name: { type: "string" },
45
+ description: { type: "string" },
46
+ title: { type: "string" },
47
+ xanoscript: { type: "string" },
48
+ created_at: { type: "string", format: "date-time" },
49
+ updated_at: { type: "string", format: "date-time" }
50
+ }
51
+ }
52
+ },
53
+ related_topics: ["mcp_server", "resource", "tool"]
54
+ };
@@ -0,0 +1,2 @@
1
+ import type { TopicDoc } from "../types.js";
2
+ export declare const resourceDoc: TopicDoc;
@@ -0,0 +1,49 @@
1
+ import { mcpPrimitiveEndpoints } from "./mcp_primitive.js";
2
+ export const resourceDoc = {
3
+ topic: "resource",
4
+ title: "MCP Resource Management",
5
+ description: `MCP resources are data an MCP server shares with clients as context (\`resources/list\`, \`resources/templates/list\`, \`resources/read\`). A resource has a \`uri\`, a \`stack\` and a \`response\`.
6
+
7
+ ## Key Concepts
8
+ - A literal uri (\`docs://readme\`) is a static resource with no input
9
+ - A uri with level-1 variables (\`orders://{region}/{order_id}\`) is a template; its variables and the \`input\` fields must be the same set
10
+ - A resource is attached to an MCP server through the server's \`resources\` block: \`resources = [{ name: "regional_order" }]\`
11
+ - Two resources on one server may not share a uri; a first-class resource wins over a legacy \`type: "resource"\` tool reference on the same uri
12
+ - The stack may use \`mcp.elicit\` and \`mcp.progress\`
13
+ - RBAC uses the same scope as tools (\`workspace:tool\`); the debug route also requires \`workspace:action:rundebug\` enabled`,
14
+ ai_hints: `- Create the resource, then add it to an MCP server's \`resources\` block (updateMcpServer)
15
+ - Prefer a resource object over the legacy \`type: "resource"\` tool reference for new work
16
+ - Validate the uri and input together; see the \`resources\` XanoScript docs topic
17
+ - Use debugResource to test; pass template variables by name in \`input\``,
18
+ endpoints: mcpPrimitiveEndpoints({
19
+ kind: "resource",
20
+ plural: "resources",
21
+ debugInputDescription: "The resource's input: a template's URI variables by name",
22
+ createExample: `resource readme {
23
+ uri = "docs://readme"
24
+ mime_type = "text/markdown"
25
+
26
+ stack {
27
+ }
28
+
29
+ response = "# Readme"
30
+ }`
31
+ }),
32
+ schemas: {
33
+ Resource: {
34
+ type: "object",
35
+ properties: {
36
+ id: { type: "integer" },
37
+ name: { type: "string" },
38
+ description: { type: "string" },
39
+ title: { type: "string" },
40
+ uri: { type: "string" },
41
+ mime_type: { type: "string" },
42
+ xanoscript: { type: "string" },
43
+ created_at: { type: "string", format: "date-time" },
44
+ updated_at: { type: "string", format: "date-time" }
45
+ }
46
+ }
47
+ },
48
+ related_topics: ["mcp_server", "prompt", "tool"]
49
+ };
@@ -1,3 +1,4 @@
1
+ import { debugDescription } from "./mcp_primitive.js";
1
2
  export const toolDoc = {
2
3
  topic: "tool",
3
4
  title: "Agent Tool Management",
@@ -9,6 +10,7 @@ export const toolDoc = {
9
10
  - Tools contain XanoScript logic
10
11
  - Can be shared across multiple agents
11
12
  - Support draft/publish workflow
13
+ - MCP metadata in XanoScript: \`title\`, \`annotations\` (read_only_hint, destructive_hint, idempotent_hint, open_world_hint), \`icons\` (https or png/jpeg/webp data URIs only) and an \`output\` schema, which makes MCP servers return validated \`structuredContent\`
12
14
 
13
15
  ## Tool Design Best Practices
14
16
  - Clear, descriptive names (e.g., "lookup_customer", "send_email")
@@ -19,7 +21,8 @@ export const toolDoc = {
19
21
  - Tool names should be descriptive verbs (lookup, create, update, send)
20
22
  - Keep tools focused on single responsibilities
21
23
  - Use \`include_xanoscript=true\` to see tool implementation
22
- - Tools can call other functions for code reuse`,
24
+ - Tools can call other functions for code reuse
25
+ - Use debugTool to test a tool, including simulated mcp.elicit answers`,
23
26
  endpoints: [
24
27
  {
25
28
  method: "GET",
@@ -116,6 +119,25 @@ export const toolDoc = {
116
119
  { name: "tool_id", type: "integer", required: true, in: "path", description: "Tool ID" }
117
120
  ]
118
121
  },
122
+ {
123
+ method: "POST",
124
+ path: "/workspace/{workspace_id}/tool/{tool_id}/debug",
125
+ tool_name: "debugTool",
126
+ description: debugDescription("tool"),
127
+ parameters: [
128
+ { name: "workspace_id", type: "integer", required: true, in: "path", description: "Workspace ID" },
129
+ { name: "tool_id", type: "integer", required: true, in: "path", description: "Tool ID" }
130
+ ],
131
+ request_body: {
132
+ type: "application/json",
133
+ properties: {
134
+ input: { type: "object", description: "The tool's input" },
135
+ elicit: { type: "object", description: "Simulated mcp.elicit answers, keyed by elicit key: {action: accept|decline|cancel, content?}" },
136
+ toolset_id: { type: "integer", description: "An MCP server the tool is assigned to; that assignment's auth then applies" },
137
+ token: { type: "string", description: "Bearer token for an auth-protected assignment" }
138
+ }
139
+ }
140
+ },
119
141
  {
120
142
  method: "PUT",
121
143
  path: "/workspace/{workspace_id}/tool/{tool_id}/security",
@@ -146,5 +168,5 @@ export const toolDoc = {
146
168
  }
147
169
  }
148
170
  },
149
- related_topics: ["agent", "mcp_server", "function"]
171
+ related_topics: ["agent", "mcp_server", "prompt", "resource", "function"]
150
172
  };
@@ -20,6 +20,8 @@ XanoScript is the declarative scripting language for [Xano](https://xano.com), a
20
20
  | `agent_trigger` | `ai/agent/trigger/{name}.xs` | Agent event handlers |
21
21
  | `tool` | `ai/tool/{name}.xs` | Tools for AI agents |
22
22
  | `mcp_server` | `ai/mcp_server/{name}.xs` | MCP server definitions |
23
+ | `prompt` | `ai/prompt/{name}.xs` | MCP prompts |
24
+ | `resource` | `ai/resource/{name}.xs` | MCP resources |
23
25
  | `mcp_server_trigger`| `ai/mcp_server/trigger/{name}.xs` | MCP server event handlers |
24
26
  | `workflow_test` | `workflow_test/{name}.xs` | End-to-end workflow tests |
25
27
  | `realtime_channel` | `realtime/channel/{name}.xs` | Realtime channel settings |
@@ -1,12 +1,12 @@
1
1
  ---
2
- applyTo: "function/**/*.xs, api/**/*.xs, task/*.xs, ai/tool/*.xs"
2
+ applyTo: "function/**/*.xs, api/**/*.xs, task/*.xs, ai/tool/*.xs, ai/prompt/*.xs, ai/resource/*.xs"
3
3
  ---
4
4
 
5
5
  # Database Operations
6
6
 
7
7
  Complete reference for XanoScript database operations.
8
8
 
9
- > **TL;DR:** Use `db.get` for single record by ID, `db.query` for filtered lists, `db.has` to check existence, `db.add` to insert, `db.edit` for inline updates, `db.patch` for dynamic fields, `db.del` to delete.
9
+ > **TL;DR:** Use `db.get` for single record by ID, `db.query` for filtered lists, `db.has` to check existence, `db.add` to insert, `db.edit` for inline updates, `db.patch` for dynamic fields, `db.increment` to adjust a numeric counter atomically, `db.del` to delete.
10
10
 
11
11
  ## Choosing an Operation
12
12
 
@@ -19,7 +19,8 @@ Need to...
19
19
  ├── Write data?
20
20
  │ ├── New record? → db.add
21
21
  │ ├── Update known fields? → db.edit
22
- │ └── Update dynamic fields? → db.patch
22
+ │ ├── Update dynamic fields? → db.patch
23
+ │ └── Adjust a counter/stock number atomically? → db.increment
23
24
  ├── Delete data?
24
25
  │ ├── Single record (by field)? → db.del
25
26
  │ ├── Multiple records (by condition)? → db.bulk.delete
@@ -41,6 +42,7 @@ Need to...
41
42
  | `db.edit` | Update record (inline data) | Updated record |
42
43
  | `db.patch` | Update record (variable data) | Updated record |
43
44
  | `db.add_or_edit` | Upsert record | Record |
45
+ | `db.increment` | Atomic add to a numeric field | Records or count |
44
46
  | `db.del` | Delete one record by field | None |
45
47
  | `db.bulk.delete` | Delete many records by `where`| Deleted count |
46
48
  | `db.truncate` | Delete every record in table | None |
@@ -511,6 +513,83 @@ db.bulk.update "product" {
511
513
  } as $count
512
514
  ```
513
515
 
516
+ ### db.increment
517
+
518
+ Atomically add a signed number to **one numeric field** (int or decimal) on **every record matching `where`**. The new value is computed inside the database in a single statement, so concurrent calls never lose an update. Reading the record, doing the math, and writing it back with `db.edit` races: two concurrent requests can both read `5` and both write `6`.
519
+
520
+ ```xs
521
+ db.increment "post" {
522
+ where = $db.post.id == $input.post_id
523
+ field_name = "view_count"
524
+ value = 1
525
+ } as $updated
526
+ ```
527
+
528
+ | Key | Required | Notes |
529
+ | --- | --- | --- |
530
+ | `where` | yes | Which records to change. Every matching record is updated. |
531
+ | `field_name` | yes | The numeric (int or decimal) field to change. The key is `field_name`, not `field`. |
532
+ | `value` | yes | Number expression added to the field. Use a negative number to decrement. |
533
+ | `return` | no | `{type: "list"}` (default: the updated records) or `{type: "count"}` (number of records updated; cheaper for large updates). |
534
+ | `output` | no | Fields to return. List return only. |
535
+ | `addon` | no | Same shape as `db.query` addons. List return only. |
536
+ | `description`, `disabled`, `mock` | no | Same as other db statements. |
537
+
538
+ No other keys are accepted.
539
+
540
+ **Behavior:**
541
+ - A null or missing current value counts as `0`.
542
+ - It is an error, and nothing changes, when the field is not an int or decimal, is a list field, or does not exist; when `value` is not a number; or when `value` has a fractional part and the field is an int.
543
+ - An empty `where` changes nothing. For example, if every condition uses `==?` and those inputs are absent, no records are updated (it does not update the whole table).
544
+ - There is no clamping. To stop a count going below zero, guard it in the `where`.
545
+
546
+ Decrement stock, only if there is stock left:
547
+
548
+ ```xs
549
+ db.increment "product" {
550
+ where = $db.product.id == $input.product_id && $db.product.stock >= 1
551
+ field_name = "stock"
552
+ value = -1
553
+ return = {type: "count"}
554
+ } as $decremented
555
+
556
+ precondition ($decremented > 0) {
557
+ error_type = "inputerror"
558
+ error = "Out of stock"
559
+ }
560
+ ```
561
+
562
+ Return only the count when updating many records:
563
+
564
+ ```xs
565
+ db.increment "account" {
566
+ where = $db.account.plan == "pro"
567
+ field_name = "credit_balance"
568
+ value = $input.bonus_credits
569
+ return = {type: "count"}
570
+ } as $accounts_updated
571
+ ```
572
+
573
+ Return the updated records with `output` and an addon (list form):
574
+
575
+ ```xs
576
+ db.increment "post" {
577
+ where = $db.post.id == $input.post_id
578
+ field_name = "like_count"
579
+ value = 1
580
+ output = ["id", "like_count"]
581
+ addon = [
582
+ {
583
+ name : "post_author"
584
+ input: {post_id: $output.id}
585
+ as : "author"
586
+ }
587
+ ]
588
+ } as $posts
589
+ ```
590
+
591
+ > **Common mistake:** `db.get` → `math.add` → `db.edit` to bump a counter loses updates under concurrency. Use `db.increment`.
592
+
514
593
  ### db.bulk.patch
515
594
 
516
595
  Patch multiple records with variable data.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.7.1",
2
+ "version": "2.8.0",
3
3
  "description": "Machine-readable index for XanoScript documentation (version mirrors version.json)",
4
4
 
5
5
  "topics": {
@@ -71,7 +71,7 @@
71
71
  "types": {
72
72
  "file": "types.md",
73
73
  "description": "Data types, input blocks, and validation",
74
- "applyTo": ["function/**/*.xs", "api/**/*.xs", "ai/tool/*.xs", "ai/agent/*.xs"],
74
+ "applyTo": ["function/**/*.xs", "api/**/*.xs", "ai/tool/*.xs", "ai/agent/*.xs", "ai/prompt/*.xs", "ai/resource/*.xs"],
75
75
  "priority": 5,
76
76
  "aliases": ["validation", "input", "data-types"]
77
77
  },
@@ -112,8 +112,8 @@
112
112
  },
113
113
  "database": {
114
114
  "file": "database.md",
115
- "description": "All db.* operations: query, get, add, edit, patch, delete",
116
- "applyTo": ["function/**/*.xs", "api/**/*.xs", "task/*.xs", "ai/tool/*.xs"],
115
+ "description": "All db.* operations: query, get, add, edit, patch, increment, delete",
116
+ "applyTo": ["function/**/*.xs", "api/**/*.xs", "task/*.xs", "ai/tool/*.xs", "ai/prompt/*.xs", "ai/resource/*.xs"],
117
117
  "priority": 5,
118
118
  "aliases": ["db", "crud", "query", "sql"]
119
119
  },
@@ -138,6 +138,20 @@
138
138
  "priority": 3,
139
139
  "aliases": ["mcp", "model-context-protocol"]
140
140
  },
141
+ "prompts": {
142
+ "file": "prompts.md",
143
+ "description": "MCP prompts: reusable prompt templates an MCP server offers, with arguments and completions",
144
+ "applyTo": ["ai/prompt/*.xs"],
145
+ "priority": 3,
146
+ "aliases": ["prompt", "mcp-prompts"]
147
+ },
148
+ "resources": {
149
+ "file": "resources.md",
150
+ "description": "MCP resources: static and URI-template resources an MCP server shares as context",
151
+ "applyTo": ["ai/resource/*.xs"],
152
+ "priority": 3,
153
+ "aliases": ["resource", "mcp-resources", "resource-templates"]
154
+ },
141
155
  "unit-testing": {
142
156
  "file": "unit-testing.md",
143
157
  "description": "Unit tests, mocks, and assertions within functions, APIs, and middleware",
@@ -355,6 +369,8 @@
355
369
  "agent": { "file": "agents.md", "tools": "tools.md" },
356
370
  "tool": { "file": "tools.md", "mcp": "mcp-servers.md" },
357
371
  "mcp_server": { "file": "mcp-servers.md", "triggers": "triggers.md" },
372
+ "prompt": { "file": "prompts.md", "mcp": "mcp-servers.md" },
373
+ "resource": { "file": "resources.md", "mcp": "mcp-servers.md" },
358
374
  "table_trigger": { "file": "triggers.md", "section": "table-trigger" },
359
375
  "realtime_trigger": { "file": "triggers.md", "section": "realtime-trigger" },
360
376
  "workspace_trigger": { "file": "triggers.md", "section": "workspace-trigger" },
@@ -373,12 +389,15 @@
373
389
  "operations": {
374
390
  "realtime.publish": { "file": "realtime-v2.md" },
375
391
  "realtime.get_session": { "file": "realtime-v2.md" },
392
+ "mcp.elicit": { "file": "mcp-servers.md" },
393
+ "mcp.progress": { "file": "mcp-servers.md" },
376
394
  "db.query": { "file": "database.md" },
377
395
  "db.get": { "file": "database.md" },
378
396
  "db.has": { "file": "database.md" },
379
397
  "db.add": { "file": "database.md" },
380
398
  "db.edit": { "file": "database.md" },
381
399
  "db.patch": { "file": "database.md" },
400
+ "db.increment": { "file": "database.md" },
382
401
  "db.del": { "file": "database.md" },
383
402
  "db.truncate": { "file": "database.md" },
384
403
  "api.request": { "file": "integrations/external-apis.md" },
@@ -693,6 +693,18 @@ db.truncate "session" { reset = true }
693
693
 
694
694
  See `xano_xanoscript_docs({ topic: "database" })` for all delete operations.
695
695
 
696
+ ### 16. Read-then-edit counters (lost updates)
697
+
698
+ `db.get` → add → `db.edit` races: two concurrent requests both read `5` and write `6`. Use `db.increment` (atomic; negative `value` decrements; guard with `where`, no clamping; the key is `field_name`).
699
+
700
+ ```xs
701
+ db.increment "product" {
702
+ where = $db.product.id == $input.id && $db.product.stock >= 1
703
+ field_name = "stock"
704
+ value = -1
705
+ } as $products
706
+ ```
707
+
696
708
  ---
697
709
 
698
710
  ## Validation is syntax-only
@@ -4,7 +4,7 @@ applyTo: "ai/mcp_server/*.xs"
4
4
 
5
5
  # MCP Servers
6
6
 
7
- Model Context Protocol servers that expose tools to external AI clients.
7
+ Model Context Protocol servers that expose tools, prompts and resources to external AI clients.
8
8
 
9
9
  ## Quick Reference
10
10
 
@@ -15,6 +15,8 @@ mcp_server "<name>" {
15
15
  instructions = "How to use this server's tools"
16
16
  tags = ["category"]
17
17
  tools = [{ name: "<tool-name>" }]
18
+ prompts = [{ name: "<prompt-name>" }]
19
+ resources = [{ name: "<resource-name>" }]
18
20
  }
19
21
  ```
20
22
 
@@ -49,6 +51,8 @@ mcp_server "Customer Support" {
49
51
  | `tags` | Organization/categorization | No |
50
52
  | `docs` | Internal team notes | No |
51
53
  | `tools` | List of exposed tools | Yes |
54
+ | `prompts` | List of exposed prompts (see `prompts`) | No |
55
+ | `resources` | List of exposed resources (see `resources`) | No |
52
56
 
53
57
  ---
54
58
 
@@ -77,7 +81,7 @@ change the tool itself or how any other server exposes it.
77
81
  | `name` | Tool file name in `ai/tool/` | — (required) |
78
82
  | `active` | Whether connections to this entry are allowed | `true` |
79
83
  | `auth` | Name of an auth-enabled table required to call it | omitted = no auth |
80
- | `type` | `"tool"` or `"resource"` | `"tool"` |
84
+ | `type` | `"tool"`, or the legacy `"resource"` | `"tool"` |
81
85
  | `resource_uri` | URI identifying the resource (`type: "resource"` only) | `""` |
82
86
  | `tool_meta` | MCP `_meta` payload sent with the tool (`type: "tool"` only) | `""` |
83
87
 
@@ -108,7 +112,9 @@ Set `auth` to the name of a table that has authentication enabled. Only requests
108
112
  with a valid access token for that table may call the tool. Omit `auth` to leave
109
113
  the tool public. An unknown table name resolves to no auth rather than an error.
110
114
 
111
- ### `type` and `resource_uri`
115
+ ### `type` and `resource_uri` (legacy)
116
+
117
+ > **Legacy:** `type: "resource"` predates first-class resources. It still works for existing servers, but new work should create a `resource` object and list it in the server's `resources` block (see below and the `resources` topic). If a first-class resource and a legacy reference share a uri, the first-class resource wins.
112
118
 
113
119
  `type` chooses what MCP object the connected tool is advertised as:
114
120
 
@@ -142,6 +148,143 @@ the server is exported.
142
148
 
143
149
  ---
144
150
 
151
+ ## Prompts and Resources Blocks
152
+
153
+ First-class prompts (`ai/prompt/`) and resources (`ai/resource/`) are attached the same way as tools. These blocks exist on `mcp_server` only; an `agent` cannot have them.
154
+
155
+ ```xs
156
+ mcp_server "Orders" {
157
+ canonical = "orders-mcp"
158
+ tools = [{ name: "search_orders" }]
159
+ prompts = [
160
+ { name: "summarize_order", auth: "user" },
161
+ { name: "old_prompt", active: false }
162
+ ]
163
+ resources = [{ name: "regional_order" }]
164
+ }
165
+ ```
166
+
167
+ Each entry takes `name` (required, the file name), `active` (default `true`) and `auth` (an auth-enabled table name; omitted = public). A client only sees, fetches and completes the prompts and resources attached to the server it connected to.
168
+
169
+ ---
170
+
171
+ ## Elicitation
172
+
173
+ `mcp.elicit` asks the user a question in the middle of a tool, prompt or resource, and gives the stack the answer.
174
+
175
+ ```xs
176
+ tool refund_order {
177
+ instructions = "Refund an order after the user confirms the amount."
178
+ input {
179
+ int order_id
180
+ }
181
+
182
+ stack {
183
+ mcp.elicit {
184
+ key = "confirm_refund"
185
+ message = "Refund order " ~ $input.order_id ~ "?"
186
+ input {
187
+ bool proceed
188
+ text reason? filters=max:200
189
+ }
190
+ } as $answer
191
+
192
+ conditional {
193
+ if ($answer.action == "accept" && $answer.content.proceed) {
194
+ db.edit order {
195
+ field_name = "id"
196
+ field_value = $input.order_id
197
+ data = {status: "refunded", refund_reason: $answer.content.reason}
198
+ } as $order
199
+ }
200
+
201
+ else {
202
+ var $order {
203
+ value = null
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ response = {refunded: $order != null}
210
+ }
211
+ ```
212
+
213
+ - `key` (required) names the answer. Use a different key for each elicit in the stack.
214
+ - `message` (required) is the question shown to the user.
215
+ - `input` (optional) is the form. It supports `text`, `email`, `date`, `int`, `decimal`, `bool`, `enum` and `enum[]` fields, with `min`/`max` filters, descriptions and defaults. Nested objects, other lists, files, json, timestamps, `password` and `sensitive` fields are refused.
216
+ - The result is `{action, content}`. `action` is `accept`, `decline` or `cancel`; `content` holds the form fields on `accept`.
217
+
218
+ ### Rule 1: always handle `cancel`
219
+
220
+ Input is only collected from clients on MCP `2026-07-28` that support form elicitation. **Every other client gets `{action: "cancel"}` immediately**, and so does a run outside MCP (an agent, a function test, or a debug run with no simulated answer for that key). A stack that treats anything but `accept` as "stop" is correct everywhere.
221
+
222
+ ### Rule 2: writes go after the last elicit
223
+
224
+ The server does not pause. It ends the call with an `input_required` result, and the client calls the tool again with the answer attached. **The whole stack runs again from the top on every retry**, so a `db.add` placed before the elicit runs once per round trip. Put writes, emails, non-GET `api.request` calls and `function.run` after the last `mcp.elicit`. The editor warns when one comes first.
225
+
226
+ Other elicitation rules:
227
+
228
+ - It cannot run inside an async-shared function.
229
+ - An elicit inside `db.transaction` commits that transaction's earlier writes on each attempt.
230
+ - Debug runs (`debugTool`, `debugPrompt`, `debugResource` in the Meta API) take simulated answers keyed by elicit key, e.g. `{"confirm_refund": {"action": "accept", "content": {"proceed": true}}}`; an elicit with no simulated answer gets `cancel`.
231
+
232
+ ---
233
+
234
+ ## Progress
235
+
236
+ `mcp.progress` sends a progress update to the client during a long tool, prompt or resource:
237
+
238
+ ```xs
239
+ tool import_rows {
240
+ input {
241
+ object[] rows {
242
+ schema {
243
+ text name
244
+ }
245
+ }
246
+ }
247
+
248
+ stack {
249
+ var $count {
250
+ value = $input.rows|count
251
+ }
252
+
253
+ for ($count) {
254
+ each as $idx {
255
+ db.add row_import {
256
+ data = {name: $input.rows[$idx].name}
257
+ }
258
+
259
+ mcp.progress {
260
+ progress = $idx + 1
261
+ total = $count
262
+ message = "Imported row " ~ ($idx + 1)
263
+ }
264
+ }
265
+ }
266
+ }
267
+
268
+ response = {imported: $count}
269
+ }
270
+ ```
271
+
272
+ `progress` must increase on every call; a value that does not is dropped. `total` and `message` are optional. Outside MCP, or when the client did not ask for progress, no notification is sent; a debug run (`debugTool`, `debugPrompt`, `debugResource`) captures the calls in its response instead.
273
+
274
+ ---
275
+
276
+ ## Change Notifications
277
+
278
+ When a tool, prompt or resource attached to a server changes, clients on MCP `2026-07-28` that hold a `subscriptions/listen` stream receive `notifications/tools/list_changed` (or `prompts/`, `resources/`). A client only hears about changes to the server it is connected to. **This requires a Swoole instance**; elsewhere the server does not advertise `listChanged` and clients re-list instead.
279
+
280
+ ---
281
+
282
+ ## Protocol Versions
283
+
284
+ A server answers MCP `2026-07-28` clients and older clients (`2024-11-05` through `2025-11-25`) on the same URL, chosen per request. You do not configure anything. Older clients get every feature their version has; what they miss is listed above (elicitation answers and change notifications).
285
+
286
+ ---
287
+
145
288
  ## Examples
146
289
 
147
290
  ### Task Management Server
@@ -267,6 +410,8 @@ The MCP protocol handles:
267
410
 
268
411
  | Topic | Description |
269
412
  |-------|-------------|
270
- | `tools` | AI tool definitions used by MCP servers |
413
+ | `tools` | AI tool definitions and MCP tool metadata |
414
+ | `prompts` | First-class MCP prompts |
415
+ | `resources` | First-class MCP resources |
271
416
  | `agents` | AI agent configuration |
272
417
  | `triggers` | MCP server triggers for connection events |
@@ -0,0 +1,153 @@
1
+ ---
2
+ applyTo: "ai/prompt/*.xs"
3
+ ---
4
+
5
+ # Prompts
6
+
7
+ Reusable prompt templates that an MCP server offers to clients. A client lists them with `prompts/list` and fetches one, with arguments, through `prompts/get`.
8
+
9
+ > **TL;DR:** A `prompt` is shaped like a tool: `input { }` holds the arguments, `stack { }` builds the messages, and `response` returns them. Attach it to a server with `prompts = [{ name: "<prompt>" }]` on the `mcp_server`. Prompts cannot be attached to agents.
10
+
11
+ ---
12
+
13
+ ## Quick Reference
14
+
15
+ ```xs
16
+ prompt "<name>" {
17
+ description = "Shown to the client as the prompt description"
18
+ title = "Human readable name"
19
+ input { ... }
20
+ stack { ... }
21
+ response = $messages
22
+ }
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Basic Structure
28
+
29
+ ```xs
30
+ // Review a code change
31
+ prompt code_review {
32
+ title = "Code review"
33
+ icons = [
34
+ {
35
+ src : "https://cdn.example.com/icons/review.png"
36
+ mime_type: "image/png"
37
+ sizes : ["48x48"]
38
+ }
39
+ ]
40
+
41
+ input {
42
+ // The code to review
43
+ text code
44
+
45
+ // The language of the code
46
+ enum language? {
47
+ values = ["php", "typescript"]
48
+ }
49
+ }
50
+
51
+ stack {
52
+ var $messages {
53
+ value = [
54
+ {role: "user", content: "Review this code: " ~ $input.code}
55
+ {role: "assistant", content: "Sure, reviewing it now."}
56
+ ]
57
+ }
58
+ }
59
+
60
+ response = $messages
61
+ tags = ["mcp", "review"]
62
+ }
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Key Fields
68
+
69
+ | Field | Purpose | Required |
70
+ |-------|---------|----------|
71
+ | `input` | The prompt's arguments. Each field becomes a prompt argument; its `description` is sent to the client | Yes (may be empty) |
72
+ | `stack` | Logic that builds the messages | Yes |
73
+ | `response` | The messages to return. The grammar allows omitting it, but a prompt without one fails every `prompts/get` | Yes, in practice |
74
+ | `description` | The prompt description sent to the client | No |
75
+ | `title` | Human readable display name | No |
76
+ | `icons` | Icons a client may show. Same rules as tool icons (see `tools`) | No |
77
+ | `middleware` | Pre/post middleware, as on a tool | No |
78
+ | `history` | Execution history retention | No |
79
+ | `tags`, `docs`, `guid` | Organization and internal notes | No |
80
+
81
+ An input field that is required and has no default becomes a required prompt argument. A client that omits one gets an error before the stack runs.
82
+
83
+ ---
84
+
85
+ ## What `response` May Return
86
+
87
+ | Response | Messages the client receives |
88
+ |----------|------------------------------|
89
+ | A string or a number | One `user` message with that text |
90
+ | A list of `{role, content}` objects | Those messages, in order |
91
+ | A single `{role, content}` object | One message |
92
+
93
+ `role` is `user` or `assistant`. `content` is a string (a text block) or one MCP content block: `text`, `image`, `audio`, `resource_link` or `resource`.
94
+
95
+ ```xs
96
+ prompt greeting {
97
+ input {
98
+ text name
99
+ }
100
+
101
+ stack {
102
+ }
103
+
104
+ response = "Write a warm greeting for " ~ $input.name
105
+ }
106
+ ```
107
+
108
+ Any other response (no response at all, `null`, a bool, an object that is not a message) is an authoring error, and the client receives it as an internal error that names the bad value.
109
+
110
+ ---
111
+
112
+ ## Argument Completions
113
+
114
+ An `enum` input field gives the client argument completions: `completion/complete` answers with the enum `values` that start with what the user typed. No stack runs. Any other field type completes to nothing.
115
+
116
+ ---
117
+
118
+ ## Elicitation and Progress
119
+
120
+ A prompt's stack can use `mcp.elicit` and `mcp.progress`, exactly as a tool can. See `mcp-servers` ("Elicitation" and "Progress") for the rules, in particular that input is only collected from `2026-07-28` clients.
121
+
122
+ ---
123
+
124
+ ## Attaching to a Server
125
+
126
+ ```xs
127
+ mcp_server "Engineering" {
128
+ canonical = "eng-mcp"
129
+ tools = [{ name: "search_code" }]
130
+ prompts = [
131
+ { name: "code_review" },
132
+ { name: "greeting", auth: "user" },
133
+ { name: "old_prompt", active: false }
134
+ ]
135
+ }
136
+ ```
137
+
138
+ | Entry field | Purpose | Default |
139
+ |-------------|---------|---------|
140
+ | `name` | Prompt file name in `ai/prompt/` | (required) |
141
+ | `active` | Whether this server offers the prompt | `true` |
142
+ | `auth` | Name of an auth-enabled table whose token is required to fetch it | omitted = public |
143
+
144
+ ---
145
+
146
+ ## Related Topics
147
+
148
+ | Topic | Description |
149
+ |-------|-------------|
150
+ | `mcp-servers` | Attaching prompts, elicitation, progress, protocol versions |
151
+ | `resources` | The other first-class MCP primitive |
152
+ | `tools` | Tool metadata and icon rules |
153
+ | `types` | Input field types |
@@ -0,0 +1,178 @@
1
+ ---
2
+ applyTo: "ai/resource/*.xs"
3
+ ---
4
+
5
+ # Resources
6
+
7
+ Data an MCP server shares with clients as context: documents, records, schemas. A client lists them with `resources/list` (and `resources/templates/list`) and reads one with `resources/read`.
8
+
9
+ > **TL;DR:** A `resource` has a `uri`, a `stack` and a `response`. A literal uri (`docs://readme`) is a static resource with no input. A uri with `{variables}` (`orders://{order_id}`) is a template: every variable must be declared in `input { }`, and nothing else may be. Attach it with `resources = [{ name: "<resource>" }]` on the `mcp_server`.
10
+
11
+ ---
12
+
13
+ ## Quick Reference
14
+
15
+ ```xs
16
+ resource "<name>" {
17
+ uri = "<scheme>://<path-with-optional-{variables}>"
18
+ mime_type = "application/json"
19
+ input { ... }
20
+ stack { ... }
21
+ response = $data
22
+ }
23
+ ```
24
+
25
+ ---
26
+
27
+ ## Static Resource
28
+
29
+ ```xs
30
+ resource readme {
31
+ uri = "docs://readme"
32
+ mime_type = "text/markdown"
33
+
34
+ stack {
35
+ }
36
+
37
+ response = "# Readme"
38
+ }
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Template Resource
44
+
45
+ ```xs
46
+ // One order in a region
47
+ resource regional_order {
48
+ title = "Regional order"
49
+ uri = "orders://{region}/{order_id}"
50
+ mime_type = "application/json"
51
+ annotations = {
52
+ audience : ["user", "assistant"]
53
+ priority : 0.5
54
+ last_modified: "2025-01-12T15:00:58Z"
55
+ }
56
+
57
+ input {
58
+ // The region
59
+ enum region {
60
+ values = ["us", "eu"]
61
+ }
62
+
63
+ // The order id
64
+ int order_id
65
+ }
66
+
67
+ stack {
68
+ db.get order {
69
+ field_name = "id"
70
+ field_value = $input.order_id
71
+ } as $order
72
+ }
73
+
74
+ response = $order
75
+ }
76
+ ```
77
+
78
+ Reading `orders://eu/42` binds `region = "eu"` and `order_id = 42`, converted to the declared types before the stack runs. A value that does not convert (for example `orders://eu/abc`) is refused with an invalid-params error.
79
+
80
+ ---
81
+
82
+ ## Key Fields
83
+
84
+ | Field | Purpose | Required |
85
+ |-------|---------|----------|
86
+ | `uri` | A literal URI, or a template whose `{variables}` are the input fields | Yes |
87
+ | `stack` | Logic that produces the content | Yes |
88
+ | `response` | The content to return | No |
89
+ | `input` | The template variables. Must be omitted (or empty) for a static resource | No |
90
+ | `mime_type` | The content's MIME type, such as `text/markdown` | No |
91
+ | `annotations` | `audience`, `priority`, `last_modified` (see below) | No |
92
+ | `description` | Sent to the client | No |
93
+ | `title` | Human readable display name | No |
94
+ | `icons` | Same rules as tool icons (see `tools`) | No |
95
+ | `middleware`, `history`, `tags`, `docs`, `guid` | As on a tool | No |
96
+
97
+ The declaration name (`resource regional_order`) is the resource's name. It is never its uri.
98
+
99
+ ---
100
+
101
+ ## URI Rules
102
+
103
+ - It starts with a scheme: `docs:`, `orders:`, `file:`.
104
+ - It contains no whitespace.
105
+ - Only level-1 template variables are allowed: `{name}`. Operators (`{+path}`, `{#x}`, `{/x}`), modifiers (`{x*}`, `{x:3}`) and lists (`{a,b}`) are refused.
106
+ - Each variable appears at most once, and two variables may not be adjacent (`{a}{b}`), because a concrete URI could not be split back into them.
107
+ - A variable matches one path segment: `file:///{path}` does not match `file:///a/b`.
108
+ - Variable names are letters, digits and `_`, and each must be declared in `input` as a single (non-list) `text`, `int`, `decimal`, `bool`, `enum`, `email` or `uuid` field.
109
+ - Every `input` field must be a uri variable. A static resource has no input.
110
+
111
+ ---
112
+
113
+ ## Annotations
114
+
115
+ | Key | Value |
116
+ |-----|-------|
117
+ | `audience` | A list of `"user"` and/or `"assistant"` |
118
+ | `priority` | A number from 0 to 1 |
119
+ | `last_modified` | An ISO 8601 date, e.g. `"2025-01-12T15:00:58Z"` |
120
+
121
+ Any other key is an error.
122
+
123
+ ---
124
+
125
+ ## What `response` May Return
126
+
127
+ | Response | Content the client receives |
128
+ |----------|-----------------------------|
129
+ | A UTF-8 string | `text` |
130
+ | A string that is not valid UTF-8 (binary bytes) | `blob` (base64) |
131
+ | A file resource or file variable | `blob` (base64 of the file bytes) |
132
+ | `{text: ...}` or `{blob: ...}` (optionally with `mime_type`, `uri`), or a list of them | Those items as written. A `blob` must already be base64 |
133
+ | Any other object or list | JSON `text` |
134
+ | A number, bool or null | `text` |
135
+
136
+ The content's MIME type is, in order: an explicit `{text}`/`{blob}` item's own `mime_type`, then the resource's `mime_type`, then the file's own type, then `text/plain`, `application/json` or `application/octet-stream` by shape.
137
+
138
+ ---
139
+
140
+ ## Argument Completions
141
+
142
+ For a template resource, an `enum` variable gives the client completions: `completion/complete` answers with the enum `values` that start with what the user typed. No stack runs.
143
+
144
+ ---
145
+
146
+ ## Elicitation and Progress
147
+
148
+ A resource's stack can use `mcp.elicit` and `mcp.progress`, exactly as a tool can. See `mcp-servers`.
149
+
150
+ ---
151
+
152
+ ## Attaching to a Server
153
+
154
+ ```xs
155
+ mcp_server "Orders" {
156
+ canonical = "orders-mcp"
157
+ tools = [{ name: "search_orders" }]
158
+ resources = [
159
+ { name: "readme" },
160
+ { name: "regional_order", auth: "user" }
161
+ ]
162
+ }
163
+ ```
164
+
165
+ Entry fields are `name` (required), `active` (default `true`) and `auth` (an auth-enabled table name; omitted = public). Two resources attached to one server may not share a uri.
166
+
167
+ > **Legacy:** before first-class resources, a tool reference could be advertised as a resource with `{ name: "...", type: "resource", resource_uri: "..." }` in the `tools` block. That still works for existing servers, but new work should use a `resource` object. If both exist on one uri, the first-class resource wins.
168
+
169
+ ---
170
+
171
+ ## Related Topics
172
+
173
+ | Topic | Description |
174
+ |-------|-------------|
175
+ | `mcp-servers` | Attaching resources, elicitation, progress, protocol versions |
176
+ | `prompts` | The other first-class MCP primitive |
177
+ | `tools` | Tool metadata and icon rules |
178
+ | `types` | Input field types |
@@ -59,6 +59,10 @@ tool "get_user_by_email" {
59
59
  | `input` | Parameters with descriptions | Sent to AI |
60
60
  | `stack` | Execution logic | Not sent to AI |
61
61
  | `response` | Return value | Sent to AI |
62
+ | `title` | Human readable display name (MCP) | Shown by MCP clients |
63
+ | `annotations` | Behavior hints (MCP) | Sent to MCP clients |
64
+ | `icons` | Icons a client may show (MCP) | Sent to MCP clients |
65
+ | `output` | Output schema; enables structured results (MCP) | Sent to MCP clients |
62
66
 
63
67
  **Important:** `instructions` and input `description` fields are sent to the AI. Write them clearly.
64
68
 
@@ -80,6 +84,119 @@ input {
80
84
 
81
85
  ---
82
86
 
87
+ ## MCP Metadata
88
+
89
+ When a tool is exposed through an `mcp_server`, these optional fields describe it to MCP clients. Agents ignore them.
90
+
91
+ ```xs
92
+ tool lookup_order {
93
+ title = "Look up an order"
94
+ annotations = {
95
+ read_only_hint : true
96
+ destructive_hint: false
97
+ idempotent_hint : true
98
+ open_world_hint : false
99
+ }
100
+
101
+ icons = [
102
+ {
103
+ src : "https://cdn.example.com/icons/order.webp"
104
+ sizes: ["any"]
105
+ theme: "light"
106
+ }
107
+ ]
108
+
109
+ input {
110
+ int order_id
111
+ }
112
+
113
+ stack {
114
+ var $order {
115
+ value = {id: $input.order_id, status: "open"}
116
+ }
117
+ }
118
+
119
+ response = $order
120
+
121
+ output {
122
+ int id
123
+ enum status {
124
+ values = ["open", "closed"]
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ ### `title`
131
+
132
+ A human readable name, e.g. `"Look up an order"`. The tool name stays the identifier.
133
+
134
+ ### `annotations`
135
+
136
+ Hints about the tool's behavior. Clients use them to decide, for example, whether to ask the user before calling it. They are hints only: nothing enforces them.
137
+
138
+ | Key | Meaning |
139
+ |-----|---------|
140
+ | `read_only_hint` | The tool does not change anything |
141
+ | `destructive_hint` | The tool may delete or overwrite data |
142
+ | `idempotent_hint` | Calling it twice with the same input has no extra effect |
143
+ | `open_world_hint` | The tool reaches systems outside Xano (external APIs, the web) |
144
+
145
+ Any other key is an error.
146
+
147
+ ### `icons`
148
+
149
+ A list of `{ src, mime_type?, sizes?, theme? }`:
150
+
151
+ - `src` is an `https://` URL (at most 2048 characters) or a base64 `data:` URI of `image/png`, `image/jpeg` or `image/webp` (at most 64 KB decoded). SVG and every other scheme (`http:`, `javascript:`, `file:`) are refused, because an icon must never carry script. Xano never fetches the URL.
152
+ - `mime_type` is `image/png`, `image/jpeg` or `image/webp`.
153
+ - `sizes` is a list of `"WxH"` strings or `"any"`.
154
+ - `theme` is `light` or `dark`.
155
+
156
+ `prompt` and `resource` accept the same `title` and `icons`.
157
+
158
+ ### `output`
159
+
160
+ Declares the shape of the tool's result, with the same field syntax as `input`. When it is set, the MCP server returns the response as `structuredContent` (plus the same JSON as text) and validates it first: a response that does not match is returned as a tool error naming the first failing field. Without `output`, the response is returned as one text block, unless the stack returns a complete MCP `CallToolResult` itself (an object with a `content` list, optionally `structuredContent` and `isError`), which is passed through as-is. When `output` is set, the `structuredContent` of such a hand-built result is validated too.
161
+
162
+ ---
163
+
164
+ ## MCP Statements
165
+
166
+ `mcp.elicit` asks the MCP client a question and waits for the answer; `mcp.progress` reports progress. Both work in tools, prompts and resources. Read the rules in `mcp-servers` before using `mcp.elicit`: **the client retries the whole call with each answer, so put writes after the last elicit, and always handle `cancel`**.
167
+
168
+ ```xs
169
+ tool delete_order {
170
+ instructions = "Delete an order after the user confirms."
171
+ input {
172
+ int order_id
173
+ }
174
+
175
+ stack {
176
+ mcp.elicit {
177
+ key = "confirm"
178
+ message = "Delete order " ~ $input.order_id ~ "?"
179
+ input {
180
+ bool proceed
181
+ }
182
+ } as $answer
183
+
184
+ precondition ($answer.action == "accept" && $answer.content.proceed) {
185
+ error = "Not confirmed"
186
+ }
187
+
188
+ db.del order {
189
+ field_name = "id"
190
+ field_value = $input.order_id
191
+ }
192
+ }
193
+
194
+ response = {deleted: $input.order_id}
195
+ }
196
+ ```
197
+
198
+ ---
199
+
83
200
  ## Tool-Specific Statements
84
201
 
85
202
  > **Where these belong:** `api.call`, `task.call`, and `tool.call` are for **tools**. Use them to compose a tool from other Xano constructs. Don't reach for them in API endpoints, functions, or tasks. (To call a function from a regular stack, use `function.run`.)
@@ -307,6 +424,8 @@ tool "cancel_order" {
307
424
  | Topic | Description |
308
425
  |-------|-------------|
309
426
  | `agents` | AI agents that use tools |
310
- | `mcp-servers` | MCP servers that expose tools |
427
+ | `mcp-servers` | MCP servers that expose tools; elicitation and progress |
428
+ | `prompts` | MCP prompts |
429
+ | `resources` | MCP resources |
311
430
  | `functions` | Similar structure to tools |
312
431
  | `types` | Input type definitions |
@@ -1,5 +1,5 @@
1
1
  ---
2
- applyTo: "function/**/*.xs, api/**/*.xs, ai/tool/*.xs, ai/agent/*.xs"
2
+ applyTo: "function/**/*.xs, api/**/*.xs, ai/tool/*.xs, ai/agent/*.xs, ai/prompt/*.xs, ai/resource/*.xs"
3
3
  ---
4
4
 
5
5
  # Types & Inputs
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "2.7.1",
3
- "updated": "2026-08-03"
2
+ "version": "2.8.0",
3
+ "updated": "2026-09-28"
4
4
  }
@@ -392,6 +392,7 @@ function.run "send_notification" {
392
392
  ```
393
393
  Read: db.get (single by ID) | db.has (exists?) | db.query (filtered list)
394
394
  Write: db.add (insert) | db.edit (update known fields) | db.patch (dynamic fields) | db.add_or_edit (upsert)
395
+ Counter: db.increment (atomic add/subtract on a numeric field, rows matching where)
395
396
  Delete: db.del (single) | db.truncate (all)
396
397
  ```
397
398
 
@@ -458,6 +459,16 @@ conditional {
458
459
  db.patch "product" { field_name = "id" field_value = $input.id data = $updates } as $product
459
460
  ```
460
461
 
462
+ ### db.increment — Atomic counter (no read-then-edit race)
463
+ ```xs
464
+ // Negative value decrements; guard with where (no clamping). return = {type: "count"} returns the row count.
465
+ db.increment "product" {
466
+ where = $db.product.id == $input.id && $db.product.stock >= 1
467
+ field_name = "stock"
468
+ value = -1
469
+ } as $products
470
+ ```
471
+
461
472
  ### db.del — Delete
462
473
  ```xs
463
474
  db.del "product" { field_name = "id" field_value = $input.product_id }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xano/developer-mcp",
3
- "version": "2.2.6-beta.0",
3
+ "version": "2.3.0-beta.0",
4
4
  "description": "MCP server and library for Xano development - XanoScript validation, Meta API, Run API, and CLI documentation",
5
5
  "mcpName": "io.github.xano-inc/xano-developer-mcp",
6
6
  "type": "module",
@@ -62,7 +62,7 @@
62
62
  "license": "MIT",
63
63
  "dependencies": {
64
64
  "@modelcontextprotocol/sdk": "^1.26.0",
65
- "@xano/xanoscript-language-server": "^12.14.0",
65
+ "@xano/xanoscript-language-server": "^12.17.0",
66
66
  "minimatch": "^10.1.2",
67
67
  "zod": "^4.0.0"
68
68
  },