Skip to content

Commit

Permalink
Add MCP server example (#35)
Browse files Browse the repository at this point in the history
* Add MCP server example

* Update examples/mcp-server/README.md
  • Loading branch information
csweichel authored Feb 17, 2025
1 parent d05435d commit 364fd42
Showing 6 changed files with 409 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -5,19 +5,18 @@ RUN apt-get update && apt-get install -y \
libxkbcommon0 \
ca-certificates \
git \
golang \
unzip \
libc++1 \
vim \
curl \
procps \
&& apt-get clean autoclean

RUN curl -OL https://go.dev/dl/go1.24.0.linux-amd64.tar.gz && \
tar -C /usr/local -xzvf go1.24.0.linux-amd64.tar.gz && \
rm go1.24.0.linux-amd64.tar.gz
ENV PATH="$PATH:/usr/local/go/bin"

# Ensure UTF-8 encoding
ENV LANG=C.UTF-8
ENV LC_ALL=C.UTF-8

ENV GOPATH=/go
ENV PATH=$GOPATH/bin:$PATH

WORKDIR /workspace

COPY . /workspace
1 change: 1 addition & 0 deletions examples/mcp-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mcp-server
65 changes: 65 additions & 0 deletions examples/mcp-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Gitpod MCP Server

A Model Control Protocol (MCP) server that provides access to Gitpod resources and operations through Claude.

## Features

- List Gitpod projects
- List Gitpod environments
- Create new environments
- Stop environments
- Execute commands in environments

## Claude Desktop Configuration

1. Create a file containing your Gitpod personal access token:
```bash
echo "your_api_key_here" > /tmp/gitpod-personal-access-token.txt
```

2. Build the server:
```bash
go build -o /tmp/gitpod-mcp
```

3. Add the following to your Claude Desktop configuration to enable Gitpod integration:

```json
{
"mcpServers": {
"gitpod": {
"command": "/tmp/gitpod-mcp",
"env": {
"GITPOD_API_KEY": "your-key-here",
}
}
}
}
```

>**Note:** Don't forget to delete the token file after you're done.
## Available Resources

- `gitpod://projects` - List all available Gitpod projects
- `gitpod://environments` - List current Gitpod environments

## Available Tools

### create_environment
Creates a new Gitpod environment for a project.
- Parameters:
- `project_id` (string, required): The ID of the project to create the environment in

### stop_environment
Stops a running Gitpod environment.
- Parameters:
- `environment_id` (string, required): The ID of the environment to stop

### execute_command
Executes a command in a Gitpod environment.
- Parameters:
- `environment_id` (string, required): The ID of the environment to execute the command in
- `command` (string, required): The command to execute (runs as a bash script in project root)
- `description` (string, required): A short description of the command (max 200 characters)
```
16 changes: 16 additions & 0 deletions examples/mcp-server/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module github.com/gitpod-io/gitpod-sdk-go/examples/mcp-server

go 1.23.0

replace github.com/gitpod-io/gitpod-sdk-go => ../..

require github.com/mark3labs/mcp-go v0.8.4

require (
github.com/gitpod-io/gitpod-sdk-go v0.0.0-00010101000000-000000000000 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
)
22 changes: 22 additions & 0 deletions examples/mcp-server/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/mark3labs/mcp-go v0.8.4 h1:/VxjJ0+4oN2eYLuAgVzixrYNfrmwJnV38EfPIX3VbPE=
github.com/mark3labs/mcp-go v0.8.4/go.mod h1:cjMlBU0cv/cj9kjlgmRhoJ5JREdS7YX83xeIG9Ko/jE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 364fd42

Please sign in to comment.