Skip to main content
Glama
get-comments.ts2.57 kB
import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { McpToolResponse } from '../types/common.js'; import { GetCommentsInputSchema } from '../types/tools.js'; import { validateInput } from '../utils/validators.js'; import { getComments } from '../utils/api-helpers.js'; import { formatCommentsResponse } from '../utils/formatters.js'; import { handleError } from '../utils/error-handler.js'; import { TOOL_NAMES } from '../config/constants.js'; import { createLogger } from '../utils/logger.js'; const log = createLogger('tool:get-comments'); export const getCommentsTool: Tool = { name: TOOL_NAMES.GET_COMMENTS, description: 'Retrieves all comments for a Jira issue. Returns comment author, content, timestamps, and visibility settings. Supports pagination for issues with many comments.', inputSchema: { type: 'object', properties: { issueKey: { type: 'string', description: 'Issue key to get comments for (e.g., PROJECT-123)', }, maxResults: { type: 'number', description: 'Maximum number of comments to return (default: 50, max: 100)', minimum: 1, maximum: 100, }, orderBy: { type: 'string', enum: ['created', '-created', '+created'], description: 'Sort order for comments: "created" or "+created" (oldest first), "-created" (newest first)', }, startAt: { type: 'number', description: 'Index of first comment to return (for pagination, default: 0)', minimum: 0, }, }, required: ['issueKey'], }, }; export async function handleGetComments(input: unknown): Promise<McpToolResponse> { try { const validated = validateInput(GetCommentsInputSchema, input); log.info(`Getting comments for issue ${validated.issueKey}...`); const options: { maxResults?: number; orderBy?: string; startAt?: number; } = {}; if (validated.maxResults !== undefined) { options.maxResults = validated.maxResults; } if (validated.orderBy !== undefined) { options.orderBy = validated.orderBy; } if (validated.startAt !== undefined) { options.startAt = validated.startAt; } const comments = await getComments(validated.issueKey, options); log.info(`Retrieved ${comments.comments.length} comment(s) for ${validated.issueKey}`); return formatCommentsResponse(comments, validated.issueKey); } catch (error) { log.error('Error in handleGetComments:', error); return handleError(error); } }

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/freema/mcp-jira-stdio'

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