programmingparadigm
Apply different programming paradigms to solve coding problems, including imperative, functional, object-oriented, and reactive approaches, by structuring code with appropriate methodologies.
Instructions
A tool for applying different programming paradigms to solve problems. Supports various programming paradigms including:
Imperative Programming
Procedural Programming
Object-Oriented Programming
Functional Programming
Declarative Programming
Logic Programming
Event-Driven Programming
Aspect-Oriented Programming
Concurrent Programming
Reactive Programming
Each paradigm provides a different approach to structuring and executing code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paradigmName | Yes | ||
| problem | Yes | ||
| approach | No | ||
| benefits | No | ||
| limitations | No | ||
| codeExample | No | ||
| languages | No |
Implementation Reference
- The ProgrammingParadigmServer class contains the logic to validate, format, and process the "programmingparadigm" tool request. The primary handler method is processParadigm.
export class ProgrammingParadigmServer { private validateParadigmData(input: unknown): ProgrammingParadigmData { const data = input as Record<string, unknown>; if (!data.paradigmName || typeof data.paradigmName !== 'string') { throw new Error('Invalid paradigmName: must be a string'); } if (!data.problem || typeof data.problem !== 'string') { throw new Error('Invalid problem: must be a string'); } return { paradigmName: data.paradigmName as string, problem: data.problem as string, approach: Array.isArray(data.approach) ? data.approach.map(String) : [], benefits: Array.isArray(data.benefits) ? data.benefits.map(String) : [], limitations: Array.isArray(data.limitations) ? data.limitations.map(String) : [], codeExample: typeof data.codeExample === 'string' ? data.codeExample as string : undefined, languages: Array.isArray(data.languages) ? data.languages.map(String) : undefined }; } private formatParadigmOutput(data: ProgrammingParadigmData): string { const { paradigmName, problem, approach, benefits, limitations, codeExample, languages } = data; let output = `\n${chalk.bold.blue('Programming Paradigm:')} ${chalk.bold(paradigmName)}\n`; output += `${chalk.bold.green('Problem:')} ${problem}\n`; if (approach.length > 0) { output += `\n${chalk.bold.yellow('Approach:')}\n`; approach.forEach((step, index) => { output += `${chalk.bold(`${index + 1}.`)} ${step}\n`; }); } if (benefits.length > 0) { output += `\n${chalk.bold.magenta('Benefits:')}\n`; benefits.forEach((benefit) => { output += `${chalk.bold(`•`)} ${benefit}\n`; }); } if (limitations.length > 0) { output += `\n${chalk.bold.red('Limitations:')}\n`; limitations.forEach((limitation) => { output += `${chalk.bold(`•`)} ${limitation}\n`; }); } if (languages && languages.length > 0) { output += `\n${chalk.bold.cyan('Applicable Languages:')} ${languages.join(', ')}\n`; } if (codeExample) { output += `\n${chalk.bold.green('Code Example:')}\n${codeExample}\n`; } return output; } public processParadigm(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const validatedInput = this.validateParadigmData(input); const formattedOutput = this.formatParadigmOutput(validatedInput); console.error(formattedOutput); return { content: [{ type: "text", text: JSON.stringify({ paradigmName: validatedInput.paradigmName, status: 'success', hasApproach: validatedInput.approach.length > 0, hasCodeExample: !!validatedInput.codeExample }, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), status: 'failed' }, null, 2) }], isError: true }; } } } - src/index.ts:1070-1073 (registration)The tool "programmingparadigm" is registered and handled within the main server loop in src/index.ts, delegating to the processParadigm method.
case "programmingparadigm": { const result = paradigmServer.processParadigm( request.params.arguments ); - src/models/interfaces.ts:37-41 (schema)The ProgrammingParadigmData interface defines the structure of the input required by the "programmingparadigm" tool.
export interface ProgrammingParadigmData { paradigmName: string; problem: string; approach: string[]; benefits: string[];