@attentionform/astra-mcp-server 0.2.1 → 0.4.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.
@@ -4,7 +4,7 @@
4
4
  * Named re-exports ONLY (no `export *`): the public surface stays explicit
5
5
  * and reviewable — every name below is listed deliberately.
6
6
  */
7
- export { MCP_SESSION_MAX_DOCS, MCP_SESSION_MAX_BYTES, MCP_SESSION_IDLE_MS, SessionMutex, McpSessionStore, collectTrackedExtrasForGit, ensureGitRepo, getMcpAllowedRoots, canonicalizeForMcp, validateDocPath, validateSaveTarget, validateOpenBufferLabel, SESSION_REDO_MAX_DEPTH_CLAMP, SESSION_REDO_MAX_BYTES_CLAMP, createMcpSessionStore, } from './session-store';
7
+ export { MCP_SESSION_MAX_DOCS, MCP_SESSION_MAX_BYTES, MCP_SESSION_IDLE_MS, SessionMutex, McpSessionStore, collectTrackedExtrasForGit, ensureGitRepo, getMcpAllowedRoots, describeAllowedFolders, canonicalizeForMcp, validateDocPath, validateSaveTarget, validateOpenBufferLabel, SESSION_REDO_MAX_DEPTH_CLAMP, SESSION_REDO_MAX_BYTES_CLAMP, createMcpSessionStore, } from './session-store';
8
8
  export type { McpSessionStoreOptions, DocHandle, McpSessionStats, } from './session-store';
9
9
  export { MCP_RESEARCH_FLAG, isResearchEnabled, LEAN6_TOOL_NAMES, getLean6ToolNames, GIT_HISTORY_TOOL_NAMES, getGitHistoryToolNames, mcpError, sanitizeCommitMessage, sanitizeCommitAuthor, COMMIT_MESSAGE_MAX, COMMIT_AUTHOR_MAX, COMMIT_AUTHOR_DEFAULT, MCP_ECMA_ESSENTIALS, MCP_WORKFLOW, LEAN6_DESCRIPTIONS, GIT_HISTORY_DESCRIPTIONS, OpenDocumentSchema, InspectDocumentSchema, SearchContentSchema, ExecuteBatchSchema, SaveDocumentSchema, CloseDocumentSchema, GetDocumentHistorySchema, RevertDocumentSchema, RedoDocumentSchema, extractStylePalette, handleOpenDocument, handleInspectDocument, handleSearchContent, handleExecuteBatch, executeSaveDocument, handleSaveDocument, handleCloseDocument, handleGetDocumentHistory, handleRevertDocument, handleRedoDocument, LEAN6_HANDLERS, GIT_HISTORY_HANDLERS, } from './mcp-tool-adapter';
10
10
  export type { Lean6ToolName, GitHistoryToolName, HistoryEntry, McpErrorCode, McpErrorShape, OpenDocumentInput, InspectDocumentInput, SearchContentInput, ExecuteBatchInput, SaveDocumentInput, CloseDocumentInput, GetDocumentHistoryInput, RevertDocumentInput, RedoDocumentInput, StylePalette, } from './mcp-tool-adapter';
@@ -27,6 +27,26 @@ export declare function resolveBaseline(handle: DocHandle): Promise<ValidationBa
27
27
  export declare function judgeRestoredPackage(handle: DocHandle, result: ValidationResult): Promise<BaselineVerdict>;
28
28
  /** The first `limit` descriptions of a result, cut to a readable length. */
29
29
  export declare function firstMessages(result: ValidationResult, limit?: number): string[];
30
+ /** Validation errors carried on an answer (bounded, first errors only). */
31
+ export declare const AUDIT_VALIDATION_ERRORS_MAX = 10;
32
+ export interface AuditValidation {
33
+ valid: boolean;
34
+ errorCount: number;
35
+ errors: Array<{
36
+ description: string;
37
+ xPath?: string;
38
+ }>;
39
+ }
40
+ /** The first `max` errors as {description, xPath?}, each cut to a readable length. */
41
+ export declare function summarizeValidationErrors(errors: unknown, max?: number): Array<{
42
+ description: string;
43
+ xPath?: string;
44
+ }>;
45
+ /** The shape validate_document returns: valid, how many errors, and the first of them. */
46
+ export declare function toAuditValidation(validation: {
47
+ ok: boolean;
48
+ errors?: unknown;
49
+ }, max?: number): AuditValidation;
30
50
  /** The error a save or normalize raises when the edit adds validator errors. */
31
51
  export declare function introducedError(toolName: string, verdict: Extract<BaselineVerdict, {
32
52
  kind: 'introduced';
@@ -38,8 +58,12 @@ export declare function validationField(result: ValidationResult, verdict: Basel
38
58
  preExistingErrors: number;
39
59
  introducedErrors: 0;
40
60
  messages: string[];
61
+ valid: false;
62
+ errorCount: number;
41
63
  } | {
42
64
  ok: true;
65
+ valid: true;
66
+ errorCount: 0;
43
67
  tolerated?: undefined;
44
68
  preExistingErrors?: undefined;
45
69
  introducedErrors?: undefined;
@@ -87,6 +87,8 @@ export interface BatchOpCreatedIds {
87
87
  index: number;
88
88
  action: string;
89
89
  createdNodeIds: string[];
90
+ /** coverPage on a fresh template: the placeholder nodes it replaced, so the caller sees what went. */
91
+ removedSeedNodes?: string[];
90
92
  }
91
93
  /** Echo of unsaved edits discarded by a revert (counts + ids only, never text). */
92
94
  export interface DiscardedUnsavedSummary {
@@ -103,6 +105,8 @@ export declare function collectAstIdTexts(ast: {
103
105
  sections: Array<{
104
106
  nodes: Array<{
105
107
  id: string;
108
+ type?: string;
109
+ xml?: unknown;
106
110
  metadata: {
107
111
  text?: unknown;
108
112
  };
@@ -160,6 +164,7 @@ export declare function hashDocumentXml(xml: string): string;
160
164
  * for the save path (which does not go through executeBatch).
161
165
  */
162
166
  export declare function countPendingRevisionsInParser(parser: {
167
+ countPackageRevisions?: () => number;
163
168
  getDocumentDom?: () => unknown;
164
169
  getDom?: () => unknown;
165
170
  }): number;
@@ -5,6 +5,12 @@ export interface McpErrorShape {
5
5
  code: McpErrorCode;
6
6
  message: string;
7
7
  remedy: string;
8
+ /** Present when the failure is a validation refusal: how many errors there are, and the first of them. */
9
+ errorCount?: number;
10
+ errors?: Array<{
11
+ description: string;
12
+ xPath?: string;
13
+ }>;
8
14
  }
9
15
  export declare function mcpError(code: McpErrorCode, message: string, remedy: string): McpErrorShape;
10
16
  /**
@@ -68,4 +68,6 @@ export declare function handleInspectDocument(store: McpSessionStore, input: unk
68
68
  remedy?: string;
69
69
  /** Compact summary of the session style guide (absent when none attached). */
70
70
  styleGuide?: StyleGuideSummary;
71
+ comments?: unknown;
72
+ revisions?: unknown;
71
73
  } | McpErrorShape>;
@@ -1,15 +1,8 @@
1
1
  import { PII_COVERAGE } from '@attentionform/astra-engine';
2
+ import { type AuditValidation } from '../baseline-gate';
2
3
  import { type McpSessionStore } from '../../session-store';
3
4
  import { handleComposeDocument } from '../../../tools/compose-document';
4
5
  import type { McpErrorShape } from '../errors';
5
- export interface AuditValidation {
6
- valid: boolean;
7
- errorCount: number;
8
- errors: Array<{
9
- description: string;
10
- xPath?: string;
11
- }>;
12
- }
13
6
  /**
14
7
  * validate_document: strictly read-only preflight ISO audit. The verdict runs
15
8
  * on an isolated fork (see serializeSessionFork): revision, dirty flag,
@@ -41,6 +34,7 @@ export declare function handleGetStats(store: McpSessionStore, input: unknown):
41
34
  words: number;
42
35
  paragraphs: number;
43
36
  tables: number;
37
+ callouts: number;
44
38
  images: number;
45
39
  pages: number;
46
40
  } | McpErrorShape>;
@@ -57,6 +51,13 @@ export interface SanitizeDocumentOk {
57
51
  piiCoverage: typeof PII_COVERAGE;
58
52
  piiNote: string;
59
53
  acceptedRevisions: number;
54
+ unresolvedRevisions: {
55
+ kind: string;
56
+ count: number;
57
+ reason: string;
58
+ part: string;
59
+ }[];
60
+ revisionByKind: Record<string, number>;
60
61
  strippedComments: number;
61
62
  strippedMacros: string[];
62
63
  macroParts: string[];
@@ -24,13 +24,22 @@ export declare function executeSaveDocument(store: McpSessionStore, input: unkno
24
24
  /** Result of the validator gate: clean, or tolerated with the number of errors the file already had. */
25
25
  validation: {
26
26
  ok: true;
27
+ valid: true;
28
+ errorCount: 0;
27
29
  } | {
28
30
  ok: false;
31
+ valid: false;
32
+ errorCount: number;
29
33
  tolerated: true;
30
34
  preExistingErrors: number;
31
35
  introducedErrors: 0;
32
36
  messages: string[];
33
37
  };
38
+ /** The title written from the content because dc:title was a template placeholder, and where it came from. */
39
+ title?: string;
40
+ titleSetFrom?: string;
41
+ /** The configured author written as creator in place of the tool default. */
42
+ creatorSet?: string;
34
43
  /** R-1: pending tracked revisions (w:ins + w:del) in the saved package. */
35
44
  revisionsPending: number;
36
45
  /** R-1: accept remedy, present only when revisionsPending > 0. */
@@ -65,13 +74,22 @@ export declare function handleSaveDocument(store: McpSessionStore, input: unknow
65
74
  /** Result of the validator gate: clean, or tolerated with the number of errors the file already had. */
66
75
  validation: {
67
76
  ok: true;
77
+ valid: true;
78
+ errorCount: 0;
68
79
  } | {
69
80
  ok: false;
81
+ valid: false;
82
+ errorCount: number;
70
83
  tolerated: true;
71
84
  preExistingErrors: number;
72
85
  introducedErrors: 0;
73
86
  messages: string[];
74
87
  };
88
+ /** The title written from the content because dc:title was a template placeholder, and where it came from. */
89
+ title?: string;
90
+ titleSetFrom?: string;
91
+ /** The configured author written as creator in place of the tool default. */
92
+ creatorSet?: string;
75
93
  /** R-1: pending tracked revisions (w:ins + w:del) in the saved package. */
76
94
  revisionsPending: number;
77
95
  /** R-1: accept remedy, present only when revisionsPending > 0. */
@@ -24,6 +24,8 @@ export declare function handleSearchContent(store: McpSessionStore, input: unkno
24
24
  cells?: string[];
25
25
  }>;
26
26
  hint?: string;
27
+ /** True when more than 50 items matched and the list was cut at 50. */
28
+ truncated?: boolean;
27
29
  } | McpErrorShape>;
28
30
  export declare function handleExecuteBatch(store: McpSessionStore, input: unknown): Promise<{
29
31
  ok: true;
@@ -39,8 +41,30 @@ export declare function handleExecuteBatch(store: McpSessionStore, input: unknow
39
41
  results: BatchOpCreatedIds[];
40
42
  /** R-1: pending tracked revisions (w:ins + w:del) remaining after the batch. */
41
43
  revisionsPending: number;
42
- /** R-1: accept remedy, present only when revisionsPending > 0. */
44
+ revisionResolution?: {
45
+ resolved: number;
46
+ resolvedIds: number[];
47
+ byKind: Record<string, number>;
48
+ unresolved: {
49
+ kind: string;
50
+ count: number;
51
+ reason: string;
52
+ part: string;
53
+ }[];
54
+ removedNodeIds?: string[];
55
+ idsMayHaveChanged?: boolean;
56
+ /** Bookmarks, comment ids and links affected when a deleted or moved paragraph was removed. */
57
+ removedBookmarks?: string[];
58
+ removedComments?: number[];
59
+ staleLinks?: {
60
+ bookmark: string;
61
+ count: number;
62
+ }[];
63
+ };
64
+ /** R-1: remedy, present only when revisionsPending > 0. Names acceptAll only when running it can still help. */
43
65
  revisionsRemedy?: string;
66
+ /** FX-07: how many of revisionsPending the resolution in this batch could not resolve. Absent when none. */
67
+ revisionsUnresolved?: number;
44
68
  /** R-14: advisory chart stale body refs (same shape [{nodeId, preview}]). Additive, never a failure. */
45
69
  possiblyStaleBodyRefs: {
46
70
  nodeId: string;
@@ -7,6 +7,9 @@ export interface ToolDefinition {
7
7
  }
8
8
  export declare function getToolDefinitions(): ToolDefinition[];
9
9
  export declare function buildStamp(version: string): string;
10
+ /** The SDK defaults to inlining repeated Zod nodes. Use shared definitions for
11
+ * the published catalog while keeping the same Zod schemas for call validation. */
12
+ export declare function compactToolSchema(schema: unknown): Record<string, unknown>;
10
13
  export declare function generateSchemasToDir(targetDir: string, version?: string): {
11
14
  written: string[];
12
15
  count: number;
@@ -22,11 +22,24 @@ export declare const InspectDocumentSchema: z.ZodObject<{
22
22
  aroundNode: z.ZodOptional<z.ZodString>;
23
23
  window: z.ZodOptional<z.ZodNumber>;
24
24
  maxTokens: z.ZodOptional<z.ZodNumber>;
25
+ include: z.ZodOptional<z.ZodArray<z.ZodEnum<{
26
+ comments: "comments";
27
+ revisions: "revisions";
28
+ }>>>;
29
+ reviewOffset: z.ZodOptional<z.ZodNumber>;
30
+ reviewLimit: z.ZodOptional<z.ZodNumber>;
31
+ commentId: z.ZodOptional<z.ZodNumber>;
32
+ revisionId: z.ZodOptional<z.ZodNumber>;
25
33
  }, z.core.$strict>;
26
34
  export declare const SearchContentSchema: z.ZodObject<{
27
35
  sessionId: z.ZodString;
28
36
  query: z.ZodString;
29
37
  regex: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
38
+ scope: z.ZodOptional<z.ZodEnum<{
39
+ comments: "comments";
40
+ body: "body";
41
+ all: "all";
42
+ }>>;
30
43
  }, z.core.$strict>;
31
44
  export declare const ExecuteBatchSchema: z.ZodObject<{
32
45
  sessionId: z.ZodString;
@@ -77,8 +90,8 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
77
90
  widthEmu: z.ZodOptional<z.ZodNumber>;
78
91
  heightEmu: z.ZodOptional<z.ZodNumber>;
79
92
  chartType: z.ZodOptional<z.ZodEnum<{
80
- line: "line";
81
93
  area: "area";
94
+ line: "line";
82
95
  bar: "bar";
83
96
  column: "column";
84
97
  columnStacked: "columnStacked";
@@ -365,7 +378,6 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
365
378
  border: z.ZodOptional<z.ZodString>;
366
379
  color: z.ZodOptional<z.ZodString>;
367
380
  sz: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
368
- fontSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
369
381
  vAlign: z.ZodOptional<z.ZodString>;
370
382
  align: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
371
383
  center: "center";
@@ -557,8 +569,8 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
557
569
  }>>;
558
570
  target: z.ZodOptional<z.ZodString>;
559
571
  chartType: z.ZodOptional<z.ZodEnum<{
560
- line: "line";
561
572
  area: "area";
573
+ line: "line";
562
574
  bar: "bar";
563
575
  column: "column";
564
576
  columnStacked: "columnStacked";
@@ -598,8 +610,8 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
598
610
  b: "b";
599
611
  tr: "tr";
600
612
  t: "t";
601
- none: "none";
602
613
  r: "r";
614
+ none: "none";
603
615
  l: "l";
604
616
  }>>;
605
617
  overlay: z.ZodOptional<z.ZodBoolean>;
@@ -724,6 +736,7 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
724
736
  action: z.ZodLiteral<"callout">;
725
737
  text: z.ZodString;
726
738
  anchor: z.ZodOptional<z.ZodString>;
739
+ id: z.ZodOptional<z.ZodString>;
727
740
  title: z.ZodOptional<z.ZodString>;
728
741
  theme: z.ZodOptional<z.ZodString>;
729
742
  position: z.ZodOptional<z.ZodEnum<{
@@ -820,24 +833,31 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
820
833
  }, z.core.$strict>, z.ZodObject<{
821
834
  action: z.ZodLiteral<"comment">;
822
835
  operation: z.ZodEnum<{
836
+ delete: "delete";
823
837
  insert: "insert";
824
838
  reply: "reply";
839
+ resolve: "resolve";
840
+ unresolve: "unresolve";
825
841
  }>;
826
842
  target: z.ZodString;
827
- text: z.ZodString;
843
+ text: z.ZodOptional<z.ZodString>;
828
844
  author: z.ZodOptional<z.ZodString>;
829
845
  date: z.ZodOptional<z.ZodString>;
830
846
  expectedVersion: z.ZodOptional<z.ZodNumber>;
831
847
  }, z.core.$strict>, z.ZodObject<{
832
848
  action: z.ZodLiteral<"trackedChange">;
833
849
  operation: z.ZodEnum<{
850
+ accept: "accept";
851
+ reject: "reject";
834
852
  delete: "delete";
835
853
  insert: "insert";
836
854
  acceptAll: "acceptAll";
837
855
  rejectAll: "rejectAll";
838
856
  }>;
857
+ ids: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
839
858
  target: z.ZodOptional<z.ZodString>;
840
859
  text: z.ZodOptional<z.ZodString>;
860
+ occurrence: z.ZodOptional<z.ZodNumber>;
841
861
  author: z.ZodOptional<z.ZodString>;
842
862
  date: z.ZodOptional<z.ZodString>;
843
863
  expectedVersion: z.ZodOptional<z.ZodNumber>;
@@ -256,6 +256,12 @@ export interface McpSessionStats {
256
256
  * sandbox/paths), so MCP/engine verdicts can never disagree on semantics.
257
257
  */
258
258
  export declare function getMcpAllowedRoots(): string[];
259
+ /**
260
+ * Plain-words description of where files may go right now, for error remedies. When the user
261
+ * named folders (--allowed-dir, ASTRA_EXTRA_DOC_ROOTS) those folders are the whole boundary, so
262
+ * the text names them; otherwise it names the defaults and how to widen them.
263
+ */
264
+ export declare function describeAllowedFolders(): string;
259
265
  export { canonicalizeForMcp };
260
266
  /**
261
267
  * M3: jailed document-path validator.
@@ -41,6 +41,11 @@ export declare const ComposeDocumentSchema: z.ZodObject<{
41
41
  }>>;
42
42
  styleGuide: z.ZodOptional<z.ZodString>;
43
43
  dollarMath: z.ZodOptional<z.ZodBoolean>;
44
+ anchor: z.ZodOptional<z.ZodString>;
45
+ position: z.ZodOptional<z.ZodEnum<{
46
+ before: "before";
47
+ after: "after";
48
+ }>>;
44
49
  }, z.core.$strict>;
45
50
  export type ComposeDocumentInput = z.infer<typeof ComposeDocumentSchema>;
46
51
  export declare const COMPOSE_DOCUMENT_DESCRIPTION: string;
@@ -61,6 +66,8 @@ type ComposeDocumentOk = {
61
66
  * renumbered by position on reopen.
62
67
  */
63
68
  persistentIds?: Record<string, string>;
69
+ /** Set when dc:title was a template placeholder and is now written from the content: where it came from. */
70
+ titleSetFrom?: string;
64
71
  /** Per-op attribution (same rule as execute_batch: exact id claims, remainder best-effort). */
65
72
  results: BatchOpCreatedIds[];
66
73
  /** Read-only post-compose OOXML verdict (proof the composed package validates; save re-gates before writing). */
@@ -5,8 +5,8 @@ export declare const ExportDocumentSchema: z.ZodObject<{
5
5
  sessionId: z.ZodString;
6
6
  format: z.ZodEnum<{
7
7
  markdown: "markdown";
8
- html: "html";
9
8
  md: "md";
9
+ html: "html";
10
10
  pdf: "pdf";
11
11
  }>;
12
12
  outPath: z.ZodOptional<z.ZodString>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attentionform/astra-mcp-server",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Official Model Context Protocol (MCP) server for ASTra document IDE",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,8 +41,8 @@
41
41
  "adm-zip-gate": "node ../../scripts/check-adm-zip-imports.mjs"
42
42
  },
43
43
  "dependencies": {
44
- "@attentionform/astra-engine": "^0.2.1",
45
- "@attentionform/ooxml-validator": "^0.2.1",
44
+ "@attentionform/astra-engine": "^0.4.0",
45
+ "@attentionform/ooxml-validator": "^0.4.0",
46
46
  "@modelcontextprotocol/sdk": "^1.32.2",
47
47
  "@xmldom/xmldom": "0.8.15",
48
48
  "adm-zip": "0.6.1",