Logo vun 无服务器Nova Sonic聊天应用

无服务器Nova Sonic聊天应用

Organisatioun
aws-samples

Run Nova Sonic on AWS Serverless (with MCP support)

Editeuraws-samples
Repositorysample-serverless-nova-sonic-chat
SproochTypeScript
Forks
8
Stären
30
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzMIT-0
Linken
  • Tools mat KI-Workflows verbannen

    无服务器Nova Sonic聊天应用 stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    30 Stären an 8 Forks aus dem verlinkte Repository.

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).

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

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

无服务器Nova Sonic聊天应用 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal 无服务器Nova Sonic聊天应用 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

无服务器Nova Sonic聊天应用 als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu 无服务器Nova Sonic聊天应用 an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "aws-samples-sample-serverless-nova-sonic-chat": {
      "command": "npx",
      "args": [
        "-y",
        "sample-serverless-nova-sonic-chat"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu 无服务器Nova Sonic聊天应用. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu 无服务器Nova Sonic聊天应用.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat 无服务器Nova Sonic聊天应用?
无服务器Nova Sonic聊天应用
Jo. Ech hunn et gelies.
Dat hunn ech mat 无服务器Nova Sonic聊天应用 fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server 无服务器Nova Sonic聊天应用 benotzt?

无服务器Nova Sonic聊天应用 ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech 无服务器Nova Sonic聊天应用 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir 无服务器Nova Sonic聊天应用 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat 无服务器Nova Sonic聊天应用 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann 无服务器Nova Sonic聊天应用 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech 无服务器Nova Sonic聊天应用 MCP mat TypingMind?

无服务器Nova Sonic聊天应用 leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt 无服务器Nova Sonic聊天应用 MCP an TypingMind zur Verfügung?

无服务器Nova Sonic聊天应用 stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir 无服务器Nova Sonic聊天应用 MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann 无服务器Nova Sonic聊天应用 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇