Skip to content

Commit 5f119f8

Browse files
authored
Merge pull request #213 from DefangLabs/linda-mcp-docs
2 parents 2794129 + c2a583e commit 5f119f8

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

docs/concepts/mcp.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
title: MCP
3+
description: Model Context Protocol (MCP) server with built-in tools to allow users to deploy with Defang through a supported IDE.
4+
sidebar-position: 200
5+
---
6+
7+
# Model Context Protocol (MCP)
8+
9+
The Defang [Model Context Protocol (MCP) server](https://github.com/DefangLabs/defang/tree/main/src/pkg/mcp) includes built-in tools to allow users to deploy and manage cloud services through a supported IDE.
10+
11+
Using this MCP server with an IDE will enable the AI coding agent (e.g. Copilot) to use Defang tools and resources to perform tasks, such as deploying a service to the cloud. This means you can now use Defang with IDE-integrated AI coding agents.
12+
13+
![Defang MCP Server Diagram](/img/mcp-concept/diagram.png)
14+
15+
For more details about MCP architecture, visit the [official MCP documentation](https://modelcontextprotocol.io/introduction).
16+
17+
:::info
18+
The MCP Server currently supports deployments to [Defang Playground](/docs/providers/playground). We plan to support Defang BYOC in future updates.
19+
:::
20+
21+
## Installation
22+
23+
First, make sure you have the [npm package manager](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) installed so that you can use `npx` commands.
24+
25+
Connect the MCP server with your IDE by running the following command in your terminal:
26+
27+
```bash
28+
npx -y defang mcp setup --client=<your-ide>
29+
```
30+
31+
Replace `<your-ide>` with the name of your preferred IDE. See our list of [Supported IDEs](#supported-ides). After setup, you can start the MCP server with the command:
32+
33+
```bash
34+
npx -y defang mcp serve
35+
```
36+
37+
Once the server is running, you can access the Defang MCP tools directly through the AI agent chat in your IDE.
38+
39+
![IDE Screenshot](/img/mcp-concept/ide.png)
40+
41+
That's it! Feel free to explore our [Example Prompts](#example-prompts) to get ideas on how to interact with the AI agent and make the most of the Defang MCP Server.
42+
43+
## Supported IDEs
44+
45+
### Cursor
46+
47+
```bash
48+
npx -y defang mcp setup --client=cursor
49+
```
50+
51+
### Windsurf
52+
53+
```bash
54+
npx -y defang mcp setup --client=windsurf
55+
```
56+
57+
### VSCode
58+
59+
```bash
60+
npx -y defang mcp setup --client=vscode
61+
```
62+
63+
### Claude Desktop
64+
65+
(While this is not an IDE in the traditional sense, it can support MCP servers.)
66+
67+
```bash
68+
npx -y defang mcp setup --client=claude
69+
```
70+
71+
## MCP Tools
72+
73+
Below are the tools available in the Defang MCP Server.
74+
75+
### `deploy`
76+
77+
The `deploy` tool scans your project directory for Dockerfiles and `compose.yaml` files, then deploys the detected service(s) using Defang. You can monitor the deployment process in the Defang Portal.
78+
79+
:::info
80+
The MCP Server currently supports deployments to [Defang Playground](/docs/providers/playground). We plan to support Defang BYOC in future updates.
81+
:::
82+
83+
### `services`
84+
85+
The `services` tool displays the details of all your services that are currently deployed in your project with Defang. It shows the Service Name, Deployment ID, Public URL and Service Status. If there are no services found, it will display an appropriate message.
86+
87+
### `destroy`
88+
89+
Given a project name or directory, the `destroy` tool identifies any services deployed with Defang and terminates them. If no services are found, it will display an appropriate message.
90+
91+
:::info
92+
This page is a guide to the Defang MCP Server detailing its installation, tools, and usage. If you are looking for an example of how you can deploy a MCP project with Defang, please instead refer to our [MCP sample application](https://github.com/DefangLabs/samples/tree/main/samples/mcp).
93+
:::
94+
95+
## Example Prompts
96+
97+
After connecting the Defang MCP Server to your IDE using an installation method, you can type in prompts in your chat to invoke the AI agent to use any MCP tool(s).
98+
99+
For example, you can ask the AI agent:
100+
101+
```
102+
can you deploy this to defang?
103+
```
104+
105+
```
106+
please destroy this project.
107+
```
108+
109+
```
110+
what services do I have?
111+
```
112+
113+
You can also choose to specify a project name or project directory if you do not have the project open:
114+
115+
```
116+
deploy this with defang /Users/yourname/Documents/project1
117+
```
118+
119+
```
120+
do I have a service called project1
121+
```

static/img/mcp-concept/diagram.png

158 KB
Loading

static/img/mcp-concept/ide.png

388 KB
Loading

0 commit comments

Comments
 (0)