Skip to content

Commit 4b564b5

Browse files
committed
Fool around with a crane MCP server for exploring registries with Claude code
Signed-off-by: Matt Moore <[email protected]>
1 parent 098045d commit 4b564b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+10428
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ dist/
88
cmd/crane/crane
99
cmd/gcrane/gcrane
1010
cmd/krane/krane
11+
cmd/crane/mcp/crane-mcp
1112

1213
.DS_Store

CLAUDE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build Commands
6+
- Run all tests: `go test ./...`
7+
- Run specific test: `go test ./path/to/package -run TestName`
8+
- Run linter: `staticcheck ./pkg/...`
9+
- Verify formatting: `gofmt -d -e -l ./`
10+
- Full presubmit checks: `./hack/presubmit.sh`
11+
- Update generated docs: `./hack/update-codegen.sh`
12+
13+
## Code Style
14+
- Use standard Go formatting (gofmt)
15+
- Import ordering: standard library, third-party, internal packages
16+
- Naming: follow Go conventions (CamelCase for exported, camelCase for unexported)
17+
- Error handling: return errors with context rather than logging
18+
- Testing: use standard Go testing patterns, include table-driven tests
19+
- Copyright header required at top of each file
20+
- Interface-driven design, with immutable view resources
21+
- Implement minimal subset interfaces, use partial package for derived accessors
22+
- Avoid binary data in logs (use redact.NewContext)

cmd/crane/mcp/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Crane MCP Server
2+
3+
This is an implementation of the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) for the `crane` CLI tool. It allows AI assistants and other MCP clients to interact with container registries using the functionality provided by the `crane` command line tool.
4+
5+
## Overview
6+
7+
The server exposes several tools from the `crane` CLI as MCP tools, including:
8+
9+
- `digest`: Get the digest of a container image
10+
- `pull`: Pull a container image and save it as a tarball
11+
- `push`: Push a container image from a tarball to a registry
12+
- `copy`: Copy an image from one registry to another
13+
- `catalog`: List repositories in a registry
14+
- `ls`: List tags for a repository
15+
- `config`: Get the config of an image
16+
- `manifest`: Get the manifest of an image
17+
18+
## Usage
19+
20+
### Building
21+
22+
```bash
23+
go build -o crane-mcp
24+
```
25+
26+
### Running
27+
28+
```bash
29+
./crane-mcp
30+
```
31+
32+
The server communicates through stdin/stdout according to the MCP protocol. It can be integrated with any MCP client.
33+
34+
## Authentication
35+
36+
The server uses the same authentication mechanisms as the `crane` CLI. For private registries, you may need to:
37+
38+
1. Log in to the registry with `docker login` or `crane auth login`
39+
2. Set up appropriate environment variables or credentials files
40+
41+
## Example Client Requests
42+
43+
To get the digest of an image:
44+
45+
```json
46+
{
47+
"type": "call_tool",
48+
"id": "1",
49+
"params": {
50+
"name": "digest",
51+
"arguments": {
52+
"image": "docker.io/library/ubuntu:latest",
53+
"full-ref": true
54+
}
55+
}
56+
}
57+
```
58+
59+
To copy an image between registries:
60+
61+
```json
62+
{
63+
"type": "call_tool",
64+
"id": "2",
65+
"params": {
66+
"name": "copy",
67+
"arguments": {
68+
"source": "docker.io/library/nginx:latest",
69+
"destination": "otherregistry.io/nginx:latest"
70+
}
71+
}
72+
}
73+
```
74+
75+
## License
76+
77+
Licensed under the Apache License, Version 2.0. See LICENSE file for details.

0 commit comments

Comments
 (0)