Skip to content

Commit 17bf5d1

Browse files
authored
Add the CRD reference and automation (#29)
* Add the CRD reference page * Update script to handle Operator releases
1 parent 66ab7d8 commit 17bf5d1

File tree

7 files changed

+526
-106
lines changed

7 files changed

+526
-106
lines changed

.github/workflows/update-toolhive-reference.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@ name: Update ToolHive Reference Docs
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'ToolHive version to update reference docs for'
8+
required: true
9+
default: 'latest'
510
repository_dispatch:
611
types: [published-release]
712

813
permissions:
914
contents: write
1015
pull-requests: write
1116

17+
concurrency:
18+
group: update-toolhive-reference
19+
cancel-in-progress: false
20+
1221
jobs:
1322
update-reference:
1423
runs-on: ubuntu-latest
@@ -23,11 +32,23 @@ jobs:
2332
git config --global user.name "github-actions[bot]"
2433
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2534
26-
- name: Run update-toolhive-reference.sh and capture version
35+
- name: Determine version
36+
id: get-version
37+
run: |
38+
if [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
39+
echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
40+
else
41+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Run update script
2745
id: imports
2846
run: |
2947
chmod +x scripts/update-toolhive-reference.sh
30-
scripts/update-toolhive-reference.sh
48+
if ! scripts/update-toolhive-reference.sh ${{ steps.get-version.outputs.version }}; then
49+
echo "::error::Failed to update ToolHive reference docs"
50+
exit 1
51+
fi
3152
3253
- name: Check for changes
3354
id: git-diff

.markdownlint-cli2.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"gitignore": true,
33
"globs": ["**/*.md"],
4-
"ignores": ["docs/toolhive/reference/cli/"],
4+
"ignores": ["docs/toolhive/reference/cli/", "static/api-specs/*.md"],
55
}

.vscode/settings.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,7 @@
99
"prettier.requireConfig": true,
1010
"yaml.format.proseWrap": "always",
1111
"css.lint.emptyRules": "ignore",
12-
13-
"[markdown]": {
14-
"editor.defaultFormatter": "esbenp.prettier-vscode"
15-
},
16-
"[mdx]": {
17-
"editor.defaultFormatter": "esbenp.prettier-vscode"
18-
},
19-
"[css]": {
20-
"editor.defaultFormatter": "esbenp.prettier-vscode"
21-
},
22-
"[json]": {
23-
"editor.defaultFormatter": "esbenp.prettier-vscode"
24-
},
25-
"[yaml]": {
12+
"[markdown][mdx][css][json][jsonc][yaml]": {
2613
"editor.defaultFormatter": "esbenp.prettier-vscode"
2714
}
2815
}

docs/toolhive/guides-k8s/run-mcp-k8s.md

Lines changed: 18 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ When you apply an `MCPServer` resource, here's what happens:
163163

164164
:::
165165

166+
For more examples of `MCPServer` resources, see the
167+
[example MCP server manifests](https://github.com/stacklok/toolhive/tree/main/examples/operator/mcp-servers)
168+
in the ToolHive repo.
169+
166170
## Automatic RBAC management
167171

168172
The ToolHive operator automatically handles RBAC (Role-Based Access Control) for
@@ -185,14 +189,13 @@ This approach provides:
185189
- Better security isolation between different MCPServer instances
186190
- Support for multi-tenant deployments across different namespaces
187191

188-
For more examples of `MCPServer` resources, see the
189-
[example MCP server manifests](https://github.com/stacklok/toolhive/tree/main/examples/operator/mcp-servers)
190-
in the ToolHive repo.
191-
192192
## Customize server settings
193193

194194
You can customize the MCP server by adding additional fields to the `MCPServer`
195-
resource. Here are some common configurations.
195+
resource. The full specification is available in the
196+
[Kubernetes CRD reference](../reference/crd-spec.mdx).
197+
198+
Below are some common configurations.
196199

197200
### Customize the MCP server pod
198201

@@ -363,56 +366,19 @@ For more details about a specific MCP server:
363366
kubectl -n <NAMESPACE> describe mcpserver <NAME>
364367
```
365368

366-
## Configuration reference
367-
368-
### MCPServer spec
369-
370-
| Field | Description | Required | Default |
371-
| ------------------- | ----------------------------------------------- | -------- | ------- |
372-
| `image` | Container image for the MCP server | Yes | - |
373-
| `transport` | Transport method (stdio or sse) | No | stdio |
374-
| `port` | Port to expose the MCP server on | No | 8080 |
375-
| `targetPort` | Port to use for the MCP server (for SSE) | No | |
376-
| `args` | Additional arguments to pass to the MCP server | No | - |
377-
| `env` | Environment variables to set in the container | No | - |
378-
| `resources` | Resource requirements for the container | No | - |
379-
| `secrets` | References to secrets to mount in the container | No | - |
380-
| `permissionProfile` | Permission profile configuration | No | - |
381-
| `podTemplateSpec` | Custom pod specification for the MCP server | No | - |
382-
383-
### Secrets
384-
385-
The `secrets` field has the following parameters:
386-
387-
- `name`: The name of the Kubernetes secret (required)
388-
- `key`: The key in the secret (required)
389-
- `targetEnvName`: The environment variable to be used when setting up the
390-
secret in the MCP server (optional). If left unspecified, it defaults to the
391-
key.
392-
393-
### Permission Profiles
394-
395-
Permission profiles can be configured in two ways:
396-
397-
1. Using a built-in profile:
398-
399-
```yaml
400-
permissionProfile:
401-
type: builtin
402-
name: network # or "none"
403-
```
369+
## Next steps
404370

405-
2. Using a ConfigMap:
371+
See the [Client compatibility](../reference/client-compatibility.mdx) reference
372+
to learn how to connect to MCP servers using different clients.
406373

407-
```yaml
408-
permissionProfile:
409-
type: configmap
410-
name: my-permission-profile
411-
key: profile.json
412-
```
374+
## Related information
413375

414-
The ConfigMap should contain a JSON
415-
[permission profile](../guides-cli/custom-permissions.mdx#create-a-custom-permission-profile).
376+
- [Kubernetes CRD reference](../reference/crd-spec.mdx) - Reference for the
377+
`MCPServer` Custom Resource Definition (CRD)
378+
- [Deploy the operator using Helm](./deploy-operator-helm.md) - Install the
379+
ToolHive operator
380+
- [Custom permissions](../guides-cli/custom-permissions.mdx) - Configure
381+
permission profiles
416382

417383
:::important
418384

@@ -425,18 +391,6 @@ visiting our [GitHub repository](https://github.com/stacklok/toolhive).
425391

426392
:::
427393

428-
## Next steps
429-
430-
See the [Client compatibility](../reference/client-compatibility.mdx) reference
431-
to learn how to connect to MCP servers using different clients.
432-
433-
## Related information
434-
435-
- [Deploy the operator using Helm](./deploy-operator-helm.md) - Install the
436-
ToolHive operator
437-
- [Custom permissions](../guides-cli/custom-permissions.mdx) - Configure
438-
permission profiles
439-
440394
## Troubleshooting
441395

442396
### MCPServer resource not creating pods

docs/toolhive/reference/crd-spec.mdx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Kubernetes CRD reference
3+
description:
4+
ToolHive Kubernetes Operator Custom Resource Definitions (CRDs) reference.
5+
sidebar_position: 30
6+
toc_max_heading_level: 4
7+
---
8+
9+
import CRDRef from '@site/static/api-specs/crd-api.md';
10+
11+
<CRDRef />

scripts/update-toolhive-reference.sh

Lines changed: 96 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/bin/bash
22

3+
set -euo pipefail
4+
35
REPO_ROOT=$(git rev-parse --show-toplevel)
4-
cd $REPO_ROOT
6+
cd "$REPO_ROOT"
57

68
IMPORT_DIR="./imports"
79
DOCS_DIR="./docs"
@@ -20,39 +22,108 @@ if [ ! -d "$STATIC_DIR" ]; then
2022
exit 1
2123
fi
2224

23-
RELEASE_JSON=$(curl -s https://api.github.com/repos/stacklok/toolhive/releases/latest)
24-
LATEST_RELEASE_TARBALL=$(echo "$RELEASE_JSON" | grep "tarball_url" | cut -d '"' -f 4)
25-
LATEST_RELEASE_VERSION=$(echo "$RELEASE_JSON" | grep '"tag_name"' | cut -d '"' -f 4)
25+
# Check if jq is installed
26+
if ! command -v jq >/dev/null 2>&1; then
27+
echo "Error: 'jq' is required but not installed. Please install jq and try again."
28+
exit 1
29+
fi
30+
31+
VERSION=$(echo "${1:-}" | tr -cd '[:alnum:].-')
32+
33+
# Handle tag name parameter - default to "latest" if not provided
34+
if [ -z "$VERSION" ] || [ "$VERSION" = "latest" ]; then
35+
API_ENDPOINT="https://api.github.com/repos/stacklok/toolhive/releases/latest"
36+
echo "No tag specified or 'latest' specified, using latest release"
37+
else
38+
TAG_NAME="$VERSION"
39+
API_ENDPOINT="https://api.github.com/repos/stacklok/toolhive/releases/tags/$TAG_NAME"
40+
echo "Using specified tag: $TAG_NAME"
41+
fi
42+
43+
# Fetch release information
44+
RELEASE_JSON=$(curl -sf "$API_ENDPOINT" || {
45+
echo "Failed to fetch release information from GitHub API"
46+
exit 1
47+
})
48+
RELEASE_TARBALL=$(echo "$RELEASE_JSON" | jq -r '.tarball_url // empty')
49+
RELEASE_VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty')
2650

27-
if [ -z "$LATEST_RELEASE_TARBALL" ]; then
28-
echo "Failed to get the latest release tarball URL for ${LATEST_RELEASE_VERSION}"
51+
if [ -z "$RELEASE_TARBALL" ]; then
52+
echo "Failed to get release tarball URL for release: ${RELEASE_VERSION}"
53+
echo "Please check if the tag exists in the repository"
2954
exit 1
3055
fi
3156

32-
# Output the latest release version for use in CI workflows
33-
if [ ! -z "$GITHUB_OUTPUT" ]; then
34-
echo "version=$LATEST_RELEASE_VERSION" >> "$GITHUB_OUTPUT"
57+
# Output the release version for use in CI workflows (if running in GitHub Actions)
58+
if [ -n "${GITHUB_OUTPUT:-}" ]; then
59+
echo "version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
3560
fi
3661

62+
# Clean up and prepare import directory
3763
rm -rf ${IMPORT_DIR}/toolhive
3864
mkdir -p ${IMPORT_DIR}/toolhive
3965

40-
echo "Fetching the latest ToolHive release (${LATEST_RELEASE_VERSION}) from: $LATEST_RELEASE_TARBALL"
66+
echo "Fetching ToolHive release (${RELEASE_VERSION}) from: $RELEASE_TARBALL"
4167
echo "Importing to: $IMPORT_DIR"
4268

43-
curl -sL "$LATEST_RELEASE_TARBALL" | tar xz --strip-components=1 -C ./imports/toolhive
44-
45-
## CLI reference
46-
47-
echo "Updating ToolHive CLI reference documentation in ${DOCS_DIR}/toolhive/reference/cli"
48-
49-
# Remove existing CLI reference documentation files in case we remove any commands
50-
rm -f ${DOCS_DIR}/toolhive/reference/cli/thv_*.md
51-
52-
cp -r ${IMPORT_DIR}/toolhive/docs/cli/* ${DOCS_DIR}/toolhive/reference/cli
53-
54-
## API reference
55-
56-
echo "Updating ToolHive API reference in ${STATIC_DIR}/api-specs"
69+
# Download and extract the release tarball
70+
curl -sfL "$RELEASE_TARBALL" | tar xz --strip-components=1 -C ./imports/toolhive
71+
72+
# Determine release type and process accordingly
73+
if [[ "$RELEASE_VERSION" =~ ^v.* ]]; then
74+
echo "Processing main CLI release: $RELEASE_VERSION"
75+
76+
## CLI reference
77+
echo "Updating ToolHive CLI reference documentation in ${DOCS_DIR}/toolhive/reference/cli"
78+
79+
# Remove existing CLI reference documentation files in case we remove any commands
80+
rm -f ${DOCS_DIR}/toolhive/reference/cli/thv_*.md
81+
82+
# Copy CLI documentation
83+
if [ -d "${IMPORT_DIR}/toolhive/docs/cli" ]; then
84+
cp -r ${IMPORT_DIR}/toolhive/docs/cli/* ${DOCS_DIR}/toolhive/reference/cli
85+
echo "CLI reference documentation updated successfully"
86+
else
87+
echo "Warning: CLI documentation not found in ${IMPORT_DIR}/toolhive/docs/cli"
88+
fi
89+
90+
## API reference
91+
echo "Updating ToolHive API reference in ${STATIC_DIR}/api-specs"
92+
93+
# Copy API specification
94+
if [ -f "${IMPORT_DIR}/toolhive/docs/server/swagger.yaml" ]; then
95+
cp ${IMPORT_DIR}/toolhive/docs/server/swagger.yaml ${STATIC_DIR}/api-specs/toolhive-api.yaml
96+
echo "API reference updated successfully"
97+
else
98+
echo "Warning: API specification not found in ${IMPORT_DIR}/toolhive/docs/server/swagger.yaml"
99+
fi
100+
101+
elif [[ "$RELEASE_VERSION" =~ ^toolhive-operator-crds-.* ]]; then
102+
echo "Processing operator CRD release: $RELEASE_VERSION"
103+
104+
## CRD API reference
105+
echo "Updating ToolHive CRD API reference in ${STATIC_DIR}/api-specs"
106+
107+
# Copy CRD API documentation
108+
if [ -f "${IMPORT_DIR}/toolhive/docs/operator/crd-api.md" ]; then
109+
# Remove h1 title from the CRD API documentation, Docusaurus will use the title from the front matter
110+
sed '1{/^# /d;}' ${IMPORT_DIR}/toolhive/docs/operator/crd-api.md > ${STATIC_DIR}/api-specs/crd-api.md
111+
echo "CRD API reference updated successfully"
112+
else
113+
echo "Warning: CRD API documentation not found in ${IMPORT_DIR}/toolhive/docs/operator/crd-api.md"
114+
fi
115+
116+
elif [[ "$RELEASE_VERSION" =~ ^toolhive-operator- ]]; then
117+
echo "Processing main operator release: $RELEASE_VERSION"
118+
echo "Placeholder: No specific processing implemented for this release type yet"
119+
120+
else
121+
echo "Unknown release type for tag: $RELEASE_VERSION"
122+
echo "Supported release types:"
123+
echo " - v* (main CLI releases)"
124+
echo " - toolhive-operator-crds-* (CRD releases)"
125+
echo " - toolhive-operator-* (other operator releases)"
126+
exit 1
127+
fi
57128

58-
cp -r ${IMPORT_DIR}/toolhive/docs/server/swagger.yaml ${STATIC_DIR}/api-specs/toolhive-api.yaml
129+
echo "Release processing completed for: $RELEASE_VERSION"

0 commit comments

Comments
 (0)