Skip to content

Commit cc0d58a

Browse files
committed
move to golang
1 parent be9a2b9 commit cc0d58a

20 files changed

+764
-548
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,7 @@ cover/
8484
*.swp
8585
*.swo
8686
*~
87+
88+
# Go binaries
89+
harness-mcp-server
90+
*.exe

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# harness-mcp MCP server
1+
# Harness MCP Server
22

3-
MCP server for Harness
3+
The Harness MCP Server is a [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) server that provides seamless integration with Harness APIs, enabling advanced automation and interaction capabilities for developers and tools.
44

55
## Components
66

@@ -11,111 +11,99 @@ The server implements one tool:
1111
- Takes "connector_type", "connector_names", and "connector_ids" as optional arguments
1212
- Returns a list of connectors in JSON format
1313

14-
## To do
14+
## Prerequisites
1515

16-
We need to figure out a good way to handle auth, it's just hardcoded for this POC.
16+
1. You will need to have Go 1.23 or later installed on your system.
17+
2. A Harness API key for authentication.
1718

1819
## Quickstart
1920

20-
### Install
21-
22-
#### Virtual Environment Setup
21+
### Build from source
2322

24-
1. Create a virtual environment (already done):
23+
1. Clone the repository:
2524
```bash
26-
python -m venv venv
25+
git clone https://github.com/yourusername/harness-mcp.git
26+
cd harness-mcp
2727
```
2828

29-
2. Activate the virtual environment:
29+
2. Build the binary:
3030
```bash
31-
# On macOS/Linux
32-
source venv/bin/activate
33-
34-
# On Windows
35-
venv\Scripts\activate
31+
go build -o harness-mcp-server ./cmd/harness-mcp-server
3632
```
3733

38-
3. Install dependencies:
34+
3. Run the server:
3935
```bash
40-
pip install -r requirements.txt
36+
HARNESS_API_KEY=your_api_key ./harness-mcp-server stdio
4137
```
4238

43-
4. Configure your API key by updating the `.env` file with your Harness API key.
39+
### Claude Desktop Configuration
4440

45-
#### Claude Desktop
46-
47-
On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
41+
On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
4842
On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
4943

5044
<details>
51-
<summary>Development/Unpublished Servers Configuration</summary>
52-
```
53-
"mcpServers": {
54-
"harness-mcp": {
55-
"command": "uv",
56-
"args": [
57-
"--directory",
58-
"<path-to-harness-mcp>",
59-
"run",
60-
"harness-mcp"
61-
]
45+
<summary>Server Configuration</summary>
46+
47+
```json
48+
{
49+
"mcpServers": {
50+
"harness": {
51+
"command": "/path/to/harness-mcp-server",
52+
"args": ["stdio"],
53+
"env": {
54+
"HARNESS_API_KEY": "<YOUR_API_KEY>"
55+
}
56+
}
6257
}
6358
}
6459
```
6560
</details>
6661

67-
<details>
68-
<summary>Published Servers Configuration</summary>
69-
```
70-
"mcpServers": {
71-
"harness-mcp": {
72-
"command": "uvx",
73-
"args": [
74-
"harness-mcp"
75-
]
76-
}
77-
}
78-
```
79-
</details>
62+
## Usage with Claude Code
63+
64+
```bash
65+
HARNESS_API_KEY=your_api_key /path/to/harness-mcp-server stdio
66+
```
8067

8168
## Development
8269

83-
### Building and Publishing
70+
### Command Line Arguments
8471

85-
To prepare the package for distribution:
72+
The Harness MCP Server supports the following command line arguments:
8673

87-
1. Sync dependencies and update lockfile:
88-
```bash
89-
uv sync
90-
```
74+
- `--toolsets`: Comma-separated list of tool groups to enable (default: "all")
75+
- `--read-only`: Run the server in read-only mode
76+
- `--log-file`: Path to log file for debugging
77+
- `--enable-command-logging`: Enable logging of all commands
78+
- `--version`: Show version information
79+
- `--help`: Show help message
9180

92-
2. Build package distributions:
93-
```bash
94-
uv build
95-
```
81+
### Environment Variables
9682

97-
This will create source and wheel distributions in the `dist/` directory.
83+
Environment variables are prefixed with `HARNESS_`:
9884

99-
3. Publish to PyPI:
100-
```bash
101-
uv publish
102-
```
85+
- `HARNESS_API_KEY`: Harness API key
86+
- `HARNESS_TOOLSETS`: Comma-separated list of toolsets to enable
87+
- `HARNESS_READ_ONLY`: Set to "true" to run in read-only mode
88+
- `HARNESS_LOG_FILE`: Path to log file
89+
- `HARNESS_ENABLE_COMMAND_LOGGING`: Set to "true" to enable command logging
10390

104-
Note: You'll need to set PyPI credentials via environment variables or command flags:
105-
- Token: `--token` or `UV_PUBLISH_TOKEN`
106-
- Or username/password: `--username`/`UV_PUBLISH_USERNAME` and `--password`/`UV_PUBLISH_PASSWORD`
91+
### Authentication
10792

108-
### Debugging
93+
The server uses a Harness API key for authentication. This can be set via the `HARNESS_API_KEY` environment variable.
10994

110-
Since MCP servers run over stdio, debugging can be challenging. For the best debugging
111-
experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
95+
## Debugging
11296

97+
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
11398

114-
You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:
99+
You can launch the MCP Inspector with this command:
115100

116101
```bash
117-
npx @modelcontextprotocol/inspector uv --directory <path-to-harness-mcp> run harness-mcp
102+
npx @modelcontextprotocol/inspector /path/to/harness-mcp-server stdio
118103
```
119104

105+
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
106+
107+
## To do
120108

121-
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
109+
We need to figure out a good way to handle auth configuration, it's just hardcoded for this POC.

build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Build the harness-mcp-server binary
6+
echo "Building harness-mcp-server..."
7+
go build -o harness-mcp-server ./cmd/harness-mcp-server
8+
9+
echo "Build complete. You can run the server with:"
10+
echo "HARNESS_API_KEY=your_api_key ./harness-mcp-server stdio"

go.mod

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module github.com/harness/harness-mcp
2+
3+
go 1.23
4+
5+
toolchain go1.23.8
6+
7+
require (
8+
github.com/mark3labs/mcp-go v0.20.1
9+
github.com/sirupsen/logrus v1.9.3
10+
github.com/spf13/cobra v1.8.0
11+
github.com/spf13/viper v1.18.2
12+
)
13+
14+
require (
15+
github.com/fsnotify/fsnotify v1.7.0 // indirect
16+
github.com/google/uuid v1.6.0 // indirect
17+
github.com/hashicorp/hcl v1.0.0 // indirect
18+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
19+
github.com/magiconair/properties v1.8.7 // indirect
20+
github.com/mitchellh/mapstructure v1.5.0 // indirect
21+
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
22+
github.com/sagikazarmark/locafero v0.4.0 // indirect
23+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
24+
github.com/sourcegraph/conc v0.3.0 // indirect
25+
github.com/spf13/afero v1.11.0 // indirect
26+
github.com/spf13/cast v1.6.0 // indirect
27+
github.com/spf13/pflag v1.0.5 // indirect
28+
github.com/subosito/gotenv v1.6.0 // indirect
29+
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
30+
go.uber.org/atomic v1.9.0 // indirect
31+
go.uber.org/multierr v1.9.0 // indirect
32+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
33+
golang.org/x/sys v0.15.0 // indirect
34+
golang.org/x/text v0.14.0 // indirect
35+
gopkg.in/ini.v1 v1.67.0 // indirect
36+
gopkg.in/yaml.v3 v3.0.1 // indirect
37+
)

go.sum

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
5+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
7+
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
8+
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
9+
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
10+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
11+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
12+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
13+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
14+
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
15+
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
16+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
17+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
18+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
19+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
20+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
21+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
22+
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
23+
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
24+
github.com/mark3labs/mcp-go v0.20.1 h1:E1Bbx9K8d8kQmDZ1QHblM38c7UU2evQ2LlkANk1U/zw=
25+
github.com/mark3labs/mcp-go v0.20.1/go.mod h1:KmJndYv7GIgcPVwEKJjNcbhVQ+hJGJhrCCB/9xITzpE=
26+
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
27+
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
28+
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
29+
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
30+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
31+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
32+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
33+
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
34+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
35+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
36+
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
37+
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
38+
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
39+
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
40+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
41+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
42+
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
43+
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
44+
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
45+
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
46+
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
47+
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
48+
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
49+
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
50+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
51+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
52+
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
53+
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
54+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
55+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
56+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
57+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
58+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
59+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
60+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
61+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
62+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
63+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
64+
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
65+
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
66+
github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
67+
github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4=
68+
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
69+
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
70+
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
71+
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
72+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
73+
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
74+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
75+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
76+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
77+
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
78+
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
79+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
80+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
81+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
82+
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
83+
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
84+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
85+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
86+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)