Skip to content

Commit bd1e9ad

Browse files
mcp-function (#572)
* mcp-function Summary: Implements Model Context Protocol server to enable LLMs to consume StackQL as a first-class information source. Key features: - Backend interface abstraction for flexible query execution - Comprehensive configuration with JSON/YAML support - Complete MCP protocol implementation (initialize, resources, tools) - Multiple transport support (stdio, TCP, WebSocket) - Zero dependencies on StackQL internals - Example backend for testing and demonstration The package provides clean separation of concerns with interfaces that can be implemented for in-memory, TCP, or other communication methods as requested in issue #110. 🤖 Generated with [Claude Code](https://claude.ai/code) --- - Hide all concrete types behind interfaces except config structures - Make factory functions return interface types - Create hierarchical schema interface instead of flat schema - Add nolint comments for driver import - Remove unused imports and ensure clean API 🤖 Generated with [Claude Code](https://claude.ai/code) --- Summary: - Leverage golang mcp SDK. - Conform golang versioning. - Added `stackql_mcp_client` to Dockerfile. - Agnostic backend for MCP. - Added robot test `MCP HTTP Server Run List Tools`. - Added robot test `MCP HTTP Server Verify Greeting Tool`. - Added robot test `MCP HTTP Server List Providers Tool`. - Added robot test `MCP HTTP Server List Services Tool`. - Added robot test `MCP HTTP Server List Resources Tool`. - Added robot test `MCP HTTP Server List Methods Tool`. - Added robot test `MCP HTTP Server Query Tool`. - Doc improvements. * - Linter fix.
1 parent 1aa6590 commit bd1e9ad

File tree

87 files changed

+3692
-494
lines changed

Some content is hidden

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

87 files changed

+3692
-494
lines changed

.github/workflows/build.yml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
- name: Set up Go 1.x
9292
uses: actions/setup-go@v5.0.0
9393
with:
94-
go-version: '~1.22'
94+
go-version: '~1.23'
9595
check-latest: true
9696
cache: true
9797
id: go
@@ -193,6 +193,7 @@ jobs:
193193
echo "BUILDPATCHVERSION=$env:BUILDPATCHVERSION" >> $GITHUB_ENV
194194
195195
python cicd/python/build.py --verbose --build
196+
python cicd/python/build.py --verbose --build-mcp-client
196197
197198
build\stackql.exe --help
198199
@@ -260,7 +261,7 @@ jobs:
260261
- name: Set up Go 1.x
261262
uses: actions/setup-go@v5.0.0
262263
with:
263-
go-version: '~1.22'
264+
go-version: '~1.24'
264265
check-latest: true
265266
cache: true
266267
id: go
@@ -345,6 +346,16 @@ jobs:
345346
echo "BUILDPATCHVERSION=${BUILDPATCHVERSION}"
346347
} >> "${GITHUB_ENV}"
347348
python cicd/python/build.py --verbose --build
349+
350+
- name: Build MCP client
351+
env:
352+
BUILDCOMMITSHA: ${{github.sha}}
353+
BUILDBRANCH: ${{github.ref}}
354+
BUILDPLATFORM: ${{runner.os}}
355+
BUILDPATCHVERSION: ${{github.run_number}}
356+
CGO_ENABLED: 1
357+
run: |
358+
python cicd/python/build.py --verbose --build-mcp-client
348359
349360
- name: Test
350361
if: success()
@@ -410,6 +421,13 @@ jobs:
410421
with:
411422
name: stackql_linux_amd64
412423
path: build/stackql
424+
425+
- name: Upload Artifact
426+
uses: actions/upload-artifact@v4.3.1
427+
if: success()
428+
with:
429+
name: stackql_mcp_client_linux_amd64
430+
path: build/stackql_mcp_client
413431

414432
- name: prepare deb boilerplate
415433
run: |
@@ -459,6 +477,11 @@ jobs:
459477
name: stackql_linux_amd64
460478
path: build
461479

480+
- name: Download Artifact
481+
uses: actions/download-artifact@v4.1.2
482+
with:
483+
name: stackql_mcp_client_linux_amd64
484+
path: build
462485

463486
- name: Download deb Artifact
464487
uses: actions/download-artifact@v4.1.2
@@ -474,13 +497,15 @@ jobs:
474497
- name: Stackql permissions
475498
run: |
476499
sudo chmod a+rwx build/stackql
500+
sudo chmod a+rwx build/stackql_mcp_client
477501
ls -al build/stackql
502+
ls -al build/stackql_mcp_client
478503
ls -al .
479504
480505
- name: Set up Go 1.x
481506
uses: actions/setup-go@v5.0.0
482507
with:
483-
go-version: '~1.22'
508+
go-version: '~1.24'
484509
check-latest: true
485510
cache: true
486511
id: go
@@ -649,6 +674,7 @@ jobs:
649674
if: matrix.registry != 'test/registry'
650675
env:
651676
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
677+
IS_SKIP_MCP_TEST: 'true'
652678
run: |
653679
mkdir -p deb_test
654680
cp stackql_${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}_amd64.deb deb_test/
@@ -682,7 +708,7 @@ jobs:
682708
- name: Set up Go 1.x
683709
uses: actions/setup-go@v5.0.0
684710
with:
685-
go-version: '~1.22'
711+
go-version: '~1.23'
686712
check-latest: true
687713
cache: true
688714
id: go
@@ -693,7 +719,7 @@ jobs:
693719
cache: pip
694720
python-version: '3.12'
695721

696-
- name: Git Ref Parse
722+
- name: Git Ref Parse
697723
id: git_ref_parse
698724
run: |
699725
{
@@ -763,6 +789,16 @@ jobs:
763789
echo "BUILDPATCHVERSION=${BUILDPATCHVERSION}"
764790
} >> "${GITHUB_ENV}"
765791
python cicd/python/build.py --verbose --build
792+
793+
- name: Build MCP client
794+
env:
795+
BUILDCOMMITSHA: ${{github.sha}}
796+
BUILDBRANCH: ${{github.ref}}
797+
BUILDPLATFORM: ${{runner.os}}
798+
BUILDPATCHVERSION: ${{github.run_number}}
799+
CGO_ENABLED: 1
800+
run: |
801+
python cicd/python/build.py --verbose --build-mcp-client
766802
767803
- name: Test
768804
if: success()
@@ -931,6 +967,7 @@ jobs:
931967
pkgVersion: ${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}
932968
pkgArchitecture: 'arm64'
933969
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
970+
IS_SKIP_MCP_TEST: 'true'
934971
run: |
935972
mkdir -p deb_test
936973
DEB_FILE="${pkgName}_${pkgVersion}_${pkgArchitecture}.deb"
@@ -979,6 +1016,13 @@ jobs:
9791016
with:
9801017
name: stackql_linux_amd64
9811018
path: build
1019+
1020+
- name: Download MCP Client Artifact
1021+
# uses: actions/download-artifact@v3
1022+
uses: actions/download-artifact@v4.1.2
1023+
with:
1024+
name: stackql_mcp_client_linux_amd64
1025+
path: build
9821026

9831027
- name: Setup WSL with dependencies
9841028
# uses: Vampire/setup-wsl@v1
@@ -1090,7 +1134,7 @@ jobs:
10901134
- name: Set up Go 1.x
10911135
uses: actions/setup-go@v5.0.0
10921136
with:
1093-
go-version: '~1.22'
1137+
go-version: '~1.23'
10941138
check-latest: true
10951139
cache: true
10961140
id: go
@@ -1164,6 +1208,7 @@ jobs:
11641208
} >> "${GITHUB_ENV}"
11651209
11661210
python cicd/python/build.py --verbose --build
1211+
python cicd/python/build.py --verbose --build-mcp-client
11671212
11681213
- name: Test
11691214
if: success()
@@ -1236,7 +1281,7 @@ jobs:
12361281
- name: Set up Go 1.x
12371282
uses: actions/setup-go@v5.0.0
12381283
with:
1239-
go-version: '~1.22'
1284+
go-version: '~1.23'
12401285
check-latest: true
12411286
cache: true
12421287
id: go
@@ -1288,6 +1333,7 @@ jobs:
12881333
export GOOS="darwin"
12891334
export GOARCH="arm64"
12901335
python cicd/python/build.py --verbose --build
1336+
python cicd/python/build.py --verbose --build-mcp-client
12911337
12921338
- name: Upload Artifact
12931339
uses: actions/upload-artifact@v4.3.1
@@ -1421,7 +1467,7 @@ jobs:
14211467
- name: Pull Docker base images for cache purposes
14221468
if: env.BUILD_IMAGE_REQUIRED == 'true'
14231469
run: |
1424-
docker pull --platform ${{ matrix.platform }} golang:1.18.4-bullseye || echo 'could not pull image for cache purposes'
1470+
docker pull --platform ${{ matrix.platform }} golang:1.23-bullseye || echo 'could not pull image for cache purposes'
14251471
docker pull --platform ${{ matrix.platform }} ubuntu:22.04 || echo 'could not pull image for cache purposes'
14261472
14271473
- name: Pull Docker image for cache purposes
@@ -1659,6 +1705,7 @@ jobs:
16591705
- name: Run robot mocked functional tests
16601706
env:
16611707
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
1708+
IS_SKIP_MCP_TEST: 'true'
16621709
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true' && matrix.db_backend == 'sqlite'
16631710
timeout-minutes: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && 20 || vars.DEFAULT_STEP_TIMEOUT_MIN }}
16641711
run: |
@@ -1669,6 +1716,7 @@ jobs:
16691716
- name: Run POSTGRES BACKEND robot mocked functional tests
16701717
env:
16711718
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
1719+
IS_SKIP_MCP_TEST: 'true'
16721720
if: success() && env.CI_IS_EXPRESS != 'true' && matrix.platform == 'linux/amd64' && env.BUILD_IMAGE_REQUIRED == 'true' && matrix.db_backend == 'postgres_tcp'
16731721
timeout-minutes: ${{ vars.DEFAULT_LONG_STEP_TIMEOUT_MIN == '' && 40 || vars.DEFAULT_LONG_STEP_TIMEOUT_MIN }}
16741722
run: |

.github/workflows/claude.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Claude PR Assistant
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude-code-action:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19+
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Run Claude PR Action
33+
uses: anthropics/claude-code-action@beta
34+
with:
35+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
36+
timeout_minutes: "60"

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313

1414
env:
15-
GOLANGCI_LINT_VERSION: ${{ vars.GOLANGCI_LINT_VERSION == '' && 'v1.59.1' || vars.GOLANGCI_LINT_VERSION }}
15+
GOLANGCI_LINT_VERSION: ${{ vars.GOLANGCI_LINT_VERSION == '' && 'v2.5.0' || vars.GOLANGCI_LINT_VERSION }}
1616
DEFAULT_STEP_TIMEOUT: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && '20' || vars.DEFAULT_STEP_TIMEOUT_MIN }}
1717

1818
jobs:
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup Go environment
2626
uses: actions/setup-go@v5.0.0
2727
with:
28-
go-version: '1.22.0'
28+
go-version: '1.23.0'
2929
cache: false
3030

3131
- name: Check workflow files
@@ -35,7 +35,7 @@ jobs:
3535

3636

3737
- name: Run golangci-lint
38-
uses: golangci/golangci-lint-action@v4.0.0
38+
uses: golangci/golangci-lint-action@v8.0.0
3939
with:
4040
version: ${{ env.GOLANGCI_LINT_VERSION }}
4141
args: --timeout ${{ env.DEFAULT_STEP_TIMEOUT }}m

0 commit comments

Comments
 (0)