@bloklabs/mcp 0.0.0-stage → 2.0.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.
@@ -0,0 +1,10 @@
1
+ // src/mcp/stdout-guard.ts
2
+ var installStdoutGuard = (target) => {
3
+ const toStderr = (...args) => target.error(...args);
4
+ Object.assign(target, {
5
+ log: toStderr,
6
+ info: toStderr,
7
+ debug: toStderr
8
+ });
9
+ };
10
+ export { installStdoutGuard };
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@bloklabs/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0",
4
+ "description": "MCP server for Blok — lets outside agents read and edit Blok documents, in live rooms or stored.",
5
+ "license": "Apache-2.0",
6
+ "author": "JackUait",
7
+ "homepage": "https://blokeditor.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/JackUait/blok.git",
11
+ "directory": "packages/mcp"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/JackUait/blok/issues"
15
+ },
16
+ "keywords": [
17
+ "blok",
18
+ "mcp",
19
+ "model-context-protocol",
20
+ "agent",
21
+ "block-editor",
22
+ "rich-text-editor",
23
+ "collaboration"
24
+ ],
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./types/index.d.ts",
29
+ "import": "./dist/mcp.mjs"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "bin": {
34
+ "blok-mcp": "bin/blok-mcp.mjs"
35
+ },
36
+ "files": [
37
+ "bin",
38
+ "dist",
39
+ "types"
40
+ ],
41
+ "engines": {
42
+ "node": ">=20.19.0"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "dependencies": {
48
+ "@modelcontextprotocol/server": "2.4.0",
49
+ "ws": "8.22.0"
50
+ }
51
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Public types for `@bloklabs/mcp`.
3
+ *
4
+ * Hand-authored: a published `.d.ts` may not reach outside its own tarball,
5
+ * and this package has no `@bloklabs/core` dependency.
6
+ * AgentActor, ManifestOverrides and BlokCustomToolsFile copy core's types;
7
+ * test/unit/mcp/public-types.test.ts fails the type check when they drift.
8
+ */
9
+
10
+ export interface AgentActor {
11
+ id: string;
12
+ name: string;
13
+ kind: 'agent';
14
+ onBehalfOf?: string;
15
+ color?: string;
16
+ }
17
+
18
+ export type ManifestOverrides = Record<string, { hidden?: boolean; hiddenActions?: string[]; guidance?: string }>;
19
+
20
+ export interface BlokCustomToolsFile {
21
+ formatVersion: 1;
22
+ blocks: Array<{
23
+ name: string;
24
+ /** A `BlockToolDescription` from `@bloklabs/core`. `object`, not a Record: core's interfaces have no index signature. */
25
+ description: object;
26
+ /** `SnapshotBlockStatics` from `@bloklabs/core`. */
27
+ statics: object;
28
+ /** Object and boolean sanitize rules only. */
29
+ sanitize?: Record<string, unknown>;
30
+ }>;
31
+ /** The host's own inline tools. Their marks are `tag:<tag>` keys. */
32
+ inlineTools?: Array<{
33
+ name: string;
34
+ title?: string;
35
+ /** The tool's `static sanitize` as JSON: tag to `true` or to its attributes. */
36
+ sanitize: Record<string, true | Record<string, boolean | string>>;
37
+ }>;
38
+ }
39
+
40
+ export interface BlokMcpOptions {
41
+ transport: { kind: 'stdio' } | { kind: 'http'; listen: string; public?: boolean };
42
+ auth: { kind: 'none' } | { kind: 'oauth'; issuer: string; audience: string; jwksUrl: string };
43
+ /** Absent: no live mode. */
44
+ sync?: { url: string; origin?: string };
45
+ tickets?: { kind: 'secret'; secret: string } | { kind: 'url'; url: string; hostToken: string };
46
+ authorize?: (principal: string, documentId: string, write: boolean) => Promise<boolean>;
47
+ /**
48
+ * Builds the session's actor. The ticket `user` must equal the returned `id`.
49
+ * Blocks the agent writes name `onBehalfOf` in `createdBy`/`lastEditedBy` and the
50
+ * actor's `id` in `createdWith`/`lastEditedWith`. Leave `onBehalfOf` out and the
51
+ * agent's id is named alone. The default actor sets it to the principal.
52
+ */
53
+ agentActor?: (principal: string, clientName: string) => AgentActor;
54
+ source?: { kind: 'endpoint'; url: string; endpointAuth: string; list?: string } | { kind: 'files'; dir: string };
55
+ /** Host custom tool descriptions, as `--manifest <file>` loads them. */
56
+ manifest?: BlokCustomToolsFile;
57
+ /** 'page-map' turns on headless page.rename / page.setIcon, and inserting a page block (it creates the page document). Default 'off'. */
58
+ pageTitles?: 'off' | 'page-map';
59
+ /** Same shape as `--manifest-overrides <file>`. */
60
+ overrides?: ManifestOverrides;
61
+ /** Only for block types missing from the manifest. */
62
+ richTextFields?: Record<string, string[]>;
63
+ /** Default 'mixed': full arguments for the common commands, the envelope for the rest. */
64
+ schema?: 'envelope' | 'full' | 'mixed';
65
+ /** Default 600000 (10 minutes). */
66
+ handleIdleMs?: number;
67
+ /** Default 8. */
68
+ maxHandlesPerPrincipal?: number;
69
+ /** stdio and auth 'none' only: who the caller is. Default 'local'. */
70
+ principal?: string;
71
+ /** Turns on `image.uploadFile`, `video.uploadFile`, `audio.uploadFile` and `file.uploadFile`. */
72
+ uploads?: McpUploads;
73
+ /**
74
+ * False: the editors keep comments in the host's own system (a `comments` hook). Agent
75
+ * comments would be invisible to people there, so the comment commands are unavailable.
76
+ * On by default.
77
+ */
78
+ comments?: boolean;
79
+ }
80
+
81
+ export type McpAssetKind = 'image' | 'video' | 'audio' | 'file';
82
+
83
+ /** Copies core's `UploadContext`, without the progress and variant fields an agent upload never sends. */
84
+ export interface McpUploadContext {
85
+ kind: McpAssetKind;
86
+ tool?: string;
87
+ }
88
+
89
+ /** The host's own uploader, which an agent's upload goes through. */
90
+ export interface McpUploads {
91
+ uploader: {
92
+ /** A file card keeps `size` and `mimeType` when the host returns them. */
93
+ uploadByFile(file: File, ctx: McpUploadContext): Promise<{ url: string; fileName?: string; size?: number; mimeType?: string }>;
94
+ /** When set, `<tool>.setSource` copies a linked file to the host too. */
95
+ uploadByUrl?(url: string, ctx: McpUploadContext): Promise<{ url: string; fileName?: string }>;
96
+ };
97
+ /** A folder the agent may upload from by path. stdio only; symlinks out of it are refused. Absent: base64 bytes only. */
98
+ root?: string;
99
+ /** Per kind, like a media tool's `types` and `maxSize`. Defaults: image/*, audio/* and video/* only; 30 MiB, video 100 MiB. */
100
+ limits?: Partial<Record<McpAssetKind, { types?: string[]; maxSize?: number }>>;
101
+ }
102
+
103
+ export declare function createBlokMcpServer(options: BlokMcpOptions): { start(): Promise<void>; stop(): Promise<void> };