@attentionform/astra-mcp-server 0.3.0 → 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.
- package/LICENSE +132 -84
- package/README.md +5 -3
- package/dist/index.js +1000 -418
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/mcp/baseline-gate.d.ts +24 -0
- package/dist/lib/mcp/diff.d.ts +4 -0
- package/dist/lib/mcp/errors.d.ts +6 -0
- package/dist/lib/mcp/handlers/parity.d.ts +2 -8
- package/dist/lib/mcp/handlers/save-close.d.ts +18 -0
- package/dist/lib/mcp/schemas.d.ts +1 -1
- package/dist/lib/session-store.d.ts +6 -0
- package/dist/tools/compose-document.d.ts +7 -0
- package/dist/tools/export.d.ts +1 -1
- package/package.json +3 -3
package/dist/lib/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/lib/mcp/diff.d.ts
CHANGED
|
@@ -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
|
};
|
package/dist/lib/mcp/errors.d.ts
CHANGED
|
@@ -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
|
/**
|
|
@@ -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>;
|
|
@@ -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. */
|
|
@@ -378,7 +378,6 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
|
|
|
378
378
|
border: z.ZodOptional<z.ZodString>;
|
|
379
379
|
color: z.ZodOptional<z.ZodString>;
|
|
380
380
|
sz: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
381
|
-
fontSize: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
382
381
|
vAlign: z.ZodOptional<z.ZodString>;
|
|
383
382
|
align: z.ZodOptional<z.ZodPreprocess<z.ZodEnum<{
|
|
384
383
|
center: "center";
|
|
@@ -737,6 +736,7 @@ export declare const ExecuteBatchSchema: z.ZodObject<{
|
|
|
737
736
|
action: z.ZodLiteral<"callout">;
|
|
738
737
|
text: z.ZodString;
|
|
739
738
|
anchor: z.ZodOptional<z.ZodString>;
|
|
739
|
+
id: z.ZodOptional<z.ZodString>;
|
|
740
740
|
title: z.ZodOptional<z.ZodString>;
|
|
741
741
|
theme: z.ZodOptional<z.ZodString>;
|
|
742
742
|
position: z.ZodOptional<z.ZodEnum<{
|
|
@@ -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). */
|
package/dist/tools/export.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attentionform/astra-mcp-server",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
45
|
-
"@attentionform/ooxml-validator": "^0.
|
|
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",
|