Skip to content

Commit 31022c6

Browse files
Add Shipwright MCP Server proposal document
Introduces a Model Context Protocol (MCP) server for Shipwright Build, enabling AI-assisted DevOps workflows and natural language interactions with Shipwright resources.
1 parent 2587381 commit 31022c6

File tree

1 file changed

+272
-0
lines changed

1 file changed

+272
-0
lines changed
Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
<!--
2+
Copyright The Shipwright Contributors
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
---
8+
- title: shipwright-mcp-server
9+
- authors:
10+
- "@ayushsatyam"
11+
- reviewers:TBD
12+
- approvers: TBD
13+
- creation-date: 2025-12-17
14+
- last-updated: 2025-12-17
15+
= status: provisional
16+
- see-also:
17+
- replaces: []
18+
- superseded-by: []
19+
---
20+
21+
# Shipwright MCP Server
22+
23+
## Release Signoff Checklist
24+
25+
- [x] Enhancement is `implementable`
26+
- [x] Design details are appropriately documented from clear requirements
27+
- [ ] Test plan is defined
28+
- [ ] Graduation criteria for dev preview, tech preview, GA
29+
- [ ] User-facing documentation is created in [docs](/docs/)
30+
31+
## Summary
32+
33+
This proposal introduces a Model Context Protocol (MCP) server for the Shipwright Build project. The MCP server exposes Shipwright Build functionality through standardized tools that can be consumed by AI assistants, IDE integrations, chatbots, and other MCP-compatible clients. This enables AI-assisted DevOps workflows where developers can interact with Shipwright resources using natural language through tools like Claude, Cursor, and other AI-powered development environments.
34+
35+
The MCP server provides a complete set of tools for managing Shipwright resources:
36+
- **Build Management**: Create, list, get, and delete Build resources
37+
- **BuildRun Management**: Create, list, get, restart, and delete BuildRun resources
38+
- **Strategy Discovery**: List BuildStrategies and ClusterBuildStrategies
39+
40+
This enhancement positions Shipwright as an AI-native container image build platform, meeting developers where they are increasingly working—within AI-assisted development environments.
41+
42+
## Motivation
43+
44+
The developer experience landscape is rapidly evolving with AI-assisted development becoming mainstream. Tools like GitHub Copilot, Cursor, and Claude are fundamentally changing how developers interact with their development environments and infrastructure. The Model Context Protocol (MCP), introduced by Anthropic, provides a standardized way for AI systems to interact with external tools and data sources.
45+
46+
Currently, Shipwright users interact with the build system through:
47+
- `kubectl` commands
48+
- The `shp` CLI tool
49+
- Direct API calls via client libraries
50+
- GitOps workflows with declarative manifests
51+
52+
While these interfaces are powerful, they require developers to context-switch away from their AI-assisted workflows. As AI assistants become the primary interface for many development tasks, Shipwright needs a native integration point.
53+
54+
An MCP server for Shipwright enables:
55+
- **Natural language build management**: Developers can ask their AI assistant to "create a build for my Go application using the buildah strategy"
56+
- **Intelligent troubleshooting**: AI can query build status, analyze failures, and suggest remediations
57+
- **Workflow automation**: AI agents can orchestrate complex build workflows without manual intervention
58+
- **Reduced cognitive load**: Developers don't need to remember specific API fields or CLI flags
59+
60+
### Goals
61+
62+
1. Provide a standardized MCP interface for Shipwright Build resources
63+
2. Enable AI assistants to create, manage, and monitor builds through natural language
64+
3. Support both reference-based and inline BuildRun creation for flexible build workflows
65+
4. Expose build strategy discovery to help users understand available build options
66+
5. Provide comprehensive error handling with actionable feedback for AI consumption
67+
6. Support deployment both inside and outside Kubernetes clusters
68+
7. Maintain compatibility with the Shipwright v1beta1 API
69+
70+
### Non-Goals
71+
72+
1. Replace existing interfaces (CLI, kubectl, client libraries)
73+
2. Implement MCP resources or prompts (only tools are in scope for initial implementation)
74+
3. Provide build log streaming (future enhancement)
75+
4. Implement authentication/authorization beyond Kubernetes RBAC
76+
5. Support Shipwright v1alpha1 API (deprecated)
77+
6. Provide direct Tekton resource management
78+
79+
## Proposal
80+
81+
Introduce a new project `shipwright-io/mcp-server` (or integrate into the main build repository) that implements an MCP server exposing Shipwright Build operations as standardized tools. I recommend a seperate reposditory.
82+
83+
### Example Usage
84+
85+
The following examples demonstrate how developers interact with Shipwright through an AI assistant using the MCP server:
86+
87+
**Build Creation:**
88+
```
89+
Developer: Create a build for my Node.js app at github.com/myorg/myapp
90+
using buildah, output to quay.io/myorg/myapp:latest
91+
92+
AI Assistant: [Calls create_build tool]
93+
Successfully created Build 'myapp-build' in namespace 'default'
94+
```
95+
96+
**Build Troubleshooting:**
97+
```
98+
Developer: Why did my build fail?
99+
100+
AI Assistant: [Calls get_buildrun tool]
101+
Your build failed: BuildRunTimeout - exceeded configured timeout of 10m.
102+
Would you like me to restart with a longer timeout?
103+
```
104+
105+
**Strategy Discovery:**
106+
```
107+
Developer: What build strategies are available?
108+
109+
AI Assistant: [Calls list_clusterbuildstrategies]
110+
Available: buildah, buildpacks-v3, kaniko, source-to-image
111+
```
112+
113+
### Implementation Notes
114+
115+
#### Architecture
116+
117+
```
118+
┌─────────────────────────────────────────────────────────────────────────────┐
119+
│ MCP Clients │
120+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌──────────────────┐ │
121+
│ │ Claude │ │ Cursor │ │ Slack/Teams │ │ Custom AI │ │
122+
│ │ Desktop │ │ IDE │ │ Bots │ │ Agents │ │
123+
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ └────────┬─────────┘ │
124+
└─────────┼────────────────┼────────────────┼───────────────────┼─────────────┘
125+
│ │ │ │
126+
│ stdio/SSE Transport (MCP Protocol) │
127+
│ │ │ │
128+
└────────────────┴────────┬───────┴───────────────────┘
129+
130+
┌───────────────▼───────────────┐
131+
│ Shipwright MCP Server │
132+
│ │
133+
│ ┌─────────────────────────┐ │
134+
│ │ Tool Handlers │ │
135+
│ │ │ │
136+
│ │ • list_builds │ │
137+
│ │ • get_build │ │
138+
│ │ • create_build │ │
139+
│ │ • delete_build │ │
140+
│ │ • list_buildruns │ │
141+
│ │ • get_buildrun │ │
142+
│ │ • create_buildrun │ │
143+
│ │ • restart_buildrun │ │
144+
│ │ • delete_buildrun │ │
145+
│ │ • list_buildstrategies │ │
146+
│ │ • list_clusterbuild... │ │
147+
│ └───────────┬─────────────┘ │
148+
│ │ │
149+
│ ┌───────────▼─────────────┐ │
150+
│ │ Kubernetes Client │ │
151+
│ │ (controller-runtime) │ │
152+
│ └───────────┬─────────────┘ │
153+
└──────────────┼────────────────┘
154+
155+
│ Kubernetes API
156+
157+
┌──────────────▼────────────────┐
158+
│ Kubernetes Cluster │
159+
│ │
160+
│ ┌─────────────────────────┐ │
161+
│ │ Shipwright Build APIs │ │
162+
│ │ │ │
163+
│ │ • Build │ │
164+
│ │ • BuildRun │ │
165+
│ │ • BuildStrategy │ │
166+
│ │ • ClusterBuildStrategy │ │
167+
│ └─────────────────────────┘ │
168+
└───────────────────────────────┘
169+
```
170+
171+
#### MCP Tools Specification
172+
173+
The server implements 11 MCP tools organized by resource type:
174+
175+
##### Build Tools
176+
177+
| Tool | Description | Required Parameters | Optional Parameters |
178+
|------|-------------|---------------------|---------------------|
179+
| `list_builds` | List Builds in a namespace | `namespace` | `prefix`, `label-selector` |
180+
| `get_build` | Get Build details | `name` | `namespace` |
181+
| `create_build` | Create a new Build | `name`, `source-type`, `source-url`, `strategy`, `output-image` | `namespace`, `context-dir`, `revision`, `strategy-kind`, `parameters`, `timeout` |
182+
| `delete_build` | Delete a Build | `name` | `namespace` |
183+
184+
##### BuildRun Tools
185+
186+
| Tool | Description | Required Parameters | Optional Parameters |
187+
|------|-------------|---------------------|---------------------|
188+
| `list_buildruns` | List BuildRuns in a namespace | `namespace` | `prefix`, `label-selector` |
189+
| `get_buildrun` | Get BuildRun details | `name` | `namespace` |
190+
| `create_buildrun` | Create a new BuildRun | `build-name` OR (`source-type`, `source-url`, `strategy`, `output-image`) | `name`, `namespace`, `parameters`, `timeout`, `service-account`, `context-dir`, `revision`, `strategy-kind` |
191+
| `restart_buildrun` | Restart a BuildRun | `name` | `namespace` |
192+
| `delete_buildrun` | Delete a BuildRun | `name` | `namespace` |
193+
194+
##### Strategy Tools
195+
196+
| Tool | Description | Required Parameters | Optional Parameters |
197+
|------|-------------|---------------------|---------------------|
198+
| `list_buildstrategies` | List namespace BuildStrategies | `namespace` | `prefix`, `label-selector` |
199+
| `list_clusterbuildstrategies` | List ClusterBuildStrategies | none | `prefix`, `label-selector` |
200+
201+
#### Server Implementation
202+
203+
The MCP server is already implemented in Go, leveraging the official MCP Go SDK.
204+
It is currently available at [github.com/ayushsatyam146/shipwright-mcp-server](https://github.com/ayushsatyam146/shipwright-mcp-server) and I would like to transfer
205+
ownership to the `github.com/shipwright-io` organization. It is still a relatively new implementation with significant improvements needed but I think it still serves as a solid POC and a good v1 for the project.
206+
207+
Key implementation details:
208+
209+
```go
210+
// Server initialization
211+
server := mcp.NewServer(&mcp.Implementation{
212+
Name: "shipwright-build-mcp-server",
213+
Version: "v1.0.0",
214+
}, nil)
215+
216+
// Tool registration example
217+
mcp.AddTool(server, &mcp.Tool{
218+
Name: "create_build",
219+
Description: "Create a new Build resource",
220+
}, tools.CreateBuild)
221+
```
222+
223+
The server uses:
224+
- **Transport**: stdio (standard input/output) for local MCP clients
225+
- **Kubernetes Client**: controller-runtime client with typed Shipwright APIs
226+
- **Configuration**: Automatic detection of in-cluster config or kubeconfig file
227+
228+
#### Error Handling
229+
230+
All tools return structured error responses that AI clients can interpret:
231+
232+
```go
233+
if err := k8sClient.Create(ctx, build); err != nil {
234+
return &mcp.CallToolResultFor[any]{
235+
IsError: true,
236+
Content: []mcp.Content{&mcp.TextContent{
237+
Text: fmt.Sprintf("Failed to create build: %v", err),
238+
}},
239+
}, nil
240+
}
241+
```
242+
243+
Error categories include:
244+
- **Validation Errors**: Missing required parameters, invalid formats
245+
- **Kubernetes Errors**: Resource not found, permission denied, quota exceeded
246+
- **Network Errors**: Connection issues, timeout errors
247+
248+
249+
## Drawbacks
250+
251+
1. **Additional Component**: Introduces another service to deploy and maintain alongside the Shipwright controller.
252+
253+
2. **AI Dependency**: Effectiveness depends on AI client capabilities and prompt engineering.
254+
255+
3. **Security Surface**: Exposes Kubernetes operations through a new interface that must be secured.
256+
257+
4. **Ecosystem Maturity**: MCP is a relatively new protocol; ecosystem is still evolving.
258+
259+
## Alternatives
260+
261+
### 1. Extend the `shp` CLI with AI Features
262+
263+
Instead of a dedicated MCP server, we could add natural language processing to the existing CLI.
264+
265+
**Pros**: Single tool, familiar interface
266+
**Cons**: Requires LLM integration in CLI, doesn't integrate with IDE-based AI assistants
267+
268+
## Open Questions
269+
270+
1. Should the MCP server be deployed as a sidecar to the Shipwright controller or as a standalone deployment?
271+
2. What authentication mechanisms should be supported for AI clients connecting to the MCP server?
272+
3. Should we support additional MCP features like prompts and resources beyond tools?

0 commit comments

Comments
 (0)