Skip to content

Commit 3271110

Browse files
committed
Improve ql-mcp-client from PR feedback
1 parent e5f5a7b commit 3271110

File tree

15 files changed

+575
-132
lines changed

15 files changed

+575
-132
lines changed

.github/agents/ql-agent-skills-developer.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ Get the current list of all tools available in the CodeQL Development MCP Server
3535
gh-ql-mcp-client list tools --format json
3636
```
3737

38+
### List QL MCP Server Prompts
39+
40+
Get the current list of all prompts available in the CodeQL Development MCP Server:
41+
42+
```sh
43+
gh-ql-mcp-client list prompts --format json
44+
```
45+
46+
### List QL MCP Server Resources
47+
48+
Get the current list of all resources available in the CodeQL Development MCP Server:
49+
50+
```sh
51+
gh-ql-mcp-client list resources --format json
52+
```
53+
3854
## References
3955

4056
- [`.github/skills/README.md`](../skills/README.md)

.github/workflows/client-integration-tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ jobs:
3636
os: [ubuntu-latest, windows-latest]
3737

3838
env:
39-
ENABLE_ANNOTATION_TOOLS: 'true'
4039
HTTP_HOST: 'localhost'
4140
HTTP_PORT: '3000'
4241
MCP_MODE: ${{ matrix.mcp-mode }}

client/CLI-USAGE.md

Lines changed: 23 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gh-ql-mcp-client CLI Usage Guide
22

3-
This document describes how to use the `gh-ql-mcp-client` CLI for Code Scanning alert lifecycle management and MCP server integration testing.
3+
This document describes how to use the `gh-ql-mcp-client` CLI for MCP server integration testing and MCP primitive listing.
44

55
## Overview
66

@@ -15,84 +15,42 @@ gh ql-mcp-client <command> [flags]
1515

1616
# Help for any command
1717
gh-ql-mcp-client --help
18-
gh-ql-mcp-client code-scanning --help
19-
gh-ql-mcp-client code-scanning list-alerts --help
18+
gh-ql-mcp-client list --help
19+
gh-ql-mcp-client integration-tests --help
2020
```
2121

2222
## Commands
2323

24-
### `code-scanning` (alias: `cs`)
24+
### `list`
2525

26-
Interact with the GitHub Code Scanning REST API. Requires `gh` CLI authentication.
26+
List MCP server primitives (tools, prompts, resources).
2727

28-
#### `list-analyses`
28+
#### `list tools`
2929

30-
List Code Scanning analyses for a repository.
30+
List all tools registered on the MCP server.
3131

3232
```bash
33-
gh-ql-mcp-client code-scanning list-analyses --repo owner/repo
34-
gh-ql-mcp-client cs list-analyses --repo owner/repo --tool-name CodeQL --ref refs/heads/main
35-
gh-ql-mcp-client cs list-analyses --repo owner/repo --format json
33+
gh-ql-mcp-client list tools
34+
gh-ql-mcp-client list tools --format json
35+
gh-ql-mcp-client list tools --mode http --port 3000
3636
```
3737

38-
**Flags:**
39-
40-
| Flag | Description |
41-
| ------------- | -------------------------------------------- |
42-
| `--repo` | Repository in `owner/repo` format (required) |
43-
| `--ref` | Git ref to filter by |
44-
| `--tool-name` | Tool name to filter by (e.g. `CodeQL`) |
45-
| `--sarif-id` | SARIF ID to filter by |
46-
| `--sort` | Sort by (`created`) |
47-
| `--direction` | Sort direction (`asc`, `desc`) |
48-
| `--per-page` | Results per page (default: 30, max: 100) |
49-
50-
#### `list-alerts`
51-
52-
List Code Scanning alerts for a repository.
53-
54-
```bash
55-
gh-ql-mcp-client code-scanning list-alerts --repo owner/repo
56-
gh-ql-mcp-client cs list-alerts --repo owner/repo --state open --severity high
57-
gh-ql-mcp-client cs list-alerts --repo owner/repo --tool-name CodeQL --format json
58-
```
59-
60-
**Flags:**
61-
62-
| Flag | Description |
63-
| ------------- | ---------------------------------------------------------------- |
64-
| `--repo` | Repository in `owner/repo` format (required) |
65-
| `--ref` | Git ref to filter by |
66-
| `--state` | Alert state: `open`, `closed`, `dismissed`, `fixed` |
67-
| `--severity` | Severity: `critical`, `high`, `medium`, `low`, `warning`, `note` |
68-
| `--tool-name` | Tool name to filter by |
69-
| `--sort` | Sort by (`created`, `updated`) |
70-
| `--direction` | Sort direction (`asc`, `desc`) |
71-
| `--per-page` | Results per page (default: 30, max: 100) |
38+
#### `list prompts`
7239

73-
#### `download-analysis`
74-
75-
Download a Code Scanning analysis as SARIF.
40+
List all prompts registered on the MCP server.
7641

7742
```bash
78-
gh-ql-mcp-client code-scanning download-analysis --repo owner/repo --analysis-id 12345
79-
gh-ql-mcp-client cs download-analysis --repo owner/repo --analysis-id 12345 --output my-results.sarif
43+
gh-ql-mcp-client list prompts
44+
gh-ql-mcp-client list prompts --format json
8045
```
8146

82-
**Flags:**
83-
84-
| Flag | Description |
85-
| --------------- | ----------------------------------------------------------------------- |
86-
| `--repo` | Repository in `owner/repo` format (required) |
87-
| `--analysis-id` | Analysis ID to download (required) |
88-
| `--output` | Output file path (default: `sarif-downloads/<owner>_<repo>/<id>.sarif`) |
89-
90-
### `sarif`
47+
#### `list resources`
9148

92-
SARIF analysis and alert comparison tools. These commands delegate to MCP server tools.
49+
List all resources registered on the MCP server.
9350

9451
```bash
95-
gh-ql-mcp-client sarif --help
52+
gh-ql-mcp-client list resources
53+
gh-ql-mcp-client list resources --format json
9654
```
9755

9856
### `integration-tests`
@@ -129,11 +87,13 @@ These flags are available on all commands:
12987

13088
| Flag | Default | Description |
13189
| ---------- | ----------- | ------------------------------------- |
132-
| `--mode` | `http` | MCP server transport (`stdio`/`http`) |
90+
| `--mode` | `stdio` | MCP server transport (`stdio`/`http`) |
13391
| `--host` | `localhost` | MCP server host (http mode) |
13492
| `--port` | `3000` | MCP server port (http mode) |
13593
| `--format` | `text` | Output format (`text`/`json`) |
13694

95+
Transport mode is controlled by the `--mode` flag, which defaults to `stdio`.
96+
13797
## Integration with Shell Scripts
13898

13999
The `client/scripts/run-integration-tests.sh` script builds the Go binary, starts the MCP server, and runs integration tests:
@@ -155,8 +115,7 @@ The `client/scripts/run-integration-tests.sh` script builds the Go binary, start
155115
| ----------------- | ------------------------------------------------------- | ---------------------------- |
156116
| `MCP_SERVER_URL` | Override MCP server URL (http mode) | `http://localhost:3000/mcp` |
157117
| `MCP_SERVER_PATH` | Override path to MCP server JS entry point (stdio mode) | Auto-detected from repo root |
158-
| `MCP_MODE` | Transport mode (`stdio`/`http`) | `http` |
159-
| `HTTP_HOST` | Server host | `localhost` |
160-
| `HTTP_PORT` | Server port | `3000` |
118+
119+
Transport mode is controlled by the `--mode` flag (default: `stdio`). `MCP_SERVER_URL` is only used to override the server URL when running in `http` mode.
161120

162121
Cobra provides built-in help and validation for all flags. Use `--help` on any command for details.

client/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test-unit:
2525

2626
## test-integration: Build binary and run integration tests via run-integration-tests.sh
2727
test-integration: build
28-
ENABLE_ANNOTATION_TOOLS=true scripts/run-integration-tests.sh --no-install-packs
28+
scripts/run-integration-tests.sh --no-install-packs
2929

3030
## test-verbose: Run all unit tests with verbose output
3131
test-verbose:

client/README.md

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gh-ql-mcp-client
22

3-
A Go CLI for managing Code Scanning alert lifecycles, combining GitHub's Code Scanning REST API (via `gh` auth) with the CodeQL Development MCP Server's SARIF analysis tools.
3+
A Go CLI for listing MCP server primitives, running MCP server integration tests, and (planned) managing Code Scanning alert lifecycles.
44

55
Installable as a standalone binary or as a `gh` CLI extension (`gh ql-mcp-client`).
66

@@ -42,27 +42,20 @@ Transport is configured via CLI flags. The CLI does not currently read `MCP_MODE
4242

4343
### Commands
4444

45-
#### `code-scanning` (alias: `cs`)
45+
#### `list`
4646

47-
Interact with the GitHub Code Scanning REST API.
47+
List MCP server primitives (tools, prompts, resources).
4848

4949
```bash
50-
# List analyses for a repository
51-
gh-ql-mcp-client code-scanning list-analyses --repo owner/repo
50+
# List all tools registered on the MCP server
51+
gh-ql-mcp-client list tools
52+
gh-ql-mcp-client list tools --format json
5253

53-
# List alerts with filters
54-
gh-ql-mcp-client code-scanning list-alerts --repo owner/repo --state open --severity high
54+
# List all prompts
55+
gh-ql-mcp-client list prompts
5556

56-
# Download a SARIF analysis
57-
gh-ql-mcp-client code-scanning download-analysis --repo owner/repo --analysis-id 12345
58-
```
59-
60-
#### `sarif`
61-
62-
SARIF analysis and alert comparison tools (delegates to MCP server tools).
63-
64-
```bash
65-
gh-ql-mcp-client sarif --help
57+
# List all resources
58+
gh-ql-mcp-client list resources
6659
```
6760

6861
#### `integration-tests`
@@ -96,9 +89,8 @@ make test-coverage # Unit tests with coverage report
9689
| ----------------- | ------------------------------------------------------- | ---------------------------- |
9790
| `MCP_SERVER_URL` | Override MCP server URL (http mode) | `http://localhost:3000/mcp` |
9891
| `MCP_SERVER_PATH` | Override path to MCP server JS entry point (stdio mode) | Auto-detected from repo root |
99-
| `MCP_MODE` | Transport mode (`stdio`/`http`) | `http` |
100-
| `HTTP_HOST` | Server host | `localhost` |
101-
| `HTTP_PORT` | Server port | `3000` |
92+
93+
Transport mode is controlled by the `--mode` flag, which defaults to `stdio`. `MCP_SERVER_URL` is only used to override the server URL when running in `http` mode.
10294

10395
## Architecture
10496

@@ -107,15 +99,14 @@ client/
10799
├── main.go # Entry point
108100
├── cmd/ # Cobra CLI commands
109101
│ ├── root.go # Root command + global flags
110-
│ ├── code_scanning.go # code-scanning subcommand group
111-
│ ├── code_scanning_*.go # Individual code-scanning subcommands
112-
│ ├── sarif.go # sarif subcommand group
102+
│ ├── list.go # list subcommand group (tools/prompts/resources)
103+
│ ├── helpers.go # Shared CLI helpers
113104
│ └── integration_tests.go # integration-tests command
114105
├── internal/
115-
│ ├── github/ # GitHub Code Scanning REST API client (via go-gh)
116106
│ ├── mcp/ # MCP server client (via mcp-go)
117107
│ └── testing/ # Integration test runner and parameter builder
118108
├── integration-tests/ # Test fixtures (before/after directories)
109+
├── scripts/ # Shell scripts for test orchestration
119110
├── Makefile # Build, test, lint, cross-compile targets
120111
└── go.mod # Go module definition
121112
```

client/cmd/integration_tests.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ func runIntegrationTests(cmd *cobra.Command, _ []string) error {
136136
allPassed, _ := runner.Run()
137137

138138
// Close the MCP client (and its stdio subprocess) before returning.
139-
client.Close()
139+
// The close may time out for stdio servers (Node.js doesn't always
140+
// exit promptly) — log but don't fail the test run for this.
141+
if err := client.Close(); err != nil {
142+
fmt.Fprintf(os.Stderr, "warning: %v\n", err)
143+
}
140144

141145
if !allPassed {
142146
return fmt.Errorf("some integration tests failed")

0 commit comments

Comments
 (0)