@xano/developer-mcp 1.0.13 → 1.0.15

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 (60) hide show
  1. package/README.md +8 -8
  2. package/dist/api_docs/format.js +5 -2
  3. package/dist/index.js +44 -5
  4. package/dist/meta_api_docs/format.d.ts +5 -0
  5. package/dist/meta_api_docs/format.js +171 -0
  6. package/dist/meta_api_docs/index.d.ts +52 -0
  7. package/dist/meta_api_docs/index.js +111 -0
  8. package/dist/meta_api_docs/topics/agent.d.ts +2 -0
  9. package/dist/meta_api_docs/topics/agent.js +142 -0
  10. package/dist/meta_api_docs/topics/api.d.ts +2 -0
  11. package/dist/meta_api_docs/topics/api.js +176 -0
  12. package/dist/meta_api_docs/topics/apigroup.d.ts +2 -0
  13. package/dist/meta_api_docs/topics/apigroup.js +124 -0
  14. package/dist/meta_api_docs/topics/authentication.d.ts +2 -0
  15. package/dist/meta_api_docs/topics/authentication.js +61 -0
  16. package/dist/meta_api_docs/topics/branch.d.ts +2 -0
  17. package/dist/meta_api_docs/topics/branch.js +73 -0
  18. package/dist/meta_api_docs/topics/file.d.ts +2 -0
  19. package/dist/meta_api_docs/topics/file.js +70 -0
  20. package/dist/meta_api_docs/topics/function.d.ts +2 -0
  21. package/dist/meta_api_docs/topics/function.js +164 -0
  22. package/dist/meta_api_docs/topics/history.d.ts +2 -0
  23. package/dist/meta_api_docs/topics/history.js +149 -0
  24. package/dist/meta_api_docs/topics/mcp_server.d.ts +2 -0
  25. package/dist/meta_api_docs/topics/mcp_server.js +139 -0
  26. package/dist/meta_api_docs/topics/middleware.d.ts +2 -0
  27. package/dist/meta_api_docs/topics/middleware.js +156 -0
  28. package/dist/meta_api_docs/topics/realtime.d.ts +2 -0
  29. package/dist/meta_api_docs/topics/realtime.js +112 -0
  30. package/dist/meta_api_docs/topics/start.d.ts +2 -0
  31. package/dist/meta_api_docs/topics/start.js +107 -0
  32. package/dist/meta_api_docs/topics/table.d.ts +2 -0
  33. package/dist/meta_api_docs/topics/table.js +195 -0
  34. package/dist/meta_api_docs/topics/task.d.ts +2 -0
  35. package/dist/meta_api_docs/topics/task.js +165 -0
  36. package/dist/meta_api_docs/topics/tool.d.ts +2 -0
  37. package/dist/meta_api_docs/topics/tool.js +150 -0
  38. package/dist/meta_api_docs/topics/workflows.d.ts +2 -0
  39. package/dist/meta_api_docs/topics/workflows.js +131 -0
  40. package/dist/meta_api_docs/topics/workspace.d.ts +2 -0
  41. package/dist/meta_api_docs/topics/workspace.js +153 -0
  42. package/dist/meta_api_docs/types.d.ts +79 -0
  43. package/dist/meta_api_docs/types.js +4 -0
  44. package/dist/run_api_docs/format.d.ts +5 -0
  45. package/dist/run_api_docs/format.js +175 -0
  46. package/dist/run_api_docs/index.d.ts +52 -0
  47. package/dist/run_api_docs/index.js +90 -0
  48. package/dist/run_api_docs/topics/data.d.ts +2 -0
  49. package/dist/run_api_docs/topics/data.js +104 -0
  50. package/dist/run_api_docs/topics/history.d.ts +2 -0
  51. package/dist/run_api_docs/topics/history.js +93 -0
  52. package/dist/run_api_docs/topics/run.d.ts +2 -0
  53. package/dist/run_api_docs/topics/run.js +110 -0
  54. package/dist/run_api_docs/topics/session.d.ts +2 -0
  55. package/dist/run_api_docs/topics/session.js +166 -0
  56. package/dist/run_api_docs/topics/start.d.ts +2 -0
  57. package/dist/run_api_docs/topics/start.js +97 -0
  58. package/dist/run_api_docs/topics/workflows.d.ts +2 -0
  59. package/dist/run_api_docs/topics/workflows.js +140 -0
  60. package/package.json +1 -1
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Formatting utilities for Run API documentation output
3
+ */
4
+ /**
5
+ * Base URL information included with any topic that has endpoints
6
+ * NOTE: The Run API uses a FIXED base URL, not the user's Xano instance URL
7
+ */
8
+ const BASE_URL_INFO = `## Base URL
9
+ \`\`\`
10
+ https://app.dev.xano.com/api:run/<endpoint>
11
+ \`\`\`
12
+
13
+ **Important:** This is a fixed URL - NOT your Xano instance URL. All Run API requests go to this central endpoint.
14
+
15
+ Authorization: \`Bearer <your-access-token>\`
16
+ `;
17
+ function formatParameter(param) {
18
+ const required = param.required ? " (required)" : "";
19
+ const defaultVal = param.default !== undefined ? ` [default: ${param.default}]` : "";
20
+ const enumVals = param.enum ? ` [options: ${param.enum.join(", ")}]` : "";
21
+ return ` - \`${param.name}\`: ${param.type}${required}${defaultVal}${enumVals} - ${param.description}`;
22
+ }
23
+ function formatEndpoint(ep, detailLevel) {
24
+ const lines = [];
25
+ // Method and path
26
+ lines.push(`### ${ep.method} ${ep.path}`);
27
+ if (ep.tool_name) {
28
+ lines.push(`**Tool:** \`${ep.tool_name}\``);
29
+ }
30
+ lines.push("");
31
+ lines.push(ep.description);
32
+ if (detailLevel === "overview") {
33
+ return lines.join("\n");
34
+ }
35
+ // Parameters
36
+ if (ep.parameters?.length) {
37
+ lines.push("");
38
+ lines.push("**Parameters:**");
39
+ for (const param of ep.parameters) {
40
+ lines.push(formatParameter(param));
41
+ }
42
+ }
43
+ // Request body
44
+ if (ep.request_body) {
45
+ lines.push("");
46
+ lines.push(`**Request Body:** \`${ep.request_body.type}\``);
47
+ if (ep.request_body.properties) {
48
+ for (const [key, val] of Object.entries(ep.request_body.properties)) {
49
+ const req = val.required ? " (required)" : "";
50
+ lines.push(` - \`${key}\`: ${val.type}${req} - ${val.description || ""}`);
51
+ }
52
+ }
53
+ }
54
+ // Example (only in detailed/examples mode)
55
+ if (detailLevel === "examples" && ep.example) {
56
+ lines.push("");
57
+ lines.push("**Example:**");
58
+ lines.push("```");
59
+ lines.push(`${ep.example.method} ${ep.example.path}`);
60
+ if (ep.example.body) {
61
+ lines.push(JSON.stringify(ep.example.body, null, 2));
62
+ }
63
+ lines.push("```");
64
+ }
65
+ return lines.join("\n");
66
+ }
67
+ function formatExample(ex) {
68
+ const lines = [];
69
+ lines.push(`### ${ex.title}`);
70
+ lines.push("");
71
+ lines.push(ex.description);
72
+ lines.push("");
73
+ lines.push("**Request:**");
74
+ lines.push("```");
75
+ lines.push(`${ex.request.method} ${ex.request.path}`);
76
+ if (ex.request.headers) {
77
+ for (const [key, val] of Object.entries(ex.request.headers)) {
78
+ lines.push(`${key}: ${val}`);
79
+ }
80
+ }
81
+ if (ex.request.body) {
82
+ lines.push("");
83
+ lines.push(JSON.stringify(ex.request.body, null, 2));
84
+ }
85
+ lines.push("```");
86
+ if (ex.response !== undefined) {
87
+ lines.push("");
88
+ lines.push("**Response:**");
89
+ lines.push("```json");
90
+ lines.push(JSON.stringify(ex.response, null, 2));
91
+ lines.push("```");
92
+ }
93
+ return lines.join("\n");
94
+ }
95
+ function formatPattern(pattern) {
96
+ const lines = [];
97
+ lines.push(`### ${pattern.name}`);
98
+ if (pattern.description) {
99
+ lines.push("");
100
+ lines.push(pattern.description);
101
+ }
102
+ lines.push("");
103
+ lines.push("**Steps:**");
104
+ for (const step of pattern.steps) {
105
+ lines.push(step);
106
+ }
107
+ if (pattern.example) {
108
+ lines.push("");
109
+ lines.push("**Example:**");
110
+ lines.push("```");
111
+ lines.push(pattern.example);
112
+ lines.push("```");
113
+ }
114
+ return lines.join("\n");
115
+ }
116
+ export function formatDocumentation(doc, detailLevel = "detailed", includeSchemas = true) {
117
+ const sections = [];
118
+ // Header
119
+ sections.push(`# ${doc.title}`);
120
+ sections.push("");
121
+ sections.push(doc.description);
122
+ // AI Hints (always include for AI optimization)
123
+ if (doc.ai_hints) {
124
+ sections.push("");
125
+ sections.push("## AI Usage Hints");
126
+ sections.push(doc.ai_hints);
127
+ }
128
+ // Include base URL info if topic has endpoints or patterns (workflows)
129
+ if (doc.endpoints?.length || doc.patterns?.length) {
130
+ sections.push("");
131
+ sections.push(BASE_URL_INFO);
132
+ }
133
+ // Endpoints
134
+ if (doc.endpoints?.length) {
135
+ sections.push("## Endpoints");
136
+ for (const ep of doc.endpoints) {
137
+ sections.push("");
138
+ sections.push(formatEndpoint(ep, detailLevel));
139
+ }
140
+ }
141
+ // Patterns/Workflows
142
+ if (doc.patterns?.length) {
143
+ sections.push("");
144
+ sections.push("## Workflows");
145
+ for (const pattern of doc.patterns) {
146
+ sections.push("");
147
+ sections.push(formatPattern(pattern));
148
+ }
149
+ }
150
+ // Examples
151
+ if ((detailLevel === "detailed" || detailLevel === "examples") && doc.examples?.length) {
152
+ sections.push("");
153
+ sections.push("## Examples");
154
+ for (const ex of doc.examples) {
155
+ sections.push("");
156
+ sections.push(formatExample(ex));
157
+ }
158
+ }
159
+ // Schemas
160
+ if (includeSchemas && doc.schemas && Object.keys(doc.schemas).length > 0) {
161
+ sections.push("");
162
+ sections.push("## Schemas");
163
+ sections.push("");
164
+ sections.push("```json");
165
+ sections.push(JSON.stringify(doc.schemas, null, 2));
166
+ sections.push("```");
167
+ }
168
+ // Related topics
169
+ if (doc.related_topics?.length) {
170
+ sections.push("");
171
+ sections.push("## Related Topics");
172
+ sections.push(`Use \`run_api_docs\` with topic: ${doc.related_topics.join(", ")}`);
173
+ }
174
+ return sections.join("\n");
175
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Xano Run API Documentation Index
3
+ *
4
+ * This module exports all documentation topics and provides
5
+ * the run_api_docs tool handler for the MCP server.
6
+ */
7
+ import type { TopicDoc } from "../meta_api_docs/types.js";
8
+ /**
9
+ * All available documentation topics
10
+ */
11
+ export declare const topics: Record<string, TopicDoc>;
12
+ /**
13
+ * Get list of all available topic names
14
+ */
15
+ export declare function getTopicNames(): string[];
16
+ /**
17
+ * Get topic descriptions for tool documentation
18
+ */
19
+ export declare function getTopicDescriptions(): string;
20
+ /**
21
+ * Handler for the run_api_docs tool
22
+ */
23
+ export declare function handleRunApiDocs(topic?: string, detailLevel?: string, includeSchemas?: boolean): string;
24
+ /**
25
+ * Tool definition for MCP server
26
+ */
27
+ export declare const runApiDocsToolDefinition: {
28
+ name: string;
29
+ description: string;
30
+ inputSchema: {
31
+ type: string;
32
+ properties: {
33
+ topic: {
34
+ type: string;
35
+ enum: string[];
36
+ description: string;
37
+ };
38
+ detail_level: {
39
+ type: string;
40
+ enum: string[];
41
+ default: string;
42
+ description: string;
43
+ };
44
+ include_schemas: {
45
+ type: string;
46
+ default: boolean;
47
+ description: string;
48
+ };
49
+ };
50
+ required: string[];
51
+ };
52
+ };
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Xano Run API Documentation Index
3
+ *
4
+ * This module exports all documentation topics and provides
5
+ * the run_api_docs tool handler for the MCP server.
6
+ */
7
+ import { formatDocumentation } from "./format.js";
8
+ // Import all topic documentation
9
+ import { startDoc } from "./topics/start.js";
10
+ import { runDoc } from "./topics/run.js";
11
+ import { sessionDoc } from "./topics/session.js";
12
+ import { historyDoc } from "./topics/history.js";
13
+ import { dataDoc } from "./topics/data.js";
14
+ import { workflowsDoc } from "./topics/workflows.js";
15
+ /**
16
+ * All available documentation topics
17
+ */
18
+ export const topics = {
19
+ start: startDoc,
20
+ run: runDoc,
21
+ session: sessionDoc,
22
+ history: historyDoc,
23
+ data: dataDoc,
24
+ workflows: workflowsDoc,
25
+ };
26
+ /**
27
+ * Get list of all available topic names
28
+ */
29
+ export function getTopicNames() {
30
+ return Object.keys(topics);
31
+ }
32
+ /**
33
+ * Get topic descriptions for tool documentation
34
+ */
35
+ export function getTopicDescriptions() {
36
+ return Object.entries(topics)
37
+ .map(([key, doc]) => `- ${key}: ${doc.title}`)
38
+ .join("\n");
39
+ }
40
+ /**
41
+ * Handler for the run_api_docs tool
42
+ */
43
+ export function handleRunApiDocs(topic, detailLevel, includeSchemas) {
44
+ // Validate topic
45
+ if (!topic || !topics[topic]) {
46
+ const available = getTopicNames().join(", ");
47
+ return `Error: Unknown topic "${topic}".\n\nAvailable topics: ${available}`;
48
+ }
49
+ const doc = topics[topic];
50
+ return formatDocumentation(doc, detailLevel || "detailed", includeSchemas !== false);
51
+ }
52
+ /**
53
+ * Tool definition for MCP server
54
+ */
55
+ export const runApiDocsToolDefinition = {
56
+ name: "run_api_docs",
57
+ description: `Get documentation for Xano's Run API. Use this to understand runtime execution, session management, and XanoScript execution.
58
+
59
+ **Important:** The Run API uses a fixed base URL: https://app.dev.xano.com/api:run/<endpoint> (NOT your Xano instance URL)
60
+
61
+ ## Topics
62
+ ${getTopicDescriptions()}
63
+
64
+ ## Usage
65
+ - Start with "start" topic for overview and getting started
66
+ - Use "workflows" for step-by-step guides
67
+ - Use specific topics (run, session, etc.) for detailed endpoint docs`,
68
+ inputSchema: {
69
+ type: "object",
70
+ properties: {
71
+ topic: {
72
+ type: "string",
73
+ enum: getTopicNames(),
74
+ description: "Documentation topic to retrieve",
75
+ },
76
+ detail_level: {
77
+ type: "string",
78
+ enum: ["overview", "detailed", "examples"],
79
+ default: "detailed",
80
+ description: "Level of detail: overview (brief), detailed (full docs), examples (with code examples)",
81
+ },
82
+ include_schemas: {
83
+ type: "boolean",
84
+ default: true,
85
+ description: "Include JSON schemas for requests/responses",
86
+ },
87
+ },
88
+ required: ["topic"],
89
+ },
90
+ };
@@ -0,0 +1,2 @@
1
+ import type { TopicDoc } from "../../meta_api_docs/types.js";
2
+ export declare const dataDoc: TopicDoc;
@@ -0,0 +1,104 @@
1
+ export const dataDoc = {
2
+ topic: "data",
3
+ title: "Session Data Export",
4
+ description: `The sink endpoint provides complete data export from session backups. This is the "kitchen sink" - everything from a session's database state in a single JSON response.
5
+
6
+ ## Prerequisites
7
+ - Session must have been hibernated at least once (backup must exist)
8
+ - Hibernation creates a complete snapshot of all tables and data
9
+
10
+ ## Use Cases
11
+ - Export complete session state for analysis
12
+ - Backup data before session termination
13
+ - Transfer data between sessions
14
+ - Debugging and auditing
15
+
16
+ ## Data Included
17
+ - All table schemas
18
+ - All table data/records
19
+ - Complete as single JSON object`,
20
+ ai_hints: `- Session must be hibernated before sink is available
21
+ - Hibernation happens automatically after project timeout or manually
22
+ - Large datasets may take time to export - be patient
23
+ - Use for complete data snapshots, not real-time queries
24
+ - Data is read-only - cannot modify via sink endpoint
25
+ - Public sessions can export without authentication`,
26
+ endpoints: [
27
+ {
28
+ method: "GET",
29
+ path: "/session/{session_id}/sink",
30
+ tool_name: "getSessionSink",
31
+ description: "Get full backup data from a session as JSON. Returns the complete 'kitchen sink' - all table schemas and data in one response. Session must have been hibernated at least once.",
32
+ parameters: [
33
+ { name: "session_id", type: "uuid", required: true, in: "path", description: "Session UUID" }
34
+ ],
35
+ example: {
36
+ method: "GET",
37
+ path: "/session/session-uuid-here/sink"
38
+ }
39
+ }
40
+ ],
41
+ schemas: {
42
+ SinkResponse: {
43
+ type: "object",
44
+ properties: {
45
+ tables: {
46
+ type: "object",
47
+ description: "Map of table names to their data",
48
+ additionalProperties: {
49
+ type: "object",
50
+ properties: {
51
+ schema: { type: "array", description: "Field definitions" },
52
+ records: { type: "array", description: "All records in the table" }
53
+ }
54
+ }
55
+ },
56
+ metadata: {
57
+ type: "object",
58
+ properties: {
59
+ session_id: { type: "uuid", description: "Source session" },
60
+ exported_at: { type: "timestamp", description: "Export timestamp" },
61
+ size: { type: "integer", description: "Backup size in bytes" }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ },
67
+ examples: [
68
+ {
69
+ title: "Export session data",
70
+ description: "Get all data from a hibernated session",
71
+ request: {
72
+ method: "GET",
73
+ path: "/session/abc123-session-uuid/sink",
74
+ headers: { "Authorization": "Bearer <token>" }
75
+ },
76
+ response: {
77
+ tables: {
78
+ users: {
79
+ schema: [
80
+ { name: "id", type: "int" },
81
+ { name: "email", type: "text" },
82
+ { name: "name", type: "text" }
83
+ ],
84
+ records: [
85
+ { id: 1, email: "alice@example.com", name: "Alice" },
86
+ { id: 2, email: "bob@example.com", name: "Bob" }
87
+ ]
88
+ },
89
+ orders: {
90
+ schema: [
91
+ { name: "id", type: "int" },
92
+ { name: "user_id", type: "int" },
93
+ { name: "total", type: "decimal" }
94
+ ],
95
+ records: [
96
+ { id: 1, user_id: 1, total: 99.99 }
97
+ ]
98
+ }
99
+ }
100
+ }
101
+ }
102
+ ],
103
+ related_topics: ["session", "workflows"]
104
+ };
@@ -0,0 +1,2 @@
1
+ import type { TopicDoc } from "../../meta_api_docs/types.js";
2
+ export declare const historyDoc: TopicDoc;
@@ -0,0 +1,93 @@
1
+ export const historyDoc = {
2
+ topic: "history",
3
+ title: "Run History & Document Analysis",
4
+ description: `Endpoints for viewing run execution history and analyzing XanoScript documents before execution.
5
+
6
+ ## Use Cases
7
+ - **Run History**: Review past executions, track patterns, audit usage
8
+ - **Document Analysis**: Validate scripts, understand structure before execution
9
+
10
+ ## History Features
11
+ - Paginated access to run history
12
+ - Sorted by creation time (newest first)
13
+ - Includes run metadata and configuration`,
14
+ ai_hints: `- Use doc/info to validate scripts before execution
15
+ - History is sorted by created_at descending (newest first)
16
+ - Check existing runs before creating duplicates with same script
17
+ - Use pagination for large history sets (default 20 per page, max 100)
18
+ - Document info reveals functions, services, and jobs defined in a script`,
19
+ endpoints: [
20
+ {
21
+ method: "GET",
22
+ path: "/project/{project_id}/run",
23
+ tool_name: "getRunHistory",
24
+ description: "List run execution history for a project with pagination. Returns runs sorted by creation time (newest first).",
25
+ parameters: [
26
+ { name: "project_id", type: "uuid", required: true, in: "path", description: "Project UUID" },
27
+ { name: "page", type: "integer", default: 1, description: "Page number (min: 1)" },
28
+ { name: "per_page", type: "integer", default: 20, description: "Items per page (1-100)" }
29
+ ],
30
+ example: {
31
+ method: "GET",
32
+ path: "/project/abc123-uuid/run?page=1&per_page=20"
33
+ }
34
+ },
35
+ {
36
+ method: "POST",
37
+ path: "/project/{project_id}/doc/info",
38
+ tool_name: "getDocInfo",
39
+ description: "Parse and analyze a XanoScript document. Returns metadata about the document including defined functions, services, and jobs. Use this to validate scripts before execution.",
40
+ parameters: [
41
+ { name: "project_id", type: "uuid", required: true, in: "path", description: "Project context" }
42
+ ],
43
+ request_body: {
44
+ type: "application/json",
45
+ properties: {
46
+ doc: { type: "text", required: true, description: "XanoScript document content to analyze" }
47
+ }
48
+ },
49
+ example: {
50
+ method: "POST",
51
+ path: "/project/abc123-uuid/doc/info",
52
+ body: {
53
+ doc: "job my_job {\n input { text name }\n response = \"Hello, \" + $input.name\n}\n\nservice my_service {\n // service code\n}"
54
+ }
55
+ }
56
+ }
57
+ ],
58
+ schemas: {
59
+ RunHistoryItem: {
60
+ type: "object",
61
+ properties: {
62
+ id: { type: "uuid", description: "Run identifier" },
63
+ name: { type: "text", description: "Run name" },
64
+ type: { type: "enum", enum: ["job", "service"], description: "Run type" },
65
+ sig: { type: "text", description: "Document signature" },
66
+ project_id: { type: "uuid", description: "Project reference" },
67
+ user_id: { type: "integer", description: "Owner user ID" },
68
+ created_at: { type: "timestamp", description: "Creation time" },
69
+ updated_at: { type: "timestamp", description: "Last update time" }
70
+ }
71
+ },
72
+ DocInfo: {
73
+ type: "object",
74
+ properties: {
75
+ functions: { type: "array", description: "Defined functions" },
76
+ services: { type: "array", description: "Defined services" },
77
+ jobs: { type: "array", description: "Defined jobs" },
78
+ valid: { type: "boolean", description: "Whether document is valid" },
79
+ errors: { type: "array", description: "Parsing errors if any" }
80
+ }
81
+ },
82
+ PaginatedResponse: {
83
+ type: "object",
84
+ properties: {
85
+ items: { type: "array", description: "List of runs" },
86
+ curPage: { type: "integer", description: "Current page number" },
87
+ nextPage: { type: "integer", description: "Next page number or null" },
88
+ prevPage: { type: "integer", description: "Previous page number or null" }
89
+ }
90
+ }
91
+ },
92
+ related_topics: ["run", "session", "workflows"]
93
+ };
@@ -0,0 +1,2 @@
1
+ import type { TopicDoc } from "../../meta_api_docs/types.js";
2
+ export declare const runDoc: TopicDoc;
@@ -0,0 +1,110 @@
1
+ export const runDoc = {
2
+ topic: "run",
3
+ title: "Run Execution",
4
+ description: `Endpoints for executing XanoScript runs. Runs are executable XanoScript documents that can be jobs (one-time execution) or services (long-running processes).
5
+
6
+ ## Run Types
7
+ - **Job**: Executes once and terminates. Use for data processing, migrations, one-time tasks.
8
+ - **Service**: Runs persistently in a tenant. Use for APIs, webhooks, background workers.
9
+
10
+ ## Execution Flow
11
+ 1. Submit XanoScript document via \`/run/exec\`
12
+ 2. System creates a session to track execution
13
+ 3. Session progresses through states: pending → processing → running → complete/error
14
+ 4. Retrieve results from the session
15
+
16
+ ## Templates
17
+ The \`template\` parameter controls resource allocation:
18
+ - \`small\`: Default, suitable for most workloads
19
+ - Additional templates may be available for larger workloads`,
20
+ ai_hints: `- Include complete XanoScript in the 'doc' parameter
21
+ - Use 'args' to pass dynamic data to runs (available as $args in XanoScript)
22
+ - Use 'env' to override environment variables for this execution
23
+ - Template affects resource allocation - use "small" for typical workloads
24
+ - Re-executing a run reuses its stored configuration with optional overrides
25
+ - Check the session state after execution to verify success`,
26
+ endpoints: [
27
+ {
28
+ method: "POST",
29
+ path: "/project/{project_id}/run/exec",
30
+ tool_name: "run",
31
+ description: "Execute a new XanoScript run. Creates a session to track execution and returns the result.",
32
+ parameters: [
33
+ { name: "project_id", type: "uuid", required: true, in: "path", description: "Project UUID" }
34
+ ],
35
+ request_body: {
36
+ type: "application/json",
37
+ properties: {
38
+ doc: { type: "text", required: true, description: "XanoScript document content" },
39
+ args: { type: "json", description: "Arguments passed to the job (default: {})" },
40
+ env: { type: "json", description: "Environment variable overrides (default: {})" },
41
+ template: { type: "text", description: "Execution template (default: 'small')" },
42
+ logs: { type: "json[]", description: "Execution logs array (default: [])" }
43
+ }
44
+ },
45
+ example: {
46
+ method: "POST",
47
+ path: "/project/abc123-uuid/run/exec",
48
+ body: {
49
+ doc: "job process_data {\n input { json items }\n response = $input.items.map(i => i.value * 2)\n}",
50
+ args: { items: [{ value: 1 }, { value: 2 }, { value: 3 }] },
51
+ template: "small"
52
+ }
53
+ }
54
+ },
55
+ {
56
+ method: "POST",
57
+ path: "/project/{project_id}/run/{run_id}/exec",
58
+ description: "Re-execute an existing run by its ID. Uses the stored run configuration with optional argument and environment overrides.",
59
+ parameters: [
60
+ { name: "project_id", type: "uuid", required: true, in: "path", description: "Project UUID" },
61
+ { name: "run_id", type: "uuid", required: true, in: "path", description: "Run UUID to re-execute" }
62
+ ],
63
+ request_body: {
64
+ type: "application/json",
65
+ properties: {
66
+ args: { type: "json", description: "Override arguments (default: {})" },
67
+ env: { type: "json", description: "Override environment variables (default: {})" },
68
+ template: { type: "text", description: "Execution template (default: 'small')" },
69
+ logs: { type: "json[]", description: "Execution logs array (default: [])" }
70
+ }
71
+ },
72
+ example: {
73
+ method: "POST",
74
+ path: "/project/abc123-uuid/run/run456-uuid/exec",
75
+ body: {
76
+ args: { updated_value: 100 },
77
+ template: "small"
78
+ }
79
+ }
80
+ }
81
+ ],
82
+ schemas: {
83
+ Run: {
84
+ type: "object",
85
+ properties: {
86
+ id: { type: "uuid", description: "Unique run identifier" },
87
+ name: { type: "text", description: "Run name" },
88
+ type: { type: "enum", enum: ["job", "service"], description: "Run type" },
89
+ doc: { type: "text", description: "XanoScript document content" },
90
+ args: { type: "json", description: "Stored arguments" },
91
+ project_id: { type: "uuid", description: "Associated project" },
92
+ user_id: { type: "integer", description: "Owner user ID" },
93
+ sig: { type: "text", description: "Document signature/hash" },
94
+ created_at: { type: "timestamp", description: "Creation time" },
95
+ updated_at: { type: "timestamp", description: "Last update time" }
96
+ }
97
+ },
98
+ ExecutionResult: {
99
+ type: "object",
100
+ properties: {
101
+ session_id: { type: "uuid", description: "Created session ID" },
102
+ state: { type: "enum", enum: ["pending", "processing", "running", "error", "complete"] },
103
+ response: { type: "any", description: "Execution result" },
104
+ error_msg: { type: "text", description: "Error message if failed" },
105
+ logs: { type: "json[]", description: "Execution logs" }
106
+ }
107
+ }
108
+ },
109
+ related_topics: ["session", "history", "workflows"]
110
+ };
@@ -0,0 +1,2 @@
1
+ import type { TopicDoc } from "../../meta_api_docs/types.js";
2
+ export declare const sessionDoc: TopicDoc;