tsukuboshi
MCP Servertsukuboshipublic

nextjs mastra mcp with lwa

使用 AWS CDK 和 Lambda 架构运行 Mastra Agent 和 Next.js 应用,并结合 Amazon Bedrock 和 Playwright MCP。

Repository Info

0
Stars
0
Forks
0
Watchers
0
Issues
TypeScript
Language
-
License

About This Server

使用 AWS CDK 和 Lambda 架构运行 Mastra Agent 和 Next.js 应用,并结合 Amazon Bedrock 和 Playwright MCP。

Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.

Documentation

Next.js Mastra MCP with Lambda Web Adapter

AWS CDK project for running Mastra Agent and Next.js application with Lambdalish Architecture and Amazon Bedrock to interact with MCP Server.
As an example, this project uses Playwright MCP server.

Prerequisites

  • Node.js: v20 or higher
  • AWS CDK: v2 or higher
  • Docker: v20 or higher
  • AWS Credentials: Access Key / Secret Key / Session Token

Architecture

!Architecture

Project Structure

.
├── web/                        # Next.js application
│   ├── Dockerfile              # Container image definition
│   ├── package.json            # App dependencies
│   ├── tsconfig.json           # TypeScript config for app
│   ├── parameter.ts            # App configuration
│   ├── public/                 # Static files
│   ├── run.sh                  # Startup script
│   ├── src/                    # Application source code
│   │   ├── app/                # Next.js App Router
│   │   ├── lib/                # Library code (e.g., bedrock-client.ts)
│   │   └── mastra/             # Mastra application root
│   │       ├── index.ts        # Mastra instance configuration
│   │       ├── agents/         # Agent definitions
│   │       └── mcp/            # MCP configuration
│   └── ...                     # Other config/build files
├── infra/                      # Infrastructure as Code (AWS CDK)
│   ├── bin/                    # CDK entry point
│   │   └── mastra-mcp-on-lwa.ts
│   ├── lib/                    # CDK stack definitions
│   │   └── mastra-mcp-on-lwa-stack.ts
│   ├── test/                   # Infrastructure tests
│   │   └── mastra-mcp-on-ecs.test.ts
│   ├── cdk.json                # CDK configuration
│   ├── package.json            # Infra dependencies
│   ├── tsconfig.json           # TypeScript config for infra
│   └── parameter.ts            # Infra configuration
├── image/                      # Architecture diagrams and images
├── package.json                # Root project dependencies
├── tsconfig.json               # Root TypeScript configuration
└── README.md                   # This file

Getting Started

Install Dependencies

All commands should be executed at the repository root.

First, install dependencies for the root project.

npm install:all

Next, set up environment variables by creating .env.development file which contains the aws credentials.

cat << EOF > web/.env.development
ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX
SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXX
SESSION_TOKEN=XXXXXXXXXXXXXXXXXXXX
EOF

Local Development

If you want to change the application configuration, you can modify the app/parameter.ts.

To start local mastra http server only, run the following command.

npm run mastra:dev

To start local Next.js server with mastra, run the following command.

npm run next:dev

Production Deployment

If you want to change the infrastructure configuration, you can modify the infra/parameter.ts.

If you've never used CDK before, you need to Bootstrap for the first time only. The following command is unnecessary if your environment is already bootstrapped.

npx -w infra cdk bootstrap

To deploy the application to AWS, run the following command.

npm run cdk:deploy

To remove the application from AWS, run the following command.

npm run cdk:destroy

Quick Start

1

Clone the repository

git clone https://github.com/tsukuboshi/nextjs-mastra-mcp-with-lwa
2

Install dependencies

cd nextjs-mastra-mcp-with-lwa
npm install
3

Follow the documentation

Check the repository's README.md file for specific installation and usage instructions.

Repository Details

Ownertsukuboshi
Reponextjs-mastra-mcp-with-lwa
LanguageTypeScript
License-
Last fetched8/10/2025

Recommended MCP Servers

💬

Discord MCP

Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.

integrationsdiscordchat
🔗

Knit MCP

Connect AI agents to 200+ SaaS applications and automate workflows.

integrationsautomationsaas
🕷️

Apify MCP Server

Deploy and interact with Apify actors for web scraping and data extraction.

apifycrawlerdata
🌐

BrowserStack MCP

BrowserStack MCP Server for automated testing across multiple browsers.

testingqabrowsers

Zapier MCP

A Zapier server that provides automation capabilities for various apps.

zapierautomation