UNPKG

@blario/mcp

Version:

Blar Model Context Protocol server

48 lines (47 loc) 1.7 kB
import { z } from 'zod'; import { blarAPIClient, BLAR_API_BASE } from '../api-client.js'; import { formatConsideration } from '../utils/formatters.js'; export const getHierarchicalConsiderationsSchema = { repo_name: z.string().describe('Repository name'), relative_file_path: z.string().describe('Relative file path within the repository'), }; export async function getHierarchicalConsiderationsHandler({ repo_name, relative_file_path, }) { // Build the API URL const params = new URLSearchParams(); params.append('repo_name', repo_name); params.append('relative_file_path', relative_file_path); const url = `${BLAR_API_BASE}/wiki/considerations/hierarchy/?${params.toString()}`; // Call the API const response = await blarAPIClient.makeRequestWithErrorHandling(url); if (response.error) { return { content: [ { type: 'text', text: `Error retrieving hierarchical considerations: ${JSON.stringify(response.error, null, 2)}`, }, ], isError: true, }; } if (!response.data || response.data.length === 0) { return { content: [ { type: 'text', text: `No hierarchical considerations found for file: ${relative_file_path} in repository: ${repo_name}`, }, ], }; } // Format and return the considerations const formatted = response.data.map(formatConsideration).join('\n'); return { content: [ { type: 'text', text: formatted, }, ], }; }