Skip to content

Commit e60a1a0

Browse files
committed
add github actions, fix go shadowing issues
- add shellcheck github action - add go test github action - add golangci linte github action - fix bash script shebang and file extension
1 parent 5a59bb8 commit e60a1a0

File tree

14 files changed

+357
-309
lines changed

14 files changed

+357
-309
lines changed

Diff for: .github/workflows/go-lint.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Run golangci-lint
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.go'
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- '**.go'
12+
13+
concurrency:
14+
group: golangci-lint-mcp
15+
cancel-in-progress: true
16+
17+
jobs:
18+
lint:
19+
name: Run golangci-lint
20+
runs-on: ubuntu-24.04
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version-file: "go.mod"
27+
28+
- name: golangci-lint
29+
uses: golangci/golangci-lint-action@v7
30+
with:
31+
version: v2.0
32+
args: --timeout=5m

Diff for: .github/workflows/go-test.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Run go tests
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.go'
7+
push:
8+
branches:
9+
- main
10+
tags-ignore:
11+
- '**'
12+
paths:
13+
- '**.go'
14+
15+
concurrency:
16+
group: mcp-go-test
17+
cancel-in-progress: true
18+
19+
jobs:
20+
test:
21+
name: Run tests
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-go@v5
26+
with:
27+
go-version-file: "go.mod"
28+
id: go
29+
30+
- name: Run tests
31+
run: go test -race -v ./...

Diff for: .github/workflows/shellcheck.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Shellcheck
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.bash'
7+
push:
8+
branches:
9+
- main
10+
tags-ignore:
11+
- '**'
12+
paths:
13+
- '**.bash'
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-24.04
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Run shellchecker
23+
run: |
24+
shellcheck --shell=bash scripts/*.bash

Diff for: .golangci.yml

+36-76
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,50 @@
1+
version: "2"
12
run:
2-
timeout: 5m
3+
concurrency: 4
34
modules-download-mode: readonly
4-
allow-parallel-runners: true
5-
go: '1.24'
6-
7-
output:
8-
format: colored-line-number
9-
sort-results: true
10-
11-
linters-settings:
12-
revive:
13-
rules:
14-
- name: exported
15-
severity: warning
16-
disabled: false
17-
arguments:
18-
- checkPrivateReceivers
19-
- sayRepetitiveInsteadOfStutters
20-
- name: unexported-return
21-
severity: warning
22-
disabled: false
23-
- name: unused-parameter
24-
severity: warning
25-
disabled: false
26-
govet:
27-
check-shadowing: true
28-
gocyclo:
29-
min-complexity: 15
30-
dupl:
31-
threshold: 100
32-
goconst:
33-
min-len: 2
34-
min-occurrences: 3
35-
misspell:
36-
locale: US
37-
goimports:
38-
local-prefixes: github.com/f/mcptools
39-
gofumpt:
40-
extra-rules: true
41-
nolintlint:
42-
allow-unused: false
43-
require-explanation: true
44-
require-specific: true
455

466
linters:
47-
disable-all: true
487
enable:
49-
- bodyclose
50-
- dogsled
51-
- dupl
52-
- errcheck
53-
- exportloopref
8+
- errorlint
549
- goconst
5510
- gocritic
5611
- gocyclo
57-
- gofmt
58-
- gofumpt
59-
- goimports
12+
- godot
13+
- godox
14+
- gomoddirectives
6015
- gosec
61-
- gosimple
62-
- govet
63-
- ineffassign
64-
- misspell
65-
- nakedret
66-
- noctx
67-
- nolintlint
16+
- makezero
17+
- nilerr
6818
- revive
69-
- staticcheck
70-
- stylecheck
71-
- typecheck
72-
- unconvert
73-
- unused
19+
- unparam
20+
settings:
21+
errcheck:
22+
exclude-functions:
23+
- fmt.Fprintln
24+
- fmt.Fprintf
25+
govet:
26+
enable-all: true
27+
settings:
28+
shadow:
29+
strict: true
30+
exclusions:
31+
generated: lax
32+
paths:
33+
- third_party$
34+
- builtin$
35+
- examples$
7436

7537
issues:
76-
exclude-rules:
77-
- path: _test\.go
78-
linters:
79-
- dupl
80-
- gosec
81-
- gomnd
82-
- path: pkg/jsonutils
83-
linters:
84-
- dupl
85-
- path: cmd/mcptools/main.go
86-
linters:
87-
- gocyclo
8838
max-issues-per-linter: 0
8939
max-same-issues: 0
90-
fix: false
40+
formatters:
41+
enable:
42+
- gofmt
43+
- gofumpt
44+
- goimports
45+
exclusions:
46+
generated: lax
47+
paths:
48+
- third_party$
49+
- builtin$
50+
- examples$

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ setup: \
2525

2626
check-go:
2727
@echo "$(BLUE)Checking Go installation and version...$(NC)"
28-
chmod +x ./scripts/check_go.sh
29-
./scripts/check_go.sh
28+
chmod +x ./scripts/check_go.bash
29+
./scripts/check_go.bash
3030

3131
build:
3232
@echo "$(YELLOW)Building $(BINARY_NAME)...$(NC)"

Diff for: README.md

+59-56
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[Read my Blog Post about MCP Tools](https://blog.fka.dev/blog/2025-03-26-introducing-mcp-tools-cli/)
44

5-
A command-line interface for interacting with MCP (Model Context Protocol) servers using both stdio and HTTP transport.
5+
A command-line interface for interacting with MCP (Model Context Protocol)
6+
servers using both stdio and HTTP transport.
67

78
## Overview
89

@@ -16,7 +17,9 @@ This will open a shell as following:
1617

1718
## Contributing
1819

19-
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and contribute to the project.
20+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md)
21+
for details on how to submit pull requests, report issues, and contribute to the
22+
project.
2023

2124
## Installation
2225

@@ -35,45 +38,46 @@ go install github.com/f/mcptools/cmd/mcptools@latest
3538

3639
## Usage
3740

38-
```
39-
MCP is a command line interface for interacting with MCP servers.
40-
It allows you to discover and call tools, list resources, and interact with MCP-compatible services.
41-
42-
Usage:
43-
mcp [command]
41+
MCP is a command line interface for interacting with MCP servers.
42+
It allows you to discover and call tools, list resources, and interact with MCP-compatible services.
43+
44+
Usage:
45+
mcp [command]
46+
47+
Available Commands:
48+
call Call a tool, resource, or prompt on the MCP server
49+
help Help about any command
50+
prompts List available prompts on the MCP server
51+
resources List available resources on the MCP server
52+
shell Start an interactive shell for MCP commands
53+
tools List available tools on the MCP server
54+
version Print the version information
55+
56+
Flags:
57+
-f, --format string Output format (table, json, pretty) (default "table")
58+
-h, --help Help for mcp
59+
-H, --http Use HTTP transport instead of stdio
60+
-p, --params string JSON string of parameters to pass to the tool (default "{}")
61+
-s, --server string MCP server URL (when using HTTP transport) (default "http://localhost:8080")
4462

45-
Available Commands:
46-
call Call a tool, resource, or prompt on the MCP server
47-
help Help about any command
48-
prompts List available prompts on the MCP server
49-
resources List available resources on the MCP server
50-
shell Start an interactive shell for MCP commands
51-
tools List available tools on the MCP server
52-
version Print the version information
53-
54-
Flags:
55-
-f, --format string Output format (table, json, pretty) (default "table")
56-
-h, --help Help for mcp
57-
-H, --http Use HTTP transport instead of stdio
58-
-p, --params string JSON string of parameters to pass to the tool (default "{}")
59-
-s, --server string MCP server URL (when using HTTP transport) (default "http://localhost:8080")
60-
```
6163

6264
## Transport Options
6365

6466
MCP supports two transport methods for communicating with MCP servers:
6567

6668
### Stdio Transport (Default)
6769

68-
Uses stdin/stdout to communicate with an MCP server via JSON-RPC 2.0. This is useful for command-line tools that implement the MCP protocol.
70+
Uses stdin/stdout to communicate with an MCP server via JSON-RPC 2.0. This is
71+
useful for command-line tools that implement the MCP protocol.
6972

7073
```bash
7174
mcp tools npx -y @modelcontextprotocol/server-filesystem ~/Code
7275
```
7376

7477
### HTTP Transport
7578

76-
Uses HTTP protocol to communicate with an MCP server. Use the `--http` flag for HTTP transport.
79+
Uses HTTP protocol to communicate with an MCP server. Use the `--http` flag
80+
for HTTP transport.
7781

7882
```bash
7983
mcp --http tools --server "http://mcp.example.com:8080"
@@ -179,36 +183,35 @@ mcp shell npx -y @modelcontextprotocol/server-filesystem ~/Code
179183

180184
This opens an interactive shell where you can run MCP commands:
181185

182-
```
183-
mcp > connected to MCP server over stdio
184-
mcp > Type '/h' for help or '/q' to quit
185-
mcp > tools
186-
NAME DESCRIPTION
187-
---- -----------
188-
read_file Reads a file from the filesystem
189-
...
186+
mcp > connected to MCP server over stdio
187+
mcp > Type '/h' for help or '/q' to quit
188+
mcp > tools
189+
NAME DESCRIPTION
190+
---- -----------
191+
read_file Reads a file from the filesystem
192+
...
193+
194+
mcp > call read_file --params '{"path": "README.md"}'
195+
...content of README.md...
196+
197+
# Direct tool calling is supported
198+
mcp > read_file {"path": "README.md"}
199+
...content of README.md...
200+
201+
mcp > /h
202+
MCP Shell Commands:
203+
tools List available tools
204+
resources List available resources
205+
prompts List available prompts
206+
call <entity> [--params '{...}'] Call a tool, resource, or prompt
207+
format [json|pretty|table] Get or set output format
208+
Special Commands:
209+
/h, /help Show this help
210+
/q, /quit, exit Exit the shell
211+
212+
mcp > /q
213+
Exiting MCP shell
190214

191-
mcp > call read_file --params '{"path": "README.md"}'
192-
...content of README.md...
193-
194-
# Direct tool calling is supported
195-
mcp > read_file {"path": "README.md"}
196-
...content of README.md...
197-
198-
mcp > /h
199-
MCP Shell Commands:
200-
tools List available tools
201-
resources List available resources
202-
prompts List available prompts
203-
call <entity> [--params '{...}'] Call a tool, resource, or prompt
204-
format [json|pretty|table] Get or set output format
205-
Special Commands:
206-
/h, /help Show this help
207-
/q, /quit, exit Exit the shell
208-
209-
mcp > /q
210-
Exiting MCP shell
211-
```
212215

213216
## Examples
214217

@@ -238,4 +241,4 @@ mcp shell npx -y @modelcontextprotocol/server-filesystem ~/Code
238241

239242
## License
240243

241-
MIT
244+
This project is licensed under MIT

0 commit comments

Comments
 (0)