MastraM
Mastra2mo ago
nunzio.o

Error workflow playwright mcp

Hi i am experiencing an error trying to connect a playwright mcp server to operate with tools. While inspecting docs, i got in trouble somewhere and i am getting an error:

Error: Cannot read properties of undefined (reading 'def')
at handleError (file:///path-to-my-desktop/Desktop/prova-playwright-blocking/.mastra/output/index.mjs:31250:9)  at getWorkflowsHandler (file:///path-to-my-desktop/Desktop/prova-playwright-blocking/.mastra/output/index.mjs:39815:12)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async dispatch (file:///path-to-my-desktop/Desktop/prova-playwright-blocking/.mastra/output/index.mjs:326:17)
at async file:///path-to-my-desktop/Desktop/prova-playwright-blocking/.mastra/output/index.mjs:30891:9
at async dispatch (file:///path-to-my-desktop/Desktop/prova-playwright-blocking/.mastra/output/index.mjs:326:17)


while my code very innocent shouldn't be doing much as saw from the examples and typescript types:

 
import { Mastra } from "@mastra/core/mastra";
import { z } from 'zod';
import { createStep, createWorkflow } from '@mastra/core/workflows';
import { MCPClient } from '@mastra/mcp';
import { Step, Tool } from '@mastra/core';

export const mcpPlaywright = new MCPClient({
    id: "mcp",
    servers: {
      playwright: {
        "command": "pnpm",
        "args": ["dlx","@playwright/mcp@latest"]
      }
    }
  })

export const tools: Record<string, Tool> = await mcpPlaywright.getTools();

export const navigateStep: Step = createStep(tools["playwright_browser_navigate"] as any);

export const workflow = createWorkflow({
  id: "browser-search-workflow",
  inputSchema: z.object({
    url: z.string()
  }),
  outputSchema: z.object({}),
})
.then(navigateStep as any)
.commit();

export const mastra = new Mastra({
  workflows: { workflow },
})


And here finally comes my question, can you help me with the error?
Was this page helpful?