Skip to main content
Glama
bswa006
by bswa006

get_pattern_for_task

Retrieve the appropriate coding pattern for tasks like components, APIs, or services by specifying task type and context, ensuring structured and efficient development workflows.

Instructions

Get the correct pattern to use for a specific task

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNo
taskTypeYesType of task to get pattern for

Implementation Reference

  • MCP tool handler case for 'get_pattern_for_task': validates input parameters (taskType and optional requirements), calls getPatternForTask helper, and formats the returned pattern as MCP content response.
    case 'get_pattern_for_task': { const params = z.object({ taskType: z.enum(['component', 'hook', 'service', 'api', 'test', 'error-handling']), requirements: z.array(z.string()).optional(), }).parse(args); const pattern = await getPatternForTask( params.taskType, params.requirements ); return { content: [ { type: 'text', text: pattern, }, ], }; }
  • Tool definition object for 'get_pattern_for_task' including name, description, and inputSchema specifying taskType enum and optional context properties.
    { name: 'get_pattern_for_task', description: 'Get the correct pattern to use for a specific task', inputSchema: { type: 'object', properties: { taskType: { type: 'string', enum: ['component', 'api', 'test', 'hook', 'service', 'utility'], description: 'Type of task to get pattern for', }, context: { type: 'object', properties: { hasState: { type: 'boolean' }, hasAsync: { type: 'boolean' }, needsAuth: { type: 'boolean' }, complexity: { type: 'string', enum: ['simple', 'medium', 'complex'], }, }, }, }, required: ['taskType'], }, },
  • Core helper function getPatternForTask that retrieves base pattern for taskType, enhances with project context from CODEBASE-CONTEXT.md, and adjusts for specific requirements.
    export async function getPatternForTask( taskType: TaskType, requirements?: string[] ): Promise<string> { const projectPath = process.env.PROJECT_PATH || process.cwd(); const contextPath = join(projectPath, 'CODEBASE-CONTEXT.md'); const templatePath = join(projectPath, '..', 'PROJECT-TEMPLATE-v10.md'); let basePattern = getBasePattern(taskType); // Enhance with project-specific patterns if (existsSync(contextPath)) { const contextContent = readFileSync(contextPath, 'utf-8'); basePattern = enhanceWithProjectContext(basePattern, contextContent, taskType); } // Add requirements-specific adjustments if (requirements && requirements.length > 0) { basePattern = adjustForRequirements(basePattern, requirements, taskType); } return basePattern; }
  • Tool registration via setupTools: sets ListToolsRequestHandler to return toolDefinitions array which includes the get_pattern_for_task tool.
    export function setupTools(server: Server) { // Handle tool listing server.setRequestHandler(ListToolsRequestSchema, async () => { console.error(`Handling tools/list request, returning ${toolDefinitions.length} tools`); return { tools: toolDefinitions }; });

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/bswa006/mcp-context-manager'

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