Skip to main content
Glama
ThinkFar

Clear Thought Server

designpattern

Apply design patterns to solve software architecture challenges, including modular architecture, API integration, state management, and security best practices.

Instructions

A tool for applying design patterns to software architecture and implementation. Supports various design patterns including:

  • Modular Architecture

  • API Integration Patterns

  • State Management

  • Asynchronous Processing

  • Scalability Considerations

  • Security Best Practices

  • Agentic Design Patterns

Each pattern provides a structured approach to solving common design challenges.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternNameYes
contextYes
implementationNo
benefitsNo
tradeoffsNo
codeExampleNo
languagesNo

Implementation Reference

  • The core handler function for the 'designpattern' tool. Validates input using DesignPatternData schema, formats a colored console output, logs it, and returns a structured JSON response with pattern details or error.
    public processPattern(input: unknown): { content: Array<{ type: string; text: string }>; isError?: boolean } { try { const validatedInput = this.validatePatternData(input); const formattedOutput = this.formatPatternOutput(validatedInput); console.error(formattedOutput); return { content: [{ type: "text", text: JSON.stringify({ patternName: validatedInput.patternName, status: 'success', hasImplementation: validatedInput.implementation.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 }; } }
  • Tool definition including name, description, and inputSchema which serves as the schema for validation of 'designpattern' tool calls.
    const DESIGN_PATTERN_TOOL: Tool = { name: "designpattern", description: `A tool for applying design patterns to software architecture and implementation. Supports various design patterns including: - Modular Architecture - API Integration Patterns - State Management - Asynchronous Processing - Scalability Considerations - Security Best Practices - Agentic Design Patterns Each pattern provides a structured approach to solving common design challenges.`, inputSchema: { type: "object", properties: { patternName: { type: "string", enum: [ "modular_architecture", "api_integration", "state_management", "async_processing", "scalability", "security", "agentic_design", ], }, context: { type: "string" }, implementation: { type: "array", items: { type: "string" }, }, benefits: { type: "array", items: { type: "string" }, }, tradeoffs: { type: "array", items: { type: "string" }, }, codeExample: { type: "string" }, languages: { type: "array", items: { type: "string" }, }, }, required: ["patternName", "context"], }, };
  • src/index.ts:1057-1069 (registration)
    Registration of the tool handler in the main CallToolRequestHandler switch statement, dispatching calls to designPatternServer.processPattern.
    case "designpattern": { const result = designPatternServer.processPattern( request.params.arguments ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:1000-1000 (registration)
    Registers the DESIGN_PATTERN_TOOL schema in the MCP server capabilities.tools object.
    designpattern: DESIGN_PATTERN_TOOL,
  • Helper function that validates and casts input to DesignPatternData interface, enforcing the tool schema.
    private validatePatternData(input: unknown): DesignPatternData { const data = input as Record<string, unknown>; if (!data.patternName || typeof data.patternName !== 'string') { throw new Error('Invalid patternName: must be a string'); } if (!data.context || typeof data.context !== 'string') { throw new Error('Invalid context: must be a string'); } return { patternName: data.patternName as string, context: data.context as string, implementation: Array.isArray(data.implementation) ? data.implementation.map(String) : [], benefits: Array.isArray(data.benefits) ? data.benefits.map(String) : [], tradeoffs: Array.isArray(data.tradeoffs) ? data.tradeoffs.map(String) : [], codeExample: typeof data.codeExample === 'string' ? data.codeExample as string : undefined, languages: Array.isArray(data.languages) ? data.languages.map(String) : undefined }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ThinkFar/clear-thought-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server