You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Learn how you can deploy an MCP server in a Kubernetes cluster. Choose between the following options:
28
27
29
-
2. Deploy your MCP server. Choose between the following options:
30
-
31
-
***Option 1: Use the kmcp deploy command**
32
-
33
-
The `kmcp deploy` command automatically creates an MCPServer resource in your cluster that contains the MCP server configuration that is defined in the `kmcp.yaml` file in your MCP project. The kmcp controller then uses this resource to spin up and manage the lifecycle of your MCP server. After the MCP server is deployed, the command automatically starts the MCP inspector tool so that you can test your server.
34
-
35
-
**Tip**: If you do not want to start the MCP inspector tool, add the `--no-inspector` flag to the command.
36
-
28
+
*[Option 1: Deploy an MCP server with `npx` or `uvx`](#option-1-deploy-an-mcp-server-with-npx-or-uvx): Use an existing npm package to spin up an MCP server instance with `npx` or `uvx`.
29
+
*[Option 2: Build and deploy an MCP server](#option-2-build-and-deploy-an-mcp-server): Build a Docker image for your MCP server project. Then, load this image to your Kubernetes cluster and deploy an MCP server from it.
30
+
31
+
32
+
### Option 1: Deploy an MCP server with `npx` or `uvx`
33
+
34
+
Deploy an instance of the [`server-everything`](https://github.com/modelcontextprotocol/servers/tree/main/src/everything) MCP server by using the `npx` or `uvx` command. This server provides simple tools, such as an echo tool, that you can use for testing.
35
+
Choose between using the kmcp CLI or creating the MCPServer resource yourself.
You can manually create an MCPServer resource yourself as shown in the following examples.
44
-
45
-
* FastMCP example
54
+
Example output:
55
+
```sh
56
+
NAME READY STATUS RESTARTS AGE
57
+
my-mcp-server-669bcb5d6f-zv5dn 1/1 Running 0 27h
58
+
```
59
+
</div>
60
+
<divid="mcpserver2-tab">
61
+
1. Create the MCPServer resource.
46
62
```yaml
47
-
kubectl apply -f- <<EOF
48
-
apiVersion: kagent.dev/v1alpha2
63
+
kubectl apply -f- <<EOF
64
+
apiVersion: kagent.dev/v1alpha1
49
65
kind: MCPServer
50
66
metadata:
51
67
name: my-mcp-server
68
+
namespace: default
52
69
spec:
53
70
deployment:
54
-
image: "my-mcp-server:latest"
71
+
args:
72
+
- '@modelcontextprotocol/server-everything'
73
+
cmd: npx
55
74
port: 3000
56
-
cmd: "python"
57
-
args: ["src/main.py"]
58
-
transportType: "stdio"
75
+
stdioTransport: {}
76
+
transportType: stdio
59
77
EOF
60
78
```
79
+
80
+
2. Verify that the MCP server is up and running.
81
+
```sh
82
+
kubectl get pods
83
+
```
61
84
62
-
* MCP Go example:
63
-
```yaml
64
-
kubectl apply -f- <<EOF
65
-
apiVersion: kagent.dev/v1alpha2
66
-
kind: MCPServer
67
-
metadata:
68
-
name: my-mcp-server
69
-
spec:
70
-
deployment:
71
-
image: "my-mcp-server:latest"
72
-
port: 3000
73
-
cmd: "./server"
74
-
transportType: "stdio"
75
-
EOF
85
+
Example output:
86
+
```sh
87
+
NAME READY STATUS RESTARTS AGE
88
+
my-mcp-server-669bcb5d6f-zv5dn 1/1 Running 0 27h
76
89
```
90
+
</div>
91
+
92
+
### Option 2: Build and deploy an MCP server
93
+
94
+
Learn how to use the kmcp CLI to build an image for your MCP server and to deploy the server to your Kubernetes cluster.
95
+
The following example assumes that you created a [FastMCP](/docs/kmcp/develop/fastmcp-python) or [MCP Go](/docs/kmcp/develop/mcp-go) project with a sample MCP server and tool, and that your kind cluster is named `kind`.
96
+
97
+
1. Build a Docker image for your MCP server and load it to your kind cluster.
2. Deploy your MCP server. Choose between the kmcp CLI or manually creating an MCPServer resource.
103
+
104
+
<Tabstabs={[
105
+
{ id: 'cli', label: 'kmcp CLI' },
106
+
{ id: 'mcpserver', label: 'MCPServer resource' }
107
+
]} />
108
+
109
+
<divid="cli-tab">
110
+
111
+
The `kmcp deploy` command automatically creates an MCPServer resource in your cluster that contains the MCP server configuration that is defined in the `kmcp.yaml` file in your MCP project. The kmcp controller then uses this resource to spin up and manage the lifecycle of your MCP server. After the MCP server is deployed, the command automatically starts the MCP inspector tool so that you can test your server.
112
+
113
+
**Tip**: If you do not want to start the MCP inspector tool, add the `--no-inspector` flag to the command.
You can manually create an MCPServer resource yourself as shown in the following examples.
123
+
124
+
* FastMCP example
125
+
```yaml
126
+
kubectl apply -f- <<EOF
127
+
apiVersion: kagent.dev/v1alpha1
128
+
kind: MCPServer
129
+
metadata:
130
+
name: my-mcp-server
131
+
spec:
132
+
deployment:
133
+
image: "my-mcp-server:latest"
134
+
port: 3000
135
+
cmd: "python"
136
+
args: ["src/main.py"]
137
+
transportType: "stdio"
138
+
EOF
139
+
```
140
+
141
+
* MCP Go example:
142
+
```yaml
143
+
kubectl apply -f- <<EOF
144
+
apiVersion: kagent.dev/v1alpha1
145
+
kind: MCPServer
146
+
metadata:
147
+
name: my-mcp-server
148
+
spec:
149
+
deployment:
150
+
image: "my-mcp-server:latest"
151
+
port: 3000
152
+
cmd: "./server"
153
+
transportType: "stdio"
154
+
EOF
155
+
```
156
+
</div>
77
157
78
158
3. Verify that the MCP server is up and running.
79
159
```sh
@@ -86,6 +166,7 @@ Use the kmcp controller to automatically spin up your MCP server in a Kubernetes
86
166
my-mcp-server-669bcb5d6f-zv5dn 1/1 Running 0 27h
87
167
```
88
168
169
+
89
170
## Test access to the MCP server
90
171
91
172
1. Run the MCP inspector tool. Note that if you used the `kmcp deploy` command to spin up your MCP server, the MCP inspector tool is already running. You can skip to the next step.
0 commit comments