UNPKG

mcp-chain-of-draft-server

Version:

A Model Context Protocol server which provides Chain of Draft style thinking

73 lines (72 loc) 9 kB
import { z } from "zod"; export declare const TOOL_NAME = "code-review-lens"; export declare const TOOL_PARAM_DESCRIPTIONS: { review_id: string; pull_request_id: string; repository: string; review_dimensions: string; files: string; findings: string; draft_number: string; total_drafts: string; is_critique: string; critique_focus: string; revision_instructions: string; next_step_needed: string; is_final_draft: string; }; export declare const TOOL_SCHEMA: { review_id: z.ZodString; pull_request_id: z.ZodString; repository: z.ZodString; review_dimensions: z.ZodArray<z.ZodEnum<["performance", "security", "maintainability", "readability", "testability", "correctness", "documentation"]>, "many">; files: z.ZodArray<z.ZodObject<{ path: z.ZodString; content: z.ZodString; language: z.ZodString; line_count: z.ZodNumber; }, "strip", z.ZodTypeAny, { path: string; content: string; language: string; line_count: number; }, { path: string; content: string; language: string; line_count: number; }>, "many">; findings: z.ZodArray<z.ZodObject<{ file: z.ZodString; line_range: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>; dimension: z.ZodEnum<["performance", "security", "maintainability", "readability", "testability", "correctness", "documentation"]>; severity: z.ZodEnum<["info", "suggestion", "warning", "critical"]>; description: z.ZodString; suggested_fix: z.ZodOptional<z.ZodString>; justification: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { description: string; file: string; line_range: [number, number]; dimension: "performance" | "security" | "maintainability" | "readability" | "testability" | "correctness" | "documentation"; severity: "info" | "suggestion" | "warning" | "critical"; suggested_fix?: string | undefined; justification?: string | undefined; }, { description: string; file: string; line_range: [number, number]; dimension: "performance" | "security" | "maintainability" | "readability" | "testability" | "correctness" | "documentation"; severity: "info" | "suggestion" | "warning" | "critical"; suggested_fix?: string | undefined; justification?: string | undefined; }>, "many">; draft_number: z.ZodNumber; total_drafts: z.ZodNumber; is_critique: z.ZodOptional<z.ZodBoolean>; critique_focus: z.ZodOptional<z.ZodString>; revision_instructions: z.ZodOptional<z.ZodString>; next_step_needed: z.ZodBoolean; is_final_draft: z.ZodOptional<z.ZodBoolean>; }; export declare const TOOL_DESCRIPTION = "\n # Code Review Lens: Multi-Perspective Code Evaluation\n\n A tool that facilitates structured, multi-dimensional code review through guided critique and improvement cycles.\n\n ## When to Use This Tool:\n - **Pre-submission Review:** Evaluating code before formal review submission\n - **Team Code Reviews:** Guiding team review process with structured approach\n - **Knowledge Transfer:** Capturing review insights for team learning\n - **Maintenance Readiness:** Evaluating code readiness for long-term maintenance\n - **Standard Compliance:** Verifying adherence to team coding standards\n - **Cross-training:** Helping reviewers evaluate code outside their expertise\n\n ## Key Capabilities:\n - **Multi-dimensional Analysis:** Examines code from different perspectives (performance, security, maintainability)\n - **Contextual Guidance:** Provides review focus appropriate to the code's purpose\n - **Pattern Recognition:** Identifies common code issues and improvement opportunities\n - **Progressive Depth:** Supports layered review from superficial to deep analysis\n - **Review Consistency:** Ensures consistent evaluation across different reviewers\n - **Learning Integration:** Connects review findings to learning resources\n - **Suggestion Refinement:** Iteratively improves change recommendations\n\n ## Parameters Explained:\n - **review_id:** Unique identifier for the code review session.\n \n - **pull_request_id:** Identifier of the pull request or code submission being reviewed.\n \n - **repository:** Name of the repository containing the code being reviewed.\n \n - **review_dimensions:** Array of specific aspects being evaluated in the review:\n * \"performance\": Analyzing code efficiency and resource usage\n * \"security\": Identifying security vulnerabilities and risks\n * \"maintainability\": Evaluating long-term code maintainability\n * \"readability\": Assessing how easily the code can be understood\n * \"testability\": Determining how well the code can be tested\n * \"correctness\": Verifying logical correctness and bug absence\n * \"documentation\": Evaluating code comments and documentation\n \n - **files:** Array of files being reviewed, each containing:\n * \"path\": File location within the repository\n * \"content\": Actual code content being reviewed\n * \"language\": Programming language of the file\n * \"line_count\": Number of lines in the file\n \n - **findings:** Array of review observations, each containing:\n * \"file\": Path to the file containing the finding\n * \"line_range\": Start and end line numbers [start, end]\n * \"dimension\": Which review dimension this finding relates to\n * \"severity\": Importance level (info, suggestion, warning, critical)\n * \"description\": Explanation of the issue or observation\n * \"suggested_fix\": Optional code suggestion to address the finding\n * \"justification\": Optional explanation of why this is a concern\n \n - **draft_number:** Current draft number in the review iteration sequence (starting from 1).\n \n - **total_drafts:** Estimated total number of review drafts needed.\n \n - **is_critique:** Boolean indicating the current mode:\n * true = Evaluating the current code review\n * false = Implementing revisions to the review\n \n - **critique_focus:** (Required when is_critique=true) Specific aspect being evaluated, such as:\n * \"completeness\": Ensuring all important code aspects are reviewed\n * \"accuracy\": Verifying correctness of findings\n * \"actionability\": Assessing how actionable the feedback is\n * \"prioritization\": Evaluating the emphasis on the most important issues\n \n - **revision_instructions:** (Required when is_critique=false) Detailed guidance for improving the code review based on the preceding critique.\n \n - **next_step_needed:** Boolean flag indicating whether another critique or revision cycle is needed.\n \n - **is_final_draft:** (Optional) Boolean indicating whether this is the final iteration of the code review.\n\n ## Best Practice Workflow:\n 1. **Start with Initial Draft:** Begin with a basic code review that identifies key issues across selected dimensions.\n \n 2. **Alternate Critique and Revision:** Use is_critique=true to evaluate the review, then is_critique=false to implement improvements.\n \n 3. **Focus Each Critique:** Choose a specific critique_focus for each evaluation cycle rather than attempting to address everything at once.\n \n 4. **Provide Detailed Revision Guidance:** Include specific, actionable revision_instructions based on each critique.\n \n 5. **Prioritize Findings:** Ensure the most critical issues receive appropriate emphasis and detail.\n \n 6. **Include Actionable Suggestions:** Provide specific fixes or improvements for identified issues.\n \n 7. **Balance Positive and Negative Feedback:** Highlight both problematic areas and well-implemented code.\n \n 8. **Consider Educational Value:** Frame findings to promote learning and improvement.\n\n ## Example Application:\n - **Initial Draft:** Basic code review focusing on most obvious issues\n - **Critique #1:** Focus on completeness to identify missing review dimensions\n - **Revision #1:** Expand review to cover additional code aspects\n - **Critique #2:** Focus on actionability of the feedback\n - **Revision #2:** Enhance suggestions with specific code examples\n - **Critique #3:** Focus on balancing criticism with positive reinforcement\n - **Revision #3:** Add recognition of well-implemented patterns\n - **Final Review:** Holistic evaluation of the complete code review\n - **Final Revision:** Polish and finalize the review for submission\n\n Code Review Lens is particularly valuable for elevating the quality of code reviews beyond simple issue-spotting to comprehensive, educational, and actionable feedback that improves both the code and the developer.\n";