@fugood/bricks-project 2.24.0-beta.12 → 2.24.0-beta.13
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/package.json +3 -3
- package/tools/mcp-server.ts +10 -880
- package/tools/mcp-tools/compile.ts +91 -0
- package/tools/mcp-tools/huggingface.ts +653 -0
- package/tools/mcp-tools/icons.ts +60 -0
- package/tools/mcp-tools/lottie.ts +102 -0
- package/tools/mcp-tools/media.ts +110 -0
- package/tools/pull.ts +9 -6
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
import { $ } from 'bun'
|
|
4
|
+
|
|
5
|
+
export function register(server: McpServer, projectDir: string) {
|
|
6
|
+
const { dirname } = import.meta
|
|
7
|
+
|
|
8
|
+
server.tool('compile', {}, async () => {
|
|
9
|
+
let log = ''
|
|
10
|
+
try {
|
|
11
|
+
log += 'Type checking & Compiling...'
|
|
12
|
+
log += await $`bun compile`.cwd(projectDir).text()
|
|
13
|
+
} catch (err) {
|
|
14
|
+
log += `${err.stdout.toString()}\n${err.stderr.toString()}`
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
content: [{ type: 'text', text: log }],
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
server.tool(
|
|
22
|
+
'preview',
|
|
23
|
+
{
|
|
24
|
+
delay: z
|
|
25
|
+
.number()
|
|
26
|
+
.describe('Delay in milliseconds before taking screenshot')
|
|
27
|
+
.optional()
|
|
28
|
+
.default(3000),
|
|
29
|
+
width: z.number().describe('Width of the screenshot').optional().default(600),
|
|
30
|
+
height: z.number().optional().default(480),
|
|
31
|
+
responseImage: z
|
|
32
|
+
.boolean()
|
|
33
|
+
.describe(
|
|
34
|
+
'Whether to response image content (base64 encoded jpeg). If false, only saved path will be responded as text.',
|
|
35
|
+
)
|
|
36
|
+
.optional()
|
|
37
|
+
.default(false),
|
|
38
|
+
testId: z.string().describe('Automation test ID to trigger').optional(),
|
|
39
|
+
testTitleLike: z
|
|
40
|
+
.string()
|
|
41
|
+
.describe('Find automation test by partial title match (case-insensitive)')
|
|
42
|
+
.optional(),
|
|
43
|
+
} as any,
|
|
44
|
+
async ({ delay, width, height, responseImage, testId, testTitleLike }: any) => {
|
|
45
|
+
let log = ''
|
|
46
|
+
let error = false
|
|
47
|
+
try {
|
|
48
|
+
const toolsDir = `${dirname}/..`
|
|
49
|
+
const args = [
|
|
50
|
+
'--no-keep-open',
|
|
51
|
+
'--take-screenshot',
|
|
52
|
+
JSON.stringify({
|
|
53
|
+
delay,
|
|
54
|
+
width,
|
|
55
|
+
height,
|
|
56
|
+
path: `${toolsDir}/screenshot.jpg`,
|
|
57
|
+
closeAfter: true,
|
|
58
|
+
headless: true,
|
|
59
|
+
}),
|
|
60
|
+
]
|
|
61
|
+
if (testId) args.push('--test-id', testId)
|
|
62
|
+
if (testTitleLike) args.push('--test-title-like', testTitleLike)
|
|
63
|
+
log = await $`bunx --bun electron ${toolsDir}/preview-main.mjs ${args}`
|
|
64
|
+
.cwd(projectDir)
|
|
65
|
+
.text()
|
|
66
|
+
} catch (err) {
|
|
67
|
+
log = `${err.stdout.toString()}\n${err.stderr.toString()}`
|
|
68
|
+
error = true
|
|
69
|
+
}
|
|
70
|
+
let screenshotBase64: string | null = null
|
|
71
|
+
if (!error && responseImage) {
|
|
72
|
+
const toolsDir = `${dirname}/..`
|
|
73
|
+
const screenshot = await Bun.file(`${toolsDir}/screenshot.jpg`).arrayBuffer()
|
|
74
|
+
screenshotBase64 = Buffer.from(screenshot).toString('base64')
|
|
75
|
+
}
|
|
76
|
+
const content: Array<
|
|
77
|
+
{ type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string }
|
|
78
|
+
> = [{ type: 'text', text: log }]
|
|
79
|
+
if (screenshotBase64) {
|
|
80
|
+
content.push({
|
|
81
|
+
type: 'image',
|
|
82
|
+
data: screenshotBase64,
|
|
83
|
+
mimeType: 'image/jpeg',
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
content,
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
)
|
|
91
|
+
}
|