Skip to content

Commit adf6e14

Browse files
committed
Fail production builds if MCPMetadata fetch fails
Signed-off-by: Dan Barr <[email protected]>
1 parent b8ebac9 commit adf6e14

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

docusaurus.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const config: Config = {
2323
'./plugins/mcp-metadata-plugin',
2424
{
2525
thvCommand: 'thv', // Can be customized if thv is in a different path
26+
failOnError:
27+
process.env.NODE_ENV === 'production' || process.env.CI === 'true',
2628
},
2729
],
2830
],

plugins/mcp-metadata-plugin/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function mcpMetadataPlugin(
1414
context: LoadContext,
1515
options: PluginOptions = {}
1616
): Plugin<PluginContent> {
17-
const { thvCommand = 'thv' } = options;
17+
const { thvCommand = 'thv', failOnError = false } = options;
1818

1919
return {
2020
name: 'mcp-metadata-plugin',
@@ -53,6 +53,11 @@ export default function mcpMetadataPlugin(
5353
`Failed to fetch data for MCP server: ${serverName}`,
5454
error
5555
);
56+
57+
if (failOnError) {
58+
throw error; // This will fail the build
59+
}
60+
5661
// Store error message as fallback
5762
serverData[serverName] = `# Error fetching data for ${serverName}
5863
# ${error.message}

plugins/mcp-metadata-plugin/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

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

89
export interface PluginContent {

0 commit comments

Comments
 (0)