@mailquilt/mcp 0.0.0-stage → 0.5.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 +21 -0
- package/README.md +86 -2
- package/dist/bin.js +1154 -0
- package/dist/index.d.ts +157 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1105 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -3
- package/src/bin.ts +53 -0
- package/src/catalog.ts +188 -0
- package/src/index.ts +32 -0
- package/src/server.ts +299 -0
- package/src/summary.ts +179 -0
- package/src/tools.ts +882 -0
- package/src/workspace.ts +401 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { Block, BlockType, BlocksDocument, RowLayout } from "@mailquilt/core";
|
|
2
|
+
import { Readable, Writable } from "node:stream";
|
|
3
|
+
type JsonSchemaObject = Record<string, unknown>;
|
|
4
|
+
interface BlockTypeCatalogEntry {
|
|
5
|
+
readonly type: BlockType | string;
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly requiredProps: readonly string[];
|
|
8
|
+
readonly propNames: readonly string[];
|
|
9
|
+
readonly propsSchema: JsonSchemaObject | null;
|
|
10
|
+
}
|
|
11
|
+
interface BlockCatalog {
|
|
12
|
+
readonly documentVersion: number | null;
|
|
13
|
+
readonly schemaId: string | null;
|
|
14
|
+
readonly rowLayouts: readonly RowLayout[];
|
|
15
|
+
readonly blockTypes: readonly BlockTypeCatalogEntry[];
|
|
16
|
+
readonly rowPropsSchema: JsonSchemaObject | null;
|
|
17
|
+
readonly columnPropsSchema: JsonSchemaObject | null;
|
|
18
|
+
readonly settingsSchema: JsonSchemaObject | null;
|
|
19
|
+
}
|
|
20
|
+
/** Loads the live JSON Schema published by `@mailquilt/core/schema.json`. */
|
|
21
|
+
export declare const loadCoreJsonSchema: () => JsonSchemaObject;
|
|
22
|
+
/**
|
|
23
|
+
* Builds the live Block, Row layout, and JSON Schema catalog directly from
|
|
24
|
+
* `@mailquilt/core` (`BLOCK_TYPES`, `ROW_LAYOUTS`, `@mailquilt/core/schema.json`).
|
|
25
|
+
*/
|
|
26
|
+
export declare const buildBlockCatalog: (filterBlockType?: string) => BlockCatalog;
|
|
27
|
+
interface McpToolDefinition {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly inputSchema: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
interface McpToolResult {
|
|
33
|
+
readonly content: readonly [{
|
|
34
|
+
readonly type: "text";
|
|
35
|
+
readonly text: string;
|
|
36
|
+
}];
|
|
37
|
+
readonly isError?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Returns the live tool definitions dynamically reflecting `@mailquilt/core`. */
|
|
40
|
+
export declare const getToolDefinitions: () => readonly McpToolDefinition[];
|
|
41
|
+
type JsonRpcId = string | number | null;
|
|
42
|
+
interface JsonRpcSuccess {
|
|
43
|
+
readonly jsonrpc: "2.0";
|
|
44
|
+
readonly id: JsonRpcId;
|
|
45
|
+
readonly result: unknown;
|
|
46
|
+
}
|
|
47
|
+
interface JsonRpcFailure {
|
|
48
|
+
readonly jsonrpc: "2.0";
|
|
49
|
+
readonly id: JsonRpcId;
|
|
50
|
+
readonly error: {
|
|
51
|
+
readonly code: number;
|
|
52
|
+
readonly message: string;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
type JsonRpcResponse = JsonRpcSuccess | JsonRpcFailure;
|
|
56
|
+
interface McpServerOptions {
|
|
57
|
+
/** Workspace root directory; all file reads/writes are restricted inside it. */
|
|
58
|
+
readonly root?: string | undefined;
|
|
59
|
+
/** Optional active `mailquilt dev` preview URL (overrides MAILQUILT_DEV_URL). */
|
|
60
|
+
readonly devUrl?: string | undefined;
|
|
61
|
+
}
|
|
62
|
+
interface McpServer {
|
|
63
|
+
readonly root: string;
|
|
64
|
+
readonly listTools: () => readonly McpToolDefinition[];
|
|
65
|
+
readonly callTool: (name: string, args?: Record<string, unknown>) => Promise<McpToolResult>;
|
|
66
|
+
readonly handleJsonRpcMessage: (message: unknown) => Promise<JsonRpcResponse | readonly JsonRpcResponse[] | null>;
|
|
67
|
+
readonly handleLine: (line: string) => Promise<string | null>;
|
|
68
|
+
readonly startStdio: (input?: Readable, output?: Writable) => Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a Mail Quilt MCP server scoped to `options.root` (default `process.cwd()`).
|
|
72
|
+
*/
|
|
73
|
+
export declare const createMcpServer: (options?: McpServerOptions) => McpServer;
|
|
74
|
+
/** Starts the Mail Quilt MCP stdio server and resolves once stdin closes. */
|
|
75
|
+
export declare const startMcpStdioServer: (options?: McpServerOptions & {
|
|
76
|
+
readonly input?: Readable | undefined;
|
|
77
|
+
readonly output?: Writable | undefined;
|
|
78
|
+
}) => Promise<void>;
|
|
79
|
+
interface BlockSummary {
|
|
80
|
+
readonly id: string;
|
|
81
|
+
readonly index: number;
|
|
82
|
+
readonly type: Block["type"];
|
|
83
|
+
readonly preview?: string;
|
|
84
|
+
}
|
|
85
|
+
interface ColumnSummary {
|
|
86
|
+
readonly id: string;
|
|
87
|
+
readonly index: number;
|
|
88
|
+
readonly width: number;
|
|
89
|
+
readonly blockCount: number;
|
|
90
|
+
readonly blocks: readonly BlockSummary[];
|
|
91
|
+
}
|
|
92
|
+
interface RowSummary {
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly index: number;
|
|
95
|
+
readonly layout?: string;
|
|
96
|
+
readonly columnCount: number;
|
|
97
|
+
readonly columns: readonly ColumnSummary[];
|
|
98
|
+
}
|
|
99
|
+
interface DocumentSummary {
|
|
100
|
+
readonly version: number;
|
|
101
|
+
readonly settings: {
|
|
102
|
+
readonly width: number;
|
|
103
|
+
readonly backgroundColor: string;
|
|
104
|
+
readonly fontFamily: string;
|
|
105
|
+
readonly preheader?: string;
|
|
106
|
+
readonly language?: string;
|
|
107
|
+
readonly hasStyle: boolean;
|
|
108
|
+
};
|
|
109
|
+
readonly rowCount: number;
|
|
110
|
+
readonly blockCount: number;
|
|
111
|
+
readonly rows: readonly RowSummary[];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Produces a concise structural outline of an email (Rows, Columns, Blocks and
|
|
115
|
+
* their IDs) so agents can target Commands without scanning full ProseMirror JSON.
|
|
116
|
+
*/
|
|
117
|
+
export declare const summarizeDocument: (document: BlocksDocument) => DocumentSummary;
|
|
118
|
+
/** Error thrown when a path resolves outside the configured workspace root. */
|
|
119
|
+
export declare class WorkspacePathError extends Error {
|
|
120
|
+
readonly code: "invalid_path" | "not_a_file" | "not_found" | "outside_root";
|
|
121
|
+
constructor(code: "invalid_path" | "not_a_file" | "not_found" | "outside_root", message: string);
|
|
122
|
+
}
|
|
123
|
+
interface ResolvedWorkspacePath {
|
|
124
|
+
/** Absolute, symlink-verified path on disk. */
|
|
125
|
+
readonly absolutePath: string;
|
|
126
|
+
/** Normalized POSIX-style path relative to the workspace root. */
|
|
127
|
+
readonly relativePath: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Resolves the workspace root directory to a canonical realpath when it exists,
|
|
131
|
+
* or resolves its deepest existing ancestor when the directory is not yet created.
|
|
132
|
+
*/
|
|
133
|
+
export declare const canonicalizeRoot: (root: string) => string;
|
|
134
|
+
/**
|
|
135
|
+
* Resolves an existing file inside `root`, rejecting `..` traversal, absolute
|
|
136
|
+
* paths outside `root`, directories, and symlinks pointing outside `root`.
|
|
137
|
+
*/
|
|
138
|
+
export declare const resolveWorkspaceReadPath: (root: string, inputPath: string) => Promise<ResolvedWorkspacePath>;
|
|
139
|
+
/**
|
|
140
|
+
* Resolves a target file path for writing inside `root`. Walks every existing
|
|
141
|
+
* path component from `root` downward to verify that neither an ancestor
|
|
142
|
+
* directory symlink nor the target symlink escapes `root`.
|
|
143
|
+
*/
|
|
144
|
+
export declare const resolveWorkspaceWritePath: (root: string, inputPath: string) => Promise<ResolvedWorkspacePath>;
|
|
145
|
+
/** Reads a UTF-8 file strictly inside `root`. */
|
|
146
|
+
export declare const readWorkspaceFile: (root: string, inputPath: string) => Promise<ResolvedWorkspacePath & {
|
|
147
|
+
content: string;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Atomically writes UTF-8 content to a file strictly inside `root` by writing
|
|
151
|
+
* to a sibling temporary file and renaming it into place.
|
|
152
|
+
*/
|
|
153
|
+
export declare const writeWorkspaceFileAtomic: (root: string, inputPath: string, content: string, options?: {
|
|
154
|
+
overwrite?: boolean;
|
|
155
|
+
}) => Promise<ResolvedWorkspacePath>;
|
|
156
|
+
export type { BlockCatalog, BlockSummary, BlockTypeCatalogEntry, ColumnSummary, DocumentSummary, JsonRpcFailure, JsonRpcResponse, JsonRpcSuccess, JsonSchemaObject, McpServer, McpServerOptions, McpToolDefinition, McpToolResult, ResolvedWorkspacePath, RowSummary };
|
|
157
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/catalog.ts","../src/tools.ts","../src/server.ts","../src/summary.ts","../src/workspace.ts"],"mappings":";;KAMY,mBAAmB;UAEd;WACN,MAAM;WACN;WACA;WACA;WACA,aAAa;;UAGP;WACN;WACA;WACA,qBAAqB;WACrB,qBAAqB;WACrB,gBAAgB;WAChB,mBAAmB;WACnB,gBAAgB;;;qBASd,0BAAyB;;;;;qBAuEzB,oBAAiB,6BAA+B;UClF5C;WACN;WACA;WACA,aAAa;;UAGP;WACN;aAA8B;aAAuB;;WACrD;;;qBA8lBE,mCAAkC;KCpmB1C;UAEY;WACN;WACA,IAAI;WACJ;;UAGM;WACN;WACA,IAAI;WACJ;aACE;aACA;;;KAID,kBAAkB,iBAAiB;UAE9B;;WAEN;;WAEA;;UAGM;WACN;WACA,0BAA0B;WAC1B,WACP,cACA,OAAO,4BACJ,QAAQ;WACJ,uBACP,qBACG,QAAQ,2BAA2B;WAC/B,aAAa,iBAAiB;WAC9B,aAAa,QAAQ,UAAU,SAAS,aAAa;;;;;qBA0HnD,kBAAe,UAAa,qBAAwB;;qBA4GpD,sBAAmB,UACrB;WACE,QAAQ;WACR,SAAS;MAEnB;UCpSc;WACN;WACA;WACA,MAAM;WACN;;UAGM;WACN;WACA;WACA;WACA;WACA,iBAAiB;;UAGX;WACN;WACA;WACA;WACA;WACA,kBAAkB;;UAGZ;WACN;WACA;aACE;aACA;aACA;aACA;aACA;aACA;;WAEF;WACA;WACA,eAAe;;;;;;qBA0Fb,oBAAiB,UAClB,mBACT;;qBCpHU,2BAA2B;WAC7B;EAET,YACE,oEACA;;UAQa;;WAEN;;WAEA;;;;;;qBAUE,mBAAgB;;;;;qBAsFhB,2BAAwB,cACvB,sBAEX,QAAQ;;;;;;qBA4LE,4BAAyB,cACxB,sBAEX,QAAQ;;qBAcE,oBAAiB,cAChB,sBAEX,QAAQ;EAA0B;;;;;;qBAUxB,2BAAwB,cACvB,mBACK,iBACF;EACJ;MACV,QAAQ"}
|