Logo 无服务器Nova Sonic聊天应用

无服务器Nova Sonic聊天应用

Tổ chức
aws-samples

Run Nova Sonic on AWS Serverless (with MCP support)

Nhà phát hànhaws-samples
Kho mãsample-serverless-nova-sonic-chat
Ngôn ngữTypeScript
Bản fork
8
Sao
30
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT-0
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    无服务器Nova Sonic聊天应用 cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    30 sao và 8 bản fork từ kho mã được liên kết.

Serverless Nova Sonic Chat App

This is a sample implementation for deploying a Nova Sonic application using serverless AWS services.

Architecture

Key Features

  • Implementation of serverless real-time communication between server and client using AppSync Events
  • Reference to past conversation history
  • ToolUse implementation
  • MCP (Model Context Protocol) support - Connect to various external services and tools via MCP servers
  • A conversation session can continue up to 8 hours (yes, not 8 minutes)
  • Chat UI implementation using Next.js + shadcn

Deployment Instructions

1. Prerequisites

First, prepare an environment capable of running AWS CDK. This environment must meet the following conditions:

  • Required software installed:
    • Node.js
      • v20 or higher recommended
      • Check with node -v command
    • AWS CLI v2
      • Check with aws --version command
    • Docker
      • Check with docker --version command
  • AWS CLI configured with appropriate AWS IAM permissions (Administrator equivalent required)
    • Set up IAM role or enter IAM user information with aws configure command
  • Internet connection with ability to communicate with AWS APIs
    • May not work properly in closed network environments

Any environment that meets the above requirements can be used, including local terminals or EC2 instances. Once you've confirmed these conditions, proceed to the next step.

2. Deployment Parameter Configuration

You can configure deployment parameters by editing cdk.ts.

Configurable parameters include:

  • Deployment region (default: inherits IAM session)
  • Nova Sonic model region (default: us-east-1)
  • Email domains allowed to sign up to Cognito (default: all allowed)

See the file for details.

3. Enable Bedrock Foundation Models

From the Amazon Bedrock Management Console in the bedrockRegion you specified in the step#2 (us-east-1 by default), enable Nova Sonic model.

4. CDK Bootstrap

Next, perform CDK Bootstrap.

Run the following commands:

sh
cd cdk
# Install Node dependencies
npm ci
# Initialize CDK for use in your AWS environment
npx cdk bootstrap

npm ci installs Node dependencies. This is only required for the first run.

cdk bootstrap performs initial setup to enable CDK usage in your environment. This is required when using CDK for the first time in a specific AWS account and region. It's not needed for subsequent runs.

If you see ✅ Environment aws://xxxx/us-east-1 bootstrapped, the bootstrap was successful. Proceed to the next step.

5. CDK Deploy

With CDK deployment preparation complete, run the following command to deploy all necessary CDK stacks:

sh
cd cdk
npx cdk deploy

Deployment typically takes about 5 minutes.

Upon successful deployment, stack output will be displayed as follows:

 ✅  NovaSonicWebappDemoStack

✨  Deployment time: 246.22s

Outputs:
NovaSonicWebappDemoStack.AgentHandlerFunctionName87E3B26A = CdkStack-AgentHandlerF75982B4-sr8j8OF2uqDt
...
NovaSonicWebappDemoStack.ServiceApiEndpointC0AA9658 = https://1234567.execute-api.us-east-1.amazonaws.com

Open the ServiceApiEndpoint* URL in your browser. If a login screen appears, deployment was successful.

This completes CDK deployment. Next, we'll explain how to use the application.

Usage

Sign Up / Login

When you open the URL in a browser, a login button will be displayed. Follow the on-screen instructions to create a Cognito user and log in.

[!IMPORTANT] By default, anyone who knows the URL can register as a user. It's recommended to restrict sign-up eligible email domains in 3. Deployment Parameter Configuration.

After logging in, the following screen will be displayed:

new session

Voice Conversation

Press the Start Voice Chat button to begin a conversation. You can configure the system prompt and voice before starting. Once the conversation begins, speak to it saying "Hello" or similar.

Before starting a conversation, you can customize the following:

  • System Prompt: Adjust Nova Sonic's speaking style and behavior
  • Voice: Select Nova Sonic's voice type. Currently only 3 English voices are selectable, but Nova Sonic itself supports French, Spanish, German, and more languages are planned for the future.

Press the Stop Voice Chat button to end the conversation. The conversation will also automatically end in the following cases:

  1. After more than 10 minutes have passed
  2. When left idle without speaking for several minutes

Viewing Conversation Logs

Click on history in the sidebar to view conversation history. Since long-term memory is included in the system prompt at that time, you can also see how memories change over time.

MCP Support

This agent now supports MCP (Model Context Protocol), enabling integration with various external services and tools. This allows the agent to:

  • Access databases, APIs, and other external data sources
  • Extend capabilities through community-developed MCP servers

Important Notes:

  • Supports MCP servers that can be executed via uvx or npx
  • Tools are executed synchronously, so long-running tools may not be suitable
  • Resource Requirements: MCP functionality may require additional memory and storage. If you encounter resource limitations, you can adjust the Lambda function's memory size (default: 256MB) and ephemeral storage size (default: 512MB) in cdk/lib/constructs/agent.ts

An example mcp config is below:

json
{
  "mcpServers": {
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"]
    },
    "DeepWiki": {
      "url": "https://mcp.deepwiki.com/sse",
      "enabled": false
    }
  }
}

Other Notes

  • The app works on mobile devices as well as computers (responsive design).
  • For Nova Sonic details, see agent/README.md

Cost

Assuming 10 minutes/session, the cost per session (USD) is as follows. Note that the dimensions such as token counts per session are examples and will vary depending on your actual use case.

AWS serviceDimensionsCost [USD/session]
Bedrock Nova SonicInput token (speech): 300 tokens/minute0.0102
Bedrock Nova SonicOutput token (speech): 200 tokens/minute0.0272
Bedrock Nova SonicInput token (text): 4000 tokens/session0.00024
Bedrock Nova SonicOutput token (text): 1000 tokens/session0.00024
AppSync EventsRequests: 250 events/session/minute0.0025
AppSync EventsConnection: 10 minutes/session0.00000008
LambdaDuration: 512MB, 10 minutes/session0.004
LambdaRequests: 2 invocations/session0.00000004
API GatewayRequests: 20 requests/session0.00001
DynamoDBRead: 10 RRU/session0.00000125
DynamoDBWrite: 50 WRU/session0.00003125
DynamoDBStorage: 30 kB/session (monthly)0.0000075
TOTAL0.044

Looking only at real-time communication costs (Lambda + AppSync Events), it comes to 0.00045 USD/minute. This is about 1/9th the cost of LiveKit Cloud, showing this is a scalable yet cost-efficient architecture.

Note: Pricing information is based on August 2025 data. Please check the official AWS pricing pages for the most current pricing information.

Resource Cleanup

After completing verification, it's recommended to delete unnecessary resources to prevent additional charges. To delete resources, run the following command:

sh
cd cdk
npx cdk destroy --all

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Acknowledgement

The code is heavily inspired and copied from Generative AI Use Cases (GenU).

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

{
  "mcpServers": {
    "aws-samples-sample-serverless-nova-sonic-chat": {
      "command": "",
      "args": []
    }
  }
}

Dùng MCP 无服务器Nova Sonic聊天应用 với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối 无服务器Nova Sonic聊天应用, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm 无服务器Nova Sonic聊天应用 làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của 无服务器Nova Sonic聊天应用.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "aws-samples-sample-serverless-nova-sonic-chat": {
      "command": "npx",
      "args": [
        "-y",
        "sample-serverless-nova-sonic-chat"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của 无服务器Nova Sonic聊天应用, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của 无服务器Nova Sonic聊天应用.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng 无服务器Nova Sonic聊天应用 giúp tôi làm việc này không?
无服务器Nova Sonic聊天应用
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng 无服务器Nova Sonic聊天应用.

Câu hỏi thường gặp

Máy chủ MCP 无服务器Nova Sonic聊天应用 dùng để làm gì?

无服务器Nova Sonic聊天应用 là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP 无服务器Nova Sonic聊天应用 với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng 无服务器Nova Sonic聊天应用 với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP 无服务器Nova Sonic聊天应用 với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối 无服务器Nova Sonic聊天应用, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP 无服务器Nova Sonic聊天应用 với TypingMind?

无服务器Nova Sonic聊天应用 hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP 无服务器Nova Sonic聊天应用 cung cấp những công cụ nào trong TypingMind?

无服务器Nova Sonic聊天应用 cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP 无服务器Nova Sonic聊天应用 không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu 无服务器Nova Sonic聊天应用 yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇