@blario/mcp
Version:
Blar Model Context Protocol server
57 lines (56 loc) • 2.49 kB
JavaScript
import { z } from 'zod';
import { blarAPIClient, BLAR_API_BASE } from '../api-client.js';
export const resolveIssueSchema = {
issue_id: z.string().describe('ID of the pull request issue'),
};
export async function resolveIssueHandler({ issue_id, }) {
const url = `${BLAR_API_BASE}/integrations/git/issues/${issue_id}/resolve/`;
const { data, error, status } = await blarAPIClient.makePostRequest(url, {} // Empty body as the endpoint doesn't require any data
);
// Handle errors
if (!data || error) {
return {
content: [
{
type: 'text',
text: `❌ Failed to Resolve Issue\n` +
`═══════════════════════════════════════\n` +
`Issue ID: ${issue_id}\n` +
`Error: ${error?.detail || error?.error || 'Unknown error occurred'}\n\n` +
`Status: ${status}`,
},
],
};
}
// Success response with message check
if (typeof data.message === 'string' && data.message.toLowerCase().includes('resolved successfully')) {
return {
content: [
{
type: 'text',
text: `✅ Issue Successfully Resolved\n` +
`═══════════════════════════════════════\n` +
`Issue ID: ${issue_id}\n` +
`Status: Resolved\n` +
`Message: ${data.message}\n\n` +
`The issue has been resolved both internally and in the Git platform.`,
},
],
};
}
else {
// 200 but not a true resolution (e.g., already resolved or other info)
return {
content: [
{
type: 'text',
text: `ℹ️ Issue Resolution Info\n` +
`═══════════════════════════════════════\n` +
`Issue ID: ${issue_id}\n` +
`Message: ${data.message}\n\n` +
`Note: The issue was not newly resolved. See the message above for details.`,
},
],
};
}
}