@blario/mcp
Version:
Blar Model Context Protocol server
49 lines (48 loc) • 1.51 kB
JavaScript
import { z } from 'zod';
import { blarAPIClient, BLAR_API_BASE } from '../api-client.js';
import { formatConsideration } from '../utils/formatters.js';
export const getConsiderationsByTagSchema = {
repo_url: z.string().describe('Repository url to filter considerations'),
tags: z
.enum(['design_pattern', 'context'])
.describe('Tag to get considerations for (design_pattern or context)'),
};
export async function getConsiderationsByTagHandler({ tags, repo_url, }) {
// Build the API URL
const params = new URLSearchParams();
params.append('repo_url', repo_url);
params.append('tags', tags);
const url = `${BLAR_API_BASE}/wiki/considerations/by-tag/?${params.toString()}`;
// Call the API
const data = await blarAPIClient.makeRequest(url);
if (!data) {
return {
content: [
{
type: 'text',
text: 'Failed to retrieve considerations.',
},
],
};
}
if (data.length === 0) {
return {
content: [
{
type: 'text',
text: `No considerations found for tag: ${tags}`,
},
],
};
}
// Format and return the considerations
const formatted = data.map(formatConsideration).join('\n');
return {
content: [
{
type: 'text',
text: formatted,
},
],
};
}