farseer-cli 1.13.0 → 1.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -8
- package/dist/commands/config.js +4 -3
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/install.js +5 -0
- package/dist/commands/install.js.map +2 -2
- package/dist/commands/login.js +2 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/pipeline.js +158 -0
- package/dist/commands/pipeline.js.map +7 -0
- package/dist/commands/pull.js +2 -1
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/run.js +9 -0
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/variables.js +17 -8
- package/dist/commands/variables.js.map +2 -2
- package/dist/index.js +45 -46
- package/dist/index.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +13 -68
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/resources/documentation.js +14 -0
- package/dist/mcp/resources/documentation.js.map +2 -2
- package/dist/mcp/server.js +14 -2
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/skills.js +59 -0
- package/dist/mcp/skills.js.map +7 -0
- package/dist/mcp/tools/appTools.js +4 -0
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/authTools.js +5 -3
- package/dist/mcp/tools/authTools.js.map +2 -2
- package/dist/mcp/tools/cellTools.js +3 -2
- package/dist/mcp/tools/cellTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +23 -18
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +16 -12
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/folderTools.js +5 -4
- package/dist/mcp/tools/folderTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +33 -58
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/pipelineContract.js +320 -0
- package/dist/mcp/tools/pipelineContract.js.map +7 -0
- package/dist/mcp/tools/pipelineTools.js +111 -0
- package/dist/mcp/tools/pipelineTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +10 -3
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +21 -17
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +15 -5
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/mcp/utils/registerTool.js +32 -0
- package/dist/mcp/utils/registerTool.js.map +7 -0
- package/dist/pipeline/compatibility.js +53 -0
- package/dist/pipeline/compatibility.js.map +7 -0
- package/dist/pipeline/connect.js +139 -0
- package/dist/pipeline/connect.js.map +7 -0
- package/dist/pipeline/create.js +158 -0
- package/dist/pipeline/create.js.map +7 -0
- package/dist/pipeline/errors.js +45 -0
- package/dist/pipeline/errors.js.map +7 -0
- package/dist/pipeline/generated-reference.json +115 -0
- package/dist/pipeline/guide.js +33 -0
- package/dist/pipeline/guide.js.map +7 -0
- package/dist/pipeline/init.js +204 -0
- package/dist/pipeline/init.js.map +7 -0
- package/dist/pipeline/operations.js +106 -0
- package/dist/pipeline/operations.js.map +7 -0
- package/dist/pipeline/query.js +121 -0
- package/dist/pipeline/query.js.map +7 -0
- package/dist/pipeline/queryDownloads.js +72 -0
- package/dist/pipeline/queryDownloads.js.map +7 -0
- package/dist/pipeline/queryWorker.js +96 -0
- package/dist/pipeline/queryWorker.js.map +7 -0
- package/dist/pipeline/readiness.js +62 -0
- package/dist/pipeline/readiness.js.map +7 -0
- package/dist/pipeline/reference.js +73 -0
- package/dist/pipeline/reference.js.map +7 -0
- package/dist/pipeline/requests.js +122 -0
- package/dist/pipeline/requests.js.map +7 -0
- package/dist/pipeline/runArguments.js +68 -0
- package/dist/pipeline/runArguments.js.map +7 -0
- package/dist/pipeline/runtime.js +106 -0
- package/dist/pipeline/runtime.js.map +7 -0
- package/dist/pipeline/service.js +1027 -0
- package/dist/pipeline/service.js.map +7 -0
- package/dist/services/agentApprovalFetch.js +86 -0
- package/dist/services/agentApprovalFetch.js.map +7 -0
- package/dist/services/appSyncService.js.map +1 -1
- package/dist/services/configService.js +40 -4
- package/dist/services/configService.js.map +2 -2
- package/dist/services/credentials.js +2 -0
- package/dist/services/credentials.js.map +2 -2
- package/dist/services/farseerService.js +33 -3
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/modelExport.js.map +1 -1
- package/dist/services/preflight.js +4 -0
- package/dist/services/preflight.js.map +2 -2
- package/dist/services/syncService.js +6 -0
- package/dist/services/syncService.js.map +2 -2
- package/dist/skills/pipeline.js +71 -0
- package/dist/skills/pipeline.js.map +7 -0
- package/dist/utils/agentSandbox.js +35 -0
- package/dist/utils/agentSandbox.js.map +7 -0
- package/dist/utils/helpers.js +2 -1
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/variableValues.js +78 -0
- package/dist/utils/variableValues.js.map +7 -0
- package/docs/pipeline-client-guide.md +67 -0
- package/docs/pipeline-reference.md +2064 -0
- package/package.json +5 -1
- package/skills/pipeline-authoring/SKILL.md +95 -0
- package/skills/pipeline-authoring/practices.md +325 -0
package/dist/mcp/server.js
CHANGED
|
@@ -27,6 +27,7 @@ var import_authTools = require("./tools/authTools");
|
|
|
27
27
|
var import_syncTools = require("./tools/syncTools");
|
|
28
28
|
var import_appTools = require("./tools/appTools");
|
|
29
29
|
var import_modelTools = require("./tools/modelTools");
|
|
30
|
+
var import_pipelineTools = require("./tools/pipelineTools");
|
|
30
31
|
var import_runTools = require("./tools/runTools");
|
|
31
32
|
var import_dataTools = require("./tools/dataTools");
|
|
32
33
|
var import_sheetTools = require("./tools/sheetTools");
|
|
@@ -35,11 +36,20 @@ var import_cellTools = require("./tools/cellTools");
|
|
|
35
36
|
var import_folderTools = require("./tools/folderTools");
|
|
36
37
|
var import_documentation = require("./resources/documentation");
|
|
37
38
|
var import_workflows = require("./prompts/workflows");
|
|
38
|
-
|
|
39
|
+
var import_skills = require("./skills");
|
|
40
|
+
const SERVER_INSTRUCTIONS = `Author all new repeatable data pipelines with Simple Pipelines. Do not create new TypeScript pipelines, including when TypeScript is requested; explain the supported authoring path. Before choosing a workflow, inspect the relevant existing apps and source with farseer_list_apps, farseer_get_app and farseer_pull.
|
|
41
|
+
|
|
42
|
+
Preserve existing TypeScript apps. Inspect, run, debug and make targeted fixes through the existing app tools without requiring the user to explicitly say TypeScript. A request to fix or extend an existing import is maintenance, not permission to migrate it, replace its source folder, entrypoint, runner image or schedule, or create a duplicate pipeline. Migration to Simple Pipelines requires an explicit migration request. An existing TypeScript app is not missing Simple Pipelines setup; do not reconfigure it to make pipeline commands pass. Apply this per app, including on tenants with both implementations.
|
|
43
|
+
|
|
44
|
+
For new or existing Simple Pipelines, load the pipeline-authoring skill at skill://farseer/pipeline-authoring/SKILL.md. If skill loading is unavailable, call farseer_pipeline operation=guide topic=method for the same instructions. Then read topic=grammar and the relevant Pydantic model topics; use operation=check to verify the prepared setup. If the required job, profile or source setup is missing, explain what needs preparing instead of implementing a TypeScript pipeline or direct import as a fallback. A requested one-off direct import is still supported; it does not authorize a new TypeScript pipeline.
|
|
45
|
+
|
|
46
|
+
For pipeline authoring, use the pipeline operations for sync and execution. Coordinate shared source edits with colleagues; this pipeline has no authoring ownership sessions. A refused run accepted no new run; read the reason and do not automatically retry a refusal. If compatibility requires a CLI update, tell the author to update and restart this MCP connection before continuing.
|
|
47
|
+
|
|
48
|
+
This MCP server works on a single Farseer tenant per session \u2014 one tenant for the whole session, never switched.
|
|
39
49
|
|
|
40
50
|
- If it was launched with a tenant (\`--tenant <slug>\` or the \`FARSEER_TENANT\` env), it is locked to that tenant. Tools take no tenant/organisation argument; they always act on the bound tenant. Do not use farseer CLI commands to change it.
|
|
41
51
|
- If no tenant is set yet, bind it once: when the user says which tenant/client to work on, call \`farseer_select_tenant\`. After that first selection the tenant is locked for the session; to use a different tenant, start a new session.
|
|
42
|
-
- Use \`farseer_whoami\` to see the active tenant.
|
|
52
|
+
- Use \`farseer_whoami\` to see the active tenant. Tenant operations require a bound tenant; offline guidance can be read before selection.`;
|
|
43
53
|
function createMcpServer() {
|
|
44
54
|
const server = new import_mcp.McpServer(
|
|
45
55
|
{
|
|
@@ -53,12 +63,14 @@ function createMcpServer() {
|
|
|
53
63
|
(0, import_appTools.registerAppTools)(server);
|
|
54
64
|
(0, import_modelTools.registerModelTools)(server);
|
|
55
65
|
(0, import_runTools.registerRunTools)(server);
|
|
66
|
+
(0, import_pipelineTools.registerPipelineTools)(server);
|
|
56
67
|
(0, import_dataTools.registerDataTools)(server);
|
|
57
68
|
(0, import_sheetTools.registerSheetTools)(server);
|
|
58
69
|
(0, import_dashboardTools.registerDashboardTools)(server);
|
|
59
70
|
(0, import_cellTools.registerCellTools)(server);
|
|
60
71
|
(0, import_folderTools.registerFolderTools)(server);
|
|
61
72
|
(0, import_documentation.registerDocumentationResources)(server);
|
|
73
|
+
(0, import_skills.registerSkills)(server);
|
|
62
74
|
(0, import_workflows.registerWorkflowPrompts)(server);
|
|
63
75
|
return server;
|
|
64
76
|
}
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mcp/server.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { CLI_VERSION } from '../utils/constants';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDataTools } from './tools/dataTools';\nimport { registerSheetTools } from './tools/sheetTools';\nimport { registerDashboardTools } from './tools/dashboardTools';\nimport { registerCellTools } from './tools/cellTools';\nimport { registerFolderTools } from './tools/folderTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\n// Surfaced to the model at connect time (MCP `instructions`). It sets the\n// mental model up front so an agent doesn't try to \"check out\" or authenticate\n// a tenant through CLI commands \u2014 which live on a different code path and do\n// not affect this server.\nconst SERVER_INSTRUCTIONS = `
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAA4B;AAC5B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,sBAAiC;AACjC,uBAAkC;AAClC,wBAAmC;AACnC,4BAAuC;AACvC,uBAAkC;AAClC,yBAAoC;AACpC,2BAA+C;AAC/C,uBAAwC;
|
|
4
|
+
"sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { CLI_VERSION } from '../utils/constants';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerPipelineTools } from './tools/pipelineTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDataTools } from './tools/dataTools';\nimport { registerSheetTools } from './tools/sheetTools';\nimport { registerDashboardTools } from './tools/dashboardTools';\nimport { registerCellTools } from './tools/cellTools';\nimport { registerFolderTools } from './tools/folderTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\nimport { registerSkills } from './skills';\n\n// Surfaced to the model at connect time (MCP `instructions`). It sets the\n// mental model up front so an agent doesn't try to \"check out\" or authenticate\n// a tenant through CLI commands \u2014 which live on a different code path and do\n// not affect this server.\nconst SERVER_INSTRUCTIONS = `Author all new repeatable data pipelines with Simple Pipelines. Do not create new TypeScript pipelines, including when TypeScript is requested; explain the supported authoring path. Before choosing a workflow, inspect the relevant existing apps and source with farseer_list_apps, farseer_get_app and farseer_pull.\n\nPreserve existing TypeScript apps. Inspect, run, debug and make targeted fixes through the existing app tools without requiring the user to explicitly say TypeScript. A request to fix or extend an existing import is maintenance, not permission to migrate it, replace its source folder, entrypoint, runner image or schedule, or create a duplicate pipeline. Migration to Simple Pipelines requires an explicit migration request. An existing TypeScript app is not missing Simple Pipelines setup; do not reconfigure it to make pipeline commands pass. Apply this per app, including on tenants with both implementations.\n\nFor new or existing Simple Pipelines, load the pipeline-authoring skill at skill://farseer/pipeline-authoring/SKILL.md. If skill loading is unavailable, call farseer_pipeline operation=guide topic=method for the same instructions. Then read topic=grammar and the relevant Pydantic model topics; use operation=check to verify the prepared setup. If the required job, profile or source setup is missing, explain what needs preparing instead of implementing a TypeScript pipeline or direct import as a fallback. A requested one-off direct import is still supported; it does not authorize a new TypeScript pipeline.\n\nFor pipeline authoring, use the pipeline operations for sync and execution. Coordinate shared source edits with colleagues; this pipeline has no authoring ownership sessions. A refused run accepted no new run; read the reason and do not automatically retry a refusal. If compatibility requires a CLI update, tell the author to update and restart this MCP connection before continuing.\n\nThis MCP server works on a single Farseer tenant per session \u2014 one tenant for the whole session, never switched.\n\n- If it was launched with a tenant (\\`--tenant <slug>\\` or the \\`FARSEER_TENANT\\` env), it is locked to that tenant. Tools take no tenant/organisation argument; they always act on the bound tenant. Do not use farseer CLI commands to change it.\n- If no tenant is set yet, bind it once: when the user says which tenant/client to work on, call \\`farseer_select_tenant\\`. After that first selection the tenant is locked for the session; to use a different tenant, start a new session.\n- Use \\`farseer_whoami\\` to see the active tenant. Tenant operations require a bound tenant; offline guidance can be read before selection.`;\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer(\n {\n name: 'farseer-cli',\n version: CLI_VERSION,\n },\n { instructions: SERVER_INSTRUCTIONS },\n );\n\n // Register all tools\n registerAuthTools(server);\n registerSyncTools(server);\n registerAppTools(server);\n registerModelTools(server);\n registerRunTools(server);\n registerPipelineTools(server);\n registerDataTools(server);\n registerSheetTools(server);\n registerDashboardTools(server);\n registerCellTools(server);\n registerFolderTools(server);\n\n // Register resources (documentation)\n registerDocumentationResources(server);\n registerSkills(server);\n\n // Register prompts (workflow templates)\n registerWorkflowPrompts(server);\n\n return server;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAA4B;AAC5B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,2BAAsC;AACtC,sBAAiC;AACjC,uBAAkC;AAClC,wBAAmC;AACnC,4BAAuC;AACvC,uBAAkC;AAClC,yBAAoC;AACpC,2BAA+C;AAC/C,uBAAwC;AACxC,oBAA+B;AAM/B,MAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcrB,SAAS,kBAA6B;AACzC,QAAM,SAAS,IAAI;AAAA,IACf;AAAA,MACI,MAAM;AAAA,MACN,SAAS;AAAA,IACb;AAAA,IACA,EAAE,cAAc,oBAAoB;AAAA,EACxC;AAGA,0CAAkB,MAAM;AACxB,0CAAkB,MAAM;AACxB,wCAAiB,MAAM;AACvB,4CAAmB,MAAM;AACzB,wCAAiB,MAAM;AACvB,kDAAsB,MAAM;AAC5B,0CAAkB,MAAM;AACxB,4CAAmB,MAAM;AACzB,oDAAuB,MAAM;AAC7B,0CAAkB,MAAM;AACxB,8CAAoB,MAAM;AAG1B,2DAA+B,MAAM;AACrC,oCAAe,MAAM;AAGrB,gDAAwB,MAAM;AAE9B,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var skills_exports = {};
|
|
20
|
+
__export(skills_exports, {
|
|
21
|
+
registerSkills: () => registerSkills
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(skills_exports);
|
|
24
|
+
var import_types = require("@modelcontextprotocol/sdk/types.js");
|
|
25
|
+
var import_v4 = require("zod/v4");
|
|
26
|
+
var import_pipeline = require("../skills/pipeline");
|
|
27
|
+
const listRequest = import_types.PaginatedRequestSchema.extend({ method: import_v4.z.literal("skills/list") });
|
|
28
|
+
const getRequest = import_types.RequestSchema.extend({
|
|
29
|
+
method: import_v4.z.literal("skills/get")
|
|
30
|
+
});
|
|
31
|
+
const cache = { resultType: "complete", ttlMs: 3e5, cacheScope: "public" };
|
|
32
|
+
function registerSkills(server) {
|
|
33
|
+
server.server.registerCapabilities({ extensions: { "io.modelcontextprotocol/skills": {} } });
|
|
34
|
+
for (const [uri, text] of import_pipeline.pipelineSkill.files) {
|
|
35
|
+
const isSkill = uri === import_pipeline.PIPELINE_SKILL_URI;
|
|
36
|
+
server.resource(
|
|
37
|
+
isSkill ? import_pipeline.pipelineSkill.entry.frontmatter.name : `${import_pipeline.pipelineSkill.entry.frontmatter.name}/${uri.split("/").pop()}`,
|
|
38
|
+
uri,
|
|
39
|
+
{
|
|
40
|
+
description: isSkill ? import_pipeline.pipelineSkill.entry.frontmatter.description : "Part of the pipeline-authoring skill; SKILL.md says when to read it.",
|
|
41
|
+
mimeType: "text/markdown"
|
|
42
|
+
},
|
|
43
|
+
() => ({ ...cache, contents: [{ uri, mimeType: "text/markdown", text }] })
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
server.server.setRequestHandler(listRequest, async ({ params }) => {
|
|
47
|
+
if (params?.cursor !== void 0) throw new import_types.McpError(import_types.ErrorCode.InvalidParams, "Unknown skills cursor");
|
|
48
|
+
return { ...cache, skills: [import_pipeline.pipelineSkill.entry] };
|
|
49
|
+
});
|
|
50
|
+
server.server.setRequestHandler(getRequest, async ({ params }) => {
|
|
51
|
+
if (params?.uri !== import_pipeline.PIPELINE_SKILL_URI) throw new import_types.McpError(import_types.ErrorCode.InvalidParams, "Unknown skill URI");
|
|
52
|
+
return { ...cache, skill: import_pipeline.pipelineSkill.entry };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
registerSkills
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/mcp/skills.ts"],
|
|
4
|
+
"sourcesContent": ["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { ErrorCode, McpError, PaginatedRequestSchema, RequestSchema } from '@modelcontextprotocol/sdk/types.js';\nimport { z } from 'zod/v4';\nimport { pipelineSkill, PIPELINE_SKILL_URI } from '../skills/pipeline';\n\n// Optional extension; legacy clients continue using resources or the guide tool.\n// https://skills.extensions.modelcontextprotocol.io/specification/stable/skills\nconst listRequest = PaginatedRequestSchema.extend({ method: z.literal('skills/list') });\nconst getRequest = RequestSchema.extend({\n method: z.literal('skills/get'),\n});\nconst cache = { resultType: 'complete' as const, ttlMs: 300_000, cacheScope: 'public' as const };\n\nexport function registerSkills(server: McpServer): void {\n server.server.registerCapabilities({ extensions: { 'io.modelcontextprotocol/skills': {} } });\n // Every file the manifest lists is served; SKILL.md carries the skill's name and description.\n for (const [uri, text] of pipelineSkill.files) {\n const isSkill = uri === PIPELINE_SKILL_URI;\n server.resource(\n isSkill\n ? pipelineSkill.entry.frontmatter.name\n : `${pipelineSkill.entry.frontmatter.name}/${uri.split('/').pop()}`,\n uri,\n {\n description: isSkill\n ? pipelineSkill.entry.frontmatter.description\n : 'Part of the pipeline-authoring skill; SKILL.md says when to read it.',\n mimeType: 'text/markdown',\n },\n () => ({ ...cache, contents: [{ uri, mimeType: 'text/markdown', text }] }),\n );\n }\n server.server.setRequestHandler(listRequest, async ({ params }) => {\n // The complete static catalogue fits on one page, so no cursor is issued.\n if (params?.cursor !== undefined) throw new McpError(ErrorCode.InvalidParams, 'Unknown skills cursor');\n return { ...cache, skills: [pipelineSkill.entry] };\n });\n server.server.setRequestHandler(getRequest, async ({ params }) => {\n if (params?.uri !== PIPELINE_SKILL_URI) throw new McpError(ErrorCode.InvalidParams, 'Unknown skill URI');\n return { ...cache, skill: pipelineSkill.entry };\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2E;AAC3E,gBAAkB;AAClB,sBAAkD;AAIlD,MAAM,cAAc,oCAAuB,OAAO,EAAE,QAAQ,YAAE,QAAQ,aAAa,EAAE,CAAC;AACtF,MAAM,aAAa,2BAAc,OAAO;AAAA,EACpC,QAAQ,YAAE,QAAQ,YAAY;AAClC,CAAC;AACD,MAAM,QAAQ,EAAE,YAAY,YAAqB,OAAO,KAAS,YAAY,SAAkB;AAExF,SAAS,eAAe,QAAyB;AACpD,SAAO,OAAO,qBAAqB,EAAE,YAAY,EAAE,kCAAkC,CAAC,EAAE,EAAE,CAAC;AAE3F,aAAW,CAAC,KAAK,IAAI,KAAK,8BAAc,OAAO;AAC3C,UAAM,UAAU,QAAQ;AACxB,WAAO;AAAA,MACH,UACM,8BAAc,MAAM,YAAY,OAChC,GAAG,8BAAc,MAAM,YAAY,IAAI,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI,CAAC;AAAA,MACrE;AAAA,MACA;AAAA,QACI,aAAa,UACP,8BAAc,MAAM,YAAY,cAChC;AAAA,QACN,UAAU;AAAA,MACd;AAAA,MACA,OAAO,EAAE,GAAG,OAAO,UAAU,CAAC,EAAE,KAAK,UAAU,iBAAiB,KAAK,CAAC,EAAE;AAAA,IAC5E;AAAA,EACJ;AACA,SAAO,OAAO,kBAAkB,aAAa,OAAO,EAAE,OAAO,MAAM;AAE/D,QAAI,QAAQ,WAAW,OAAW,OAAM,IAAI,sBAAS,uBAAU,eAAe,uBAAuB;AACrG,WAAO,EAAE,GAAG,OAAO,QAAQ,CAAC,8BAAc,KAAK,EAAE;AAAA,EACrD,CAAC;AACD,SAAO,OAAO,kBAAkB,YAAY,OAAO,EAAE,OAAO,MAAM;AAC9D,QAAI,QAAQ,QAAQ,mCAAoB,OAAM,IAAI,sBAAS,uBAAU,eAAe,mBAAmB;AACvG,WAAO,EAAE,GAAG,OAAO,OAAO,8BAAc,MAAM;AAAA,EAClD,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -209,6 +209,8 @@ Returns:
|
|
|
209
209
|
"farseer_create_app",
|
|
210
210
|
`Create a new Farseer app.
|
|
211
211
|
|
|
212
|
+
All new repeatable data pipelines must use Simple Pipelines through farseer_pipeline operation=guide topic=method, even when TypeScript is requested. Inspect existing apps first; do not create a replacement or duplicate to fix an existing TypeScript app. This creation workflow is for non-pipeline apps. Maintain existing TypeScript pipelines with the app tools; migration requires an explicit migration request.
|
|
213
|
+
|
|
212
214
|
A Farseer App is a named configuration that points to a TypeScript script and defines its arguments.
|
|
213
215
|
The script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).
|
|
214
216
|
|
|
@@ -248,6 +250,8 @@ Scripts should use \`new FarseerClient()\` with no arguments - credentials are i
|
|
|
248
250
|
"farseer_configure_app",
|
|
249
251
|
`Configure an existing Farseer app.
|
|
250
252
|
|
|
253
|
+
Preserve existing TypeScript apps during maintenance. Do not change their source folder, entrypoint, runner image or schedule to satisfy Simple Pipelines setup. Migration requires an explicit migration request; use the existing app tools for targeted fixes.
|
|
254
|
+
|
|
251
255
|
You can set:
|
|
252
256
|
- sourceFolder: Folder under Files/ the app's scripts come from (e.g. "Scripts/MyApp")
|
|
253
257
|
- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., "index.ts")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/mcp/tools/appTools.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * App Management Tools\n *\n * Tools for managing Farseer apps (Remote Jobs).\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { requireSession } from '../utils/session';\nimport {\n APP_COMPUTE_CHOICES,\n AppArgument,\n AppDeleteRefusedError,\n AppPredefinedAction,\n AppUpdateChanges,\n CLEAR_SETTING,\n applyRunSettings,\n applySourceFolderChange,\n formatCompute,\n redactActionValues,\n restoreRedactedValues,\n} from '../../services/apps';\nimport { successResponse, errorResponse, resolveAppItemForMcp, resolveAppForMcp } from '../utils/helpers';\nimport { matchByName } from '../../utils/nameResolver';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst listAppsSchema = {\n details: z.boolean().optional().describe('Include full details for each app'),\n};\n\nconst getAppSchema = {\n appName: z.string().optional().describe('Name of the app (can include spaces). Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n};\n\nconst createAppSchema = {\n appName: z.string().describe('Name for the new app'),\n};\n\nexport const argumentSchema = z\n .object({\n name: z.string(),\n dataType: z.enum(['string', 'boolean']).optional().describe('Data type. Defaults to \"string\" if omitted.'),\n fixed: z\n .boolean()\n .optional()\n .describe('Lock the value at run time so users cannot override it (admin sets, user reads only).'),\n options: z\n .array(z.string())\n .optional()\n .describe('Closed allowed-value set. Only meaningful for string dataType.'),\n defaultValue: z.string().optional(),\n secret: z.boolean().optional().describe('Mask the value in inputs and logs.'),\n })\n // Cross-axis checks mirror the backend's `validateExpectedArguments` so an\n // LLM caller gets pre-request feedback. Backend stays authoritative \u2014 these\n // catch the same shapes earlier, they don't replace the validator.\n .refine(\n (a) => a.dataType !== 'boolean' || a.defaultValue === undefined || ['true', 'false'].includes(a.defaultValue),\n {\n message: 'Boolean argument defaultValue must be \"true\" or \"false\"',\n path: ['defaultValue'],\n },\n )\n .refine((a) => !a.options || a.defaultValue === undefined || a.options.includes(a.defaultValue), {\n message: 'defaultValue must be one of the options',\n path: ['defaultValue'],\n });\n\nexport const predefinedActionSchema = z.object({\n name: z.string(),\n runArguments: z.record(z.string()).describe('Argument name to the value this action runs with.'),\n});\n\nconst configureAppSchema = {\n appName: z.string().optional().describe('Name of the app to configure. Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n entrypoint: z\n .string()\n .optional()\n .describe('Main script filename \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")'),\n sourceFolder: z\n .string()\n .optional()\n .describe('Source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")'),\n description: z.string().optional().describe('App description'),\n arguments: z.array(argumentSchema).optional().describe('App arguments with default values'),\n newName: z.string().optional().describe('Rename the app'),\n schedule: z\n .string()\n .optional()\n .describe(`Cron expression to run the app on, e.g. \"0 6 * * *\". Pass \"${CLEAR_SETTING}\" to clear it.`),\n runner: z\n .string()\n .optional()\n .describe(`Name of the jobrunner that runs the app. Pass \"${CLEAR_SETTING}\" to let any runner take it.`),\n runnerImage: z\n .string()\n .optional()\n .describe(\n `Container image the app runs in, as \"<repository>:<tag>\" (e.g. \"runner-typescript:latest\") or a full registry reference. Pass \"${CLEAR_SETTING}\" for the tenant default.`,\n ),\n compute: z\n .enum(APP_COMPUTE_CHOICES as unknown as [string, ...string[]])\n .optional()\n .describe(\n 'Where a run executes: \"local\" is a container on the jobrunner\\'s own machine, \"batch\" a machine created for that run. The size suffix picks how much machine; bare \"batch\" takes the deployment\\'s default size.',\n ),\n predefinedActions: z\n .array(predefinedActionSchema)\n .optional()\n .describe('Named argument presets offered as buttons in the UI. Replaces the existing list wholesale.'),\n};\n\nconst deleteAppSchema = {\n appName: z.string().optional().describe('Name of the app to delete. Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n};\n\nexport function registerAppTools(server: McpServer): void {\n // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics\n const s: any = server;\n\n // farseer_list_apps - List all apps\n s.tool(\n 'farseer_list_apps',\n `List all apps (Remote Jobs) configured on a Farseer tenant.\n\nApps are executable script configurations that include:\n- Entry point script\n- List of included scripts\n- Expected arguments with default values\n\nUse details=true to include full information for each app.`,\n listAppsSchema,\n async (params: { details?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const appList = await client.listApps();\n\n if (!params.details) {\n return successResponse({\n tenant,\n totalApps: appList.length,\n apps: appList.map((a) => ({\n name: a.name,\n reference: a.reference,\n })),\n });\n }\n\n // Get full details for each app\n const appsWithDetails = [];\n for (const item of appList) {\n const app = await client.getApp(item.reference);\n if (app) {\n const appScripts = app.scriptFiles ?? [];\n const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);\n appsWithDetails.push({\n name: app.name,\n id: app.id,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: appScripts.map((s) => s.name),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n });\n }\n }\n\n return successResponse({\n tenant,\n totalApps: appsWithDetails.length,\n apps: appsWithDetails,\n });\n } catch (error) {\n return errorResponse(`List apps failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_app - Get app details\n s.tool(\n 'farseer_get_app',\n `Get detailed information about a specific Farseer app.\n\nReturns:\n- App name and description\n- Entry point script (main script that runs)\n- List of all included scripts\n- Expected arguments with their default values\n- Schedule, runner, runner image and compute selection\n- Predefined actions (named argument presets)`,\n getAppSchema,\n async (params: { appName?: string; appId?: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const app = resolution.app;\n\n const getAppScripts = app.scriptFiles ?? [];\n const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: getAppScripts.map((s) => ({\n id: s.id,\n name: s.name,\n isEntrypoint: s.id === app.mainScriptFileId,\n })),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n status: app.status,\n lastHeartbeat: app.lastHeartbeat,\n schedule: app.schedule ?? null,\n runner: app.runnerName ?? null,\n runnerImage: app.runnerImage ?? null,\n compute: formatCompute(app.compute),\n predefinedActions: redactActionValues(app.predefinedActions ?? [], app.expectedArguments),\n },\n });\n } catch (error) {\n return errorResponse(`Get app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_app - Create new app\n s.tool(\n 'farseer_create_app',\n `Create a new Farseer app.\n\nA Farseer App is a named configuration that points to a TypeScript script and defines its arguments.\nThe script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).\n\nWorkflow to create a new app:\n1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts\n2. Push the script to remote with farseer_push (scripts must exist on remote first)\n3. Create the app with this tool (farseer_create_app)\n4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)\n5. Run it with farseer_run_app (CLI injects auth credentials automatically)\n\nScripts should use \\`new FarseerClient()\\` with no arguments - credentials are injected via environment variables by the CLI at runtime.`,\n createAppSchema,\n async (params: { appName: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchByName(await client.listApps(), params.appName);\n if (existing.length > 0) {\n return errorResponse(`App \"${params.appName}\" already exists`, 'VALIDATION_ERROR');\n }\n\n const app = await client.createApp(params.appName);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n },\n message: `App \"${params.appName}\" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,\n });\n } catch (error) {\n return errorResponse(`Create app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_configure_app - Configure app settings\n s.tool(\n 'farseer_configure_app',\n `Configure an existing Farseer app.\n\nYou can set:\n- sourceFolder: Folder under Files/ the app's scripts come from (e.g. \"Scripts/MyApp\")\n- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., \"index.ts\")\n- description: App description\n- arguments: List of expected arguments. Each has a name, optional dataType\n ('string' | 'boolean' \u2014 defaults to 'string'), optional fixed (locks the\n value at run time), optional options (closed allowed-value set, string\n dataType only), optional defaultValue, and optional secret.\n- newName: Rename the app\n- schedule: Cron expression the app runs on (e.g. \"0 6 * * *\")\n- runner: Which jobrunner runs the app\n- runnerImage: Container image, as \"<repository>:<tag>\" or a full registry reference\n- compute: Where a run executes \u2014 'local', 'batch', or 'batch:<size>' with size s, m, l or xl\n- predefinedActions: Named argument presets offered as buttons in the UI. The\n list you pass replaces the app's whole list. farseer_get_app shows a secret\n argument's value as \"<secret>\"; send \"<secret>\" back to keep the stored value\n of the action with exactly that name. Where two actions share a name, give\n the real value.\n\nImportant:\n- The app's scripts are derived from its source folder; the entrypoint must be\n one of those files. To use a script from another folder, set sourceFolder first.\n- Changing sourceFolder to a folder that doesn't contain the current entrypoint\n requires passing entrypoint in the same call.\n- Settings you don't pass are preserved (this only changes what you specify).\n- Pass \"${CLEAR_SETTING}\" to schedule, runner or runnerImage to clear it.\n- Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var\n- Boolean dataType requires defaultValue \u2208 { \"true\", \"false\" }; defaultValue\n must be one of options when options is set`,\n configureAppSchema,\n async (params: {\n appName?: string;\n appId?: string;\n entrypoint?: string;\n sourceFolder?: string;\n description?: string;\n arguments?: Array<{\n name: string;\n dataType?: 'string' | 'boolean';\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }>;\n newName?: string;\n schedule?: string;\n runner?: string;\n runnerImage?: string;\n compute?: string;\n predefinedActions?: AppPredefinedAction[];\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const app = resolution.app;\n\n // The set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (params.newName) {\n changes.name = params.newName;\n }\n\n if (params.description !== undefined) {\n changes.description = params.description;\n }\n\n if (params.arguments) {\n // PUT semantics on the backend: this `expectedArguments`\n // array replaces the existing one wholesale. So if the\n // caller supplies a name but omits axes (dataType, fixed,\n // options, secret), we look up the existing arg by name\n // and carry those fields over. Without this merge, a\n // configure_app call that only re-sets defaultValue would\n // silently clear the secret flag or demote a dropdown\n // back to a plain string variable.\n //\n // Lookup is case-insensitive for convenience (caller\n // shouldn't have to remember exact casing to update an\n // existing arg), but on the write we keep the backend's\n // stored casing: validateExpectedArguments on the server\n // is case-sensitive (seen.has(arg.name)), so writing\n // back caller-supplied case would silently rename the\n // arg (e.g. jobName \u2192 JOBNAME) and break the next push.\n const existingByName = new Map(app.expectedArguments.map((e) => [e.name.toLowerCase(), e]));\n changes.expectedArguments = params.arguments.map((a) => {\n const existing = existingByName.get(a.name.toLowerCase());\n const arg: AppArgument = {\n name: existing?.name ?? a.name,\n dataType: a.dataType ?? existing?.dataType ?? 'string',\n };\n const fixed = a.fixed ?? existing?.fixed;\n if (fixed !== undefined) arg.fixed = fixed;\n const options = a.options ?? existing?.options;\n if (options !== undefined) arg.options = options;\n const defaultValue = a.defaultValue ?? existing?.defaultValue;\n if (defaultValue !== undefined) arg.defaultValue = defaultValue;\n const secret = a.secret ?? existing?.secret;\n if (secret !== undefined) arg.secret = secret;\n return arg;\n });\n }\n\n // Source folder + entrypoint. An app's scripts derive from its\n // source folder, and the entrypoint must be one of those files.\n // The decision lives in applySourceFolderChange (shared with the\n // CLI `app configure` command); the 'mcp' caller gets a plain,\n // param-worded error string.\n const sourceFolderError = await applySourceFolderChange(\n client,\n app,\n changes,\n { sourceFolder: params.sourceFolder, entrypoint: params.entrypoint },\n 'mcp',\n );\n if (sourceFolderError) {\n return errorResponse(sourceFolderError, 'VALIDATION_ERROR');\n }\n\n if (params.predefinedActions) {\n const restored = restoreRedactedValues(params.predefinedActions, app.predefinedActions ?? []);\n if ('error' in restored) {\n return errorResponse(restored.error, 'VALIDATION_ERROR');\n }\n changes.predefinedActions = restored.actions;\n }\n\n // Schedule, runner, image and compute. Shared with the CLI\n // `app configure` command so both surfaces take the same vocabulary.\n const runSettings = await applyRunSettings(client, app, changes, {\n schedule: params.schedule,\n runner: params.runner,\n runnerImage: params.runnerImage,\n compute: params.compute,\n });\n if ('error' in runSettings) {\n return errorResponse(runSettings.error, 'VALIDATION_ERROR');\n }\n\n const reference = app.id.toString();\n const updated = await client.updateApp(reference, changes, app);\n\n return successResponse({\n tenant,\n appName: params.newName || app.name,\n updated: Object.keys(changes),\n compute: formatCompute(updated.compute),\n warnings: runSettings.warnings,\n message: `App \"${app.name}\" configured successfully`,\n });\n } catch (error) {\n return errorResponse(`Configure app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_app - Delete app\n s.tool(\n 'farseer_delete_app',\n `Delete an app from a Farseer tenant.\n\nWARNING: This is irreversible - the app will be permanently removed from the remote instance.\n\nThis does NOT delete the script files, only the app configuration.`,\n deleteAppSchema,\n async (params: { appName?: string; appId?: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppItemForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const appItem = resolution.item;\n\n await client.deleteApp(appItem.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await client.listApps();\n if (remaining.some((a) => a.reference === appItem.reference)) {\n return errorResponse(\n `Delete reported success but \"${appItem.name}\" is still present`,\n 'NETWORK_ERROR',\n );\n }\n\n return successResponse({\n tenant,\n deletedApp: appItem.name,\n message: `App \"${appItem.name}\" has been deleted`,\n });\n } catch (error) {\n // A guard refusal is not retryable \u2014 nothing was deleted and a\n // retry cannot change that. Don't let it read as a transport blip.\n return errorResponse(\n `Delete app failed: ${await formatClientError(error)}`,\n error instanceof AppDeleteRefusedError ? 'VALIDATION_ERROR' : 'NETWORK_ERROR',\n );\n }\n },\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * App Management Tools\n *\n * Tools for managing Farseer apps (Remote Jobs).\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerTool } from '../utils/registerTool';\nimport { z } from 'zod';\nimport { requireSession } from '../utils/session';\nimport {\n APP_COMPUTE_CHOICES,\n AppArgument,\n AppDeleteRefusedError,\n AppPredefinedAction,\n AppUpdateChanges,\n CLEAR_SETTING,\n applyRunSettings,\n applySourceFolderChange,\n formatCompute,\n redactActionValues,\n restoreRedactedValues,\n} from '../../services/apps';\nimport { successResponse, errorResponse, resolveAppItemForMcp, resolveAppForMcp } from '../utils/helpers';\nimport { matchByName } from '../../utils/nameResolver';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Define schemas outside of tool registration to avoid deep type instantiation\nconst listAppsSchema = {\n details: z.boolean().optional().describe('Include full details for each app'),\n};\n\nconst getAppSchema = {\n appName: z.string().optional().describe('Name of the app (can include spaces). Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n};\n\nconst createAppSchema = {\n appName: z.string().describe('Name for the new app'),\n};\n\nexport const argumentSchema = z\n .object({\n name: z.string(),\n dataType: z.enum(['string', 'boolean']).optional().describe('Data type. Defaults to \"string\" if omitted.'),\n fixed: z\n .boolean()\n .optional()\n .describe('Lock the value at run time so users cannot override it (admin sets, user reads only).'),\n options: z\n .array(z.string())\n .optional()\n .describe('Closed allowed-value set. Only meaningful for string dataType.'),\n defaultValue: z.string().optional(),\n secret: z.boolean().optional().describe('Mask the value in inputs and logs.'),\n })\n // Cross-axis checks mirror the backend's `validateExpectedArguments` so an\n // LLM caller gets pre-request feedback. Backend stays authoritative \u2014 these\n // catch the same shapes earlier, they don't replace the validator.\n .refine(\n (a) => a.dataType !== 'boolean' || a.defaultValue === undefined || ['true', 'false'].includes(a.defaultValue),\n {\n message: 'Boolean argument defaultValue must be \"true\" or \"false\"',\n path: ['defaultValue'],\n },\n )\n .refine((a) => !a.options || a.defaultValue === undefined || a.options.includes(a.defaultValue), {\n message: 'defaultValue must be one of the options',\n path: ['defaultValue'],\n });\n\nexport const predefinedActionSchema = z.object({\n name: z.string(),\n runArguments: z.record(z.string()).describe('Argument name to the value this action runs with.'),\n});\n\nconst configureAppSchema = {\n appName: z.string().optional().describe('Name of the app to configure. Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n entrypoint: z\n .string()\n .optional()\n .describe('Main script filename \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")'),\n sourceFolder: z\n .string()\n .optional()\n .describe('Source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")'),\n description: z.string().optional().describe('App description'),\n arguments: z.array(argumentSchema).optional().describe('App arguments with default values'),\n newName: z.string().optional().describe('Rename the app'),\n schedule: z\n .string()\n .optional()\n .describe(`Cron expression to run the app on, e.g. \"0 6 * * *\". Pass \"${CLEAR_SETTING}\" to clear it.`),\n runner: z\n .string()\n .optional()\n .describe(`Name of the jobrunner that runs the app. Pass \"${CLEAR_SETTING}\" to let any runner take it.`),\n runnerImage: z\n .string()\n .optional()\n .describe(\n `Container image the app runs in, as \"<repository>:<tag>\" (e.g. \"runner-typescript:latest\") or a full registry reference. Pass \"${CLEAR_SETTING}\" for the tenant default.`,\n ),\n compute: z\n .enum(APP_COMPUTE_CHOICES as unknown as [string, ...string[]])\n .optional()\n .describe(\n 'Where a run executes: \"local\" is a container on the jobrunner\\'s own machine, \"batch\" a machine created for that run. The size suffix picks how much machine; bare \"batch\" takes the deployment\\'s default size.',\n ),\n predefinedActions: z\n .array(predefinedActionSchema)\n .optional()\n .describe('Named argument presets offered as buttons in the UI. Replaces the existing list wholesale.'),\n};\n\nconst deleteAppSchema = {\n appName: z.string().optional().describe('Name of the app to delete. Omit if using appId.'),\n appId: z.string().optional().describe('Numeric app id \u2014 use instead of appName when names collide.'),\n};\n\nexport function registerAppTools(server: McpServer): void {\n // Cast to avoid TS2589 deep type instantiation with MCP SDK + Zod generics\n const s: any = server;\n\n // farseer_list_apps - List all apps\n s.tool(\n 'farseer_list_apps',\n `List all apps (Remote Jobs) configured on a Farseer tenant.\n\nApps are executable script configurations that include:\n- Entry point script\n- List of included scripts\n- Expected arguments with default values\n\nUse details=true to include full information for each app.`,\n listAppsSchema,\n async (params: { details?: boolean }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const appList = await client.listApps();\n\n if (!params.details) {\n return successResponse({\n tenant,\n totalApps: appList.length,\n apps: appList.map((a) => ({\n name: a.name,\n reference: a.reference,\n })),\n });\n }\n\n // Get full details for each app\n const appsWithDetails = [];\n for (const item of appList) {\n const app = await client.getApp(item.reference);\n if (app) {\n const appScripts = app.scriptFiles ?? [];\n const mainScript = appScripts.find((s) => s.id === app.mainScriptFileId);\n appsWithDetails.push({\n name: app.name,\n id: app.id,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: appScripts.map((s) => s.name),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n });\n }\n }\n\n return successResponse({\n tenant,\n totalApps: appsWithDetails.length,\n apps: appsWithDetails,\n });\n } catch (error) {\n return errorResponse(`List apps failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_get_app - Get app details\n s.tool(\n 'farseer_get_app',\n `Get detailed information about a specific Farseer app.\n\nReturns:\n- App name and description\n- Entry point script (main script that runs)\n- List of all included scripts\n- Expected arguments with their default values\n- Schedule, runner, runner image and compute selection\n- Predefined actions (named argument presets)`,\n getAppSchema,\n async (params: { appName?: string; appId?: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const app = resolution.app;\n\n const getAppScripts = app.scriptFiles ?? [];\n const mainScript = getAppScripts.find((s) => s.id === app.mainScriptFileId);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n description: app.description || '',\n entrypoint: mainScript?.name || null,\n scripts: getAppScripts.map((s) => ({\n id: s.id,\n name: s.name,\n isEntrypoint: s.id === app.mainScriptFileId,\n })),\n arguments: app.expectedArguments.map((a) => ({\n name: a.name,\n dataType: a.dataType,\n ...(a.fixed !== undefined ? { fixed: a.fixed } : {}),\n ...(a.options !== undefined ? { options: a.options } : {}),\n ...(a.defaultValue !== undefined ? { defaultValue: a.defaultValue } : {}),\n ...(a.secret !== undefined ? { secret: a.secret } : {}),\n })),\n status: app.status,\n lastHeartbeat: app.lastHeartbeat,\n schedule: app.schedule ?? null,\n runner: app.runnerName ?? null,\n runnerImage: app.runnerImage ?? null,\n compute: formatCompute(app.compute),\n predefinedActions: redactActionValues(app.predefinedActions ?? [], app.expectedArguments),\n },\n });\n } catch (error) {\n return errorResponse(`Get app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_create_app - Create new app\n s.tool(\n 'farseer_create_app',\n `Create a new Farseer app.\n\nAll new repeatable data pipelines must use Simple Pipelines through farseer_pipeline operation=guide topic=method, even when TypeScript is requested. Inspect existing apps first; do not create a replacement or duplicate to fix an existing TypeScript app. This creation workflow is for non-pipeline apps. Maintain existing TypeScript pipelines with the app tools; migration requires an explicit migration request.\n\nA Farseer App is a named configuration that points to a TypeScript script and defines its arguments.\nThe script uses farseer-client to interact with the Farseer API (import data, export reports, etc.).\n\nWorkflow to create a new app:\n1. Write the script at farseer-apps/<tenant>/files/Scripts/<name>.ts\n2. Push the script to remote with farseer_push (scripts must exist on remote first)\n3. Create the app with this tool (farseer_create_app)\n4. Configure it with farseer_configure_app (set entrypoint, scripts, arguments)\n5. Run it with farseer_run_app (CLI injects auth credentials automatically)\n\nScripts should use \\`new FarseerClient()\\` with no arguments - credentials are injected via environment variables by the CLI at runtime.`,\n createAppSchema,\n async (params: { appName: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n // Any name match means the name is taken \u2014 a collision still counts.\n const existing = matchByName(await client.listApps(), params.appName);\n if (existing.length > 0) {\n return errorResponse(`App \"${params.appName}\" already exists`, 'VALIDATION_ERROR');\n }\n\n const app = await client.createApp(params.appName);\n\n return successResponse({\n tenant,\n app: {\n id: app.id,\n name: app.name,\n },\n message: `App \"${params.appName}\" created. Use farseer_configure_app to set entrypoint, scripts, and arguments.`,\n });\n } catch (error) {\n return errorResponse(`Create app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_configure_app - Configure app settings\n s.tool(\n 'farseer_configure_app',\n `Configure an existing Farseer app.\n\nPreserve existing TypeScript apps during maintenance. Do not change their source folder, entrypoint, runner image or schedule to satisfy Simple Pipelines setup. Migration requires an explicit migration request; use the existing app tools for targeted fixes.\n\nYou can set:\n- sourceFolder: Folder under Files/ the app's scripts come from (e.g. \"Scripts/MyApp\")\n- entrypoint: Main script to execute \u2014 must be a file in the source folder (e.g., \"index.ts\")\n- description: App description\n- arguments: List of expected arguments. Each has a name, optional dataType\n ('string' | 'boolean' \u2014 defaults to 'string'), optional fixed (locks the\n value at run time), optional options (closed allowed-value set, string\n dataType only), optional defaultValue, and optional secret.\n- newName: Rename the app\n- schedule: Cron expression the app runs on (e.g. \"0 6 * * *\")\n- runner: Which jobrunner runs the app\n- runnerImage: Container image, as \"<repository>:<tag>\" or a full registry reference\n- compute: Where a run executes \u2014 'local', 'batch', or 'batch:<size>' with size s, m, l or xl\n- predefinedActions: Named argument presets offered as buttons in the UI. The\n list you pass replaces the app's whole list. farseer_get_app shows a secret\n argument's value as \"<secret>\"; send \"<secret>\" back to keep the stored value\n of the action with exactly that name. Where two actions share a name, give\n the real value.\n\nImportant:\n- The app's scripts are derived from its source folder; the entrypoint must be\n one of those files. To use a script from another folder, set sourceFolder first.\n- Changing sourceFolder to a folder that doesn't contain the current entrypoint\n requires passing entrypoint in the same call.\n- Settings you don't pass are preserved (this only changes what you specify).\n- Pass \"${CLEAR_SETTING}\" to schedule, runner or runnerImage to clear it.\n- Arguments are passed to the script as a JSON-encoded FARSEER_ARGS env var\n- Boolean dataType requires defaultValue \u2208 { \"true\", \"false\" }; defaultValue\n must be one of options when options is set`,\n configureAppSchema,\n async (params: {\n appName?: string;\n appId?: string;\n entrypoint?: string;\n sourceFolder?: string;\n description?: string;\n arguments?: Array<{\n name: string;\n dataType?: 'string' | 'boolean';\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }>;\n newName?: string;\n schedule?: string;\n runner?: string;\n runnerImage?: string;\n compute?: string;\n predefinedActions?: AppPredefinedAction[];\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const app = resolution.app;\n\n // The set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (params.newName) {\n changes.name = params.newName;\n }\n\n if (params.description !== undefined) {\n changes.description = params.description;\n }\n\n if (params.arguments) {\n // PUT semantics on the backend: this `expectedArguments`\n // array replaces the existing one wholesale. So if the\n // caller supplies a name but omits axes (dataType, fixed,\n // options, secret), we look up the existing arg by name\n // and carry those fields over. Without this merge, a\n // configure_app call that only re-sets defaultValue would\n // silently clear the secret flag or demote a dropdown\n // back to a plain string variable.\n //\n // Lookup is case-insensitive for convenience (caller\n // shouldn't have to remember exact casing to update an\n // existing arg), but on the write we keep the backend's\n // stored casing: validateExpectedArguments on the server\n // is case-sensitive (seen.has(arg.name)), so writing\n // back caller-supplied case would silently rename the\n // arg (e.g. jobName \u2192 JOBNAME) and break the next push.\n const existingByName = new Map(app.expectedArguments.map((e) => [e.name.toLowerCase(), e]));\n changes.expectedArguments = params.arguments.map((a) => {\n const existing = existingByName.get(a.name.toLowerCase());\n const arg: AppArgument = {\n name: existing?.name ?? a.name,\n dataType: a.dataType ?? existing?.dataType ?? 'string',\n };\n const fixed = a.fixed ?? existing?.fixed;\n if (fixed !== undefined) arg.fixed = fixed;\n const options = a.options ?? existing?.options;\n if (options !== undefined) arg.options = options;\n const defaultValue = a.defaultValue ?? existing?.defaultValue;\n if (defaultValue !== undefined) arg.defaultValue = defaultValue;\n const secret = a.secret ?? existing?.secret;\n if (secret !== undefined) arg.secret = secret;\n return arg;\n });\n }\n\n // Source folder + entrypoint. An app's scripts derive from its\n // source folder, and the entrypoint must be one of those files.\n // The decision lives in applySourceFolderChange (shared with the\n // CLI `app configure` command); the 'mcp' caller gets a plain,\n // param-worded error string.\n const sourceFolderError = await applySourceFolderChange(\n client,\n app,\n changes,\n { sourceFolder: params.sourceFolder, entrypoint: params.entrypoint },\n 'mcp',\n );\n if (sourceFolderError) {\n return errorResponse(sourceFolderError, 'VALIDATION_ERROR');\n }\n\n if (params.predefinedActions) {\n const restored = restoreRedactedValues(params.predefinedActions, app.predefinedActions ?? []);\n if ('error' in restored) {\n return errorResponse(restored.error, 'VALIDATION_ERROR');\n }\n changes.predefinedActions = restored.actions;\n }\n\n // Schedule, runner, image and compute. Shared with the CLI\n // `app configure` command so both surfaces take the same vocabulary.\n const runSettings = await applyRunSettings(client, app, changes, {\n schedule: params.schedule,\n runner: params.runner,\n runnerImage: params.runnerImage,\n compute: params.compute,\n });\n if ('error' in runSettings) {\n return errorResponse(runSettings.error, 'VALIDATION_ERROR');\n }\n\n const reference = app.id.toString();\n const updated = await client.updateApp(reference, changes, app);\n\n return successResponse({\n tenant,\n appName: params.newName || app.name,\n updated: Object.keys(changes),\n compute: formatCompute(updated.compute),\n warnings: runSettings.warnings,\n message: `App \"${app.name}\" configured successfully`,\n });\n } catch (error) {\n return errorResponse(`Configure app failed: ${await formatClientError(error)}`, 'NETWORK_ERROR');\n }\n },\n );\n\n // farseer_delete_app - Delete app\n s.tool(\n 'farseer_delete_app',\n `Delete an app from a Farseer tenant.\n\nWARNING: This is irreversible - the app will be permanently removed from the remote instance.\n\nThis does NOT delete the script files, only the app configuration.`,\n deleteAppSchema,\n async (params: { appName?: string; appId?: string }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, client } = gate.session;\n\n try {\n const resolution = await resolveAppItemForMcp(client, {\n appName: params.appName,\n id: params.appId,\n });\n if ('error' in resolution) {\n return resolution.error;\n }\n const appItem = resolution.item;\n\n await client.deleteApp(appItem.reference);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await client.listApps();\n if (remaining.some((a) => a.reference === appItem.reference)) {\n return errorResponse(\n `Delete reported success but \"${appItem.name}\" is still present`,\n 'NETWORK_ERROR',\n );\n }\n\n return successResponse({\n tenant,\n deletedApp: appItem.name,\n message: `App \"${appItem.name}\" has been deleted`,\n });\n } catch (error) {\n // A guard refusal is not retryable \u2014 nothing was deleted and a\n // retry cannot change that. Don't let it read as a transport blip.\n return errorResponse(\n `Delete app failed: ${await formatClientError(error)}`,\n error instanceof AppDeleteRefusedError ? 'VALIDATION_ERROR' : 'NETWORK_ERROR',\n );\n }\n },\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,iBAAkB;AAClB,qBAA+B;AAC/B,kBAYO;AACP,qBAAuF;AACvF,0BAA4B;AAC5B,4BAAkC;AAGlC,MAAM,iBAAiB;AAAA,EACnB,SAAS,aAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,mCAAmC;AAChF;AAEA,MAAM,eAAe;AAAA,EACjB,SAAS,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,4DAA4D;AAAA,EACpG,OAAO,aAAE,OAAO,EAAE,SAAS,EAAE,SAAS,kEAA6D;AACvG;AA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A,EACJ;AAGA,IAAE;AAAA,IACE;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,IACA,OAAO,WAAiD;AACpD,YAAM,OAAO,UAAM,+BAAe;AAClC,UAAI,CAAC,KAAK,GAAI,QAAO,KAAK;AAC1B,YAAM,EAAE,QAAQ,OAAO,IAAI,KAAK;AAEhC,UAAI;AACA,cAAM,aAAa,UAAM,qCAAqB,QAAQ;AAAA,UAClD,SAAS,OAAO;AAAA,UAChB,IAAI,OAAO;AAAA,QACf,CAAC;AACD,YAAI,WAAW,YAAY;AACvB,iBAAO,WAAW;AAAA,QACtB;AACA,cAAM,UAAU,WAAW;AAE3B,cAAM,OAAO,UAAU,QAAQ,SAAS;AAGxC,cAAM,YAAY,MAAM,OAAO,SAAS;AACxC,YAAI,UAAU,KAAK,CAAC,MAAM,EAAE,cAAc,QAAQ,SAAS,GAAG;AAC1D,qBAAO;AAAA,YACH,gCAAgC,QAAQ,IAAI;AAAA,YAC5C;AAAA,UACJ;AAAA,QACJ;AAEA,mBAAO,gCAAgB;AAAA,UACnB;AAAA,UACA,YAAY,QAAQ;AAAA,UACpB,SAAS,QAAQ,QAAQ,IAAI;AAAA,QACjC,CAAC;AAAA,MACL,SAAS,OAAO;AAGZ,mBAAO;AAAA,UACH,sBAAsB,UAAM,yCAAkB,KAAK,CAAC;AAAA,UACpD,iBAAiB,oCAAwB,qBAAqB;AAAA,QAClE;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": ["s"]
|
|
7
7
|
}
|
|
@@ -21,6 +21,7 @@ __export(authTools_exports, {
|
|
|
21
21
|
registerAuthTools: () => registerAuthTools
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(authTools_exports);
|
|
24
|
+
var import_registerTool = require("../utils/registerTool");
|
|
24
25
|
var import_zod = require("zod");
|
|
25
26
|
var import_configService = require("../../services/configService");
|
|
26
27
|
var import_preflight = require("../../services/preflight");
|
|
@@ -32,7 +33,8 @@ const selectTenantSchema = {
|
|
|
32
33
|
organisation: import_zod.z.string().optional().describe("Organisation subdomain. Defaults to the saved mapping for the tenant, else the tenant name.")
|
|
33
34
|
};
|
|
34
35
|
function registerAuthTools(server) {
|
|
35
|
-
|
|
36
|
+
(0, import_registerTool.registerTool)(
|
|
37
|
+
server,
|
|
36
38
|
"farseer_whoami",
|
|
37
39
|
`Check Farseer authentication status and the tenant this session is bound to.
|
|
38
40
|
|
|
@@ -62,7 +64,8 @@ If not authenticated, run "farseer login --org <organisation>" in a terminal.`,
|
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
);
|
|
65
|
-
|
|
67
|
+
(0, import_registerTool.registerTool)(
|
|
68
|
+
server,
|
|
66
69
|
"farseer_select_tenant",
|
|
67
70
|
`Bind this MCP session to a Farseer tenant. Call this once when the user says which tenant/client to work on.
|
|
68
71
|
|
|
@@ -73,7 +76,6 @@ Rules:
|
|
|
73
76
|
|
|
74
77
|
Use this before any other farseer tool when no tenant is set yet (farseer_whoami tells you).`,
|
|
75
78
|
selectTenantSchema,
|
|
76
|
-
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
77
79
|
async (params) => {
|
|
78
80
|
const { tenant, organisation } = params;
|
|
79
81
|
if ((0, import_tenantPin.isLaunchPinned)()) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/mcp/tools/authTools.ts"],
|
|
4
|
-
"sourcesContent": ["/** Authentication and tenant binding. See tenantPin.ts for the binding rules. */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { getTenantOrg } from '../../services/configService';\nimport { openTenantSession } from '../../services/preflight';\nimport {\n getAuthStatus,\n successResponse,\n errorResponse,\n describeSessionFailure,\n describeSessionWarning,\n} from '../utils/helpers';\nimport { getSessionWarning, rememberSession } from '../utils/session';\nimport { selectTenant, getTenantPin, isLaunchPinned } from '../utils/tenantPin';\n\n// Defined outside registration to avoid deep zod type instantiation.\nconst selectTenantSchema = {\n tenant: z.string().describe('Tenant to bind this session to (e.g. \"salvus-prodaja\"), from the user\\'s request.'),\n organisation: z\n .string()\n .optional()\n .describe('Organisation subdomain. Defaults to the saved mapping for the tenant, else the tenant name.'),\n};\n\nexport function registerAuthTools(server: McpServer): void {\n // farseer_whoami - Auth status + the tenant this session is bound to\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAkB;AAClB,2BAA6B;AAC7B,uBAAkC;AAClC,qBAMO;AACP,qBAAmD;AACnD,uBAA2D;AAG3D,MAAM,qBAAqB;AAAA,EACvB,QAAQ,aAAE,OAAO,EAAE,SAAS,kFAAmF;AAAA,EAC/G,cAAc,aACT,OAAO,EACP,SAAS,EACT,SAAS,6FAA6F;AAC/G;AAEO,SAAS,kBAAkB,QAAyB;AAEvD,
|
|
4
|
+
"sourcesContent": ["/** Authentication and tenant binding. See tenantPin.ts for the binding rules. */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerTool } from '../utils/registerTool';\nimport { z } from 'zod';\nimport { getTenantOrg } from '../../services/configService';\nimport { openTenantSession } from '../../services/preflight';\nimport {\n getAuthStatus,\n successResponse,\n errorResponse,\n describeSessionFailure,\n describeSessionWarning,\n} from '../utils/helpers';\nimport { getSessionWarning, rememberSession } from '../utils/session';\nimport { selectTenant, getTenantPin, isLaunchPinned } from '../utils/tenantPin';\n\n// Defined outside registration to avoid deep zod type instantiation.\nconst selectTenantSchema = {\n tenant: z.string().describe('Tenant to bind this session to (e.g. \"salvus-prodaja\"), from the user\\'s request.'),\n organisation: z\n .string()\n .optional()\n .describe('Organisation subdomain. Defaults to the saved mapping for the tenant, else the tenant name.'),\n};\n\nexport function registerAuthTools(server: McpServer): void {\n // farseer_whoami - Auth status + the tenant this session is bound to\n registerTool(\n server,\n 'farseer_whoami',\n `Check Farseer authentication status and the tenant this session is bound to.\n\nReturns:\n- Whether a JWT (browser login) is valid for this tenant's Keycloak realm, and when it expires\n- Every browser login, one per realm\n- The tenant this session operates on, and whether it is locked\n- Tenants with API keys configured\n\nIf not authenticated, run \"farseer login --org <organisation>\" in a terminal.`,\n {},\n async () => {\n const status = getAuthStatus();\n const pin = status.tenant;\n const message = !pin\n ? 'No tenant selected yet. Tell me which tenant/client to work on and I will call farseer_select_tenant to connect (once per session).'\n : status.launchPinned\n ? `This session is locked to tenant \"${pin.tenant}\" (org: ${pin.organisation}), fixed at launch.`\n : `This session is working on tenant \"${pin.tenant}\" (org: ${pin.organisation}), selected and locked for the session.`;\n const warning = getSessionWarning();\n return successResponse({\n jwtValid: status.jwtValid,\n jwtExpiresAt: status.jwtExpiresAt,\n jwtRealm: status.jwtRealm,\n logins: status.logins,\n tenant: pin,\n tenantLocked: !!pin,\n configuredTenants: status.configuredTenants,\n warning: warning && describeSessionWarning(warning),\n message: warning ? `${message} ${describeSessionWarning(warning)}` : message,\n });\n },\n );\n\n // farseer_select_tenant - Bind this session to a tenant, once\n registerTool(\n server,\n 'farseer_select_tenant',\n `Bind this MCP session to a Farseer tenant. Call this once when the user says which tenant/client to work on.\n\nRules:\n- Works only if the server was launched without --tenant. If it was launched with --tenant, it is already locked and this returns an error.\n- Can be called only ONCE. After the first selection the tenant is locked for the session and cannot be changed. To work on a different tenant, start a new session.\n- The tenant must be reachable (you must be logged in). If it can't be connected \u2014 wrong name or not logged in \u2014 selection fails WITHOUT locking, so you can correct it and call again.\n\nUse this before any other farseer tool when no tenant is set yet (farseer_whoami tells you).`,\n selectTenantSchema,\n async (params: { tenant: string; organisation?: string }) => {\n const { tenant, organisation } = params;\n\n // A locked session can't change tenant. Reject before any network\n // call, and don't verify a tenant we won't bind to.\n if (isLaunchPinned()) {\n return errorResponse(\n `This server is pinned to tenant \"${getTenantPin()!.tenant}\" via --tenant; the tenant cannot be changed from here.`,\n 'VALIDATION_ERROR',\n );\n }\n const bound = getTenantPin();\n if (bound) {\n return errorResponse(\n `This session is already working on tenant \"${bound.tenant}\" and the tenant cannot be changed. Start a new session to use a different tenant.`,\n 'VALIDATION_ERROR',\n );\n }\n\n const org = organisation || getTenantOrg(tenant) || tenant;\n\n // Before locking: selection is one-shot, so this is the last moment a\n // wrong organisation is still correctable. Costs no extra round trip.\n const outcome = await openTenantSession(org, tenant);\n if (!outcome.ok) {\n return describeSessionFailure(outcome.failure, 'Correct it and call farseer_select_tenant again.');\n }\n\n const result = selectTenant({ organisation: org, tenant });\n if (!result.ok) {\n // Lost a race to a concurrent selection between the check above\n // and here \u2014 treat as already-bound.\n return errorResponse(\n `This session is already working on tenant \"${result.current.tenant}\" and the tenant cannot be changed. Start a new session to use a different tenant.`,\n 'VALIDATION_ERROR',\n );\n }\n\n // The pair is proven and can no longer change, so the first tool call\n // has nothing left to ask.\n rememberSession(result.checkout, outcome.auth, outcome.warning);\n\n const selected = `Selected tenant \"${result.checkout.tenant}\" (org: ${result.checkout.organisation}). This session is now locked to it for its lifetime.`;\n return successResponse({\n tenant: result.checkout,\n warning: outcome.warning && describeSessionWarning(outcome.warning),\n message: outcome.warning ? `${selected} ${describeSessionWarning(outcome.warning)}` : selected,\n });\n },\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA6B;AAC7B,iBAAkB;AAClB,2BAA6B;AAC7B,uBAAkC;AAClC,qBAMO;AACP,qBAAmD;AACnD,uBAA2D;AAG3D,MAAM,qBAAqB;AAAA,EACvB,QAAQ,aAAE,OAAO,EAAE,SAAS,kFAAmF;AAAA,EAC/G,cAAc,aACT,OAAO,EACP,SAAS,EACT,SAAS,6FAA6F;AAC/G;AAEO,SAAS,kBAAkB,QAAyB;AAEvD;AAAA,IACI;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,CAAC;A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AO;AAAA,UACH,8CAA8C,OAAO,QAAQ,MAAM;AAAA,UACnE;AAAA,QACJ;AAAA,MACJ;AAIA,0CAAgB,OAAO,UAAU,QAAQ,MAAM,QAAQ,OAAO;AAE9D,YAAM,WAAW,oBAAoB,OAAO,SAAS,MAAM,WAAW,OAAO,SAAS,YAAY;AAClG,iBAAO,gCAAgB;AAAA,QACnB,QAAQ,OAAO;AAAA,QACf,SAAS,QAAQ,eAAW,uCAAuB,QAAQ,OAAO;AAAA,QAClE,SAAS,QAAQ,UAAU,GAAG,QAAQ,QAAI,uCAAuB,QAAQ,OAAO,CAAC,KAAK;AAAA,MAC1F,CAAC;AAAA,IACL;AAAA,EACJ;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,6 +21,7 @@ __export(cellTools_exports, {
|
|
|
21
21
|
registerCellTools: () => registerCellTools
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cellTools_exports);
|
|
24
|
+
var import_registerTool = require("../utils/registerTool");
|
|
24
25
|
var import_zod = require("zod");
|
|
25
26
|
var import_session = require("../utils/session");
|
|
26
27
|
var import_helpers = require("../utils/helpers");
|
|
@@ -38,7 +39,8 @@ const queryCellsSchema = {
|
|
|
38
39
|
).describe("Array of cell queries to execute")
|
|
39
40
|
};
|
|
40
41
|
function registerCellTools(server) {
|
|
41
|
-
|
|
42
|
+
(0, import_registerTool.registerTool)(
|
|
43
|
+
server,
|
|
42
44
|
"farseer_query_cells",
|
|
43
45
|
`Query cell values from a Farseer tenant.
|
|
44
46
|
|
|
@@ -58,7 +60,6 @@ Returns the value for each queried cell along with its dimension coordinates.
|
|
|
58
60
|
|
|
59
61
|
To write data, use farseer_create_import_job instead \u2014 it provides audit trail and undo support.`,
|
|
60
62
|
queryCellsSchema,
|
|
61
|
-
// @ts-expect-error TS2589 - MCP SDK deep type inference with zod schemas
|
|
62
63
|
async (params) => {
|
|
63
64
|
const gate = await (0, import_session.requireSession)();
|
|
64
65
|
if (!gate.ok) return gate.response;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/mcp/tools/cellTools.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Cell Tools\n *\n * MCP tools for querying cell values in Farseer.\n * For writing data, use farseer_create_import_job which provides audit trail and undo support.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport { requireSession } from '../utils/session';\nimport { successResponse, errorResponse } from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Shared dimension schema\nconst dimensionSchema = z.object({\n dimensionTable: z.string().describe('Dimension table name (e.g., \"Years\", \"Product\")'),\n dimensionValue: z.string().describe('Dimension member value (e.g., \"2024\", \"Widget A\")'),\n});\n\n// Define schemas outside of tool registration to avoid TS2589\nconst queryCellsSchema = {\n queries: z\n .array(\n z.object({\n variable: z.string().describe('Variable name'),\n dimensions: z.array(dimensionSchema).describe('Dimension filters'),\n }),\n )\n .describe('Array of cell queries to execute'),\n};\n\nexport function registerCellTools(server: McpServer): void {\n // farseer_query_cells\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,iBAAkB;AAClB,qBAA+B;AAC/B,qBAA+C;AAC/C,4BAAkC;AAGlC,MAAM,kBAAkB,aAAE,OAAO;AAAA,EAC7B,gBAAgB,aAAE,OAAO,EAAE,SAAS,iDAAiD;AAAA,EACrF,gBAAgB,aAAE,OAAO,EAAE,SAAS,mDAAmD;AAC3F,CAAC;AAGD,MAAM,mBAAmB;AAAA,EACrB,SAAS,aACJ;AAAA,IACG,aAAE,OAAO;AAAA,MACL,UAAU,aAAE,OAAO,EAAE,SAAS,eAAe;AAAA,MAC7C,YAAY,aAAE,MAAM,eAAe,EAAE,SAAS,mBAAmB;AAAA,IACrE,CAAC;AAAA,EACL,EACC,SAAS,kCAAkC;AACpD;AAEO,SAAS,kBAAkB,QAAyB;AAEvD,
|
|
4
|
+
"sourcesContent": ["/**\n * Cell Tools\n *\n * MCP tools for querying cell values in Farseer.\n * For writing data, use farseer_create_import_job which provides audit trail and undo support.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerTool } from '../utils/registerTool';\nimport { z } from 'zod';\nimport { requireSession } from '../utils/session';\nimport { successResponse, errorResponse } from '../utils/helpers';\nimport { formatClientError } from '../../utils/errorFormatter';\n\n// Shared dimension schema\nconst dimensionSchema = z.object({\n dimensionTable: z.string().describe('Dimension table name (e.g., \"Years\", \"Product\")'),\n dimensionValue: z.string().describe('Dimension member value (e.g., \"2024\", \"Widget A\")'),\n});\n\n// Define schemas outside of tool registration to avoid TS2589\nconst queryCellsSchema = {\n queries: z\n .array(\n z.object({\n variable: z.string().describe('Variable name'),\n dimensions: z.array(dimensionSchema).describe('Dimension filters'),\n }),\n )\n .describe('Array of cell queries to execute'),\n};\n\nexport function registerCellTools(server: McpServer): void {\n // farseer_query_cells\n registerTool(\n server,\n 'farseer_query_cells',\n `Query cell values from a Farseer tenant.\n\nEach query specifies a variable name and dimension filters to locate specific cells.\nMultiple queries can be batched in a single call.\n\nExample query:\n{\n \"variable\": \"Revenue\",\n \"dimensions\": [\n { \"dimensionTable\": \"Years\", \"dimensionValue\": \"Y2025\" },\n { \"dimensionTable\": \"Product\", \"dimensionValue\": \"Widget A\" }\n ]\n}\n\nReturns the value for each queried cell along with its dimension coordinates.\n\nTo write data, use farseer_create_import_job instead \u2014 it provides audit trail and undo support.`,\n queryCellsSchema,\n async (params: {\n queries: Array<{\n variable: string;\n dimensions: Array<{ dimensionTable: string; dimensionValue: string }>;\n }>;\n }) => {\n const gate = await requireSession();\n if (!gate.ok) return gate.response;\n const { tenant, native: nativeClient } = gate.session;\n\n try {\n const results = await nativeClient.cells.query(params.queries);\n\n return successResponse({\n tenant,\n queryCount: params.queries.length,\n results,\n });\n } catch (error) {\n return errorResponse(`Query cells failed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