Skip to content

Commit 20378c9

Browse files
committed
chore: update vite and adjust package configurations
1 parent d47f168 commit 20378c9

File tree

8 files changed

+103
-116
lines changed

8 files changed

+103
-116
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"spawn-sync"
3737
],
3838
"overrides": {
39-
"vite": "npm:rolldown-vite@latest"
39+
"vite": "8.0.0-beta.1"
4040
}
4141
}
4242
}

packages/mcp-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@tempad-dev/mcp",
33
"description": "MCP server for TemPad Dev.",
4-
"version": "0.3.5",
4+
"version": "0.3.6",
55
"type": "module",
66
"main": "dist/cli.js",
77
"bin": "dist/cli.js",

packages/mcp-server/src/hub.ts

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -257,46 +257,60 @@ function registerProxiedTool<T extends ExtensionTool>(tool: T): void {
257257
type Name = T['name']
258258
type Result = ToolResultMap[Name]
259259

260+
const registerToolFn = mcp.registerTool.bind(mcp) as (
261+
name: string,
262+
options: { description: string; inputSchema: ZodType; outputSchema?: ZodType },
263+
handler: (args: unknown) => Promise<CallToolResult>
264+
) => unknown
265+
260266
const schema = tool.parameters
261-
mcp.registerTool(
267+
const handler = async (args: unknown) => {
268+
try {
269+
const parsedArgs = schema.parse(args)
270+
const activeExt = extensions.find((e) => e.active)
271+
if (!activeExt) throw new Error('No active TemPad Dev extension available.')
272+
273+
const { promise, requestId } = register<Result>(activeExt.id, toolTimeoutMs)
274+
275+
const message: ToolCallMessage = {
276+
type: 'toolCall',
277+
id: requestId,
278+
payload: {
279+
name: tool.name,
280+
args: parsedArgs
281+
}
282+
}
283+
activeExt.ws.send(JSON.stringify(message))
284+
log.info({ tool: tool.name, req: requestId, extId: activeExt.id }, 'Forwarded tool call.')
285+
286+
const payload = await promise
287+
return createToolResponse(tool.name, payload)
288+
} catch (error) {
289+
log.error({ tool: tool.name, error }, 'Tool invocation failed before reaching extension.')
290+
return createToolErrorResponse(tool.name, error)
291+
}
292+
}
293+
294+
registerToolFn(
262295
tool.name,
263296
{
264297
description: tool.description,
265298
inputSchema: schema as unknown as McpInputSchema
266299
},
267-
async (args: unknown) => {
268-
try {
269-
const parsedArgs = schema.parse(args)
270-
const activeExt = extensions.find((e) => e.active)
271-
if (!activeExt) throw new Error('No active TemPad Dev extension available.')
272-
273-
const { promise, requestId } = register<Result>(activeExt.id, toolTimeoutMs)
274-
275-
const message: ToolCallMessage = {
276-
type: 'toolCall',
277-
id: requestId,
278-
payload: {
279-
name: tool.name,
280-
args: parsedArgs
281-
}
282-
}
283-
activeExt.ws.send(JSON.stringify(message))
284-
log.info({ tool: tool.name, req: requestId, extId: activeExt.id }, 'Forwarded tool call.')
285-
286-
const payload = await promise
287-
return createToolResponse(tool.name, payload)
288-
} catch (error) {
289-
log.error({ tool: tool.name, error }, 'Tool invocation failed before reaching extension.')
290-
return createToolErrorResponse(tool.name, error)
291-
}
292-
}
300+
handler
293301
)
294302
}
295303

296304
function registerLocalTool(tool: HubOnlyTool): void {
297305
const schema = tool.parameters
298306
const handler = tool.handler
299307

308+
const registerToolFn = mcp.registerTool.bind(mcp) as (
309+
name: string,
310+
options: { description: string; inputSchema: ZodType; outputSchema?: ZodType },
311+
handler: (args: unknown) => Promise<CallToolResult>
312+
) => unknown
313+
300314
const registrationOptions: {
301315
description: string
302316
inputSchema: McpInputSchema
@@ -310,15 +324,17 @@ function registerLocalTool(tool: HubOnlyTool): void {
310324
registrationOptions.outputSchema = tool.outputSchema as unknown as McpOutputSchema
311325
}
312326

313-
mcp.registerTool(tool.name, registrationOptions, async (args: unknown) => {
327+
const registerHandler = async (args: unknown) => {
314328
try {
315329
const parsed = schema.parse(args)
316330
return await handler(parsed)
317331
} catch (error) {
318332
log.error({ tool: tool.name, error }, 'Local tool invocation failed.')
319333
return createToolErrorResponse(tool.name, error)
320334
}
321-
})
335+
}
336+
337+
registerToolFn(tool.name, registrationOptions, registerHandler)
322338
}
323339

324340
function createToolResponse<Name extends ToolName>(

packages/mcp-server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"include": ["src/**/*"],
3+
"include": ["**/*"],
44
"compilerOptions": {
55
"types": ["node"],
66
"noEmit": true
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
import { readFileSync } from 'node:fs'
2+
import { dirname, join } from 'node:path'
3+
import { fileURLToPath } from 'node:url'
14
import { defineConfig } from 'tsdown'
25

6+
const dir = dirname(fileURLToPath(import.meta.url))
7+
const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))
8+
9+
// Treat workspace-internal deps as bundled, leave others external.
10+
const internalDeps = Object.keys(pkg.dependencies ?? {}).filter((name: string) =>
11+
name.startsWith('@tempad-dev/')
12+
)
13+
314
export default defineConfig({
415
entry: ['src/cli.ts', 'src/hub.ts'],
516
format: ['esm'],
@@ -8,6 +19,6 @@ export default defineConfig({
819
sourcemap: true,
920
clean: true,
1021
outDir: 'dist',
11-
// Leave deps external automatically; tsdown will treat deps/peerDeps as externals when unbundle=true.
12-
unbundle: true
22+
unbundle: false,
23+
noExternal: internalDeps
1324
})

packages/mcp-shared/tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"extends": "../../tsconfig.base.json",
3+
"include": ["**/*"],
34
"compilerOptions": {
4-
"outDir": "./dist",
55
"declaration": true,
66
"noEmit": true
7-
},
8-
"include": ["src/**/*"]
7+
}
98
}

packages/plugins/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"include": ["src/**/*"],
3+
"include": ["**/*"],
44
"compilerOptions": {
5-
"outDir": "./dist",
65
"declaration": true,
76
"noEmit": true
87
}

0 commit comments

Comments
 (0)