inistate-mcp 1.1.1 → 1.1.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 CHANGED
@@ -80,14 +80,14 @@ Then point your MCP client at `node /absolute/path/to/inistate-mcp/build/index.j
80
80
 
81
81
  ## Tools
82
82
 
83
- Tools marked **(configure)** are only exposed in configure mode — see [Modes](#modes).
83
+ Tools marked **(configure)** are only exposed in configure mode — see [Modes](#modes). Tools the active backend cannot serve (e.g. `scaffold_module` on the hosted Platform) stay registered but return a structured capability message instead of failing silently.
84
84
 
85
85
  | Tool | Description |
86
86
  |------|-------------|
87
87
  | `list_workspaces` | List workspaces the user has access to |
88
88
  | `set_workspace` | Set the active workspace |
89
89
  | `list_modules` | List all discoverable modules in the workspace |
90
- | `get_module_schema` | Get the canvas schema (basic or extended tier) **(configure)** |
90
+ | `get_module_schema` | Get the canvas schema (basic or extended tier) — available in every mode |
91
91
  | `get_module_canvas` | Get full module definition with stable IDs (round-trippable) **(configure)** |
92
92
  | `list_entries` | Query entries with filters, sorting, and pagination |
93
93
  | `get_entry` | Read a single entry by ID |
@@ -103,6 +103,7 @@ Tools marked **(configure)** are only exposed in configure mode — see [Modes](
103
103
  | `validate_design` | Validate a module schema before creating or updating **(configure)** |
104
104
  | `create_module` | Create a new module with schema **(configure)** |
105
105
  | `update_module` | Update an existing module's schema **(configure)** |
106
+ | `scaffold_module` | Draft a module schema from existing data (SQLite, Notion, or Airtable table) **(configure)** — served by the local runtime (inistate-core); on the hosted Platform backend it returns a capability message pointing to `design_workflow` |
106
107
  | `switch_mode` | Switch the active mode (runtime / configure / frontend) |
107
108
 
108
109
  ## Resources
@@ -233,7 +234,7 @@ npm run pm2:logs
233
234
  npm run pm2:stop
234
235
  ```
235
236
 
236
- Set required environment variables (`INISTATE_API_TOKEN`, and optionally `INISTATE_API_URL`, `INISTATE_WORKSPACE_ID`, `OAUTH_ISSUER_URL`, `INISTATE_APP_URL`) in your shell, PM2 ecosystem `env`, or deployment secret manager before starting.
237
+ Set required environment variables (`INISTATE_API_TOKEN`, and optionally `INISTATE_API_BASE`, `INISTATE_WORKSPACE_ID`, `OAUTH_ISSUER_URL`, `INISTATE_APP_URL`) in your shell, PM2 ecosystem `env`, or deployment secret manager before starting.
237
238
 
238
239
  ## Testing
239
240
 
@@ -255,21 +256,22 @@ Tests are in `src/` alongside the source files and use [Vitest](https://vitest.d
255
256
 
256
257
  | File | Type | What it covers |
257
258
  |------|------|----------------|
258
- | `src/schema.test.ts` | Unit tests (41) | `designWorkflow`, `validateDesign`, helper functions (`isValidFieldType`, `isValidColor`, `isValidActor`, `suggestColorForState`) |
259
- | `src/activity-guard.test.ts` | Unit tests (35) | `submit_activity` guard rules — human/hybrid actor, state-change confirmation, confidence-inflation, reference-shape validation |
259
+ | `src/schema.test.ts` | Unit tests (76) | `designWorkflow`, `validateDesign` (including platform parity and input normalization), helper functions (`isValidFieldType`, `isValidColor`, `isValidActor`, `suggestColorForState`) |
260
+ | `src/activity-guard.test.ts` | Unit tests (42) | `submit_activity` guard rules — human/hybrid actor, state-change confirmation, confidence-inflation, reference-shape validation |
260
261
  | `src/tools.schema.test.ts` | Unit tests (19) | Tool input-schema shapes and validation |
261
- | `src/backend-capabilities.test.ts` | Unit tests (6) | Capability gating — Platform-only tools return a capability message on reduced backends |
262
- | `src/server.test.ts` | Integration tests (15) | Spins up the MCP server as a child process and exercises it through the official MCP SDK client — mode-gated tool/resource/prompt discovery, `switch_mode`, resource reads, prompt retrieval, and local tool calls |
262
+ | `src/backend-capabilities.test.ts` | Unit tests (9) | Capability gating — tools the active backend cannot serve return a capability message |
263
+ | `src/flagged-annotation.test.ts` | Integration tests (5) | Flagged-response annotation — suppressed transitions are explained (`flag_reason` + `agent_action`) so agents stop retrying with higher confidence |
264
+ | `src/server.test.ts` | Integration tests (17) | Spins up the MCP server as a child process and exercises it through the official MCP SDK client — mode-gated tool/resource/prompt discovery, `switch_mode`, resource reads, prompt retrieval, and local tool calls |
263
265
 
264
266
  Unit tests cover:
265
267
  - Field type and color validation against the schema
266
268
  - State color suggestion logic
267
269
  - Design validation: duplicate names, invalid types/colors/actors, initial state rules, flow integrity, unreachable states, unused activities, AI confidence warnings
270
+ - Input normalization: field-type, state-color, and industry aliases; parsing states from a description
268
271
  - Workflow design: pattern detection (approval, ticket, pipeline, record list), industry defaults
269
- - Intent resolution: all 5 modes, context boosting, confidence scoring
270
272
 
271
273
  Integration tests verify (no API token needed):
272
- - All 20 tools, 8 resources, and 4 prompts are registered (in configure mode)
274
+ - Mode-gated tool/resource/prompt discovery — runtime mode hides the configure surface, `switch_mode` reveals and collapses it
273
275
  - `design_workflow`, `validate_design` work end-to-end through the MCP protocol
274
276
  - Static resources (`inistate://schema/runtime`, `inistate://design-guide`) return valid content
275
277
  - All 4 prompts return correctly templated messages
@@ -24,6 +24,9 @@ interface ExtendedSchema {
24
24
  states?: Array<string | {
25
25
  name?: string;
26
26
  }>;
27
+ flows?: Record<string, {
28
+ activities?: Record<string, string>;
29
+ }>;
27
30
  }
28
31
  interface CanvasSchema {
29
32
  activities?: ActivityDef[];
@@ -59,6 +62,11 @@ interface FlaggedRecord {
59
62
  export declare function recordFlagged(moduleName: string, entryId: unknown, activity: string, confidence: number): void;
60
63
  export declare function clearFlagged(moduleName: string, entryId: unknown, activity: string): void;
61
64
  export declare function getPriorFlag(moduleName: string, entryId: unknown, activity: string): FlaggedRecord | undefined;
65
+ /** The human-actor block recorded for an entry, if still fresh. */
66
+ export declare function getHumanBlockedStates(moduleName: string, entryId: unknown): {
67
+ activity: string;
68
+ states: Set<string>;
69
+ } | undefined;
62
70
  export interface GuardInput {
63
71
  module: string;
64
72
  activity: string;
@@ -101,6 +109,24 @@ export declare function getModuleFieldTypes(moduleName: string, fetchSchema?: Sc
101
109
  * (schema unavailable), returns [] so the server makes the final call.
102
110
  */
103
111
  export declare function validateInputShapesWith(types: Map<string, string> | null, input: Record<string, unknown> | undefined | null): RefShapeError[];
112
+ export interface InputKeyResolution {
113
+ /** Near-miss keys (casing/spacing/underscores) rewritten in place to the exact field name. */
114
+ remapped: Array<{
115
+ from: string;
116
+ to: string;
117
+ }>;
118
+ /** Keys matching no field at all — the platform silently drops these, losing the data. */
119
+ unknown: string[];
120
+ }
121
+ /**
122
+ * Match input keys against the module's field names, in place. Exact names
123
+ * pass; a key that differs only in case/spacing/underscores is rewritten to
124
+ * the exact field name; anything else is reported so the caller can reject
125
+ * it — the platform discards unmatched keys without any signal, which turns
126
+ * a key typo into silent data loss. Fail-open on a null map (schema
127
+ * unavailable): the server makes the final call.
128
+ */
129
+ export declare function resolveInputKeys(types: Map<string, string> | null, input: Record<string, unknown> | undefined | null): InputKeyResolution;
104
130
  /**
105
131
  * Validate that User/Module/Users/Modules fields in `input` carry the
106
132
  * correct shape. Convenience wrapper around getModuleFieldTypes +
@@ -119,6 +119,36 @@ export function getPriorFlag(moduleName, entryId, activity) {
119
119
  }
120
120
  return rec;
121
121
  }
122
+ const HUMAN_BLOCK_TTL_MS = 30 * 60 * 1000;
123
+ const humanBlockCache = new Map();
124
+ function humanBlockKey(moduleName, entryId) {
125
+ return cacheKey("humanblock", [moduleName, String(entryId)]);
126
+ }
127
+ /** Target states an activity can transition to, per the module's flows. */
128
+ async function activityTargetStates(moduleName, activity, fetchSchema) {
129
+ const schema = await getExtendedSchema(moduleName, fetchSchema);
130
+ const out = [];
131
+ for (const from of Object.values(schema?.flows ?? {})) {
132
+ const target = from?.activities?.[activity];
133
+ if (typeof target === "string" && !out.includes(target))
134
+ out.push(target);
135
+ }
136
+ return out;
137
+ }
138
+ /** The human-actor block recorded for an entry, if still fresh. */
139
+ export function getHumanBlockedStates(moduleName, entryId) {
140
+ if (entryId === undefined || entryId === null)
141
+ return undefined;
142
+ const k = humanBlockKey(moduleName, entryId);
143
+ const rec = humanBlockCache.get(k);
144
+ if (!rec)
145
+ return undefined;
146
+ if (Date.now() - rec.at > HUMAN_BLOCK_TTL_MS) {
147
+ humanBlockCache.delete(k);
148
+ return undefined;
149
+ }
150
+ return rec;
151
+ }
122
152
  export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher, fetchCanvas = defaultCanvasFetcher) {
123
153
  const { module: moduleName, activity, entryId, entryIds, state, confidence, confirmed } = input;
124
154
  // Rule 1 — confidence inflation after a prior flag.
@@ -157,6 +187,29 @@ export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher
157
187
  };
158
188
  }
159
189
  }
190
+ // Rule 2c — bypass detection. Once a human-only activity was blocked for an
191
+ // entry, an explicit state change that reaches the same target state is the
192
+ // same transition wearing different clothes. Runs before the `confirmed`
193
+ // shortcuts: confirmed does not unlock human-only transitions.
194
+ if (state) {
195
+ for (const target of targets) {
196
+ const blocked = getHumanBlockedStates(moduleName, target);
197
+ if (blocked?.states.has(state)) {
198
+ return {
199
+ ok: false,
200
+ structured: {
201
+ error: "human_actor_bypass_blocked",
202
+ message: `Activity '${blocked.activity}' (actor='human') was blocked for this entry, and this state change reaches its target state '${state}'. confirmed: true does not unlock human-only transitions.`,
203
+ activity,
204
+ state,
205
+ entryId: target,
206
+ blocked_activity: blocked.activity,
207
+ agent_action: "Stop and do not work around this. A human must perform the transition in Inistate — report it to the user.",
208
+ },
209
+ };
210
+ }
211
+ }
212
+ }
160
213
  // Rule 2a — `changeStatus` (alias `changeState`) is the explicit
161
214
  // state-change override.
162
215
  if ((activity === "changeStatus" || activity === "changeState") && !confirmed) {
@@ -191,6 +244,20 @@ export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher
191
244
  return { ok: true }; // unknown activity — let the API decide.
192
245
  const actor = (def.actor || "").toLowerCase();
193
246
  if (actor === "human") {
247
+ // Remember which states this activity would have reached, so a follow-up
248
+ // changeState/state-override to the same state is caught (Rule 2c).
249
+ const targetStates = await activityTargetStates(moduleName, activity, fetchSchema);
250
+ if (targetStates.length > 0) {
251
+ for (const target of targets) {
252
+ if (target === undefined || target === null)
253
+ continue;
254
+ humanBlockCache.set(humanBlockKey(moduleName, target), {
255
+ activity,
256
+ states: new Set(targetStates),
257
+ at: Date.now(),
258
+ });
259
+ }
260
+ }
194
261
  return {
195
262
  ok: false,
196
263
  structured: {
@@ -198,7 +265,7 @@ export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher
198
265
  message: `Activity '${activity}' is marked actor='human'. AI agents are not permitted to execute human-only activities.`,
199
266
  activity,
200
267
  actor: "human",
201
- agent_action: "Do not retry — confirmed: true does NOT unlock this. Tell the user the activity must be performed by a human, then stop.",
268
+ agent_action: "Do not retry — confirmed: true does NOT unlock this, and neither does changeState. Tell the user the activity must be performed by a human, then stop.",
202
269
  },
203
270
  };
204
271
  }
@@ -236,8 +303,21 @@ function checkSingleRef(field, type, value, index) {
236
303
  const valueOk = typeof obj.value === "string";
237
304
  const usernameOk = !isUserType ||
238
305
  (typeof obj.username === "string" && obj.username.length > 0);
239
- if (idOk && valueOk && usernameOk)
306
+ if (idOk && valueOk && usernameOk) {
307
+ // A display name standing in for the id ({ id: "carol" }) passes the key
308
+ // checks but the platform stores it as-is — a silently dangling reference.
309
+ // Real ids are numeric or document ids ("CLN00001"); a string id with
310
+ // whitespace or no digit at all is a name, not an id.
311
+ if (typeof obj.id === "string" && (/\s/.test(obj.id) || !/\d/.test(obj.id))) {
312
+ return {
313
+ field,
314
+ type,
315
+ received: value,
316
+ message: `${type} field '${locator}' id '${obj.id}' looks like a display name, not an entry id. Look up the entry with list_entries on the connected module and round-trip its reference object unchanged.`,
317
+ };
318
+ }
240
319
  return null;
320
+ }
241
321
  const missing = [];
242
322
  if (!idOk)
243
323
  missing.push("id (string|number)");
@@ -330,6 +410,44 @@ export function validateInputShapesWith(types, input) {
330
410
  }
331
411
  return errors;
332
412
  }
413
+ // ---------- Input key resolution ----------
414
+ /** Case/space/underscore-insensitive key for field-name matching. */
415
+ function fieldKey(name) {
416
+ return name.trim().toLowerCase().replace(/[\s_-]/g, "");
417
+ }
418
+ /**
419
+ * Match input keys against the module's field names, in place. Exact names
420
+ * pass; a key that differs only in case/spacing/underscores is rewritten to
421
+ * the exact field name; anything else is reported so the caller can reject
422
+ * it — the platform discards unmatched keys without any signal, which turns
423
+ * a key typo into silent data loss. Fail-open on a null map (schema
424
+ * unavailable): the server makes the final call.
425
+ */
426
+ export function resolveInputKeys(types, input) {
427
+ const result = { remapped: [], unknown: [] };
428
+ if (!input || !types)
429
+ return result;
430
+ // null marks a collision — two fields fold to the same key; never remap those.
431
+ const byKey = new Map();
432
+ for (const name of types.keys()) {
433
+ const k = fieldKey(name);
434
+ byKey.set(k, byKey.has(k) ? null : name);
435
+ }
436
+ for (const key of Object.keys(input)) {
437
+ if (types.has(key))
438
+ continue;
439
+ const match = byKey.get(fieldKey(key));
440
+ if (match && !Object.prototype.hasOwnProperty.call(input, match)) {
441
+ input[match] = input[key];
442
+ delete input[key];
443
+ result.remapped.push({ from: key, to: match });
444
+ }
445
+ else {
446
+ result.unknown.push(key);
447
+ }
448
+ }
449
+ return result;
450
+ }
333
451
  /**
334
452
  * Validate that User/Module/Users/Modules fields in `input` carry the
335
453
  * correct shape. Convenience wrapper around getModuleFieldTypes +
@@ -357,4 +475,5 @@ export function __resetGuardCaches() {
357
475
  schemaCache.clear();
358
476
  canvasCache.clear();
359
477
  flaggedCache.clear();
478
+ humanBlockCache.clear();
360
479
  }
package/build/api.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  export declare function setWorkspaceId(wsid: string): void;
2
2
  export declare function getWorkspaceId(): string | null;
3
+ /**
4
+ * A bare "Module 'X' not found" sends agents hunting across workspaces one
5
+ * set_workspace at a time (observed: 7 calls to locate a module created in
6
+ * the wrong workspace). Anchor the error to the active workspace and name
7
+ * the two possible fixes.
8
+ */
9
+ export declare function annotateModuleNotFound(message: string): string;
3
10
  export declare function get(path: string): Promise<unknown>;
4
11
  export declare function post(path: string, body?: unknown): Promise<unknown>;
5
12
  export declare function put(path: string, body?: unknown): Promise<unknown>;
package/build/api.js CHANGED
@@ -73,6 +73,20 @@ function headers() {
73
73
  function authHeader() {
74
74
  return buildHeaders();
75
75
  }
76
+ /**
77
+ * A bare "Module 'X' not found" sends agents hunting across workspaces one
78
+ * set_workspace at a time (observed: 7 calls to locate a module created in
79
+ * the wrong workspace). Anchor the error to the active workspace and name
80
+ * the two possible fixes.
81
+ */
82
+ export function annotateModuleNotFound(message) {
83
+ if (!/^module '.+' not found\.?$/i.test(message.trim()))
84
+ return message;
85
+ const wsid = effectiveWorkspaceId();
86
+ return wsid
87
+ ? `${message.trim().replace(/\.$/, "")} in the active workspace (id ${wsid}). Check list_modules for the exact name, or call set_workspace if the module lives in another workspace.`
88
+ : `${message.trim().replace(/\.$/, "")}. No active workspace is set — call set_workspace (or pass workspaceId) first.`;
89
+ }
76
90
  function agentAction(status) {
77
91
  switch (status) {
78
92
  case 400:
@@ -101,7 +115,7 @@ async function handleResponse(res) {
101
115
  }
102
116
  const error = {
103
117
  error: body.error || `HTTP ${res.status}`,
104
- message: body.message || text || res.statusText,
118
+ message: annotateModuleNotFound(String(body.message || text || res.statusText)),
105
119
  details: body.details || null,
106
120
  agent_action: agentAction(res.status),
107
121
  };
@@ -44,6 +44,7 @@ export interface Capabilities {
44
44
  }
45
45
  export interface ListEntriesParams {
46
46
  module: string;
47
+ listing?: string;
47
48
  state?: string;
48
49
  search?: string;
49
50
  filters?: Record<string, unknown>;
package/build/backend.js CHANGED
@@ -39,11 +39,13 @@ export class CloudBackend {
39
39
  api.setWorkspaceId(wsid);
40
40
  }
41
41
  listWorkspaces(search) {
42
+ // The /api/mcp mirror (not /api/workspace) so scoped connection tokens
43
+ // pass the deny-by-default endpoint guard; same Mongo source, slim shape.
42
44
  const query = search ? `?search=${encodeURIComponent(search)}` : "";
43
- return api.get(`/api/workspace${query}`);
45
+ return api.get(`/api/mcp/workspace${query}`);
44
46
  }
45
47
  getWorkspace(workspaceId) {
46
- return api.get(`/api/workspace/${api.enc(workspaceId)}`);
48
+ return api.get(`/api/mcp/workspace/${api.enc(workspaceId)}`);
47
49
  }
48
50
  listModules() {
49
51
  return api.get("/api/mcp/");
@@ -62,6 +64,8 @@ export class CloudBackend {
62
64
  }
63
65
  listEntries(p) {
64
66
  const body = { module: p.module };
67
+ if (p.listing)
68
+ body.listing = p.listing;
65
69
  if (p.state)
66
70
  body.state = p.state;
67
71
  if (p.search)
package/build/http.js CHANGED
@@ -9,7 +9,7 @@ import { mcpAuthRouter } from "@modelcontextprotocol/sdk/server/auth/router.js";
9
9
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
10
10
  import { createServer } from "./server.js";
11
11
  import { requestContext } from "./context.js";
12
- import { InistateOAuthProvider, decodeJwtSub } from "./oauth-provider.js";
12
+ import { InistateOAuthProvider, decodeJwtSub, isConnectionToken, connectionModeKey, SUPPORTED_SCOPES, } from "./oauth-provider.js";
13
13
  import { getUserMode } from "./mode-store.js";
14
14
  const PORT = parseInt(process.env.PORT || "3000", 10);
15
15
  const BASE_URL = process.env.INISTATE_API_BASE ||
@@ -46,6 +46,7 @@ app.use(mcpAuthRouter({
46
46
  issuerUrl: new URL(ISSUER_URL),
47
47
  baseUrl: new URL(ISSUER_URL),
48
48
  resourceServerUrl: new URL("/mcp", ISSUER_URL),
49
+ scopesSupported: SUPPORTED_SCOPES,
49
50
  }));
50
51
  /* ------------------------------------------------------------------ */
51
52
  /* OAuth authorize callback (login page POSTs here) */
@@ -92,9 +93,12 @@ app.post("/mcp", express.raw({ type: "*/*", limit: "4mb" }), async (req, res) =>
92
93
  return;
93
94
  }
94
95
  const body = JSON.parse(req.body.toString());
95
- // Extract per-request auth context from HTTP headers
96
+ // Extract per-request auth context from HTTP headers. Connection tokens
97
+ // (ist_) are opaque — key per-user state off a hash of the token instead
98
+ // of the JWT subject; stable for the session, reset on rotation.
96
99
  const bearer = authHeader.replace(/^Bearer\s+/i, "");
97
- const userId = decodeJwtSub(bearer);
100
+ const userId = decodeJwtSub(bearer) ??
101
+ (isConnectionToken(bearer) ? connectionModeKey(bearer) : undefined);
98
102
  const mode = userId ? getUserMode(userId) : undefined;
99
103
  const ctx = {
100
104
  authorization: authHeader,
@@ -3,6 +3,29 @@ import type { OAuthServerProvider, AuthorizationParams } from "@modelcontextprot
3
3
  import type { OAuthRegisteredClientsStore } from "@modelcontextprotocol/sdk/server/auth/clients.js";
4
4
  import type { OAuthClientInformationFull, OAuthTokens, OAuthTokenRevocationRequest } from "@modelcontextprotocol/sdk/shared/auth.js";
5
5
  import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
6
+ /**
7
+ * Scope vocabulary of the Inistate Connections API (ApiScopes.cs). Advertised as
8
+ * scopes_supported in the authorization-server metadata and granted to the
9
+ * connection token minted at code exchange. Must stay in sync with the backend.
10
+ */
11
+ export declare const SUPPORTED_SCOPES: string[];
12
+ /** Matches ApiConnectionTokens.LooksLikeToken — "ist_" + 43 base62 chars. */
13
+ export declare function isConnectionToken(value: string | undefined): boolean;
14
+ /**
15
+ * The backend explicitly refused to mint a connection for this user — a policy
16
+ * answer (pricing gate, connection limit), not an availability problem. Must
17
+ * surface to the connecting user as an OAuth error, never silently downgrade
18
+ * to a JWT session: that would let e.g. Lite-seat users bypass the pricing gate.
19
+ */
20
+ export declare class ConnectionMintDeniedError extends Error {
21
+ readonly code: string;
22
+ constructor(code: string, message: string);
23
+ }
24
+ /**
25
+ * Stable per-session key for opaque connection tokens (mode store etc.).
26
+ * Hash, not plaintext, so the secret never becomes a long-lived map key.
27
+ */
28
+ export declare function connectionModeKey(token: string): string;
6
29
  /** Decode the `sub` claim from a JWT payload without verifying the signature. */
7
30
  export declare function decodeJwtSub(jwt: string): string | undefined;
8
31
  declare class InMemoryClientsStore implements OAuthRegisteredClientsStore {
@@ -17,6 +40,7 @@ export declare class InistateOAuthProvider implements OAuthServerProvider {
17
40
  private codes;
18
41
  private pendingAuth;
19
42
  private tokens;
43
+ private patVerify;
20
44
  private baseUrl;
21
45
  private appUrl;
22
46
  private mcpUrl;
@@ -32,7 +56,23 @@ export declare class InistateOAuthProvider implements OAuthServerProvider {
32
56
  };
33
57
  challengeForAuthorizationCode(_client: OAuthClientInformationFull, authorizationCode: string): Promise<string>;
34
58
  exchangeAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string): Promise<OAuthTokens>;
35
- exchangeRefreshToken(_client: OAuthClientInformationFull, refreshToken: string): Promise<OAuthTokens>;
59
+ /**
60
+ * Mint (or rotate) the Inistate connection token backing this MCP session.
61
+ *
62
+ * One connection per client app: an active connection with the same name is
63
+ * updated to the new grant and rotated (rotation is the only way to get a
64
+ * fresh plaintext token), so repeat authorizations don't pile up rows on the
65
+ * Connections page. The backend keeps the previous token alive for the
66
+ * configured overlap window, so an existing session on another device fades
67
+ * out rather than breaking mid-call.
68
+ *
69
+ * Returns null when the Connections feature is unavailable (flag off, older
70
+ * backend, network failure) — the caller falls back to the JWT flow.
71
+ */
72
+ private mintConnectionToken;
73
+ /** Re-grant (scopes may have changed) then rotate for a fresh plaintext token. */
74
+ private updateAndRotate;
75
+ exchangeRefreshToken(_client: OAuthClientInformationFull, refreshToken: string, _scopes?: string[]): Promise<OAuthTokens>;
36
76
  verifyAccessToken(token: string): Promise<AuthInfo>;
37
77
  revokeToken(_client: OAuthClientInformationFull, request: OAuthTokenRevocationRequest): Promise<void>;
38
78
  private cleanup;