Skip to main content

3 posts tagged with "GCP"

View All Tags

· 7 min read

mcp

Anthropic recently unveiled the Model Context Protocol (MCP), “a new standard for connecting AI assistants to the systems where data lives”. However, as Docker pointed out, “packaging and distributing MCP Servers is very challenging due to complex environment setups across multiple architectures and operating systems”. Docker helps to solve this problem by enabling developers to “encapsulate their development environment into containers, ensuring consistency across all team members’ machines and deployments.” The Docker work includes a list of reference MCP Servers packaged up as containers, which you can deploy locally and test your AI application.

However, to put such containerized AI applications into production, you need to be able to not only test locally, but also easily deploy the application to the cloud. This is what Defang enables. In this blog and the accompanying sample, we show how to build a sample AI application using one of the reference MCP Servers, run and test it locally using Docker, and when ready, to easily deploy it to the cloud of your choice (AWS, GCP, or DigitalOcean) using Defang.

Sample Model Context Protocol Time Chatbot Application​

Using Docker’s mcp/time image and Anthropic Claude, we made a chatbot application that can access time-based resources directly on the user’s local machine and answer time-based questions.

The application is containerized using Docker, enabling a convenient and easy way to get it running locally. We will later demonstrate how we deployed it to the cloud using Defang.

Let’s go over the structure of the application in a local environment.

mcp_before

General Overview​

  1. There are two containerized services, Service 1 and Service 2, that sit on the local machine.
    • Service 1 contains a custom-built web server that interacts with an MCP Client.
    • Service 2 contains an MCP Server from Docker as a base image for the container, and a custom-built MCP Client we created for interacting with the MCP Server.
  2. We have a browser on our local machine, which interacts with the web server in Service 1.
  3. The MCP Server in Service 2 is able to access tools from either a cloud or on our local machine. This configuration is included as a part of the Docker MCP image.
  4. The MCP Client in Service 2 interacts with the Anthropic API and the web server.

Architecture​

Service 1: Web Server

Service 1 contains a web server and the UI for a chat application (not shown in the diagram), written in Next.js. The chat UI updates based on user-entered queries and chatbot responses. A POST request is sent to Service 1 every time a user enters a query from the browser. In the web server, a Next.js server action function is used to forward the user queries to the endpoint URL of Service 2 to be processed by the MCP Client.

Service 2: MCP Service Configuration

The original Docker mcp/time image is not designed with the intent of being deployed to the cloud - it is created for a seamless experience with Claude Desktop. To achieve cloud deployment, an HTTP layer is needed in front of the MCP Server. To address this, we've bundled an MCP Client together with the Server into one container. The MCP Client provides the HTTP interface and communicates with the MCP Server via standard input/output (stdio).

MCP Client

The MCP Client is written in Python, and runs in a virtual environment (/app/.venv/bin) to accommodate specific package dependencies. The MCP Client is instantiated in a Quart app, where it connects to the MCP Server and handles POST requests from the web server in Service 1. Additionally, the MCP Client connects to the Anthropic API to request LLM responses.

MCP Server and Tools (from the Docker Image)

The MCP Server enables access to tools from an external source, whether it be from a cloud or from the local machine. This configuration is included as a part of the Docker MCP image. The tools can be accessed indirectly by the MCP Client through the MCP Server. The Docker image is used as a base image for Service 2, and the MCP Client is built in the same container as the MCP Server. Note that the MCP Server also runs in a virtual environment (/app/.venv/bin).

Anthropic API

The MCP Client connects to the Anthropic API to request responses from a Claude model. Two requests are sent to Claude for each query. The first request will send the query contents and a list of tools available, and let Claude respond with a selection of the tools needed to craft a response. The MCP Client will then call the tools indirectly through the MCP Server. Once the tool results come back to the Client, a second request is sent to Claude with the query contents and tool results to craft the final response.

Setting Up Dockerfiles​

Service 1: Web Server - Dockerfile

The base image for Service 1 is the node:bookworm-slim image. We construct the image by copying the server code and setting an entry point command to start the web server.

Service 2: MCP Service Configuration - Dockerfile

The base image for Service 2 is the Docker mcp/time image. Since both the MCP Client and Server run in a virtual environment, we activate a venv command in the Dockerfile for Service 2 and create a run.sh shell script that runs the file containing the MCP Client and Server connection code. We then add the shell script as an entry point command for the container.

Compose File​

To define Services 1 and 2 as Docker containers, we’ve written a compose.yaml file in the root directory, as shown below.

services:
service-1: # Web Server and UI
build:
context: ./service-1
dockerfile: Dockerfile
ports:
- target: 3000
published: 3000
mode: ingress
deploy:
resources:
reservations:
memory: 256M
environment:
- MCP_SERVICE_URL=http://service-2:8000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]

service-2: # MCP Service (MCP Client and Server)
build:
context: ./service-2
dockerfile: Dockerfile
ports:
- target: 8000
published: 8000
mode: host
environment:
- ANTHROPIC_API_KEY

Testing and Running on Local Machine​

Now that we’ve defined our application in Docker containers using a compose.yaml file, we can test and run it on our local machine by running the command:

docker compose up --build

Once the application is started up, it can be easily tested in a local environment. However, to make it easily accessible to others online, we should deploy it to the cloud. Fortunately, deploying the application is a straightforward process using Defang, particularly since the application is Compose-compatible.

Deploying to the Cloud​

Let’s go over the structure of the application after cloud deployment.

mcp_after

Here we can see what changes if we deploy to the cloud:

  1. Service 1 and Service 2 are now deployed to the cloud, not on the local machine anymore.
  2. The only part on the local machine is the browser.

Using the same compose.yaml file as shown earlier, we can deploy the containers to the cloud with the Defang CLI. Once we’ve authenticated and logged in, we can choose a cloud provider (i.e. AWS, GCP, or DigitalOcean) and use our own cloud account for deployment. Then, we can set a configuration variable for the Anthropic API key:

defang config set ANTHROPIC_API=<your-api-key-value>

Then, we can run the command:

defang compose up

Now, the MCP time chatbot application will be up and running in the cloud. This means that anyone can access the application online and try it for themselves!

For our case, anyone can use the chatbot to ask for the exact time or convert time zones from their machine, regardless of where they are located.

mcp_time_chatbot

Most importantly, this chatbot application can be adapted to use any of the other Docker reference MCP Server images, not just the mcp/time server.

Have fun building and deploying MCP-based containerized applications to the cloud with Defang!

· 3 min read

Defang Compose Update

Welcome to 2025! As we had shared in our early Dec update, we reached our V1 milestone with support for GCP and DigitalOcean in Preview and production support for AWS. We were very gratified to see the excitement around our launch, with Defang ending 2024 with twice the number of users as our original goal!

We are excited to build on that momentum going into 2025. And we are off to a great start in Jan, with some key advancements:

  1. GCP parity with AWS: We are really excited to announce that our GCP provider is now feature-complete, with support for key features such as Managed Postgres, Managed Redis, BYOD (Bring-Your-Own-Domain), GPUs, AI-assisted Debugging, and more. Install the latest version of our CLI and give it a try! Please let us know your feedback.
  2. Defang Deployed with Defang: In 2025, we are doubling our focus on production use-cases where developers are using Defang every day to deploy their production apps. And where better to start than with Defang itself? We had already been using Defang to deploy portions of our infrastructure (such as our web site), but we are super happy to report that now we are using Defang to deploy all our services - including our Portal, Playground, the Defang back-end (aka Fabric) and more. We’ll be sharing more about how we did this, and publishing some of the related artifacts, in a blog post soon - stay tuned.
  3. Campus Advocate Program: One of our key goals for 2025 is to bring Defang to more students and hobbyists. To do this, we are very excited to launch our Campus Advocate Program, a community of student leaders passionate about cloud technology. Our advocates will build communities, host events, and help peers adopt cloud development with Defang. If you’re a student eager to drive cloud innovation on your campus, we’d love to hear from you - you can apply here.
  4. 1-click Deploy instructions: One of our most popular features is the ability to deploy any of our 50+ samples with a single click. We have now published instructions showing how you can provide a similar experience for your project or sample. We are curious to see what you deploy with this!
  5. Model Context Protocol sample: AI agents are of course the rage nowadays. Recently, Docker published a blog showing how you can use Docker to containerize “servers” following Anthropic’s Model Context Protocol. We have now published a sample that shows you how to easily deploy such containerized servers to the cloud using Defang - check it out here.

So, you can see we have been busy! But that is not all - we have a lot more in the pipeline in the coming months. Stay tuned - it’s going to be an exciting 2025!

P.S.: Defang is now on Bluesky! Follow us to stay connected, get the latest updates, and join the conversation. See you there!

· 4 min read

Defang Compose Update

At Defang, we’re enabling developers go from idea to code to deployment 10x faster. We’re thrilled to announce that Defang V1 is officially launching during our action-packed Launch Week, running from December 4–10, 2024! This marks a major milestone as we officially release the tools and features developers have been waiting for.

What’s New in Defang CLI V1?​

Defang is a powerful tool that lets you easily develop, deploy, and debug production-ready cloud applications. With Defang V1, we continue to deliver on our vision to make cloud development effortlessly simple and portable, with the ability to develop once and deploy anywhere. Here’s what’s included in this milestone release:

  • Production-Ready Support for AWS

Seamlessly deploy and scale with confidence on AWS. Defang is now WAFR-compliant, assuring that your deployments conform to all the best-practices for AWS deployments. Defang is now officially part of the AWS Partner Network.

  • New - Google Cloud Platform (GCP) in Preview

This week, we are excited to unveil support for deployments to GCP, in Preview. Start building and exploring and give us feedback as we work to enhance the experience further and move towards production support. Defang is also now officially part of the Google Cloud Partner Advantage program.

  • Support for DigitalOcean in Preview

Developers using DigitalOcean can explore our Preview features, with further enhancements and production support coming soon.

Defang Product Tiers and Introductory Pricing 🛠️

As we move into V1, we are also rolling out our differentiated product tiers, along with our special introductory pricing. Fear not, we will always have a free tier for hobbyists - conveniently called the Hobby tier. We now also provide Personal, Pro, and Enterprise tiers for customers with more advanced requirements. Check out what is included in each here. And as always, the Defang CLI is and remains open-source.

Launch Week Activities​

We’ve lined up an exciting week of activities to showcase the power of Defang and bring together our growing community:

  • December 4: Vancouver CDW x AWS re:Invent Watch Party

Join us at the Vancouver CDW x AWS re:Invent Watch Party, where we will have a booth showcasing Defang’s capabilities and AWS integration. Stop by to learn more about Defang and see a live demo from the Defang dev team.

  • December 5–6: GFSA DemoDay and Git Push to 2025: Devs Social Party

Hear directly from Defang’s co-founder and CTO, Lio Lunesu, as we unveil Defang’s support for GCP at the Google for Startups Accelerator (GFSA) DemoDay event in Toronto. This event will also be live-streamed here.

Additionally, join us on December 5th for the final meetup of the year for Vancouver’s developer groups, hosted by VanJS in collaboration with other local dev communities.

  • December 6 & 7: MLH Global Hack Week (GHW)

Join us during MLH Global Hack Week for hands-on workshops and learn how to build production-ready cloud applications in minutes with Defang.

  • December 7: Cloud Chat

An IRL event with our team to explore V1 features in depth, answer your questions, and share insights from our journey. Register here to join.

  • December 10: Product Hunt Launch

Be part of our Product Hunt debut and show your support as we reach the broader tech community.

Join the Celebration 🎉​

This launch week is not just about us. It is about you, our community. Here is how you can get involved:

  1. Explore the Platform: Sign up at Defang.io and dive into V1.

  2. Attend Events: Mark your calendar for our scheduled activities.

  3. Spread the Word: Follow us on LinkedIn and X, share your experiences, and let others know why you love Defang.

We’re excited to celebrate this milestone with all of you. Stay tuned for more updates, and let’s make Launch Week unforgettable!