Skip to main content
Glama
path-resolver.ts3.2 kB
/** * Path Resolution Plugin - Smart path analysis for MCP usage * Helps users understand file vs directory paths and suggests correct parameters */ import { BasePlugin } from '../plugins/base-plugin.js'; import { IPromptPlugin } from '../prompts/shared/types.js'; import { withSecurity } from '../security/integration-helpers.js'; import { analyzePathForMCP } from '../utils/path-resolver.js'; export class PathResolverPlugin extends BasePlugin implements IPromptPlugin { name = 'resolve_path'; category = 'system' as const; description = 'Analyze a file system path and suggest correct MCP parameters'; parameters = { path: { type: 'string' as const, description: 'File system path to analyze (file or directory)', required: true }, suggestions: { type: 'boolean' as const, description: 'Include parameter suggestions and usage examples', default: true, required: false } }; async execute(params: any, llmClient: any) { return await withSecurity(this, params, llmClient, async (secureParams) => { try { const pathAnalysis = await analyzePathForMCP(secureParams.path); const result: any = { path: secureParams.path, analysis: pathAnalysis, timestamp: new Date().toISOString() }; // Add usage suggestions if requested if (secureParams.suggestions !== false) { result.suggestions = { recommendedParameter: pathAnalysis.suggestedParameter, exampleUsage: pathAnalysis.type === 'directory' ? `houtini-lm:count_files projectPath="${secureParams.path}"` : `houtini-lm:analyze_single_file filePath="${secureParams.path}"`, alternativeUsage: pathAnalysis.type === 'directory' ? `houtini-lm:security_audit projectPath="${secureParams.path}"` : `houtini-lm:generate_unit_tests filePath="${secureParams.path}"` }; } return { success: true, timestamp: new Date().toISOString(), modelUsed: 'system-utility', executionTimeMs: 0, data: { content: result, metadata: { functionName: 'resolve_path', parsedAt: new Date().toISOString(), responseLength: JSON.stringify(result).length } } }; } catch (error: any) { return { success: false, timestamp: new Date().toISOString(), modelUsed: 'system-utility', executionTimeMs: 0, error: { code: 'PATH_RESOLUTION_ERROR', message: error.message || 'Failed to analyze path', details: { originalError: error.message } } }; } }); } // Not used for system functions, but required by interface getPromptStages(params: any): any { return { systemAndContext: 'Path resolution system function', dataPayload: `Path: ${params.path}`, outputInstructions: 'Return path analysis and suggestions' }; } } // Export as default for plugin loader export default PathResolverPlugin;

Implementation Reference

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/houtini-ai/lm'

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