install_openfeature_sdk
Fetch OpenFeature SDK installation prompts and setup instructions for specific frameworks like React using the provided guide name. Simplifies SDK integration with clear Markdown guidance.
Instructions
Fetch and return OpenFeature install prompt Markdown by guide name. Available guides: react. Input: { guide: string }
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guide | Yes |
Implementation Reference
- src/tools/installTools.ts:121-144 (handler)The main handler function for the 'install_openfeature_sdk' tool. Parses args, fetches bundled prompt for the specified technology, builds provider prompts if any, processes the final text, logs it, and returns text content with provider resource links.async (args: unknown): Promise<CallToolResult> => { const { technology, providers } = InstallTechnologyArgsSchema.parse(args); const prompt: string = BUNDLED_PROMPTS[technology]; const providerPrompts = buildProviderPrompts(providers, technology); const finalText = processPromptWithProviders( prompt, providers, technology, providerPrompts ); console.error(`install_openfeature_sdk prompt text: \n${finalText}`); return { content: [ { type: "text" as const, text: finalText, }, // Include resource links for any available provider docs so clients can read them directly ...buildProviderResourceLinks(providers, technology), ], }; }
- src/tools/installTools.ts:106-145 (registration)The registration of the 'install_openfeature_sdk' tool within the registerInstallTools function, including name, description, annotations, inputSchema, and inline handler.registerToolWithErrorHandling( "install_openfeature_sdk", { description: [ "Fetch OpenFeature SDK installation instructions, and follow the instructions to install the OpenFeature SDK.", "If you are installing a provider, also fetches the provider installation instructions.", "Also includes documentation and examples for using OpenFeature SDK in your application.", "Choose the technology that matches the application's language/framework.", ].join(" "), annotations: { title: "Install OpenFeature SDK", readOnlyHint: true, }, inputSchema: InstallTechnologyArgsSchema.shape, }, async (args: unknown): Promise<CallToolResult> => { const { technology, providers } = InstallTechnologyArgsSchema.parse(args); const prompt: string = BUNDLED_PROMPTS[technology]; const providerPrompts = buildProviderPrompts(providers, technology); const finalText = processPromptWithProviders( prompt, providers, technology, providerPrompts ); console.error(`install_openfeature_sdk prompt text: \n${finalText}`); return { content: [ { type: "text" as const, text: finalText, }, // Include resource links for any available provider docs so clients can read them directly ...buildProviderResourceLinks(providers, technology), ], }; } );
- src/tools/installTools.ts:16-19 (schema)Zod schema defining the input for the tool: technology (from InstallTechnologySchema) and optional providers array.const InstallTechnologyArgsSchema = z.object({ technology: InstallTechnologySchema, providers: providersSchema.optional().default([]), });
- src/tools/installTools.ts:21-63 (helper)Helper function that generates provider-specific installation prompt strings based on available documentation links.function buildProviderPrompts( providers: ProviderName[], technology: z.infer<typeof InstallTechnologySchema> ): string[] { const providerPrompts: string[] = []; for (const providerName of providers) { const providerDocLinks = PROVIDER_DOCS[providerName]; if (!providerDocLinks) { throw new Error( `Provider '${providerName}' is not recognized. Available providers: ${Object.keys( PROVIDER_DOCS ).join(", ")}` ); } console.error(`providerDocLinks: ${providerDocLinks}`); console.error(`technology: ${technology}`); const perTechnologyUrl = providerDocLinks[technology] || ""; if (perTechnologyUrl) { if (!DISABLE_RESOURCES) { const resourceName = `of-provider-doc:${providerName}:${technology}`; providerPrompts.push( `- **${providerName}**: If your AI Agent supports MCP resources, fetch the MCP resource named \`${resourceName}\` ` + `(otherwise read the documentation from this link: ${perTechnologyUrl}) ` + `and evaluate the best way to install and configure this provider alongside the OpenFeature ${technology} SDK.` ); } else { providerPrompts.push( `- **${providerName}**: Read the provider documentation from this link: ${perTechnologyUrl} ` + `and evaluate the best way to install and configure this provider alongside the OpenFeature ${technology} SDK.` ); } } else { providerPrompts.push( `- **${providerName}**: No specific ${technology} documentation URL found. Search for "${providerName} OpenFeature ${technology}" ` + `installation documentation and provide installation instructions if available.` ); } } return providerPrompts; }
- src/tools/installTools.ts:65-101 (helper)Helper function that processes the base prompt by injecting or appending provider instructions, handling markers or fallback appendix.function processPromptWithProviders( prompt: string, providers: ProviderName[], technology: z.infer<typeof InstallTechnologySchema>, providerPrompts: string[] ): string { // Marker-based injection: replace the block between markers when providers are specified const providersMarkerPattern = /<!--\s*PROVIDERS:START\s*-->[\s\S]*?<!--\s*PROVIDERS:END\s*-->/; const providerBlock = providerPrompts.length ? ["### Step 2: Provider installation", "", ...providerPrompts].join("\n") : ""; const providersAppendix = providerPrompts.length ? `\n\n---\n\nProvider installation instructions for ${technology}:\n\n${providerPrompts.join( "\n" )}` : ""; let finalText = prompt; if (providers.length > 0) { if (providersMarkerPattern.test(prompt)) { // Replace the marker block with provider content (without the markers) finalText = prompt.replace(providersMarkerPattern, providerBlock); } else { // Fallback: append to the end if no marker exists in the prompt finalText = `${prompt}${providersAppendix}`; } } else { // No providers specified: strip the marker block entirely finalText = prompt.replace(providersMarkerPattern, ""); } return finalText; }