Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const config: Config = {
'./plugins/mcp-metadata-plugin',
{
thvCommand: 'thv', // Can be customized if thv is in a different path
failOnError:
process.env.NODE_ENV === 'production' || process.env.CI === 'true',
},
],
],
Expand Down
7 changes: 6 additions & 1 deletion plugins/mcp-metadata-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function mcpMetadataPlugin(
context: LoadContext,
options: PluginOptions = {}
): Plugin<PluginContent> {
const { thvCommand = 'thv' } = options;
const { thvCommand = 'thv', failOnError = false } = options;

return {
name: 'mcp-metadata-plugin',
Expand Down Expand Up @@ -53,6 +53,11 @@ export default function mcpMetadataPlugin(
`Failed to fetch data for MCP server: ${serverName}`,
error
);

if (failOnError) {
throw error; // This will fail the build
}

// Store error message as fallback
serverData[serverName] = `# Error fetching data for ${serverName}
# ${error.message}
Expand Down
1 change: 1 addition & 0 deletions plugins/mcp-metadata-plugin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

export interface PluginOptions {
thvCommand?: string; // Custom thv command path
failOnError?: boolean; // Whether to fail the build on thv command errors
}

export interface PluginContent {
Expand Down
41 changes: 20 additions & 21 deletions scripts/install-thv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,23 @@ if ! command -v jq >/dev/null 2>&1; then
exit 1
fi

#API_ENDPOINT="https://api.github.com/repos/stacklok/toolhive/releases/latest"
API_ENDPOINT="https://api.github.com/repos/stacklok/toolhive/releases/latest"

# Fetch release information
#RELEASE_JSON=$(curl -sf "$API_ENDPOINT" || {
# echo "Failed to fetch release information from GitHub API"
# exit 1
#})
#RELEASE_VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty' | sed 's/^v//')
#RELEASE_TARBALL=$(echo "$RELEASE_JSON" | jq -r \
# --arg version "$RELEASE_VERSION" \
# '.assets[] | select(.name == "toolhive_" + $version + "_linux_amd64.tar.gz") | .browser_download_url // empty')

#if [ -z "$RELEASE_TARBALL" ]; then
# echo "Failed to get release tarball URL for release: ${RELEASE_VERSION}"
# echo "Please check if the tag exists in the repository"
# exit 1
#fi

# Temporary fix for early exit if container runtime isn't found
RELEASE_JSON=$(curl -sf "$API_ENDPOINT" || {
echo "Failed to fetch release information from GitHub API"
exit 1
})
RELEASE_VERSION=$(echo "$RELEASE_JSON" | jq -r '.tag_name // empty' | sed 's/^v//')
RELEASE_TARBALL=$(echo "$RELEASE_JSON" | jq -r \
--arg version "$RELEASE_VERSION" \
'.assets[] | select(.name == "toolhive_" + $version + "_linux_amd64.tar.gz") | .browser_download_url // empty')

RELEASE_VERSION="v0.2.17"
RELEASE_TARBALL="https://github.com/stacklok/toolhive/releases/download/v0.2.17/toolhive_0.2.17_linux_amd64.tar.gz"
if [ -z "$RELEASE_TARBALL" ]; then
echo "Failed to get release tarball URL for release: ${RELEASE_VERSION}"
echo "Please check if the tag exists in the repository"
exit 1
fi

# Determine installation location based on write permissions
if [[ -w "/usr/local/bin" ]]; then
Expand Down Expand Up @@ -72,5 +67,9 @@ chmod +x /tmp/thv
cp /tmp/thv "$INSTALL_DIR/thv"
rm -f /tmp/toolhive.tar.gz /tmp/thv

echo "ToolHive CLI (thv) installed successfully. Version: $RELEASE_VERSION"
echo "The 'thv' command is now available in your PATH."
thv version || {
echo "Installation failed: 'thv' command is not working."
exit 1
}

echo "ToolHive CLI (thv) installed successfully."