@genart-dev/mcp-server 0.1.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/dist/index.cjs +3879 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3882 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.cjs +3874 -0
- package/dist/lib.cjs.map +1 -0
- package/dist/lib.d.cts +98 -0
- package/dist/lib.d.ts +98 -0
- package/dist/lib.js +3862 -0
- package/dist/lib.js.map +1 -0
- package/package.json +82 -0
package/dist/lib.d.cts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { WorkspaceDefinition, SketchDefinition } from '@genart-dev/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EditorState — server-scoped mutable state for the MCP server.
|
|
7
|
+
* Tracks the active workspace, loaded sketches, and current selection.
|
|
8
|
+
* Emits mutation events for real-time state broadcasting.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** A loaded sketch with its parsed definition and absolute file path. */
|
|
12
|
+
interface LoadedSketch {
|
|
13
|
+
definition: SketchDefinition;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
/** Mutation event types emitted by EditorState. */
|
|
17
|
+
type EditorMutationType = "workspace:loaded" | "workspace:saved" | "workspace:updated" | "sketch:loaded" | "sketch:created" | "sketch:updated" | "sketch:saved" | "sketch:removed" | "sketch:deleted" | "selection:changed";
|
|
18
|
+
/** Payload for EditorState mutation events. */
|
|
19
|
+
interface EditorMutationEvent {
|
|
20
|
+
type: EditorMutationType;
|
|
21
|
+
payload: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** Serializable snapshot of the full editor state. */
|
|
24
|
+
interface EditorStateSnapshot {
|
|
25
|
+
workspacePath: string | null;
|
|
26
|
+
workspace: WorkspaceDefinition | null;
|
|
27
|
+
sketches: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
definition: SketchDefinition;
|
|
30
|
+
path: string;
|
|
31
|
+
}>;
|
|
32
|
+
selection: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Server-scoped mutable state for the MCP server. */
|
|
35
|
+
declare class EditorState extends EventEmitter {
|
|
36
|
+
/** Absolute path to the active .genart-workspace file, or null. */
|
|
37
|
+
workspacePath: string | null;
|
|
38
|
+
/** Parsed workspace definition, or null if no workspace is open. */
|
|
39
|
+
workspace: WorkspaceDefinition | null;
|
|
40
|
+
/** Loaded sketches keyed by sketch ID. */
|
|
41
|
+
sketches: Map<string, LoadedSketch>;
|
|
42
|
+
/** Currently selected sketch IDs. */
|
|
43
|
+
selection: Set<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Base directory for all file operations. When set, all paths are
|
|
46
|
+
* resolved relative to this directory and constrained within it.
|
|
47
|
+
* Used by mcp-host for per-session sandboxing.
|
|
48
|
+
*/
|
|
49
|
+
basePath: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* When true, the server is running remotely and cannot access the
|
|
52
|
+
* user's local filesystem. Tools return file content in responses
|
|
53
|
+
* instead of writing to disk. Set by mcp-host for HTTP-based sessions.
|
|
54
|
+
*/
|
|
55
|
+
remoteMode: boolean;
|
|
56
|
+
constructor(options?: {
|
|
57
|
+
basePath?: string;
|
|
58
|
+
remoteMode?: boolean;
|
|
59
|
+
});
|
|
60
|
+
/** Update the working directory / sandbox base path. */
|
|
61
|
+
setBasePath(dir: string): void;
|
|
62
|
+
/** Resolve a file path, respecting the sandbox basePath when set. */
|
|
63
|
+
resolvePath(file: string): string;
|
|
64
|
+
/** Resolve a sketch file reference (relative to workspace dir) to an absolute path. */
|
|
65
|
+
resolveSketchPath(file: string): string;
|
|
66
|
+
/** Load a workspace from disk and all its referenced sketches. */
|
|
67
|
+
loadWorkspace(absPath: string): Promise<void>;
|
|
68
|
+
/** Load a single sketch from disk and add it to the cache. */
|
|
69
|
+
loadSketch(absPath: string): Promise<SketchDefinition>;
|
|
70
|
+
/** Get a loaded sketch by ID. */
|
|
71
|
+
getSketch(id: string): LoadedSketch | undefined;
|
|
72
|
+
/** Require a loaded sketch by ID, throwing if not found. */
|
|
73
|
+
requireSketch(id: string): LoadedSketch;
|
|
74
|
+
/** Require an open workspace, throwing if none is open. */
|
|
75
|
+
requireWorkspace(): WorkspaceDefinition;
|
|
76
|
+
/** Remove a sketch from the in-memory cache. */
|
|
77
|
+
removeSketch(id: string): void;
|
|
78
|
+
/** Save the active workspace to disk. */
|
|
79
|
+
saveWorkspace(): Promise<void>;
|
|
80
|
+
/** Save a sketch to disk. */
|
|
81
|
+
saveSketch(id: string): Promise<void>;
|
|
82
|
+
/** Update the selection and return the new set. */
|
|
83
|
+
setSelection(ids: string[]): void;
|
|
84
|
+
/** Get a serializable snapshot of the full editor state. */
|
|
85
|
+
getSnapshot(): EditorStateSnapshot;
|
|
86
|
+
/** Emit a mutation event for external listeners (WebSocket broadcast, sidecar IPC). */
|
|
87
|
+
emitMutation(type: EditorMutationType, payload: unknown): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* MCP server creation and tool registration.
|
|
92
|
+
* Creates a McpServer instance with all tools, resources, and prompts.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/** Create and configure the MCP server with all tools. */
|
|
96
|
+
declare function createServer(state: EditorState): McpServer;
|
|
97
|
+
|
|
98
|
+
export { type EditorMutationEvent, type EditorMutationType, EditorState, type EditorStateSnapshot, type LoadedSketch, createServer };
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { WorkspaceDefinition, SketchDefinition } from '@genart-dev/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EditorState — server-scoped mutable state for the MCP server.
|
|
7
|
+
* Tracks the active workspace, loaded sketches, and current selection.
|
|
8
|
+
* Emits mutation events for real-time state broadcasting.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** A loaded sketch with its parsed definition and absolute file path. */
|
|
12
|
+
interface LoadedSketch {
|
|
13
|
+
definition: SketchDefinition;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
/** Mutation event types emitted by EditorState. */
|
|
17
|
+
type EditorMutationType = "workspace:loaded" | "workspace:saved" | "workspace:updated" | "sketch:loaded" | "sketch:created" | "sketch:updated" | "sketch:saved" | "sketch:removed" | "sketch:deleted" | "selection:changed";
|
|
18
|
+
/** Payload for EditorState mutation events. */
|
|
19
|
+
interface EditorMutationEvent {
|
|
20
|
+
type: EditorMutationType;
|
|
21
|
+
payload: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** Serializable snapshot of the full editor state. */
|
|
24
|
+
interface EditorStateSnapshot {
|
|
25
|
+
workspacePath: string | null;
|
|
26
|
+
workspace: WorkspaceDefinition | null;
|
|
27
|
+
sketches: Array<{
|
|
28
|
+
id: string;
|
|
29
|
+
definition: SketchDefinition;
|
|
30
|
+
path: string;
|
|
31
|
+
}>;
|
|
32
|
+
selection: string[];
|
|
33
|
+
}
|
|
34
|
+
/** Server-scoped mutable state for the MCP server. */
|
|
35
|
+
declare class EditorState extends EventEmitter {
|
|
36
|
+
/** Absolute path to the active .genart-workspace file, or null. */
|
|
37
|
+
workspacePath: string | null;
|
|
38
|
+
/** Parsed workspace definition, or null if no workspace is open. */
|
|
39
|
+
workspace: WorkspaceDefinition | null;
|
|
40
|
+
/** Loaded sketches keyed by sketch ID. */
|
|
41
|
+
sketches: Map<string, LoadedSketch>;
|
|
42
|
+
/** Currently selected sketch IDs. */
|
|
43
|
+
selection: Set<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Base directory for all file operations. When set, all paths are
|
|
46
|
+
* resolved relative to this directory and constrained within it.
|
|
47
|
+
* Used by mcp-host for per-session sandboxing.
|
|
48
|
+
*/
|
|
49
|
+
basePath: string | null;
|
|
50
|
+
/**
|
|
51
|
+
* When true, the server is running remotely and cannot access the
|
|
52
|
+
* user's local filesystem. Tools return file content in responses
|
|
53
|
+
* instead of writing to disk. Set by mcp-host for HTTP-based sessions.
|
|
54
|
+
*/
|
|
55
|
+
remoteMode: boolean;
|
|
56
|
+
constructor(options?: {
|
|
57
|
+
basePath?: string;
|
|
58
|
+
remoteMode?: boolean;
|
|
59
|
+
});
|
|
60
|
+
/** Update the working directory / sandbox base path. */
|
|
61
|
+
setBasePath(dir: string): void;
|
|
62
|
+
/** Resolve a file path, respecting the sandbox basePath when set. */
|
|
63
|
+
resolvePath(file: string): string;
|
|
64
|
+
/** Resolve a sketch file reference (relative to workspace dir) to an absolute path. */
|
|
65
|
+
resolveSketchPath(file: string): string;
|
|
66
|
+
/** Load a workspace from disk and all its referenced sketches. */
|
|
67
|
+
loadWorkspace(absPath: string): Promise<void>;
|
|
68
|
+
/** Load a single sketch from disk and add it to the cache. */
|
|
69
|
+
loadSketch(absPath: string): Promise<SketchDefinition>;
|
|
70
|
+
/** Get a loaded sketch by ID. */
|
|
71
|
+
getSketch(id: string): LoadedSketch | undefined;
|
|
72
|
+
/** Require a loaded sketch by ID, throwing if not found. */
|
|
73
|
+
requireSketch(id: string): LoadedSketch;
|
|
74
|
+
/** Require an open workspace, throwing if none is open. */
|
|
75
|
+
requireWorkspace(): WorkspaceDefinition;
|
|
76
|
+
/** Remove a sketch from the in-memory cache. */
|
|
77
|
+
removeSketch(id: string): void;
|
|
78
|
+
/** Save the active workspace to disk. */
|
|
79
|
+
saveWorkspace(): Promise<void>;
|
|
80
|
+
/** Save a sketch to disk. */
|
|
81
|
+
saveSketch(id: string): Promise<void>;
|
|
82
|
+
/** Update the selection and return the new set. */
|
|
83
|
+
setSelection(ids: string[]): void;
|
|
84
|
+
/** Get a serializable snapshot of the full editor state. */
|
|
85
|
+
getSnapshot(): EditorStateSnapshot;
|
|
86
|
+
/** Emit a mutation event for external listeners (WebSocket broadcast, sidecar IPC). */
|
|
87
|
+
emitMutation(type: EditorMutationType, payload: unknown): void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* MCP server creation and tool registration.
|
|
92
|
+
* Creates a McpServer instance with all tools, resources, and prompts.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/** Create and configure the MCP server with all tools. */
|
|
96
|
+
declare function createServer(state: EditorState): McpServer;
|
|
97
|
+
|
|
98
|
+
export { type EditorMutationEvent, type EditorMutationType, EditorState, type EditorStateSnapshot, type LoadedSketch, createServer };
|