mcp-chain-of-draft-server
Version:
A Model Context Protocol server which provides Chain of Draft style thinking
81 lines (80 loc) • 8.29 kB
TypeScript
import { z } from "zod";
export declare const TOOL_NAME = "api-blueprint-designer";
export declare const TOOL_PARAM_DESCRIPTIONS: {
api_id: string;
name: string;
path: string;
method: string;
description: string;
request_params: string;
request_body: string;
responses: string;
draft_number: string;
total_drafts: string;
is_critique: string;
critique_focus: string;
revision_instructions: string;
is_final_draft: string;
};
export declare const TOOL_SCHEMA: {
api_id: z.ZodString;
name: z.ZodString;
path: z.ZodString;
method: z.ZodEnum<["GET", "POST", "PUT", "DELETE", "PATCH"]>;
description: z.ZodString;
request_params: z.ZodArray<z.ZodObject<{
name: z.ZodString;
type: z.ZodString;
required: z.ZodBoolean;
description: z.ZodString;
}, "strip", z.ZodTypeAny, {
type: string;
name: string;
required: boolean;
description: string;
}, {
type: string;
name: string;
required: boolean;
description: string;
}>, "many">;
request_body: z.ZodOptional<z.ZodObject<{
content_type: z.ZodString;
schema: z.ZodRecord<z.ZodString, z.ZodAny>;
example: z.ZodString;
}, "strip", z.ZodTypeAny, {
content_type: string;
schema: Record<string, any>;
example: string;
}, {
content_type: string;
schema: Record<string, any>;
example: string;
}>>;
responses: z.ZodArray<z.ZodObject<{
status_code: z.ZodNumber;
description: z.ZodString;
content_type: z.ZodString;
schema: z.ZodRecord<z.ZodString, z.ZodAny>;
example: z.ZodString;
}, "strip", z.ZodTypeAny, {
description: string;
content_type: string;
schema: Record<string, any>;
example: string;
status_code: number;
}, {
description: string;
content_type: string;
schema: Record<string, any>;
example: string;
status_code: number;
}>, "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>;
is_final_draft: z.ZodOptional<z.ZodBoolean>;
};
export declare const TOOL_DESCRIPTION = "\n # API Blueprint Designer: Interface Design Through Iterative Refinement\n\n A tool that facilitates the design, documentation, and refinement of APIs through structured critique and improvement cycles.\n\n ## When to Use This Tool:\n - **New API Design:** When creating interfaces for new services or components\n - **API Versioning:** Planning and documenting API changes between versions\n - **Contract Negotiation:** Collaborating on interface design between teams\n - **API Standardization:** Ensuring consistency across multiple interfaces\n - **Client Experience Design:** Optimizing APIs for developer experience\n - **Protocol Selection:** Deciding between REST, GraphQL, gRPC, or other approaches\n\n ## Key Capabilities:\n - **Contract Definition:** Structured specification of endpoints, methods, parameters\n - **Example Generation:** Creates realistic request/response examples\n - **Consistency Analysis:** Ensures naming, parameter, and pattern consistency\n - **Client Usage Simulation:** Demonstrates how clients would use the API\n - **Backward Compatibility Checking:** Identifies breaking changes\n - **Documentation Generation:** Produces comprehensive API documentation\n - **Mock Implementation:** Generates functional mock implementations for testing\n - **Schema Validation:** Ensures data structures are properly defined and validated\n\n ## Parameters Explained:\n - **api_id:** Unique identifier for the API being designed.\n \n - **name:** Name of the API or endpoint being designed.\n \n - **path:** URL path pattern for the endpoint, including any path parameters in curly braces (e.g., '/users/{id}').\n \n - **method:** HTTP method for the endpoint:\n * \"GET\": For retrieving resources\n * \"POST\": For creating resources\n * \"PUT\": For replacing resources\n * \"DELETE\": For removing resources\n * \"PATCH\": For partial updates to resources\n \n - **description:** Detailed description of the endpoint's purpose and behavior.\n \n - **request_params:** Array of request parameters with:\n * name: Parameter name\n * type: Data type (string, number, boolean, etc.)\n * required: Whether the parameter is mandatory\n * description: Explanation of the parameter's purpose\n \n - **request_body:** Schema and example for the request body, if applicable, with:\n * content_type: Media type (e.g., \"application/json\")\n * schema: Structure definition\n * example: Sample request payload\n \n - **responses:** Array of possible responses with:\n * status_code: HTTP status code\n * description: Explanation of the response condition\n * content_type: Media type of the response\n * schema: Structure definition of the response\n * example: Sample response payload\n \n - **draft_number:** Integer tracking the current iteration (starting from 1). Increments with each critique or revision.\n \n - **total_drafts:** Estimated number of drafts needed for completion. This can be adjusted as the design process evolves.\n \n - **is_critique:** Boolean indicating the current mode:\n * true = Evaluating previous API design\n * false = Implementing revisions\n \n - **critique_focus:** (Required when is_critique=true) Specific aspect being evaluated, such as:\n * \"naming\": Evaluating the clarity and consistency of resource and parameter names\n * \"consistency\": Checking for pattern consistency across the API\n * \"completeness\": Ensuring all necessary information is included\n * \"usability\": Assessing how easily developers can understand and use the API\n \n - **revision_instructions:** (Required when is_critique=false) Detailed guidance for improving the API design based on the preceding critique.\n \n - **is_final_draft:** (Optional) Boolean indicating whether this is the final iteration of the API design.\n\n ## Best Practice Workflow:\n 1. **Start with Initial Draft:** Begin with a first-pass API endpoint design and set a reasonable total_drafts (typically 3-5).\n \n 2. **Alternate Critique and Revision:** Use is_critique=true to evaluate the design, 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. **Consider Client Perspective:** Ensure critiques evaluate the API from the client developer's perspective.\n \n 6. **Document Examples Thoroughly:** Provide realistic examples for requests and responses that demonstrate typical usage.\n \n 7. **Mark Completion Appropriately:** Set is_final_draft=true only when the API design is complete and ready for implementation.\n \n 8. **Version Control Changes:** Maintain a record of design changes for future reference.\n\n ## Example Application:\n - **Initial Draft:** Basic endpoint definition with path, method, and simple parameters\n - **Critique #1:** Focus on naming consistency and resource structure\n - **Revision #1:** Improve parameter names and path structure\n - **Critique #2:** Focus on completeness of response definitions\n - **Revision #2:** Add detailed response examples and error cases\n - **Final Critique:** Holistic review of API usability\n - **Final Revision:** Refine documentation and examples for clarity\n\n API Blueprint Designer is particularly effective for defining clear, consistent, and well-documented APIs. By providing structure and promoting iterative improvement, it leads to interfaces that are easier to implement, maintain, and use.\n";