@sapiom/mcp 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,16 +5,25 @@ import { resolveEnvironment } from "./credentials.js";
5
5
  import { register as registerAuthenticate } from "./tools/authenticate.js";
6
6
  import { register as registerStatus } from "./tools/status.js";
7
7
  import { register as registerOrchestrations } from "./tools/orchestrations.js";
8
+ import { fetchInstructions } from "./instructions-fetch.js";
8
9
  async function main() {
9
10
  // Resolve environment: SAPIOM_ENVIRONMENT env var > file > "production"
10
11
  const env = await resolveEnvironment(process.env.SAPIOM_ENVIRONMENT);
11
12
  if (env.name !== "production") {
12
13
  console.error(`\u26a0 Using environment "${env.name}": app=${env.appURL} api=${env.apiURL}`);
13
14
  }
15
+ // Pull the latest authoring instructions from the backend (falls back to the
16
+ // bundled copy offline / on error), so guidance can change without a release.
17
+ const instructions = await fetchInstructions(env);
14
18
  const server = new McpServer({
15
19
  // The local dev surface — distinct from the remote Sapiom capabilities MCP.
16
20
  name: "sapiom-dev",
17
21
  version: "0.1.0",
22
+ }, {
23
+ // Returned in the MCP `initialize` handshake; capable clients surface it to the
24
+ // model on connect, so an agent that adds this server gets the authoring primer
25
+ // automatically. Fetched from the backend; bundled fallback in ./instructions.ts.
26
+ instructions,
18
27
  });
19
28
  // Register all tools
20
29
  registerAuthenticate(server, env);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,QAAQ,IAAI,cA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AK,CAAC,wCAAwC,CAAC,CAAC;AAC1D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ResolvedEnvironment } from "./credentials.js";
2
+ /**
3
+ * Fetch the authoring instructions from the Sapiom backend
4
+ * (`GET {apiURL}/v1/mcp/instructions`, public / no auth), so the guidance a
5
+ * coding agent receives on connect can change without republishing this package.
6
+ *
7
+ * Falls back to the bundled {@link AUTHORING_INSTRUCTIONS} on any failure — a
8
+ * non-200, an empty body, a network error, or a timeout. Never throws: the MCP
9
+ * server must always start with usable instructions, online or off.
10
+ */
11
+ export declare function fetchInstructions(env: ResolvedEnvironment): Promise<string>;
12
+ //# sourceMappingURL=instructions-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions-fetch.d.ts","sourceRoot":"","sources":["../src/instructions-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBjF"}
@@ -0,0 +1,33 @@
1
+ import { AUTHORING_INSTRUCTIONS } from "./instructions.js";
2
+ /** How long to wait for the instructions endpoint before falling back. */
3
+ const FETCH_TIMEOUT_MS = 5000;
4
+ /**
5
+ * Fetch the authoring instructions from the Sapiom backend
6
+ * (`GET {apiURL}/v1/mcp/instructions`, public / no auth), so the guidance a
7
+ * coding agent receives on connect can change without republishing this package.
8
+ *
9
+ * Falls back to the bundled {@link AUTHORING_INSTRUCTIONS} on any failure — a
10
+ * non-200, an empty body, a network error, or a timeout. Never throws: the MCP
11
+ * server must always start with usable instructions, online or off.
12
+ */
13
+ export async function fetchInstructions(env) {
14
+ const controller = new AbortController();
15
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
16
+ try {
17
+ const response = await fetch(`${env.apiURL}/v1/mcp/instructions`, {
18
+ headers: { Accept: "text/markdown, text/plain" },
19
+ signal: controller.signal,
20
+ });
21
+ if (!response.ok)
22
+ return AUTHORING_INSTRUCTIONS;
23
+ const body = (await response.text()).trim();
24
+ return body.length > 0 ? body : AUTHORING_INSTRUCTIONS;
25
+ }
26
+ catch {
27
+ return AUTHORING_INSTRUCTIONS;
28
+ }
29
+ finally {
30
+ clearTimeout(timeout);
31
+ }
32
+ }
33
+ //# sourceMappingURL=instructions-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions-fetch.js","sourceRoot":"","sources":["../src/instructions-fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,0EAA0E;AAC1E,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAwB;IAC9D,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,gBAAgB,CAAC,CAAC;IACvE,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,sBAAsB,EAAE;YAChE,OAAO,EAAE,EAAE,MAAM,EAAE,2BAA2B,EAAE;YAChD,MAAM,EAAE,UAAU,CAAC,MAAM;SAC1B,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,sBAAsB,CAAC;QAChD,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,sBAAsB,CAAC;IAChC,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The MCP server `instructions` string, returned during the `initialize` handshake.
3
+ * Capable MCP clients surface it to the model on connect, so an agent that adds this
4
+ * server gets a workflow-authoring primer without any extra setup.
5
+ *
6
+ * Kept intentionally short — it stays in the model's context for the whole session, and
7
+ * points to the full documentation and the `AGENTS.md` generated into each scaffolded
8
+ * project rather than restating them.
9
+ */
10
+ export declare const AUTHORING_INSTRUCTIONS = "# Sapiom dev MCP (sapiom-dev)\n\n`sapiom-dev` is Sapiom's local developer MCP \u2014 the terminal surface for setting up and managing\nyour Sapiom projects. Today it drives **workflow authoring** (more dev/management tools will land\nhere over time): these tools build, test, and deploy a Sapiom workflow \u2014 a\n`defineOrchestration({ name, entry, steps })` (from `@sapiom/orchestration`) where each step's\n`run(input, ctx)` does work and returns a directive. All from the terminal; no dashboard.\n\n## Two ways to use Sapiom\nThis server (`sapiom-dev`) is where you **author workflows** \u2014 the\n`sapiom_dev_orchestrations_*` tools build, test, and deploy them. For a **one-off capability call** without authoring a\nworkflow, use Sapiom's **remote MCP** at `https://api.sapiom.ai/v1/mcp`\n(`claude mcp add sapiom --transport http https://api.sapiom.ai/v1/mcp`) \u2014 it exposes every\ncapability as a direct `sapiom_*` tool (e.g. `sapiom_search`; run `tool_discover` to find the right one) \u2014 or call the gateway from code with the SDK\n(`@sapiom/fetch`). Rule of thumb: author a workflow for anything multi-step, scheduled, or\ndeployable; use the remote MCP or the SDK for a single action.\n\n## Lifecycle (in order)\n1. `sapiom_authenticate` \u2014 browser login; caches an API key (makes you an API-key principal,\n required for deploy/run). Confirm with `sapiom_status`.\n2. `sapiom_dev_orchestrations_scaffold` \u2014 writes a project. READ its `AGENTS.md` first; it is\n the full authoring guide, shipped inside every scaffold. Then `npm install`.\n3. Test for free: `npm run typecheck` \u2192 `sapiom_dev_orchestrations_check` (validates the step\n graph, offline) \u2192 `sapiom_dev_orchestrations_run_local` (capabilities are stubbed; zero spend).\n4. Ship: `sapiom_dev_orchestrations_link` \u2192 `_deploy` \u2192 `_run` (real, billed) \u2192 `_inspect`.\n\n## Canonical rules (types are the source of truth \u2014 run `npm run typecheck`)\n- Import `defineOrchestration`, `defineStep`, and the directives\n (`goto` / `terminate` / `fail` / `retry` / `pauseUntilSignal`) from `@sapiom/orchestration`.\n NEVER `defineWorkflow` or `@sapiom/workflow-sdk` (they do not exist). Import Zod from `zod/v4`.\n- `defineStep({ name, next, terminal?, canFail?, pause?, inputSchema?, run })`:\n `terminate()` requires `terminal: true`; `fail()` requires `canFail: true`;\n `pauseUntilSignal(handle, \u2026)` requires `pause: { signal, resumeStep }`; every `goto` target\n must be listed in `next[]`. TypeScript enforces all of these.\n- Cross-step state: `ctx.shared` \u2014 the entry input reaches only the entry step.\n- Capabilities run via `ctx.sapiom.*` (sandboxes, repositories, agent(+coding), orchestrations,\n fileStorage, contentGeneration.{images,video}, search, database) \u2014 a typed subset of the gateway\n catalog; use autocomplete/typecheck.\n\nFull reference: https://docs.sapiom.ai/workflows/quick-start (authoring \u00B7 capabilities \u00B7 reference \u00B7 examples)\nand the `AGENTS.md` inside your scaffolded project.";
11
+ //# sourceMappingURL=instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,+/FAwCmB,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The MCP server `instructions` string, returned during the `initialize` handshake.
3
+ * Capable MCP clients surface it to the model on connect, so an agent that adds this
4
+ * server gets a workflow-authoring primer without any extra setup.
5
+ *
6
+ * Kept intentionally short — it stays in the model's context for the whole session, and
7
+ * points to the full documentation and the `AGENTS.md` generated into each scaffolded
8
+ * project rather than restating them.
9
+ */
10
+ export const AUTHORING_INSTRUCTIONS = `# Sapiom dev MCP (sapiom-dev)
11
+
12
+ \`sapiom-dev\` is Sapiom's local developer MCP — the terminal surface for setting up and managing
13
+ your Sapiom projects. Today it drives **workflow authoring** (more dev/management tools will land
14
+ here over time): these tools build, test, and deploy a Sapiom workflow — a
15
+ \`defineOrchestration({ name, entry, steps })\` (from \`@sapiom/orchestration\`) where each step's
16
+ \`run(input, ctx)\` does work and returns a directive. All from the terminal; no dashboard.
17
+
18
+ ## Two ways to use Sapiom
19
+ This server (\`sapiom-dev\`) is where you **author workflows** — the
20
+ \`sapiom_dev_orchestrations_*\` tools build, test, and deploy them. For a **one-off capability call** without authoring a
21
+ workflow, use Sapiom's **remote MCP** at \`https://api.sapiom.ai/v1/mcp\`
22
+ (\`claude mcp add sapiom --transport http https://api.sapiom.ai/v1/mcp\`) — it exposes every
23
+ capability as a direct \`sapiom_*\` tool (e.g. \`sapiom_search\`; run \`tool_discover\` to find the right one) — or call the gateway from code with the SDK
24
+ (\`@sapiom/fetch\`). Rule of thumb: author a workflow for anything multi-step, scheduled, or
25
+ deployable; use the remote MCP or the SDK for a single action.
26
+
27
+ ## Lifecycle (in order)
28
+ 1. \`sapiom_authenticate\` — browser login; caches an API key (makes you an API-key principal,
29
+ required for deploy/run). Confirm with \`sapiom_status\`.
30
+ 2. \`sapiom_dev_orchestrations_scaffold\` — writes a project. READ its \`AGENTS.md\` first; it is
31
+ the full authoring guide, shipped inside every scaffold. Then \`npm install\`.
32
+ 3. Test for free: \`npm run typecheck\` → \`sapiom_dev_orchestrations_check\` (validates the step
33
+ graph, offline) → \`sapiom_dev_orchestrations_run_local\` (capabilities are stubbed; zero spend).
34
+ 4. Ship: \`sapiom_dev_orchestrations_link\` → \`_deploy\` → \`_run\` (real, billed) → \`_inspect\`.
35
+
36
+ ## Canonical rules (types are the source of truth — run \`npm run typecheck\`)
37
+ - Import \`defineOrchestration\`, \`defineStep\`, and the directives
38
+ (\`goto\` / \`terminate\` / \`fail\` / \`retry\` / \`pauseUntilSignal\`) from \`@sapiom/orchestration\`.
39
+ NEVER \`defineWorkflow\` or \`@sapiom/workflow-sdk\` (they do not exist). Import Zod from \`zod/v4\`.
40
+ - \`defineStep({ name, next, terminal?, canFail?, pause?, inputSchema?, run })\`:
41
+ \`terminate()\` requires \`terminal: true\`; \`fail()\` requires \`canFail: true\`;
42
+ \`pauseUntilSignal(handle, …)\` requires \`pause: { signal, resumeStep }\`; every \`goto\` target
43
+ must be listed in \`next[]\`. TypeScript enforces all of these.
44
+ - Cross-step state: \`ctx.shared\` — the entry input reaches only the entry step.
45
+ - Capabilities run via \`ctx.sapiom.*\` (sandboxes, repositories, agent(+coding), orchestrations,
46
+ fileStorage, contentGeneration.{images,video}, search, database) — a typed subset of the gateway
47
+ catalog; use autocomplete/typecheck.
48
+
49
+ Full reference: https://docs.sapiom.ai/workflows/quick-start (authoring · capabilities · reference · examples)
50
+ and the \`AGENTS.md\` inside your scaffolded project.`;
51
+ //# sourceMappingURL=instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAwCgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapiom/mcp",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Sapiom MCP server for Claude Code — browser-based authentication and API tools",
5
5
  "mcpName": "io.github.sapiom/mcp",
6
6
  "keywords": [
@@ -33,9 +33,9 @@
33
33
  "dependencies": {
34
34
  "@modelcontextprotocol/sdk": "^1.26.0",
35
35
  "zod": "^3.25.0",
36
- "@sapiom/core": "0.5.0",
37
36
  "@sapiom/fetch": "0.5.0",
38
- "@sapiom/orchestration-core": "^0.4.0"
37
+ "@sapiom/orchestration-core": "^0.4.0",
38
+ "@sapiom/core": "0.5.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^20.11.30",